mirror of
https://github.com/cemu-project/DS4Windows.git
synced 2024-11-26 19:14:20 +01:00
Merge branch 'jay' into hidguardpropexe
This commit is contained in:
commit
3fd9c4c612
@ -1563,7 +1563,7 @@ namespace DS4Windows
|
|||||||
case DS4Controls.LXNeg:
|
case DS4Controls.LXNeg:
|
||||||
case DS4Controls.LXPos:
|
case DS4Controls.LXPos:
|
||||||
{
|
{
|
||||||
if (MappedState.LX == 127)
|
if (MappedState.LX == 128)
|
||||||
{
|
{
|
||||||
if (dc == DS4Controls.LXNeg)
|
if (dc == DS4Controls.LXNeg)
|
||||||
{
|
{
|
||||||
@ -1582,7 +1582,7 @@ namespace DS4Windows
|
|||||||
case DS4Controls.LYNeg:
|
case DS4Controls.LYNeg:
|
||||||
case DS4Controls.LYPos:
|
case DS4Controls.LYPos:
|
||||||
{
|
{
|
||||||
if (MappedState.LY == 127)
|
if (MappedState.LY == 128)
|
||||||
{
|
{
|
||||||
if (dc == DS4Controls.LYNeg)
|
if (dc == DS4Controls.LYNeg)
|
||||||
{
|
{
|
||||||
@ -1601,7 +1601,7 @@ namespace DS4Windows
|
|||||||
case DS4Controls.RXNeg:
|
case DS4Controls.RXNeg:
|
||||||
case DS4Controls.RXPos:
|
case DS4Controls.RXPos:
|
||||||
{
|
{
|
||||||
if (MappedState.RX == 127)
|
if (MappedState.RX == 128)
|
||||||
{
|
{
|
||||||
if (dc == DS4Controls.RXNeg)
|
if (dc == DS4Controls.RXNeg)
|
||||||
{
|
{
|
||||||
@ -1620,7 +1620,7 @@ namespace DS4Windows
|
|||||||
case DS4Controls.RYNeg:
|
case DS4Controls.RYNeg:
|
||||||
case DS4Controls.RYPos:
|
case DS4Controls.RYPos:
|
||||||
{
|
{
|
||||||
if (MappedState.RY == 127)
|
if (MappedState.RY == 128)
|
||||||
{
|
{
|
||||||
if (dc == DS4Controls.RYNeg)
|
if (dc == DS4Controls.RYNeg)
|
||||||
{
|
{
|
||||||
@ -3077,11 +3077,11 @@ namespace DS4Windows
|
|||||||
|
|
||||||
switch (control)
|
switch (control)
|
||||||
{
|
{
|
||||||
case DS4Controls.LXNeg: result = cState.LX < 127 - 55; break;
|
case DS4Controls.LXNeg: result = cState.LX < 128 - 55; break;
|
||||||
case DS4Controls.LYNeg: result = cState.LY < 127 - 55; break;
|
case DS4Controls.LYNeg: result = cState.LY < 128 - 55; break;
|
||||||
case DS4Controls.RXNeg: result = cState.RX < 127 - 55; break;
|
case DS4Controls.RXNeg: result = cState.RX < 128 - 55; break;
|
||||||
case DS4Controls.RYNeg: result = cState.RY < 127 - 55; break;
|
case DS4Controls.RYNeg: result = cState.RY < 128 - 55; break;
|
||||||
default: result = axisValue > 127 + 55; break;
|
default: result = axisValue > 128 + 55; break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else if (controlType == DS4StateFieldMapping.ControlType.Trigger)
|
else if (controlType == DS4StateFieldMapping.ControlType.Trigger)
|
||||||
@ -3448,7 +3448,7 @@ namespace DS4Windows
|
|||||||
{
|
{
|
||||||
byte result = 0;
|
byte result = 0;
|
||||||
byte trueVal = 0;
|
byte trueVal = 0;
|
||||||
byte falseVal = 127;
|
byte falseVal = 128;
|
||||||
|
|
||||||
if (alt)
|
if (alt)
|
||||||
trueVal = 255;
|
trueVal = 255;
|
||||||
@ -3548,6 +3548,7 @@ namespace DS4Windows
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/* TODO: Possibly remove usage of this version of the method */
|
||||||
public static byte getXYAxisMapping(int device, DS4Controls control, DS4State cState, DS4StateExposed eState, Mouse tp, bool alt = false)
|
public static byte getXYAxisMapping(int device, DS4Controls control, DS4State cState, DS4StateExposed eState, Mouse tp, bool alt = false)
|
||||||
{
|
{
|
||||||
byte result = 0;
|
byte result = 0;
|
||||||
@ -3690,74 +3691,6 @@ namespace DS4Windows
|
|||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
/* TODO: Possibly remove usage of this version of the method */
|
|
||||||
//Returns false for any bool,
|
|
||||||
//if control is one of the xy axis returns 127
|
|
||||||
//if its a trigger returns 0
|
|
||||||
public static void resetToDefaultValue(DS4Controls control, DS4State cState)
|
|
||||||
{
|
|
||||||
if (control >= DS4Controls.Square && control <= DS4Controls.Cross)
|
|
||||||
{
|
|
||||||
switch (control)
|
|
||||||
{
|
|
||||||
case DS4Controls.Cross: cState.Cross = false; break;
|
|
||||||
case DS4Controls.Square: cState.Square = false; break;
|
|
||||||
case DS4Controls.Triangle: cState.Triangle = false; break;
|
|
||||||
case DS4Controls.Circle: cState.Circle = false; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (control >= DS4Controls.L1 && control <= DS4Controls.R3)
|
|
||||||
{
|
|
||||||
switch (control)
|
|
||||||
{
|
|
||||||
case DS4Controls.L1: cState.L1 = false; break;
|
|
||||||
case DS4Controls.L2: cState.L2 = 0; break;
|
|
||||||
case DS4Controls.L3: cState.L3 = false; break;
|
|
||||||
case DS4Controls.R1: cState.R1 = false; break;
|
|
||||||
case DS4Controls.R2: cState.R2 = 0; break;
|
|
||||||
case DS4Controls.R3: cState.R3 = false; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (control >= DS4Controls.DpadUp && control <= DS4Controls.DpadLeft)
|
|
||||||
{
|
|
||||||
switch (control)
|
|
||||||
{
|
|
||||||
case DS4Controls.DpadUp: cState.DpadUp = false; break;
|
|
||||||
case DS4Controls.DpadDown: cState.DpadDown = false; break;
|
|
||||||
case DS4Controls.DpadLeft: cState.DpadLeft = false; break;
|
|
||||||
case DS4Controls.DpadRight: cState.DpadRight = false; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else if (control >= DS4Controls.LXNeg && control <= DS4Controls.RYPos)
|
|
||||||
{
|
|
||||||
switch (control)
|
|
||||||
{
|
|
||||||
case DS4Controls.LXNeg: cState.LX = 127; break;
|
|
||||||
case DS4Controls.LYNeg: cState.LY = 127; break;
|
|
||||||
case DS4Controls.RXNeg: cState.RX = 127; break;
|
|
||||||
case DS4Controls.RYNeg: cState.RY = 127; break;
|
|
||||||
case DS4Controls.LXPos: cState.LX = 127; break;
|
|
||||||
case DS4Controls.LYPos: cState.LY = 127; break;
|
|
||||||
case DS4Controls.RXPos: cState.RX = 127; break;
|
|
||||||
case DS4Controls.RYPos: cState.RY = 127; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
else
|
|
||||||
{
|
|
||||||
switch (control)
|
|
||||||
{
|
|
||||||
case DS4Controls.Share: cState.Share = false; break;
|
|
||||||
case DS4Controls.Options: cState.Options = false; break;
|
|
||||||
case DS4Controls.PS: cState.PS = false; break;
|
|
||||||
default: break;
|
|
||||||
}
|
|
||||||
}
|
|
||||||
}
|
|
||||||
|
|
||||||
private static void resetToDefaultValue2(DS4Controls control, DS4State cState,
|
private static void resetToDefaultValue2(DS4Controls control, DS4State cState,
|
||||||
DS4StateFieldMapping fieldMap)
|
DS4StateFieldMapping fieldMap)
|
||||||
{
|
{
|
||||||
@ -3769,9 +3702,9 @@ namespace DS4Windows
|
|||||||
}
|
}
|
||||||
else if (controlType == DS4StateFieldMapping.ControlType.AxisDir)
|
else if (controlType == DS4StateFieldMapping.ControlType.AxisDir)
|
||||||
{
|
{
|
||||||
fieldMap.axisdirs[controlNum] = 127;
|
fieldMap.axisdirs[controlNum] = 128;
|
||||||
int controlRelation = (controlNum % 2 == 0 ? controlNum - 1 : controlNum + 1);
|
int controlRelation = (controlNum % 2 == 0 ? controlNum - 1 : controlNum + 1);
|
||||||
fieldMap.axisdirs[controlRelation] = 127;
|
fieldMap.axisdirs[controlRelation] = 128;
|
||||||
}
|
}
|
||||||
else if (controlType == DS4StateFieldMapping.ControlType.Trigger)
|
else if (controlType == DS4StateFieldMapping.ControlType.Trigger)
|
||||||
{
|
{
|
||||||
|
@ -3488,15 +3488,12 @@ namespace DS4Windows
|
|||||||
else
|
else
|
||||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||||
|
|
||||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
int temp = (int)dc;
|
||||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
if (temp > 0)
|
||||||
{
|
{
|
||||||
DS4ControlSettings dcs = ds4settingsList[i];
|
int index = temp - 1;
|
||||||
if (dcs.control == dc)
|
DS4ControlSettings dcs = ds4settings[deviceNum][index];
|
||||||
{
|
dcs.UpdateSettings(shift, action, exts, kt, trigger);
|
||||||
dcs.UpdateSettings(shift, action, exts, kt, trigger);
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3508,19 +3505,15 @@ namespace DS4Windows
|
|||||||
else
|
else
|
||||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||||
|
|
||||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
int temp = (int)dc;
|
||||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
if (temp > 0)
|
||||||
{
|
{
|
||||||
DS4ControlSettings dcs = ds4settingsList[i];
|
int index = temp - 1;
|
||||||
if (dcs.control == dc)
|
DS4ControlSettings dcs = ds4settings[deviceNum][index];
|
||||||
{
|
if (shift)
|
||||||
if (shift)
|
dcs.shiftExtras = exts;
|
||||||
dcs.shiftExtras = exts;
|
else
|
||||||
else
|
dcs.extras = exts;
|
||||||
dcs.extras = exts;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3532,19 +3525,15 @@ namespace DS4Windows
|
|||||||
else
|
else
|
||||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||||
|
|
||||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
int temp = (int)dc;
|
||||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
if (temp > 0)
|
||||||
{
|
{
|
||||||
DS4ControlSettings dcs = ds4settingsList[i];
|
int index = temp - 1;
|
||||||
if (dcs.control == dc)
|
DS4ControlSettings dcs = ds4settings[deviceNum][index];
|
||||||
{
|
if (shift)
|
||||||
if (shift)
|
dcs.shiftKeyType = keyType;
|
||||||
dcs.shiftKeyType = keyType;
|
else
|
||||||
else
|
dcs.keyType = keyType;
|
||||||
dcs.keyType = keyType;
|
|
||||||
|
|
||||||
break;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3556,16 +3545,18 @@ namespace DS4Windows
|
|||||||
else
|
else
|
||||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||||
|
|
||||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
int temp = (int)dc;
|
||||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
if (temp > 0)
|
||||||
{
|
{
|
||||||
DS4ControlSettings dcs = ds4settingsList[i];
|
int index = temp - 1;
|
||||||
if (dcs.control == dc)
|
DS4ControlSettings dcs = ds4settings[deviceNum][index];
|
||||||
|
if (shift)
|
||||||
{
|
{
|
||||||
if (shift)
|
return dcs.shiftTrigger;
|
||||||
return dcs.shiftAction;
|
}
|
||||||
else
|
else
|
||||||
return dcs.action;
|
{
|
||||||
|
return dcs.action;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
@ -3600,17 +3591,15 @@ namespace DS4Windows
|
|||||||
else
|
else
|
||||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||||
|
|
||||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
int temp = (int)dc;
|
||||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
if (temp > 0)
|
||||||
{
|
{
|
||||||
DS4ControlSettings dcs = ds4settingsList[i];
|
int index = temp - 1;
|
||||||
if (dcs.control == dc)
|
DS4ControlSettings dcs = ds4settings[deviceNum][index];
|
||||||
{
|
if (shift)
|
||||||
if (shift)
|
return dcs.shiftExtras;
|
||||||
return dcs.shiftExtras;
|
else
|
||||||
else
|
return dcs.extras;
|
||||||
return dcs.extras;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
@ -3624,17 +3613,15 @@ namespace DS4Windows
|
|||||||
else
|
else
|
||||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||||
|
|
||||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
int temp = (int)dc;
|
||||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
if (temp > 0)
|
||||||
{
|
{
|
||||||
DS4ControlSettings dcs = ds4settingsList[i];
|
int index = temp - 1;
|
||||||
if (dcs.control == dc)
|
DS4ControlSettings dcs = ds4settings[deviceNum][index];
|
||||||
{
|
if (shift)
|
||||||
if (shift)
|
return dcs.shiftKeyType;
|
||||||
return dcs.shiftKeyType;
|
else
|
||||||
else
|
return dcs.keyType;
|
||||||
return dcs.keyType;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
|
|
||||||
return DS4KeyType.None;
|
return DS4KeyType.None;
|
||||||
@ -3648,12 +3635,12 @@ namespace DS4Windows
|
|||||||
else
|
else
|
||||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||||
|
|
||||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
int temp = (int)dc;
|
||||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
if (temp > 0)
|
||||||
{
|
{
|
||||||
DS4ControlSettings dcs = ds4settingsList[i];
|
int index = temp - 1;
|
||||||
if (dcs.control == dc)
|
DS4ControlSettings dcs = ds4settings[deviceNum][index];
|
||||||
return dcs.shiftTrigger;
|
return dcs.shiftTrigger;
|
||||||
}
|
}
|
||||||
|
|
||||||
return 0;
|
return 0;
|
||||||
@ -3680,12 +3667,12 @@ namespace DS4Windows
|
|||||||
else
|
else
|
||||||
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
dc = (DS4Controls)Enum.Parse(typeof(DS4Controls), buttonName, true);
|
||||||
|
|
||||||
List<DS4ControlSettings> ds4settingsList = ds4settings[deviceNum];
|
int temp = (int)dc;
|
||||||
for (int i = 0, settingsLen = ds4settingsList.Count; i < settingsLen; i++)
|
if (temp > 0)
|
||||||
{
|
{
|
||||||
DS4ControlSettings dcs = ds4settingsList[i];
|
int index = temp - 1;
|
||||||
if (dcs.control == dc)
|
DS4ControlSettings dcs = ds4settings[deviceNum][index];
|
||||||
return dcs;
|
return dcs;
|
||||||
}
|
}
|
||||||
|
|
||||||
return null;
|
return null;
|
||||||
|
@ -450,11 +450,11 @@ namespace DS4Windows
|
|||||||
|
|
||||||
if (isExclusive)
|
if (isExclusive)
|
||||||
{
|
{
|
||||||
hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, 0, IntPtr.Zero, NativeMethods.OpenExisting, 0x20000000 | 0x80000000 | NativeMethods.FILE_FLAG_OVERLAPPED, 0);
|
hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, 0, IntPtr.Zero, NativeMethods.OpenExisting, 0x20000000 | 0x80000000 | 0x100 | NativeMethods.FILE_FLAG_OVERLAPPED, 0);
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, NativeMethods.FILE_SHARE_READ | NativeMethods.FILE_SHARE_WRITE, IntPtr.Zero, NativeMethods.OpenExisting, 0x20000000 | 0x80000000 | NativeMethods.FILE_FLAG_OVERLAPPED, 0);
|
hidHandle = NativeMethods.CreateFile(devicePathName, NativeMethods.GENERIC_READ | NativeMethods.GENERIC_WRITE, NativeMethods.FILE_SHARE_READ | NativeMethods.FILE_SHARE_WRITE, IntPtr.Zero, NativeMethods.OpenExisting, 0x20000000 | 0x80000000 | 0x100 | NativeMethods.FILE_FLAG_OVERLAPPED, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
return hidHandle;
|
return hidHandle;
|
||||||
|
Loading…
Reference in New Issue
Block a user