mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-12-23 23:21:49 +01:00
Work around a couple of null reference problems that might occur
This commit is contained in:
parent
770ca43a2f
commit
bba8af6a63
@ -507,8 +507,11 @@ namespace DS4Windows
|
||||
|
||||
int ind = -1;
|
||||
for (int i = 0, arlength = DS4_CONTROLLER_COUNT; ind == -1 && i < arlength; i++)
|
||||
if (device == DS4Controllers[i])
|
||||
{
|
||||
DS4Device tempDev = DS4Controllers[i];
|
||||
if (tempDev != null && device == tempDev)
|
||||
ind = i;
|
||||
}
|
||||
|
||||
if (ind != -1)
|
||||
{
|
||||
@ -540,11 +543,18 @@ namespace DS4Windows
|
||||
DS4State cState = CurrentState[ind];
|
||||
device.getPreviousState(PreviousState[ind]);
|
||||
DS4State pState = PreviousState[ind];
|
||||
|
||||
// Change routine to be more specific to a device.
|
||||
// Currently updates status of all devices in DS4Form when any battery
|
||||
// state change occurs.
|
||||
if (pState.Battery != cState.Battery)
|
||||
ControllerStatusChanged(this);
|
||||
|
||||
CheckForHotkeys(ind, cState, pState);
|
||||
if (eastertime)
|
||||
EasterTime(ind);
|
||||
|
||||
// Temporarily disable easter time routine
|
||||
//if (eastertime)
|
||||
// EasterTime(ind);
|
||||
|
||||
cState = Mapping.SetCurveAndDeadzone(ind, cState);
|
||||
|
||||
@ -945,6 +955,7 @@ namespace DS4Windows
|
||||
public bool[] touchreleased = { true, true, true, true }, touchslid = { false, false, false, false };
|
||||
public byte[] oldtouchvalue = { 0, 0, 0, 0 };
|
||||
public int[] oldscrollvalue = { 0, 0, 0, 0 };
|
||||
|
||||
protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State pState)
|
||||
{
|
||||
if (!getUseTPforControls(deviceID) && cState.Touch1 && pState.PS)
|
||||
|
@ -90,10 +90,10 @@ namespace DS4Windows
|
||||
buttons[(int)DS4Controls.DpadDown] = cState.DpadDown;
|
||||
buttons[(int)DS4Controls.DpadLeft] = cState.DpadLeft;
|
||||
|
||||
buttons[(int)DS4Controls.TouchLeft] = tp.leftDown;
|
||||
buttons[(int)DS4Controls.TouchRight] = tp.rightDown;
|
||||
buttons[(int)DS4Controls.TouchUpper] = tp.upperDown;
|
||||
buttons[(int)DS4Controls.TouchMulti] = tp.multiDown;
|
||||
buttons[(int)DS4Controls.TouchLeft] = tp != null ? tp.leftDown : false;
|
||||
buttons[(int)DS4Controls.TouchRight] = tp != null ? tp.rightDown : false;
|
||||
buttons[(int)DS4Controls.TouchUpper] = tp != null ? tp.upperDown : false;
|
||||
buttons[(int)DS4Controls.TouchMulti] = tp != null ? tp.multiDown : false;
|
||||
|
||||
gryodirs[(int)DS4Controls.GyroXNeg] = exposeState.getGyroX();
|
||||
gryodirs[(int)DS4Controls.GyroXPos] = exposeState.getGyroX();
|
||||
@ -101,15 +101,15 @@ namespace DS4Windows
|
||||
gryodirs[(int)DS4Controls.GyroZPos] = exposeState.getGyroZ();
|
||||
gryodirs[(int)DS4Controls.GyroZPos] = exposeState.getGyroZ();
|
||||
|
||||
swipedirs[(int)DS4Controls.SwipeLeft] = tp.swipeLeftB;
|
||||
swipedirs[(int)DS4Controls.SwipeRight] = tp.swipeRightB;
|
||||
swipedirs[(int)DS4Controls.SwipeUp] = tp.swipeUpB;
|
||||
swipedirs[(int)DS4Controls.SwipeDown] = tp.swipeDownB;
|
||||
swipedirs[(int)DS4Controls.SwipeLeft] = tp != null ? tp.swipeLeftB : (byte)0;
|
||||
swipedirs[(int)DS4Controls.SwipeRight] = tp != null ? tp.swipeRightB : (byte)0;
|
||||
swipedirs[(int)DS4Controls.SwipeUp] = tp != null ? tp.swipeUpB : (byte)0;
|
||||
swipedirs[(int)DS4Controls.SwipeDown] = tp != null ? tp.swipeDownB : (byte)0;
|
||||
|
||||
swipedirbools[(int)DS4Controls.SwipeLeft] = tp.swipeLeft;
|
||||
swipedirbools[(int)DS4Controls.SwipeRight] = tp.swipeRight;
|
||||
swipedirbools[(int)DS4Controls.SwipeUp] = tp.swipeUp;
|
||||
swipedirbools[(int)DS4Controls.SwipeDown] = tp.swipeDown;
|
||||
swipedirbools[(int)DS4Controls.SwipeLeft] = tp != null ? tp.swipeLeft : false;
|
||||
swipedirbools[(int)DS4Controls.SwipeRight] = tp != null ? tp.swipeRight : false;
|
||||
swipedirbools[(int)DS4Controls.SwipeUp] = tp != null ? tp.swipeUp : false;
|
||||
swipedirbools[(int)DS4Controls.SwipeDown] = tp != null ? tp.swipeDown : false;
|
||||
}
|
||||
|
||||
public void populateState(DS4State state)
|
||||
|
Loading…
Reference in New Issue
Block a user