Version 8.01

Touchpad macros now work without also clicking)
Mouse Buttons are now toggleable

Version 8
More mapping options!
Toggle option: Press a button once and the key will be held down until the button is pressed again
Macro option: Assign multiple keys or mouse buttons to a single button! Just check Macro and select the buttons in the order you want them to be pressed (maximum 5)
Light bar even closer to default bluetooth when stopping
When disconnecting Controller via PS button and Options, if PS is assigned to a key or keys, the key is let go.
If Idle timeout is on, the light bar idles fades when fully charged (but doesn't disconnect)
DS4 Icon always shows, notifications only at startup, and when the main window is unfocused.
In options the tap, scroll, and slide are unchecked at start if any of them were turned off before
For always rainbow mode, the cycle goes in reverse when charging, remains dim if checked.

Version 7.8
Mouse Sensitivity now works with analog sticks as well as buttons and triggers
Option for using the controller input to change it's mapping in options
Fix for lightbar not remembering the color
Disable edit/delete buttons until controllers finish connecting
This commit is contained in:
jays2kings 2014-05-27 22:49:58 -04:00
parent 96268b0296
commit 7e4d8b7606
16 changed files with 6925 additions and 6474 deletions

View File

@ -121,34 +121,43 @@ namespace DS4Control
{
running = false;
if (showlog)
LogDebug("Stopping X360 Controllers");
bool anyUnplugged = false;
LogDebug("Stopping X360 Controllers");
bool anyUnplugged = false;
for (int i = 0; i < DS4Controllers.Length; i++)
{
if (DS4Controllers[i] != null)
{
Global.setRainbow(i, 0);
Global.setLedAsBatteryIndicator(i, false);
Global.saveColor(i, 64, 128, 128);
double oldrainbow = Global.getRainbow(i);
bool oldbatt = Global.getLedAsBatteryIndicator(i);
DS4Color oldcolor = Global.loadColor(i);
while (Global.loadColor(i).red != 32 || Global.loadColor(i).green != 64 || Global.loadColor(i).blue != 64 || Global.getRainbow(i) != 0 || Global.getLedAsBatteryIndicator(i) != false)
{
Global.setRainbow(i, 0);
Global.setLedAsBatteryIndicator(i, false);
Global.saveColor(i, 32, 64, 64); //Make Lightbar light blue like default bluetooth color
System.Threading.Thread.Sleep(5);
}
CurrentState[i].Battery = PreviousState[i].Battery = 0; // Reset for the next connection's initial status change.
x360Bus.Unplug(i);
anyUnplugged = true;
DS4Controllers[i] = null;
touchPad[i] = null;
Global.setRainbow(i, oldrainbow); //Set back settings once ds4windows stops, so when reconnecting it shows right colors
Global.setLedAsBatteryIndicator(i, oldbatt);
Global.saveColor(i, oldcolor.red, oldcolor.green, oldcolor.blue);
}
}
if (anyUnplugged)
System.Threading.Thread.Sleep(XINPUT_UNPLUG_SETTLE_TIME);
x360Bus.Stop();
if (showlog)
LogDebug("Stopping DS4 Controllers");
LogDebug("Stopping DS4 Controllers");
DS4Devices.stopControllers();
if (showlog)
LogDebug("Stopped DS4 Tool");
Global.ControllerStatusChanged(this);
LogDebug("Stopped DS4 Tool");
Global.ControllerStatusChanged(this);
}
return true;
}
public bool HotPlug()
@ -157,8 +166,6 @@ namespace DS4Control
{
DS4Devices.findControllers();
IEnumerable<DS4Device> devices = DS4Devices.getDS4Controllers();
//Stop(false);
//Start(false);
foreach (DS4Device device in devices)
{
if (device.IsDisconnecting)
@ -417,7 +424,7 @@ namespace DS4Control
}
bool touchreleased = true;
byte oldtouchvalue = 0;
byte[] oldtouchvalue = { 0, 0, 0, 0 };
protected virtual void CheckForHotkeys(int deviceID, DS4State cState, DS4State pState)
{
DS4Device d = DS4Controllers[deviceID];
@ -428,11 +435,23 @@ namespace DS4Control
else if (cState.Options)
Global.setTouchSensitivity(deviceID, 100); */
}
if ((!pState.PS || !pState.Options) && cState.PS && cState.Options)
{
d.DisconnectBT();
InputMethods.performKeyRelease(Global.getCustomKey(0, DS4Controls.PS));
string[] skeys = Global.getCustomMacro(0, DS4Controls.PS).Split('/');
ushort[] keys = new ushort[skeys.Length];
for (int i = 0; i < keys.Length; i++)
{
keys[i] = ushort.Parse(skeys[i]);
InputMethods.performKeyRelease(keys[i]);
}
}
if (cState.Touch1 && pState.PS)
{
if (Global.getTouchSensitivity(deviceID) > 0 && touchreleased)
{
oldtouchvalue = Global.getTouchSensitivity(deviceID);
oldtouchvalue[deviceID] = Global.getTouchSensitivity(deviceID);
Global.setTouchSensitivity(deviceID, 0);
LogDebug("Touchpad Movement is now " + (Global.getTouchSensitivity(deviceID) > 0 ? "On" : "Off"));
Log.LogToTray("Touchpad Movement is now " + (Global.getTouchSensitivity(deviceID) > 0 ? "On" : "Off"));
@ -440,7 +459,7 @@ namespace DS4Control
}
else if (touchreleased)
{
Global.setTouchSensitivity(deviceID, oldtouchvalue);
Global.setTouchSensitivity(deviceID, oldtouchvalue[deviceID]);
LogDebug("Touchpad Movement is now " + (Global.getTouchSensitivity(deviceID) > 0 ? "On" : "Off"));
Log.LogToTray("Touchpad Movement is now " + (Global.getTouchSensitivity(deviceID) > 0 ? "On" : "Off"));
touchreleased = false;
@ -478,5 +497,10 @@ namespace DS4Control
heavyBoosted = 255;
DS4Controllers[deviceNum].setRumble((byte)lightBoosted, (byte)heavyBoosted);
}
public DS4State getDS4State(int ind)
{
return CurrentState[ind];
}
}
}

View File

@ -32,9 +32,14 @@ namespace DS4Control
if (now >= oldnow + TimeSpan.FromMilliseconds(10)) //update by the millisecond that way it's a smooth transtion
{
oldnow = now;
counters[deviceNum] += 1.5 * 3 / Global.getRainbow(deviceNum);
if (device.Charging)
counters[deviceNum] -= 1.5 * 3 / Global.getRainbow(deviceNum);
else
counters[deviceNum] += 1.5 * 3 / Global.getRainbow(deviceNum);
}
if (Global.getLedAsBatteryIndicator(deviceNum) && (device.Charging == false || device.Battery >= 100))// when charged, don't show the charging animation
if (counters[deviceNum] < 0)
counters[deviceNum] = 180000;
if (Global.getLedAsBatteryIndicator(deviceNum))
color = HuetoRGB((float)counters[deviceNum] % 360, (byte)(2.55 * device.Battery));
else
color = HuetoRGB((float)counters[deviceNum] % 360, 255);
@ -72,14 +77,16 @@ namespace DS4Control
color = Global.loadColor(deviceNum);
}
if (Global.getIdleDisconnectTimeout(deviceNum) > 0 && !device.Charging)
if (Global.getIdleDisconnectTimeout(deviceNum) > 0 && (!device.Charging || device.Battery >= 100))
{//Fade lightbar by idle time
TimeSpan timeratio = new TimeSpan(DateTime.UtcNow.Ticks - device.lastActive.Ticks);
double botratio = timeratio.TotalMilliseconds;
double topratio = TimeSpan.FromSeconds(Global.getIdleDisconnectTimeout(deviceNum)).TotalMilliseconds;
double ratio = ((botratio / topratio) * 100);
if (ratio >= 50)
if (ratio >= 50 && ratio <= 100)
color = Global.getTransitionedColor(color, new DS4Color { red = 0, green = 0, blue = 0 }, (uint)((ratio-50)*2));
else if (ratio >= 100)
color = Global.getTransitionedColor(color, new DS4Color { red = 0, green = 0, blue = 0 }, 100);
}
DS4HapticState haptics = new DS4HapticState
{

View File

@ -10,16 +10,18 @@ namespace DS4Control
/*
* Represent the synthetic keyboard and mouse events. Maintain counts for each so we don't duplicate events.
*/
private class SyntheticState
public class SyntheticState
{
public struct MouseClick
{
public int leftCount, middleCount, rightCount, fourthCount, fifthCount, wUpCount, wDownCount;
public int leftCount, middleCount, rightCount, fourthCount, fifthCount, wUpCount, wDownCount, toggleCount;
public bool toggle;
}
public MouseClick previousClicks, currentClicks;
public struct KeyPress
{
public int vkCount, scanCodeCount, repeatCount; // repeat takes priority over non-, and scancode takes priority over non-
public int vkCount, scanCodeCount, repeatCount, toggleCount; // repeat takes priority over non-, and scancode takes priority over non-
public bool toggle;
}
public class KeyPresses
{
@ -31,17 +33,20 @@ namespace DS4Control
{
previousClicks = currentClicks;
if (performClear)
currentClicks.leftCount = currentClicks.middleCount = currentClicks.rightCount = currentClicks.fourthCount = currentClicks.fifthCount = currentClicks.wUpCount = currentClicks.wDownCount = 0;
currentClicks.leftCount = currentClicks.middleCount = currentClicks.rightCount = currentClicks.fourthCount = currentClicks.fifthCount = currentClicks.wUpCount = currentClicks.wDownCount = currentClicks.toggleCount = 0;
foreach (KeyPresses kp in keyPresses.Values)
{
kp.previous = kp.current;
if (performClear)
kp.current.repeatCount = kp.current.scanCodeCount = kp.current.vkCount = 0;
{
kp.current.repeatCount = kp.current.scanCodeCount = kp.current.vkCount = kp.current.toggleCount = 0;
//kp.current.toggle = false;
}
}
}
}
private static SyntheticState globalState = new SyntheticState();
private static SyntheticState[] deviceState = { new SyntheticState(), new SyntheticState(), new SyntheticState(), new SyntheticState() };
public static SyntheticState globalState = new SyntheticState();
public static SyntheticState[] deviceState = { new SyntheticState(), new SyntheticState(), new SyntheticState(), new SyntheticState() };
// TODO When we disconnect, process a null/dead state to release any keys or buttons.
public static DateTime oldnow = DateTime.UtcNow;
@ -53,54 +58,88 @@ namespace DS4Control
lock (globalState)
{
globalState.currentClicks.leftCount += state.currentClicks.leftCount - state.previousClicks.leftCount;
if (globalState.currentClicks.leftCount != 0 && globalState.previousClicks.leftCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN);
else if (globalState.currentClicks.leftCount == 0 && globalState.previousClicks.leftCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
globalState.currentClicks.middleCount += state.currentClicks.middleCount - state.previousClicks.middleCount;
if (globalState.currentClicks.middleCount != 0 && globalState.previousClicks.middleCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEDOWN);
else if (globalState.currentClicks.middleCount == 0 && globalState.previousClicks.middleCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEUP);
globalState.currentClicks.rightCount += state.currentClicks.rightCount - state.previousClicks.rightCount;
if (globalState.currentClicks.rightCount != 0 && globalState.previousClicks.rightCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTDOWN);
else if (globalState.currentClicks.rightCount == 0 && globalState.previousClicks.rightCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTUP);
globalState.currentClicks.fourthCount += state.currentClicks.fourthCount - state.previousClicks.fourthCount;
if (globalState.currentClicks.fourthCount != 0 && globalState.previousClicks.fourthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 1);
else if (globalState.currentClicks.fourthCount == 0 && globalState.previousClicks.fourthCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 1);
globalState.currentClicks.fifthCount += state.currentClicks.fifthCount - state.previousClicks.fifthCount;
if (globalState.currentClicks.fifthCount != 0 && globalState.previousClicks.fifthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 2);
else if (globalState.currentClicks.fifthCount == 0 && globalState.previousClicks.fifthCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 2);
globalState.currentClicks.wUpCount += state.currentClicks.wUpCount - state.previousClicks.wUpCount;
if (globalState.currentClicks.wUpCount != 0 && globalState.previousClicks.wUpCount == 0)
{
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, 100);
oldnow = DateTime.UtcNow;
wheel = 100;
}
else if (globalState.currentClicks.wUpCount == 0 && globalState.previousClicks.wUpCount != 0)
wheel = 0;
globalState.currentClicks.wDownCount += state.currentClicks.wDownCount - state.previousClicks.wDownCount;
if (globalState.currentClicks.wDownCount != 0 && globalState.previousClicks.wDownCount == 0)
globalState.currentClicks.toggleCount += state.currentClicks.toggleCount - state.previousClicks.toggleCount;
globalState.currentClicks.toggle = state.currentClicks.toggle;
if (globalState.currentClicks.toggleCount != 0 && globalState.previousClicks.toggleCount == 0 && globalState.currentClicks.toggle)
{
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, -100);
oldnow = DateTime.UtcNow;
wheel = -100;
if (globalState.currentClicks.leftCount != 0 && globalState.previousClicks.leftCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN);
if (globalState.currentClicks.rightCount != 0 && globalState.previousClicks.rightCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTDOWN);
if (globalState.currentClicks.middleCount != 0 && globalState.previousClicks.middleCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEDOWN);
if (globalState.currentClicks.fourthCount != 0 && globalState.previousClicks.fourthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 1);
if (globalState.currentClicks.fifthCount != 0 && globalState.previousClicks.fifthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 2);
}
if (globalState.currentClicks.wDownCount == 0 && globalState.previousClicks.wDownCount != 0)
wheel = 0;
else if (globalState.currentClicks.toggleCount != 0 && globalState.previousClicks.toggleCount == 0 && !globalState.currentClicks.toggle)
{
if (globalState.currentClicks.leftCount != 0 && globalState.previousClicks.leftCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
if (globalState.currentClicks.rightCount != 0 && globalState.previousClicks.rightCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTUP);
if (globalState.currentClicks.middleCount != 0 && globalState.previousClicks.middleCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEUP);
if (globalState.currentClicks.fourthCount != 0 && globalState.previousClicks.fourthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 1);
if (globalState.currentClicks.fifthCount != 0 && globalState.previousClicks.fifthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 2);
}
if (globalState.currentClicks.toggleCount == 0 && globalState.previousClicks.toggleCount == 0)
{
if (globalState.currentClicks.leftCount != 0 && globalState.previousClicks.leftCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTDOWN);
else if (globalState.currentClicks.leftCount == 0 && globalState.previousClicks.leftCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_LEFTUP);
if (globalState.currentClicks.middleCount != 0 && globalState.previousClicks.middleCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEDOWN);
else if (globalState.currentClicks.middleCount == 0 && globalState.previousClicks.middleCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_MIDDLEUP);
if (globalState.currentClicks.rightCount != 0 && globalState.previousClicks.rightCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTDOWN);
else if (globalState.currentClicks.rightCount == 0 && globalState.previousClicks.rightCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_RIGHTUP);
if (globalState.currentClicks.fourthCount != 0 && globalState.previousClicks.fourthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 1);
else if (globalState.currentClicks.fourthCount == 0 && globalState.previousClicks.fourthCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 1);
if (globalState.currentClicks.fifthCount != 0 && globalState.previousClicks.fifthCount == 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONDOWN, 2);
else if (globalState.currentClicks.fifthCount == 0 && globalState.previousClicks.fifthCount != 0)
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_XBUTTONUP, 2);
if (globalState.currentClicks.wUpCount != 0 && globalState.previousClicks.wUpCount == 0)
{
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, 100);
oldnow = DateTime.UtcNow;
wheel = 100;
}
else if (globalState.currentClicks.wUpCount == 0 && globalState.previousClicks.wUpCount != 0)
wheel = 0;
if (globalState.currentClicks.wDownCount != 0 && globalState.previousClicks.wDownCount == 0)
{
InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, -100);
oldnow = DateTime.UtcNow;
wheel = -100;
}
if (globalState.currentClicks.wDownCount == 0 && globalState.previousClicks.wDownCount != 0)
wheel = 0;
}
if (wheel != 0) //Continue mouse wheel movement
{
@ -122,6 +161,8 @@ namespace DS4Control
gkp.current.vkCount += kvp.Value.current.vkCount - kvp.Value.previous.vkCount;
gkp.current.scanCodeCount += kvp.Value.current.scanCodeCount - kvp.Value.previous.scanCodeCount;
gkp.current.repeatCount += kvp.Value.current.repeatCount - kvp.Value.previous.repeatCount;
gkp.current.toggle = kvp.Value.current.toggle;
gkp.current.toggleCount += kvp.Value.current.toggleCount - kvp.Value.previous.toggleCount;
}
else
{
@ -130,7 +171,21 @@ namespace DS4Control
globalState.keyPresses[kvp.Key] = gkp;
}
if (gkp.current.vkCount + gkp.current.scanCodeCount != 0 && gkp.previous.vkCount + gkp.previous.scanCodeCount == 0)
if (gkp.current.toggleCount != 0 && gkp.previous.toggleCount == 0 && gkp.current.toggle)
{
if (gkp.current.scanCodeCount != 0)
InputMethods.performSCKeyPress(kvp.Key);
else
InputMethods.performKeyPress(kvp.Key);
}
else if (gkp.current.toggleCount != 0 && gkp.previous.toggleCount == 0 && !gkp.current.toggle)
{
if (gkp.previous.scanCodeCount != 0) // use the last type of VK/SC
InputMethods.performSCKeyRelease(kvp.Key);
else
InputMethods.performKeyRelease(kvp.Key);
}
else if (gkp.current.vkCount + gkp.current.scanCodeCount != 0 && gkp.previous.vkCount + gkp.previous.scanCodeCount == 0)
{
if (gkp.current.scanCodeCount != 0)
{
@ -147,7 +202,7 @@ namespace DS4Control
keyshelddown = kvp.Key;
}
}
else if (gkp.current.repeatCount != 0 || // repeat or SC/VK transition
else if (gkp.current.toggleCount != 0 || gkp.previous.toggleCount != 0 || gkp.current.repeatCount != 0 || // repeat or SC/VK transition
((gkp.previous.scanCodeCount == 0) != (gkp.current.scanCodeCount == 0))) //repeat keystroke after 500ms
{
if (keyshelddown == kvp.Key)
@ -165,7 +220,7 @@ namespace DS4Control
{
oldnow = now;
InputMethods.performSCKeyPress(kvp.Key);
}
}
}
else if (pressagain)
{
@ -177,9 +232,8 @@ namespace DS4Control
}
}
}
}
else if (gkp.current.vkCount + gkp.current.scanCodeCount == 0 && gkp.previous.vkCount + gkp.previous.scanCodeCount != 0)
else if ((gkp.current.toggleCount == 0 && gkp.previous.toggleCount == 0) && gkp.current.vkCount + gkp.current.scanCodeCount == 0 && gkp.previous.vkCount + gkp.previous.scanCodeCount != 0)
{
if (gkp.previous.scanCodeCount != 0) // use the last type of VK/SC
{
@ -230,10 +284,33 @@ namespace DS4Control
public static void MapTouchpadButton(int device, DS4Controls what, Click mouseEventFallback, DS4State MappedState = null)
{
SyntheticState deviceState = Mapping.deviceState[device];
ushort key = Global.getCustomKey(device, what);
if (key != 0)
string macro = Global.getCustomMacro(device, what);
if (!string.IsNullOrEmpty(macro))
{
DS4KeyType keyType = Global.getCustomKeyType(device, what);
SyntheticState.KeyPresses kp;
string[] skeys = macro.Split('/');
ushort[] keys = new ushort[skeys.Length];
for (int i = 0; i < keys.Length; i++)
{
keys[i] = ushort.Parse(skeys[i]);
if (keys[i] == 256) deviceState.currentClicks.leftCount++; //anything above 255 is not a keyvalue
if (keys[i] == 257) deviceState.currentClicks.rightCount++;
if (keys[i] == 258) deviceState.currentClicks.middleCount++;
if (keys[i] == 259) deviceState.currentClicks.fourthCount++;
if (keys[i] == 260) deviceState.currentClicks.fifthCount++;
if (!deviceState.keyPresses.TryGetValue(keys[i], out kp))
deviceState.keyPresses[keys[i]] = kp = new SyntheticState.KeyPresses();
if (keyType.HasFlag(DS4KeyType.ScanCode))
kp.current.scanCodeCount++;
else
kp.current.vkCount++;
kp.current.repeatCount++;
}
}
else if (Global.getCustomKey(device, what) != 0)
{
ushort key = Global.getCustomKey(device, what);
DS4KeyType keyType = Global.getCustomKeyType(device, what);
SyntheticState.KeyPresses kp;
if (!deviceState.keyPresses.TryGetValue(key, out kp))
@ -242,9 +319,9 @@ namespace DS4Control
kp.current.scanCodeCount++;
else
kp.current.vkCount++;
if (keyType.HasFlag(DS4KeyType.Repeat))
kp.current.repeatCount++;
}
if (keyType.HasFlag(DS4KeyType.Toggle))
kp.current.toggleCount++;
}
else
{
X360Controls button = Global.getCustomButton(device, what);
@ -276,7 +353,7 @@ namespace DS4Control
return;
}
return;
case X360Controls.LeftMouse:
case X360Controls.LeftMouse:
deviceState.currentClicks.leftCount++;
return;
case X360Controls.MiddleMouse:
@ -296,8 +373,8 @@ namespace DS4Control
return;
case X360Controls.WDOWN:
deviceState.currentClicks.wDownCount++;
return;
return;
case X360Controls.A:
MappedState.Cross = true;
return;
@ -351,23 +428,51 @@ namespace DS4Control
if (MappedState.R2 == 0)
MappedState.R2 = 255;
return;
case X360Controls.Unbound:
return;
default:
if (MappedState == null)
return;
break;
if (MappedState == null)
return;
break;
}
}
}
public static bool[] pressedonce = new bool[261];
public static int test = 0;
/** Map DS4 Buttons/Axes to other DS4 Buttons/Axes (largely the same as Xinput ones) and to keyboard and mouse buttons. */
public static void MapCustom(int device, DS4State cState, DS4State MappedState, DS4State pState = null)
{
cState.CopyTo(MappedState);
SyntheticState deviceState = Mapping.deviceState[device];
foreach (KeyValuePair<DS4Controls, string> customKey in Global.getCustomMacros(device))
{
DS4KeyType keyType = Global.getCustomKeyType(device, customKey.Key);
if (getBoolMapping(customKey.Key, cState))
{
resetToDefaultValue(customKey.Key, MappedState);
string[] skeys = customKey.Value.Split('/');
ushort[] keys = new ushort[skeys.Length];
for (int i = 0; i < keys.Length; i++)
{
keys[i] = ushort.Parse(skeys[i]);
if (keys[i] == 256) deviceState.currentClicks.leftCount++; //anything above 255 is not a keyvalue
if (keys[i] == 257) deviceState.currentClicks.rightCount++;
if (keys[i] == 258) deviceState.currentClicks.middleCount++;
if (keys[i] == 259) deviceState.currentClicks.fourthCount++;
if (keys[i] == 260) deviceState.currentClicks.fifthCount++;
SyntheticState.KeyPresses kp;
if (!deviceState.keyPresses.TryGetValue(keys[i], out kp))
deviceState.keyPresses[keys[i]] = kp = new SyntheticState.KeyPresses();
if (keyType.HasFlag(DS4KeyType.ScanCode))
kp.current.scanCodeCount++;
else
kp.current.vkCount++;
kp.current.repeatCount++;
}
}
}
foreach (KeyValuePair<DS4Controls, ushort> customKey in Global.getCustomKeys(device))
{
DS4KeyType keyType = Global.getCustomKeyType(device, customKey.Key);
@ -381,11 +486,22 @@ namespace DS4Control
kp.current.scanCodeCount++;
else
kp.current.vkCount++;
//if (keyType.HasFlag(DS4KeyType.Repeat))
kp.current.repeatCount++;
if (keyType.HasFlag(DS4KeyType.Toggle))
{
if (!pressedonce[customKey.Value])
{
kp.current.toggle = !kp.current.toggle;
pressedonce[customKey.Value] = true;
}
kp.current.toggleCount++;
}
kp.current.repeatCount++;
}
else
pressedonce[customKey.Value] = false;
}
bool LX = false, LY = false, RX = false, RY = false;
MappedState.LX = 127;
MappedState.LY = 127;
@ -395,14 +511,43 @@ namespace DS4Control
int MouseDeltaY = 0;
Dictionary<DS4Controls, X360Controls> customButtons = Global.getCustomButtons(device);
foreach (KeyValuePair<DS4Controls, X360Controls> customButton in customButtons)
resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped
//foreach (KeyValuePair<DS4Controls, X360Controls> customButton in customButtons)
// resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped
foreach (KeyValuePair<DS4Controls, X360Controls> customButton in customButtons)
{
DS4KeyType keyType = Global.getCustomKeyType(device, customButton.Key);
int keyvalue = 0;
switch (customButton.Value)
{
case X360Controls.LeftMouse: keyvalue = 256; break;
case X360Controls.RightMouse: keyvalue = 257; break;
case X360Controls.MiddleMouse: keyvalue = 258; break;
case X360Controls.FourthMouse: keyvalue = 259; break;
case X360Controls.FifthMouse: keyvalue = 260; break;
}
if (keyType.HasFlag(DS4KeyType.Toggle))
{
if (getBoolMapping(customButton.Key, cState))
{
resetToDefaultValue(customButton.Key, MappedState);
if (!pressedonce[keyvalue])
{
deviceState.currentClicks.toggle = !deviceState.currentClicks.toggle;
test++;
pressedonce[keyvalue] = true;
}
deviceState.currentClicks.toggleCount++;
}
else// if (test = 1)// && pressedonce[keyvalue])
{
pressedonce[keyvalue] = false;
}
}
bool LXChanged = (Math.Abs(127 - MappedState.LX) < 5);
bool LYChanged = (Math.Abs(127 - MappedState.LY) < 5);
bool RXChanged = (Math.Abs(127 - MappedState.RX) < 5);
bool RYChanged = (Math.Abs(127 - MappedState.RY) < 5);
resetToDefaultValue(customButton.Key, MappedState); // erase default mappings for things that are remapped
switch (customButton.Value)
{
case X360Controls.A:
@ -557,41 +702,34 @@ namespace DS4Control
if (getBoolMapping(customButton.Key, cState))
deviceState.currentClicks.wDownCount++;
break;
}
if (pState != null)
{
switch (customButton.Value)
{
case X360Controls.MouseUp:
if (MouseDeltaY == 0)
{
MouseDeltaY = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaY = -Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
}
break;
case X360Controls.MouseDown:
if (MouseDeltaY == 0)
{
MouseDeltaY = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaY = Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
}
break;
case X360Controls.MouseLeft:
if (MouseDeltaX == 0)
{
MouseDeltaX = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaX = -Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
}
break;
case X360Controls.MouseRight:
if (MouseDeltaX == 0)
{
MouseDeltaX = calculateRelativeMouseDelta(device, customButton.Key, cState, pState);
MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
}
break;
}
case X360Controls.MouseUp:
if (MouseDeltaY == 0)
{
MouseDeltaY = getMouseMapping(device, customButton.Key, cState, pState);
MouseDeltaY = -Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
}
break;
case X360Controls.MouseDown:
if (MouseDeltaY == 0)
{
MouseDeltaY = getMouseMapping(device, customButton.Key, cState, pState);
MouseDeltaY = Math.Abs((MouseDeltaY == -2147483648 ? 0 : MouseDeltaY));
}
break;
case X360Controls.MouseLeft:
if (MouseDeltaX == 0)
{
MouseDeltaX = getMouseMapping(device, customButton.Key, cState, pState);
MouseDeltaX = -Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
}
break;
case X360Controls.MouseRight:
if (MouseDeltaX == 0)
{
MouseDeltaX = getMouseMapping(device, customButton.Key, cState, pState);
MouseDeltaX = Math.Abs((MouseDeltaX == -2147483648 ? 0 : MouseDeltaX));
}
break;
}
}
@ -606,68 +744,64 @@ namespace DS4Control
InputMethods.MoveCursorBy(MouseDeltaX, MouseDeltaY);
}
private static int calculateRelativeMouseDelta(int device, DS4Controls control, DS4State cState, DS4State pState)
private static int getMouseMapping(int device, DS4Controls control, DS4State cState, DS4State pState)
{
int axisVal = -1;
int DEAD_ZONE = 10;
float SPEED_MULTIPLIER = 0.000004f;
bool positive = false;
float deltaTime = cState.ReportTimeStamp.Ticks - pState.ReportTimeStamp.Ticks;
double value = 0;
int deadzone = 10;
int speed = Global.getButtonMouseSensitivity(device);
switch (control)
{
case DS4Controls.LXNeg:
axisVal = (byte)cState.LX;
if (cState.LX < 127 - deadzone)
value = ((cState.LX - 127) / 127d) * speed;
break;
case DS4Controls.LXPos:
positive = true;
axisVal = (byte)cState.LX;
if (cState.LX > 127 + deadzone)
value = ((cState.LX - 127) / 127d) * speed;
break;
case DS4Controls.RXNeg:
axisVal = (byte)cState.RX;
if (cState.RX < 127 - deadzone)
value = -((cState.RX-127) / 127d) * speed;
break;
case DS4Controls.RXPos:
positive = true;
axisVal = (byte)cState.RX;
if (cState.RX > 127 + deadzone)
value = ((cState.RX-127) / 127d) * speed;
break;
case DS4Controls.LYNeg:
axisVal = (byte)cState.LY;
if (cState.LY < 127 - deadzone)
value = -((cState.LY - 127)/127d) * speed;
break;
case DS4Controls.LYPos:
positive = true;
axisVal = (byte)cState.LY;
if (cState.LY > 127 + deadzone)
value = ((cState.LY - 127) / 127d) * speed;
break;
case DS4Controls.RYNeg:
axisVal = (byte)cState.RY;
if (cState.RY < 127 - deadzone)
value = -((cState.RY - 127) / 127d) * speed;
break;
case DS4Controls.RYPos:
positive = true;
axisVal = (byte)cState.RY;
if (cState.RY > 127 + deadzone)
value = ((cState.RY - 127) / 127d) * speed;
break;
case DS4Controls.Share: axisVal = (byte)(cState.Share ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.Options: axisVal = (byte)(cState.Options ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.L1: axisVal = (byte)(cState.L1 ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.R1: axisVal = (byte)(cState.R1 ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.L3: axisVal = (byte)(cState.L3 ? 117 - Global.getButtonMouseSensitivity(device) : -1); break;
case DS4Controls.R3: axisVal = (byte)(cState.R3 ? 117 - Global.getButtonMouseSensitivity(device) : -1); break;
case DS4Controls.DpadUp: axisVal = (byte)(cState.DpadUp ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.DpadDown: axisVal = (byte)(cState.DpadDown ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.DpadLeft: axisVal = (byte)(cState.DpadLeft ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.DpadRight: axisVal = (byte)(cState.DpadRight ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.PS: axisVal = (byte)(cState.PS ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.Cross: axisVal = (byte)(cState.Cross ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.Square: axisVal = (byte)(cState.Square ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.Triangle: axisVal = (byte)(cState.Triangle ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.Circle: axisVal = (byte)(cState.Circle ? -Global.getButtonMouseSensitivity(device) + 117 : -1); break;
case DS4Controls.L2: positive = true; axisVal = (byte)cState.L2; break;
case DS4Controls.R2: positive = true; axisVal = (byte)cState.R2; break;
case DS4Controls.Share: value = (cState.Share ? speed / 2 : 0); break;
case DS4Controls.Options: value = (cState.Options ? speed / 2 : 0); break;
case DS4Controls.L1: value = (cState.L1 ? speed / 2 : 0); break;
case DS4Controls.R1: value = (cState.R1 ? speed / 2 : 0); break;
case DS4Controls.L3: value = (cState.L3 ? speed / 2 : 0); break;
case DS4Controls.R3: value = (cState.R3 ? speed / 2 : 0); break;
case DS4Controls.DpadUp: value = (cState.DpadUp ? speed / 2 : 0); break;
case DS4Controls.DpadDown: value = (cState.DpadDown ? speed / 2 : 0); break;
case DS4Controls.DpadLeft: value = (cState.DpadLeft ? speed / 2 : 0); break;
case DS4Controls.DpadRight: value = (cState.DpadRight ? speed / 2 : 0); break;
case DS4Controls.PS: value = (cState.PS ? speed / 2 : 0); break;
case DS4Controls.Cross: value = (cState.Cross ? speed / 2 : 0); break;
case DS4Controls.Square: value = (cState.Square ? speed / 2 : 0); break;
case DS4Controls.Triangle: value = (cState.Triangle ? speed / 2 : 0); break;
case DS4Controls.Circle: value = (cState.Circle ? speed / 2 : 0); break;
case DS4Controls.L2: value = ((cState.L2 / 2d) / 127d) * speed; break;
case DS4Controls.R2: value = ((cState.R2 / 2d) / 127d) * speed; break;
}
axisVal = axisVal - 127;
int delta = 0;
if ((!positive && axisVal < -DEAD_ZONE) || (positive && axisVal > DEAD_ZONE))
{
delta = (int)(float)(axisVal * SPEED_MULTIPLIER * deltaTime);
}
return delta;
return (int)Math.Round(value,0);
}
public static bool compare(byte b1, byte b2)

View File

@ -5,11 +5,12 @@ using System.Text;
using System.IO;
using System.Reflection;
using System.Xml;
using System.Drawing;
using DS4Library;
namespace DS4Control
{
[Flags]
public enum DS4KeyType : byte { None = 0, ScanCode = 1, Repeat = 2, Unbound = 4 }; //Increment by exponents of 2*, starting at 2^0
public enum DS4KeyType : byte { None = 0, ScanCode = 1, Toggle = 2, Unbound = 4, Macro = 8 }; //Increment by exponents of 2*, starting at 2^0
public enum Ds3PadId : byte { None = 0xFF, One = 0x00, Two = 0x01, Three = 0x02, Four = 0x03, All = 0x04 };
public enum DS4Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, L1, L2, L3, R1, R2, R3, Square, Triangle, Circle, Cross, DpadUp, DpadRight, DpadDown, DpadLeft, PS, TouchLeft, TouchUpper, TouchMulti, TouchRight, Share, Options };
public enum X360Controls : byte { None, LXNeg, LXPos, LYNeg, LYPos, RXNeg, RXPos, RYNeg, RYPos, LB, LT, LS, RB, RT, RS, X, Y, B, A, DpadUp, DpadRight, DpadDown, DpadLeft, Guide, Back, Start, LeftMouse, RightMouse, MiddleMouse, FourthMouse, FifthMouse, WUP, WDOWN, MouseUp, MouseDown, MouseLeft, MouseRight, Unbound };
@ -338,6 +339,10 @@ namespace DS4Control
{
return m_Config.GetCustomKey(device, controlName);
}
public static string getCustomMacro(int device, DS4Controls controlName)
{
return m_Config.GetCustomMacro(device, controlName);
}
public static DS4KeyType getCustomKeyType(int device, DS4Controls controlName)
{
return m_Config.GetCustomKeyType(device, controlName);
@ -355,6 +360,10 @@ namespace DS4Control
{
return m_Config.customMapKeys[device];
}
public static Dictionary<DS4Controls, string> getCustomMacros(int device)
{
return m_Config.customMapMacros[device];
}
public static Dictionary<DS4Controls, DS4KeyType> getCustomKeyTypes(int device)
{
return m_Config.customMapKeyTypes[device];
@ -409,7 +418,7 @@ namespace DS4Control
protected String m_Profile = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool\\Profiles.xml";
protected XmlDocument m_Xdoc = new XmlDocument();
public int[] buttonMouseSensitivity = { 50, 50, 50, 50 };
public int[] buttonMouseSensitivity = { 25, 25, 25, 25 };
public Boolean[] touchpadJitterCompensation = {true, true, true, true};
public Boolean[] lowerRCOn = { false, false, false, false };
@ -449,6 +458,7 @@ namespace DS4Control
public DateTime lastChecked;
public Dictionary<DS4Controls, DS4KeyType>[] customMapKeyTypes = {null, null, null, null};
public Dictionary<DS4Controls, UInt16>[] customMapKeys = { null, null, null, null };
public Dictionary<DS4Controls, String>[] customMapMacros = { null, null, null, null };
public Dictionary<DS4Controls, X360Controls>[] customMapButtons = { null, null, null, null };
public BackingStore()
{
@ -456,6 +466,7 @@ namespace DS4Control
{
customMapKeyTypes[i] = new Dictionary<DS4Controls, DS4KeyType>();
customMapKeys[i] = new Dictionary<DS4Controls, UInt16>();
customMapMacros[i] = new Dictionary<DS4Controls, String>();
customMapButtons[i] = new Dictionary<DS4Controls, X360Controls>();
}
}
@ -472,6 +483,12 @@ namespace DS4Control
return customMapKeys[device][controlName];
else return 0;
}
public string GetCustomMacro(int device, DS4Controls controlName)
{
if (customMapMacros[device].ContainsKey(controlName))
return customMapMacros[device][controlName];
else return "0";
}
public DS4KeyType GetCustomKeyType(int device, DS4Controls controlName)
{
if (customMapKeyTypes[device].ContainsKey(controlName))
@ -528,6 +545,7 @@ namespace DS4Control
XmlNode NodeControl = m_Xdoc.CreateNode(XmlNodeType.Element, "Control", null);
XmlNode Key = m_Xdoc.CreateNode(XmlNodeType.Element, "Key", null);
XmlNode Macro = m_Xdoc.CreateNode(XmlNodeType.Element, "Macro", null);
XmlNode KeyType = m_Xdoc.CreateNode(XmlNodeType.Element, "KeyType", null);
XmlNode Button = m_Xdoc.CreateNode(XmlNodeType.Element, "Button", null);
@ -544,8 +562,10 @@ namespace DS4Control
keyType += DS4KeyType.Unbound;
}
{
/*if (button.ForeColor == System.Drawing.Color.Red)
keyType += DS4KeyType.Repeat;*/
if (button.Font.Underline)
keyType += DS4KeyType.Macro;
if (button.Font.Italic)
keyType += DS4KeyType.Toggle;
if (button.Font.Bold)
keyType += DS4KeyType.ScanCode;
}
@ -557,7 +577,12 @@ namespace DS4Control
}
buttonNode = m_Xdoc.CreateNode(XmlNodeType.Element, button.Name, null);
buttonNode.InnerText = button.Tag.ToString();
if (button.Tag is Int32 || button.Tag is UInt16)
if (button.Tag is IEnumerable<int> || button.Tag is Int32[] || button.Tag is UInt16[])
{
buttonNode.InnerText = string.Join("/", (int[])button.Tag);
Macro.AppendChild(buttonNode);
}
else if (button.Tag is Int32 || button.Tag is UInt16)
Key.AppendChild(buttonNode);
else Button.AppendChild(buttonNode);
}
@ -569,6 +594,8 @@ namespace DS4Control
Node.AppendChild(NodeControl);
if (Button.HasChildNodes)
NodeControl.AppendChild(Button);
if (Macro.HasChildNodes)
NodeControl.AppendChild(Macro);
if (Key.HasChildNodes)
NodeControl.AppendChild(Key);
if (KeyType.HasChildNodes)
@ -677,6 +704,7 @@ namespace DS4Control
Dictionary<DS4Controls, DS4KeyType> customMapKeyTypes = new Dictionary<DS4Controls, DS4KeyType>();
Dictionary<DS4Controls, UInt16> customMapKeys = new Dictionary<DS4Controls, UInt16>();
Dictionary<DS4Controls, X360Controls> customMapButtons = new Dictionary<DS4Controls, X360Controls>();
Dictionary<DS4Controls, String> customMapMacros = new Dictionary<DS4Controls, String>();
Boolean missingSetting = false;
try
@ -762,24 +790,44 @@ namespace DS4Control
}
else
{
bool SC = Item.InnerText.Contains(DS4KeyType.ScanCode.ToString());
bool TG = Item.InnerText.Contains(DS4KeyType.Toggle.ToString());
bool MC = Item.InnerText.Contains(DS4KeyType.Macro.ToString());
button.Font = new Font(button.Font, (SC ? FontStyle.Bold : FontStyle.Regular) |
(TG ? FontStyle.Italic : FontStyle.Regular) | (MC ? FontStyle.Underline : FontStyle.Regular));
if (Item.InnerText.Contains(DS4KeyType.ScanCode.ToString()))
{
keyType |= DS4KeyType.ScanCode;
button.Font = new System.Drawing.Font(button.Font, System.Drawing.FontStyle.Bold);
}
/*if (Item.InnerText.Contains(DS4KeyType.Repeat.ToString()))
{
keyType |= DS4KeyType.Repeat;
button.ForeColor = System.Drawing.Color.Red;
}*/
if (Item.InnerText.Contains(DS4KeyType.Toggle.ToString()))
keyType |= DS4KeyType.Toggle;
if (Item.InnerText.Contains(DS4KeyType.Macro.ToString()))
keyType |= DS4KeyType.Macro;
}
if (keyType != DS4KeyType.None)
customMapKeyTypes.Add(getDS4ControlsByName(Item.Name), keyType);
}
Item = m_Xdoc.SelectSingleNode(String.Format("/ScpControl/Control/Key/{0}", button.Name));
Item = m_Xdoc.SelectSingleNode(String.Format("/ScpControl/Control/Macro/{0}", button.Name));
if (Item != null)
{
string[] splitter = Item.InnerText.Split('/');
int[] keys = new int[splitter.Length];
for (int i = 0; i < keys.Length; i++)
{
keys[i] = int.Parse(splitter[i]);
if (keys[i] < 255) splitter[i] = ((System.Windows.Forms.Keys)keys[i]).ToString();
else if (keys[i] == 256) splitter[i] = "Left Mouse Button";
else if (keys[i] == 257) splitter[i] = "Right Mouse Button";
else if (keys[i] == 258) splitter[i] = "Middle Mouse Button";
else if (keys[i] == 259) splitter[i] = "4th Mouse Button";
else if (keys[i] == 260) splitter[i] = "5th Mouse Button";
}
button.Text = string.Join(", ", splitter);
button.Tag = keys;
customMapMacros.Add(getDS4ControlsByName(button.Name), Item.InnerText);
}
else if (m_Xdoc.SelectSingleNode(String.Format("/ScpControl/Control/Key/{0}", button.Name)) != null)
{
Item = m_Xdoc.SelectSingleNode(String.Format("/ScpControl/Control/Key/{0}", button.Name));
if (UInt16.TryParse(Item.InnerText, out wvk))
{
//foundBinding = true;
@ -813,6 +861,7 @@ namespace DS4Control
this.customMapButtons[device] = customMapButtons;
this.customMapKeys[device] = customMapKeys;
this.customMapKeyTypes[device] = customMapKeyTypes;
this.customMapMacros[device] = customMapMacros;
}
// Only add missing settings if the actual load was graceful
if (missingSetting && Loaded)
@ -826,6 +875,7 @@ namespace DS4Control
Dictionary<DS4Controls, DS4KeyType> customMapKeyTypes = new Dictionary<DS4Controls, DS4KeyType>();
Dictionary<DS4Controls, UInt16> customMapKeys = new Dictionary<DS4Controls, UInt16>();
Dictionary<DS4Controls, X360Controls> customMapButtons = new Dictionary<DS4Controls, X360Controls>();
Dictionary<DS4Controls, String> customMapMacros = new Dictionary<DS4Controls, String>();
Boolean missingSetting = false;
try
@ -898,6 +948,10 @@ namespace DS4Control
if (ParentItem != null)
foreach (XmlNode item in ParentItem.ChildNodes)
customMapButtons.Add(getDS4ControlsByName(item.Name), getX360ControlsByName(item.InnerText));
ParentItem = m_Xdoc.SelectSingleNode("/ScpControl/Control/Macro");
if (ParentItem != null)
foreach (XmlNode item in ParentItem.ChildNodes)
customMapMacros.Add(getDS4ControlsByName(item.Name), item.InnerText);
ParentItem = m_Xdoc.SelectSingleNode("/ScpControl/Control/Key");
if (ParentItem != null)
foreach (XmlNode item in ParentItem.ChildNodes)
@ -911,8 +965,10 @@ namespace DS4Control
keyType = DS4KeyType.None;
if (item.InnerText.Contains(DS4KeyType.ScanCode.ToString()))
keyType |= DS4KeyType.ScanCode;
//if (item.InnerText.Contains(DS4KeyType.Repeat.ToString()))
//keyType |= DS4KeyType.Repeat;
if (item.InnerText.Contains(DS4KeyType.Toggle.ToString()))
keyType |= DS4KeyType.Toggle;
if (item.InnerText.Contains(DS4KeyType.Macro.ToString()))
keyType |= DS4KeyType.Macro;
if (item.InnerText.Contains(DS4KeyType.Unbound.ToString()))
keyType |= DS4KeyType.Unbound;
if (keyType != DS4KeyType.None)
@ -927,6 +983,7 @@ namespace DS4Control
this.customMapButtons[device] = customMapButtons;
this.customMapKeys[device] = customMapKeys;
this.customMapKeyTypes[device] = customMapKeyTypes;
this.customMapMacros[device] = customMapMacros;
}
// Only add missing settings if the actual load was graceful
if (missingSetting && Loaded)

View File

@ -264,6 +264,12 @@ namespace DS4Library
return priorInputReport30 != 0xff;
}
private byte priorInputReport30 = 0xff;
[DllImport("user32.dll", SetLastError = true)]
static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo);
public void ReleaseKeys(ushort key)
{
keybd_event((byte)key, 0, 2, 0);
}
private void performDs4Input()
{
System.Timers.Timer readTimeout = new System.Timers.Timer(); // Await 30 seconds for the initial packet, then 3 seconds thereafter.
@ -404,24 +410,24 @@ namespace DS4Library
Console.Write(" " + inputReport[i].ToString("x2"));
Console.WriteLine();
} */
if (!isNonSixaxisIdle())
lastActive = utcNow;
if (conType == ConnectionType.BT)
{
bool shouldDisconnect = false;
if ((!pState.PS || !pState.Options) && cState.PS && cState.Options)
/*if ((!pState.PS || !pState.Options) && cState.PS && cState.Options)
{
shouldDisconnect = true;
}
else if (IdleTimeout > 0)
for (int i = 0; i < 255; i++)
ReleaseKeys(i);
}*/
if (IdleTimeout > 0)
{
if (!isNonSixaxisIdle())
{
lastActive = utcNow;
}
else
if (isNonSixaxisIdle())
{
DateTime timeout = lastActive + TimeSpan.FromSeconds(IdleTimeout);
shouldDisconnect = utcNow >= timeout;
if (!Charging)
shouldDisconnect = utcNow >= timeout;
}
}
if (shouldDisconnect && DisconnectBT())

View File

@ -142,6 +142,7 @@
<SubType>Designer</SubType>
<LastGenOutput>Resources1.Designer.cs</LastGenOutput>
</EmbeddedResource>
<EmbeddedResource Include="Resource.es.resx" />
<EmbeddedResource Include="ScpForm.resx">
<DependentUpon>ScpForm.cs</DependentUpon>
</EmbeddedResource>

View File

@ -28,6 +28,7 @@
/// </summary>
private void InitializeComponent()
{
System.ComponentModel.ComponentResourceManager resources = new System.ComponentModel.ComponentResourceManager(typeof(Hotkeys));
this.label1 = new System.Windows.Forms.Label();
this.label3 = new System.Windows.Forms.Label();
this.label4 = new System.Windows.Forms.Label();
@ -107,7 +108,7 @@
// button1
//
this.button1.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.button1.Location = new System.Drawing.Point(163, 275);
this.button1.Location = new System.Drawing.Point(163, 332);
this.button1.Name = "button1";
this.button1.Size = new System.Drawing.Size(75, 23);
this.button1.TabIndex = 8;
@ -135,12 +136,12 @@
//
// label13
//
this.label13.AutoSize = true;
this.label13.Location = new System.Drawing.Point(24, 171);
this.label13.Location = new System.Drawing.Point(2, 171);
this.label13.Name = "label13";
this.label13.Size = new System.Drawing.Size(362, 13);
this.label13.Size = new System.Drawing.Size(397, 57);
this.label13.TabIndex = 14;
this.label13.Text = "When mapping as keyboard, Scan Code may be needed for certain games.";
this.label13.Text = resources.GetString("label13.Text");
this.label13.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// label14
//
@ -164,7 +165,7 @@
//
this.linkProfiles.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkProfiles.AutoSize = true;
this.linkProfiles.Location = new System.Drawing.Point(292, 280);
this.linkProfiles.Location = new System.Drawing.Point(292, 337);
this.linkProfiles.Name = "linkProfiles";
this.linkProfiles.Size = new System.Drawing.Size(94, 13);
this.linkProfiles.TabIndex = 17;
@ -174,19 +175,21 @@
//
// linkElectro
//
this.linkElectro.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkElectro.AutoSize = true;
this.linkElectro.Location = new System.Drawing.Point(215, 216);
this.linkElectro.Location = new System.Drawing.Point(215, 273);
this.linkElectro.Name = "linkElectro";
this.linkElectro.Size = new System.Drawing.Size(143, 13);
this.linkElectro.Size = new System.Drawing.Size(149, 13);
this.linkElectro.TabIndex = 18;
this.linkElectro.TabStop = true;
this.linkElectro.Text = "elctrobrains (Branched off of)";
this.linkElectro.Text = "electrobrains (Branched off of)";
this.linkElectro.LinkClicked += new System.Windows.Forms.LinkLabelLinkClickedEventHandler(this.linkLabel1_LinkClicked);
//
// linkJays2Kings
//
this.linkJays2Kings.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkJays2Kings.AutoSize = true;
this.linkJays2Kings.Location = new System.Drawing.Point(95, 216);
this.linkJays2Kings.Location = new System.Drawing.Point(95, 273);
this.linkJays2Kings.Name = "linkJays2Kings";
this.linkJays2Kings.Size = new System.Drawing.Size(60, 13);
this.linkJays2Kings.TabIndex = 18;
@ -196,8 +199,9 @@
//
// label2
//
this.label2.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.label2.AutoSize = true;
this.label2.Location = new System.Drawing.Point(146, 194);
this.label2.Location = new System.Drawing.Point(146, 251);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(109, 13);
this.label2.TabIndex = 13;
@ -215,8 +219,9 @@
//
// linkInhexSTER
//
this.linkInhexSTER.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkInhexSTER.AutoSize = true;
this.linkInhexSTER.Location = new System.Drawing.Point(38, 243);
this.linkInhexSTER.Location = new System.Drawing.Point(38, 300);
this.linkInhexSTER.Name = "linkInhexSTER";
this.linkInhexSTER.Size = new System.Drawing.Size(159, 13);
this.linkInhexSTER.TabIndex = 18;
@ -226,8 +231,9 @@
//
// linkJhebbel
//
this.linkJhebbel.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkJhebbel.AutoSize = true;
this.linkJhebbel.Location = new System.Drawing.Point(268, 243);
this.linkJhebbel.Location = new System.Drawing.Point(268, 300);
this.linkJhebbel.Name = "linkJhebbel";
this.linkJhebbel.Size = new System.Drawing.Size(41, 13);
this.linkJhebbel.TabIndex = 18;
@ -239,7 +245,7 @@
//
this.linkUninstall.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left)));
this.linkUninstall.AutoSize = true;
this.linkUninstall.Location = new System.Drawing.Point(12, 280);
this.linkUninstall.Location = new System.Drawing.Point(12, 337);
this.linkUninstall.Name = "linkUninstall";
this.linkUninstall.Size = new System.Drawing.Size(106, 13);
this.linkUninstall.TabIndex = 17;
@ -251,7 +257,7 @@
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(399, 302);
this.ClientSize = new System.Drawing.Size(399, 359);
this.Controls.Add(this.linkJhebbel);
this.Controls.Add(this.linkInhexSTER);
this.Controls.Add(this.linkJays2Kings);

View File

@ -117,4 +117,10 @@
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="label13.Text" xml:space="preserve">
<value>When mapping as keyboard and mouse:
Toggle - The key will remain in a "held down" state until pressed again
Macro - Assign multiple keys to one input
Scan Code - keys are interperted differently. May be needed for certain games.</value>
</data>
</root>

View File

@ -28,7 +28,7 @@
/// </summary>
private void InitializeComponent()
{
this.label2 = new System.Windows.Forms.Label();
this.lBTip = new System.Windows.Forms.Label();
this.cbScanCode = new System.Windows.Forms.CheckBox();
this.button7 = new System.Windows.Forms.Button();
this.button5 = new System.Windows.Forms.Button();
@ -139,8 +139,8 @@
this.btnR = new System.Windows.Forms.Button();
this.bTNRIGHTMOUSE = new System.Windows.Forms.Button();
this.btnE = new System.Windows.Forms.Button();
this.button32 = new System.Windows.Forms.Button();
this.button31 = new System.Windows.Forms.Button();
this.bnWHEELDOWN = new System.Windows.Forms.Button();
this.bnWHEELUP = new System.Windows.Forms.Button();
this.btnMIDDLEMOUSE = new System.Windows.Forms.Button();
this.btnW = new System.Windows.Forms.Button();
this.button33 = new System.Windows.Forms.Button();
@ -152,7 +152,7 @@
this.btnLEFTMOUSE = new System.Windows.Forms.Button();
this.btnQ = new System.Windows.Forms.Button();
this.pictureBox2 = new System.Windows.Forms.PictureBox();
this.cbRepeat = new System.Windows.Forms.CheckBox();
this.cbToggle = new System.Windows.Forms.CheckBox();
this.btnUNBOUND2 = new System.Windows.Forms.Button();
this.button13 = new System.Windows.Forms.Button();
this.button2 = new System.Windows.Forms.Button();
@ -182,30 +182,32 @@
this.pictureBox1 = new System.Windows.Forms.PictureBox();
this.X360Label = new System.Windows.Forms.Label();
this.KBMlabel = new System.Windows.Forms.Label();
this.cBMacro = new System.Windows.Forms.CheckBox();
this.lBMacroOrder = new System.Windows.Forms.Label();
((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit();
((System.ComponentModel.ISupportInitialize)(this.pictureBox1)).BeginInit();
this.SuspendLayout();
//
// label2
// lBTip
//
this.label2.AutoSize = true;
this.label2.ForeColor = System.Drawing.SystemColors.GrayText;
this.label2.Location = new System.Drawing.Point(465, 110);
this.label2.Name = "label2";
this.label2.Size = new System.Drawing.Size(103, 26);
this.label2.TabIndex = 289;
this.label2.Text = "You can also select \r\na key by typing it";
this.label2.TextAlign = System.Drawing.ContentAlignment.TopCenter;
this.lBTip.AutoSize = true;
this.lBTip.ForeColor = System.Drawing.SystemColors.GrayText;
this.lBTip.Location = new System.Drawing.Point(465, 110);
this.lBTip.Name = "lBTip";
this.lBTip.Size = new System.Drawing.Size(103, 26);
this.lBTip.TabIndex = 289;
this.lBTip.Text = "You can also select \r\na key by typing it";
this.lBTip.TextAlign = System.Drawing.ContentAlignment.TopCenter;
//
// cbScanCode
//
this.cbScanCode.AutoSize = true;
this.cbScanCode.Location = new System.Drawing.Point(696, 169);
this.cbScanCode.Location = new System.Drawing.Point(706, 5);
this.cbScanCode.Name = "cbScanCode";
this.cbScanCode.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.cbScanCode.Size = new System.Drawing.Size(54, 30);
this.cbScanCode.Size = new System.Drawing.Size(79, 17);
this.cbScanCode.TabIndex = 288;
this.cbScanCode.Text = "Scan \r\nCode";
this.cbScanCode.Text = "Scan Code";
this.cbScanCode.UseVisualStyleBackColor = true;
//
// button7
@ -285,7 +287,7 @@
this.btnNUM0.Size = new System.Drawing.Size(54, 24);
this.btnNUM0.TabIndex = 280;
this.btnNUM0.Tag = "96";
this.btnNUM0.Text = "0";
this.btnNUM0.Text = "Num0";
this.btnNUM0.UseVisualStyleBackColor = true;
//
// btnNUM6
@ -1301,25 +1303,25 @@
this.btnE.Text = "E";
this.btnE.UseVisualStyleBackColor = true;
//
// button32
// bnWHEELDOWN
//
this.button32.Location = new System.Drawing.Point(783, 107);
this.button32.Name = "button32";
this.button32.Size = new System.Drawing.Size(24, 21);
this.button32.TabIndex = 175;
this.button32.Tag = "Mouse Wheel Down";
this.button32.Text = "↓Mouse Wheel Down";
this.button32.UseVisualStyleBackColor = true;
this.bnWHEELDOWN.Location = new System.Drawing.Point(783, 107);
this.bnWHEELDOWN.Name = "bnWHEELDOWN";
this.bnWHEELDOWN.Size = new System.Drawing.Size(24, 21);
this.bnWHEELDOWN.TabIndex = 175;
this.bnWHEELDOWN.Tag = "Mouse Wheel Down";
this.bnWHEELDOWN.Text = "↓Mouse Wheel Down";
this.bnWHEELDOWN.UseVisualStyleBackColor = true;
//
// button31
// bnWHEELUP
//
this.button31.Location = new System.Drawing.Point(783, 59);
this.button31.Name = "button31";
this.button31.Size = new System.Drawing.Size(24, 22);
this.button31.TabIndex = 174;
this.button31.Tag = "Mouse Wheel Up";
this.button31.Text = "↑Mouse Wheel Up";
this.button31.UseVisualStyleBackColor = true;
this.bnWHEELUP.Location = new System.Drawing.Point(783, 59);
this.bnWHEELUP.Name = "bnWHEELUP";
this.bnWHEELUP.Size = new System.Drawing.Size(24, 22);
this.bnWHEELUP.TabIndex = 174;
this.bnWHEELUP.Tag = "Mouse Wheel Up";
this.bnWHEELUP.Text = "↑Mouse Wheel Up";
this.bnWHEELUP.UseVisualStyleBackColor = true;
//
// btnMIDDLEMOUSE
//
@ -1432,17 +1434,17 @@
this.pictureBox2.TabIndex = 290;
this.pictureBox2.TabStop = false;
//
// cbRepeat
// cbToggle
//
this.cbRepeat.AutoSize = true;
this.cbRepeat.Location = new System.Drawing.Point(790, 25);
this.cbRepeat.Name = "cbRepeat";
this.cbRepeat.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.cbRepeat.Size = new System.Drawing.Size(61, 17);
this.cbRepeat.TabIndex = 287;
this.cbRepeat.Text = "Repeat";
this.cbRepeat.UseVisualStyleBackColor = true;
this.cbRepeat.Visible = false;
this.cbToggle.AutoSize = true;
this.cbToggle.Location = new System.Drawing.Point(641, 5);
this.cbToggle.Name = "cbToggle";
this.cbToggle.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.cbToggle.Size = new System.Drawing.Size(59, 17);
this.cbToggle.TabIndex = 287;
this.cbToggle.Text = "Toggle";
this.cbToggle.UseVisualStyleBackColor = true;
this.cbToggle.CheckedChanged += new System.EventHandler(this.cbToggle_CheckedChanged);
//
// btnUNBOUND2
//
@ -1733,11 +1735,34 @@
this.KBMlabel.TabIndex = 318;
this.KBMlabel.Text = "Keyboard and Mouse";
//
// cBMacro
//
this.cBMacro.AutoSize = true;
this.cBMacro.Location = new System.Drawing.Point(791, 5);
this.cBMacro.Name = "cBMacro";
this.cBMacro.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.cBMacro.Size = new System.Drawing.Size(56, 17);
this.cBMacro.TabIndex = 287;
this.cBMacro.Text = "Macro";
this.cBMacro.UseVisualStyleBackColor = true;
this.cBMacro.CheckedChanged += new System.EventHandler(this.cBMacro_CheckedChanged);
//
// lBMacroOrder
//
this.lBMacroOrder.AutoSize = true;
this.lBMacroOrder.Location = new System.Drawing.Point(12, 6);
this.lBMacroOrder.Name = "lBMacroOrder";
this.lBMacroOrder.Size = new System.Drawing.Size(72, 13);
this.lBMacroOrder.TabIndex = 319;
this.lBMacroOrder.Text = "Macro Order: ";
this.lBMacroOrder.Visible = false;
//
// KBM360
//
this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F);
this.AutoScaleMode = System.Windows.Forms.AutoScaleMode.Font;
this.ClientSize = new System.Drawing.Size(854, 403);
this.Controls.Add(this.lBMacroOrder);
this.Controls.Add(this.KBMlabel);
this.Controls.Add(this.X360Label);
this.Controls.Add(this.btnUNBOUND2);
@ -1767,7 +1792,7 @@
this.Controls.Add(this.button21);
this.Controls.Add(this.button3);
this.Controls.Add(this.pictureBox1);
this.Controls.Add(this.label2);
this.Controls.Add(this.lBTip);
this.Controls.Add(this.cbScanCode);
this.Controls.Add(this.button7);
this.Controls.Add(this.button5);
@ -1878,8 +1903,8 @@
this.Controls.Add(this.btnR);
this.Controls.Add(this.bTNRIGHTMOUSE);
this.Controls.Add(this.btnE);
this.Controls.Add(this.button32);
this.Controls.Add(this.button31);
this.Controls.Add(this.bnWHEELDOWN);
this.Controls.Add(this.bnWHEELUP);
this.Controls.Add(this.btnMIDDLEMOUSE);
this.Controls.Add(this.btnW);
this.Controls.Add(this.button33);
@ -1891,7 +1916,8 @@
this.Controls.Add(this.btnLEFTMOUSE);
this.Controls.Add(this.btnQ);
this.Controls.Add(this.pictureBox2);
this.Controls.Add(this.cbRepeat);
this.Controls.Add(this.cBMacro);
this.Controls.Add(this.cbToggle);
this.FormBorderStyle = System.Windows.Forms.FormBorderStyle.FixedSingle;
this.KeyPreview = true;
this.MaximizeBox = false;
@ -1909,7 +1935,7 @@
#endregion
private System.Windows.Forms.Label label2;
private System.Windows.Forms.Label lBTip;
private System.Windows.Forms.CheckBox cbScanCode;
private System.Windows.Forms.Button button7;
private System.Windows.Forms.Button button5;
@ -2020,8 +2046,8 @@
private System.Windows.Forms.Button btnR;
private System.Windows.Forms.Button bTNRIGHTMOUSE;
private System.Windows.Forms.Button btnE;
private System.Windows.Forms.Button button32;
private System.Windows.Forms.Button button31;
private System.Windows.Forms.Button bnWHEELDOWN;
private System.Windows.Forms.Button bnWHEELUP;
private System.Windows.Forms.Button btnMIDDLEMOUSE;
private System.Windows.Forms.Button btnW;
private System.Windows.Forms.Button button33;
@ -2033,7 +2059,7 @@
private System.Windows.Forms.Button btnLEFTMOUSE;
private System.Windows.Forms.Button btnQ;
private System.Windows.Forms.PictureBox pictureBox2;
private System.Windows.Forms.CheckBox cbRepeat;
private System.Windows.Forms.CheckBox cbToggle;
private System.Windows.Forms.Button btnUNBOUND2;
private System.Windows.Forms.Button button13;
private System.Windows.Forms.Button button2;
@ -2063,6 +2089,8 @@
private System.Windows.Forms.PictureBox pictureBox1;
private System.Windows.Forms.Label X360Label;
private System.Windows.Forms.Label KBMlabel;
private System.Windows.Forms.CheckBox cBMacro;
private System.Windows.Forms.Label lBMacroOrder;
}
}

View File

@ -22,10 +22,11 @@ namespace ScpServer
scpDevice = bus_device;
ops = ooo;
button = buton;
if (button.ForeColor == Color.Red)
cbRepeat.Checked = true;
if (button.Font.Bold)
cbScanCode.Checked = true;
cbToggle.Checked = button.Font.Italic;
cbScanCode.Checked = button.Font.Bold;
cBMacro.Checked = button.Font.Underline;
if (cBMacro.Checked)
lBMacroOrder.Text += button.Text;
Text = "Select an action for " + button.Name.Substring(2);
foreach (System.Windows.Forms.Control control in this.Controls)
if (control is Button)
@ -35,14 +36,18 @@ namespace ScpServer
bnMOUSEDOWN.Visible = false;
bnMOUSELEFT.Visible = false;
bnMOUSERIGHT.Visible = false;
bnMOUSEUP.Visible = false;
bnMOUSEUP.Visible = false;
}
ToolTip tp = new ToolTip();
tp.SetToolTip(cBMacro, "Max 5 actions");
}
List<string> macros = new List<string>();
List<int> macrostag = new List<int>();
public void anybtn_Click(object sender, EventArgs e)
{
if (sender is Button)
{
Button bn = ((Button)sender);
string keyname;
if (((Button)sender).Text.Contains('↑') || ((Button)sender).Text.Contains('↓') || ((Button)sender).Text.Contains('→') || ((Button)sender).Text.Contains('←') || ((Button)sender).Text.Contains('Ø'))
keyname = ((Button)sender).Text.Substring(1);
@ -61,20 +66,65 @@ namespace ScpServer
}
else
keyname = ((Button)sender).Text;
object keytag;
if (((Button)sender).Tag.ToString() == "X360")
keytag = ((Button)sender).Text;
if (!cBMacro.Checked)
{
object keytag;
if (((Button)sender).Tag.ToString() == "X360")
keytag = ((Button)sender).Text;
else
keytag = ((Button)sender).Tag;
ops.ChangeButtonText(keyname, keytag);
this.Close();
}
else
keytag = ((Button)sender).Tag;
ops.ChangeButtonText(keyname, keytag);
this.Close();
{
if (!bn.Font.Bold && bn.Tag.ToString() != "X360" && macrostag.Count < 5 && (bn.Text.Contains("Mouse") ^ !bn.Text.Contains("Button"))) //end is xor to remove mouse movement and wheel from macro
{
bn.Font = new Font(bn.Font, FontStyle.Bold);
macros.Add(keyname);
int value;
if (int.TryParse(bn.Tag.ToString(), out value))
macrostag.Add(value);
else
{
if (bn.Text == "Left Mouse Button") macrostag.Add(256);
if (bn.Text == "Right Mouse Button") macrostag.Add(257);
if (bn.Text == "Middle Mouse Button") macrostag.Add(258);
if (bn.Text == "4th Mouse Button") macrostag.Add(259);
if (bn.Text == "5th Mouse Button") macrostag.Add(260);
}
}
else if (bn.Tag.ToString() != "X360")
{
bn.Font = new Font(bn.Font, FontStyle.Regular);
macros.Remove(keyname);
int value;
if (int.TryParse(bn.Tag.ToString(), out value))
macrostag.Remove(value);
else
{
if (bn.Text == "Left Mouse Button") macrostag.Remove(256);
if (bn.Text == "Right Mouse Button") macrostag.Remove(257);
if (bn.Text == "Middle Mouse Button") macrostag.Remove(258);
if (bn.Text == "4th Mouse Button") macrostag.Remove(259);
if (bn.Text == "5th Mouse Button") macrostag.Remove(260);
}
}
string macro = string.Join(", ", macros.ToArray());
lBMacroOrder.Text = "Macro Order: " + macro;
}
}
}
private void finalMeasure(object sender, FormClosedEventArgs e)
{
ops.Toggle_ScanCode(cbScanCode.Checked);
ops.UpdateLists();
if (cBMacro.Checked && macrostag.Count > 0)
{
ops.ChangeButtonText(string.Join(", ", macros), macrostag.ToArray());
}
ops.Toggle_Bn(cbScanCode.Checked, cbToggle.Checked, cBMacro.Checked);
ops.UpdateLists();
}
private void Key_Down_Action(object sender, KeyEventArgs e)
@ -83,5 +133,18 @@ namespace ScpServer
this.Close();
}
private void cBMacro_CheckedChanged(object sender, EventArgs e)
{
lBMacroOrder.Visible = cBMacro.Checked;
if (cBMacro.Checked)
cbToggle.Checked = false;
}
private void cbToggle_CheckedChanged(object sender, EventArgs e)
{
if (cbToggle.Checked)
cBMacro.Checked = false;
}
}
}

View File

@ -135,6 +135,7 @@
this.numUDL2 = new System.Windows.Forms.NumericUpDown();
this.gBTouchpad = new System.Windows.Forms.GroupBox();
this.gBOther = new System.Windows.Forms.GroupBox();
this.cBControllerInput = new System.Windows.Forms.CheckBox();
this.gBLightbar = new System.Windows.Forms.GroupBox();
this.gBRumble = new System.Windows.Forms.GroupBox();
this.gBDeadzone = new System.Windows.Forms.GroupBox();
@ -290,7 +291,7 @@
this.MainPanel.Controls.Add(this.bnShare);
this.MainPanel.Location = new System.Drawing.Point(7, 77);
this.MainPanel.Name = "MainPanel";
this.MainPanel.Size = new System.Drawing.Size(249, 140);
this.MainPanel.Size = new System.Drawing.Size(249, 137);
this.MainPanel.TabIndex = 185;
//
// pBController
@ -662,7 +663,7 @@
this.SticksPanel.Controls.Add(this.bnR3);
this.SticksPanel.Location = new System.Drawing.Point(7, 77);
this.SticksPanel.Name = "SticksPanel";
this.SticksPanel.Size = new System.Drawing.Size(249, 146);
this.SticksPanel.Size = new System.Drawing.Size(249, 142);
this.SticksPanel.TabIndex = 187;
this.SticksPanel.Visible = false;
//
@ -990,8 +991,6 @@
this.blueBar.Value = 255;
this.blueBar.ValueChanged += new System.EventHandler(this.blueBar_ValueChanged);
this.blueBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown);
this.blueBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave);
this.blueBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover);
this.blueBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp);
//
// greenBar
@ -1008,8 +1007,6 @@
this.greenBar.Value = 255;
this.greenBar.ValueChanged += new System.EventHandler(this.greenBar_ValueChanged);
this.greenBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown);
this.greenBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave);
this.greenBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover);
this.greenBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp);
//
// redBar
@ -1026,8 +1023,6 @@
this.redBar.Value = 255;
this.redBar.ValueChanged += new System.EventHandler(this.redBar_ValueChanged);
this.redBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown);
this.redBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave);
this.redBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover);
this.redBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp);
//
// batteryLed
@ -1199,16 +1194,14 @@
this.lBButtonMouseSens.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0)));
this.lBButtonMouseSens.Location = new System.Drawing.Point(11, 16);
this.lBButtonMouseSens.Name = "lBButtonMouseSens";
this.lBButtonMouseSens.Size = new System.Drawing.Size(121, 13);
this.lBButtonMouseSens.Size = new System.Drawing.Size(92, 13);
this.lBButtonMouseSens.TabIndex = 206;
this.lBButtonMouseSens.Text = "Mouse Speed (Buttons):";
this.lBButtonMouseSens.Text = "Mouse Sensitivity:";
this.lBButtonMouseSens.TextAlign = System.Drawing.ContentAlignment.TopRight;
//
// cBlowerRCOn
//
this.cBlowerRCOn.AutoSize = true;
this.cBlowerRCOn.Checked = true;
this.cBlowerRCOn.CheckState = System.Windows.Forms.CheckState.Checked;
this.cBlowerRCOn.Location = new System.Drawing.Point(218, 12);
this.cBlowerRCOn.Name = "cBlowerRCOn";
this.cBlowerRCOn.RightToLeft = System.Windows.Forms.RightToLeft.No;
@ -1221,6 +1214,8 @@
// touchpadJitterCompensation
//
this.touchpadJitterCompensation.AutoSize = true;
this.touchpadJitterCompensation.Checked = true;
this.touchpadJitterCompensation.CheckState = System.Windows.Forms.CheckState.Checked;
this.touchpadJitterCompensation.Location = new System.Drawing.Point(42, 12);
this.touchpadJitterCompensation.Name = "touchpadJitterCompensation";
this.touchpadJitterCompensation.RightToLeft = System.Windows.Forms.RightToLeft.No;
@ -1263,7 +1258,7 @@
// lBIdleMinutes
//
this.lBIdleMinutes.AutoSize = true;
this.lBIdleMinutes.Location = new System.Drawing.Point(148, 44);
this.lBIdleMinutes.Location = new System.Drawing.Point(165, 46);
this.lBIdleMinutes.Name = "lBIdleMinutes";
this.lBIdleMinutes.Size = new System.Drawing.Size(106, 13);
this.lBIdleMinutes.TabIndex = 200;
@ -1272,7 +1267,7 @@
// idleDisconnectTimeout
//
this.idleDisconnectTimeout.DecimalPlaces = 1;
this.idleDisconnectTimeout.Location = new System.Drawing.Point(95, 42);
this.idleDisconnectTimeout.Location = new System.Drawing.Point(109, 44);
this.idleDisconnectTimeout.Maximum = new decimal(new int[] {
60,
0,
@ -1546,8 +1541,6 @@
this.lowRedBar.Value = 255;
this.lowRedBar.ValueChanged += new System.EventHandler(this.lowRedBar_ValueChanged);
this.lowRedBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown);
this.lowRedBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave);
this.lowRedBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover);
this.lowRedBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp);
//
// lowGreenBar
@ -1564,8 +1557,6 @@
this.lowGreenBar.Value = 255;
this.lowGreenBar.ValueChanged += new System.EventHandler(this.lowGreenBar_ValueChanged);
this.lowGreenBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown);
this.lowGreenBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave);
this.lowGreenBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover);
this.lowGreenBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp);
//
// lowBlueBar
@ -1582,8 +1573,6 @@
this.lowBlueBar.Value = 255;
this.lowBlueBar.ValueChanged += new System.EventHandler(this.lowBlueBar_ValueChanged);
this.lowBlueBar.MouseDown += new System.Windows.Forms.MouseEventHandler(this.LightBar_MouseDown);
this.lowBlueBar.MouseLeave += new System.EventHandler(this.Lightbar_MouseLeave);
this.lowBlueBar.MouseHover += new System.EventHandler(this.LightbarValue_MouseHover);
this.lowBlueBar.MouseUp += new System.Windows.Forms.MouseEventHandler(this.Lightbar_MouseUp);
//
// lBEmpty
@ -1635,7 +1624,7 @@
this.SixaxisPanel.Controls.Add(this.tBsixaxisGyroZ);
this.SixaxisPanel.Controls.Add(this.tBsixaxisAccelY);
this.SixaxisPanel.Controls.Add(this.tBsixaxisAccelZ);
this.SixaxisPanel.Location = new System.Drawing.Point(442, 5);
this.SixaxisPanel.Location = new System.Drawing.Point(442, 6);
this.SixaxisPanel.Name = "SixaxisPanel";
this.SixaxisPanel.Size = new System.Drawing.Size(441, 29);
this.SixaxisPanel.TabIndex = 236;
@ -1724,17 +1713,12 @@
//
// numUDMouseSens
//
this.numUDMouseSens.Location = new System.Drawing.Point(138, 14);
this.numUDMouseSens.Maximum = new decimal(new int[] {
117,
0,
0,
0});
this.numUDMouseSens.Location = new System.Drawing.Point(109, 14);
this.numUDMouseSens.Name = "numUDMouseSens";
this.numUDMouseSens.Size = new System.Drawing.Size(50, 20);
this.numUDMouseSens.TabIndex = 241;
this.numUDMouseSens.Value = new decimal(new int[] {
50,
25,
0,
0,
0});
@ -1800,6 +1784,7 @@
//
// gBOther
//
this.gBOther.Controls.Add(this.cBControllerInput);
this.gBOther.Controls.Add(this.idleDisconnectTimeout);
this.gBOther.Controls.Add(this.lBButtonMouseSens);
this.gBOther.Controls.Add(this.numUDMouseSens);
@ -1813,6 +1798,19 @@
this.gBOther.TabStop = false;
this.gBOther.Text = "Other";
//
// cBControllerInput
//
this.cBControllerInput.AutoSize = true;
this.cBControllerInput.Checked = true;
this.cBControllerInput.CheckState = System.Windows.Forms.CheckState.Checked;
this.cBControllerInput.Location = new System.Drawing.Point(303, 38);
this.cBControllerInput.Name = "cBControllerInput";
this.cBControllerInput.RightToLeft = System.Windows.Forms.RightToLeft.Yes;
this.cBControllerInput.Size = new System.Drawing.Size(106, 30);
this.cBControllerInput.TabIndex = 242;
this.cBControllerInput.Text = "Use controller to \r\nchange mapping";
this.cBControllerInput.UseVisualStyleBackColor = true;
//
// gBLightbar
//
this.gBLightbar.Controls.Add(this.pBRainbow);
@ -2063,6 +2061,7 @@
private System.Windows.Forms.GroupBox gBLightbar;
private System.Windows.Forms.GroupBox gBRumble;
private System.Windows.Forms.GroupBox gBDeadzone;
private System.Windows.Forms.CheckBox cBControllerInput;
}
}


View File

@ -50,9 +50,11 @@ namespace ScpServer
rumbleBoostBar.Value = DS4Control.Global.loadRumbleBoost(device);
flashLed.Checked = DS4Control.Global.getFlashWhenLowBattery(device);
numUDTouch.Value = Global.getTouchSensitivity(device);
cBSlide.Checked = Global.getTouchSensitivity(device) > 0;
numUDScroll.Value = Global.getScrollSensitivity(device);
cBScroll.Checked = Global.getScrollSensitivity(device) >0;
numUDTap.Value = Global.getTapSensitivity(device);
cBTap.Checked = Global.getTap(device);
cBTap.Checked = Global.getTapSensitivity(device) > 0;
cBDoubleTap.Checked = Global.getDoubleTap(device);
numUDL2.Value = (decimal)Global.getLeftTriggerMiddle(device)/255;
numUDR2.Value = (decimal)Global.getRightTriggerMiddle(device)/255;
@ -132,7 +134,7 @@ namespace ScpServer
private void InputDS4(object sender, EventArgs e)
{
#region DS4Input
if (Form.ActiveForm == this)
if (Form.ActiveForm == this && cBControllerInput.Checked)
switch (scpDevice.GetInputkeys(device))
{
case ("Cross"): Show_ControlsBn(bnCross, e); break;
@ -216,6 +218,9 @@ namespace ScpServer
private void Set()
{
lowBatteryPanel.Visible = batteryLed.Checked;
lbFull.Text = (batteryLed.Checked ? "Full:" : "Color:");
FullPanel.Location = (batteryLed.Checked ? new Point(FullPanel.Location.X, 42) : new Point(FullPanel.Location.X, 48));
Global.saveColor(device, (byte)redBar.Value, (byte)greenBar.Value, (byte)blueBar.Value);
Global.saveLowColor(device, (byte)lowRedBar.Value, (byte)lowGreenBar.Value, (byte)lowBlueBar.Value);
Global.setLeftTriggerMiddle(device, (byte)Math.Round((numUDL2.Value * 255), 0));
@ -269,6 +274,8 @@ namespace ScpServer
int value;
if (Int32.TryParse(tag.ToString(), out value))
lastSelected.Tag = value;
else if (tag is Int32[])
lastSelected.Tag = tag;
else
lastSelected.Tag = tag.ToString();
}
@ -277,16 +284,16 @@ namespace ScpServer
lastSelected.Text = controlname;
lastSelected.Tag = controlname;
}
public void Toggle_ScanCode(bool Checked)
public void Toggle_Bn(bool SC, bool TG, bool MC)
{
if (lastSelected.Tag is int || lastSelected.Tag is UInt16)
if (Checked)
lastSelected.Font = new Font(lastSelected.Font, FontStyle.Bold);
else lastSelected.Font = new Font(lastSelected.Font, FontStyle.Regular);
if (lastSelected.Tag is int || lastSelected.Tag is UInt16 || lastSelected.Tag is int[])
lastSelected.Font = new Font(lastSelected.Font, (SC ? FontStyle.Bold : FontStyle.Regular) |
(TG ? FontStyle.Italic : FontStyle.Regular) | (MC ? FontStyle.Underline : FontStyle.Regular));
else if (lastSelected.Tag is string)
if (lastSelected.Tag.ToString().Contains("Mouse Button"))
lastSelected.Font = new Font(lastSelected.Font, TG ? FontStyle.Italic : FontStyle.Regular);
else
{
lastSelected.Font = new Font(lastSelected.Font, FontStyle.Regular);
}
}
private void btnSticks_Enter(object sender, EventArgs e)
{
@ -821,14 +828,6 @@ namespace ScpServer
}
private void LightbarValue_MouseHover(object sender, EventArgs e)
{
//tp.SetToolTip(((TrackBar)sender), ((TrackBar)sender).Value.ToString());
}
private void Lightbar_MouseLeave(object sender, EventArgs e)
{
}
private void LightBar_MouseDown(object sender, MouseEventArgs e)
{

123
DS4Tool/Resource.es.resx Normal file
View File

@ -0,0 +1,123 @@
<?xml version="1.0" encoding="utf-8"?>
<root>
<!--
Microsoft ResX Schema
Version 2.0
The primary goals of this format is to allow a simple XML format
that is mostly human readable. The generation and parsing of the
various data types are done through the TypeConverter classes
associated with the data types.
Example:
... ado.net/XML headers & schema ...
<resheader name="resmimetype">text/microsoft-resx</resheader>
<resheader name="version">2.0</resheader>
<resheader name="reader">System.Resources.ResXResourceReader, System.Windows.Forms, ...</resheader>
<resheader name="writer">System.Resources.ResXResourceWriter, System.Windows.Forms, ...</resheader>
<data name="Name1"><value>this is my long string</value><comment>this is a comment</comment></data>
<data name="Color1" type="System.Drawing.Color, System.Drawing">Blue</data>
<data name="Bitmap1" mimetype="application/x-microsoft.net.object.binary.base64">
<value>[base64 mime encoded serialized .NET Framework object]</value>
</data>
<data name="Icon1" type="System.Drawing.Icon, System.Drawing" mimetype="application/x-microsoft.net.object.bytearray.base64">
<value>[base64 mime encoded string representing a byte array form of the .NET Framework object]</value>
<comment>This is a comment</comment>
</data>
There are any number of "resheader" rows that contain simple
name/value pairs.
Each data row contains a name, and value. The row also contains a
type or mimetype. Type corresponds to a .NET class that support
text/value conversion through the TypeConverter architecture.
Classes that don't support this are serialized and stored with the
mimetype set.
The mimetype is used for serialized objects, and tells the
ResXResourceReader how to depersist the object. This is currently not
extensible. For a given mimetype the value must be set accordingly:
Note - application/x-microsoft.net.object.binary.base64 is the format
that the ResXResourceWriter will generate, however the reader can
read any of the formats listed below.
mimetype: application/x-microsoft.net.object.binary.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Binary.BinaryFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.soap.base64
value : The object must be serialized with
: System.Runtime.Serialization.Formatters.Soap.SoapFormatter
: and then encoded with base64 encoding.
mimetype: application/x-microsoft.net.object.bytearray.base64
value : The object must be serialized into a byte array
: using a System.ComponentModel.TypeConverter
: and then encoded with base64 encoding.
-->
<xsd:schema id="root" xmlns="" xmlns:xsd="http://www.w3.org/2001/XMLSchema" xmlns:msdata="urn:schemas-microsoft-com:xml-msdata">
<xsd:import namespace="http://www.w3.org/XML/1998/namespace" />
<xsd:element name="root" msdata:IsDataSet="true">
<xsd:complexType>
<xsd:choice maxOccurs="unbounded">
<xsd:element name="metadata">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" />
</xsd:sequence>
<xsd:attribute name="name" use="required" type="xsd:string" />
<xsd:attribute name="type" type="xsd:string" />
<xsd:attribute name="mimetype" type="xsd:string" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="assembly">
<xsd:complexType>
<xsd:attribute name="alias" type="xsd:string" />
<xsd:attribute name="name" type="xsd:string" />
</xsd:complexType>
</xsd:element>
<xsd:element name="data">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
<xsd:element name="comment" type="xsd:string" minOccurs="0" msdata:Ordinal="2" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" msdata:Ordinal="1" />
<xsd:attribute name="type" type="xsd:string" msdata:Ordinal="3" />
<xsd:attribute name="mimetype" type="xsd:string" msdata:Ordinal="4" />
<xsd:attribute ref="xml:space" />
</xsd:complexType>
</xsd:element>
<xsd:element name="resheader">
<xsd:complexType>
<xsd:sequence>
<xsd:element name="value" type="xsd:string" minOccurs="0" msdata:Ordinal="1" />
</xsd:sequence>
<xsd:attribute name="name" type="xsd:string" use="required" />
</xsd:complexType>
</xsd:element>
</xsd:choice>
</xsd:complexType>
</xsd:element>
</xsd:schema>
<resheader name="resmimetype">
<value>text/microsoft-resx</value>
</resheader>
<resheader name="version">
<value>2.0</value>
</resheader>
<resheader name="reader">
<value>System.Resources.ResXResourceReader, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<resheader name="writer">
<value>System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089</value>
</resheader>
<data name="Disconnected" xml:space="preserve">
<value>Desconectado</value>
</data>
</root>

View File

@ -45,6 +45,7 @@
this.pnlDebug = new System.Windows.Forms.Panel();
this.pnlStatus = new System.Windows.Forms.Panel();
this.gpPads = new System.Windows.Forms.GroupBox();
this.label1 = new System.Windows.Forms.Label();
this.lbSelPro4 = new System.Windows.Forms.Label();
this.lbSelPro3 = new System.Windows.Forms.Label();
this.lbSelPro2 = new System.Windows.Forms.Label();
@ -232,6 +233,7 @@
//
this.gpPads.Anchor = ((System.Windows.Forms.AnchorStyles)(((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Left)
| System.Windows.Forms.AnchorStyles.Right)));
this.gpPads.Controls.Add(this.label1);
this.gpPads.Controls.Add(this.lbSelPro4);
this.gpPads.Controls.Add(this.lbSelPro3);
this.gpPads.Controls.Add(this.lbSelPro2);
@ -262,6 +264,16 @@
this.gpPads.TabIndex = 1;
this.gpPads.TabStop = false;
//
// label1
//
this.label1.AutoSize = true;
this.label1.Location = new System.Drawing.Point(12, 117);
this.label1.Name = "label1";
this.label1.Size = new System.Drawing.Size(35, 13);
this.label1.TabIndex = 46;
this.label1.Text = "label1";
this.label1.Visible = false;
//
// lbSelPro4
//
this.lbSelPro4.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Top | System.Windows.Forms.AnchorStyles.Right)));
@ -515,6 +527,7 @@
this.notifyIcon1.ContextMenuStrip = this.cMTaskbar;
this.notifyIcon1.Icon = ((System.Drawing.Icon)(resources.GetObject("notifyIcon1.Icon")));
this.notifyIcon1.Text = "DS4 Xinput Tool";
this.notifyIcon1.Visible = true;
this.notifyIcon1.DoubleClick += new System.EventHandler(this.notifyIcon_Click);
//
// cMTaskbar
@ -603,8 +616,6 @@
this.MinimumSize = new System.Drawing.Size(560, 192);
this.Name = "ScpForm";
this.Text = "DS4Windows 1.0 Beta J2K Build";
this.Activated += new System.EventHandler(this.ScpForm_Activated);
this.Deactivate += new System.EventHandler(this.ScpForm_Deactivate);
this.FormClosing += new System.Windows.Forms.FormClosingEventHandler(this.Form_Close);
this.Load += new System.EventHandler(this.Form_Load);
this.Resize += new System.EventHandler(this.Form_Resize);
@ -669,6 +680,7 @@
private System.Windows.Forms.LinkLabel llbHelp;
private System.Windows.Forms.Button btnImportProfiles;
private System.Windows.Forms.CheckBox StartWindowsCheckBox;
private System.Windows.Forms.Label label1;
//private System.Windows.Forms.ToolStripMenuItem toolStripMenuItem2;
}
}

View File

@ -12,7 +12,7 @@ namespace ScpServer
{
public partial class ScpForm : Form
{
double version = 7.7;
double version = 8.01;
private DS4Control.Control rootHub;
delegate void LogDebugDelegate(DateTime Time, String Data);
@ -41,7 +41,21 @@ namespace ScpServer
(ToolStripMenuItem)notifyIcon1.ContextMenuStrip.Items[3] };
foreach (ToolStripMenuItem t in shortcuts)
t.DropDownItemClicked += Profile_Changed_Menu;
CheckDrivers();
CheckDrivers();
Timer te = new Timer();
//te.Start();
te.Tick += test_Tick;
}
private void test_Tick(object sender, EventArgs e)
{
label1.Visible = true;
int speed = Global.getButtonMouseSensitivity(0);
label1.Text = (((rootHub.getDS4State(0).RX - 127) / 127d) * speed).ToString();
/*label1.Text = Mapping.globalState.currentClicks.toggle.ToString() + " Left is " +
Mapping.getBoolMapping(DS4Controls.DpadLeft, rootHub.getDS4State(0)) +
" Toggle is " + Mapping.pressedonce[256] +
Mapping.test;*/
}
private void CheckDrivers()
@ -73,7 +87,6 @@ namespace ScpServer
try
{
if (double.TryParse(File.ReadAllText(Global.appdatapath + "\\version.txt"), out newversion))
{
if (newversion > version)
if (MessageBox.Show("Download now?", "New Version Available!", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
{
@ -89,8 +102,7 @@ namespace ScpServer
else
File.Delete(Global.appdatapath + "\\version.txt");
else
File.Delete(Global.appdatapath + "\\version.txt");
}
File.Delete(Global.appdatapath + "\\version.txt");
else
File.Delete(Global.appdatapath + "\\version.txt");
}
@ -232,23 +244,24 @@ namespace ScpServer
protected void ShowNotification(object sender, DebugEventArgs args)
{
notifyIcon1.BalloonTipText = args.Data;
notifyIcon1.BalloonTipTitle = "DS4Windows";
notifyIcon1.ShowBalloonTip(1);
if (Form.ActiveForm != this)
{
this.notifyIcon1.BalloonTipText = args.Data;
notifyIcon1.BalloonTipTitle = "DS4Windows";
notifyIcon1.ShowBalloonTip(1);
}
}
protected void Form_Resize(object sender, EventArgs e)
{
if (FormWindowState.Minimized == this.WindowState)
{
notifyIcon1.Visible = true;
this.Hide();
this.ShowInTaskbar = false;
}
else if (FormWindowState.Normal == this.WindowState)
{
notifyIcon1.Visible = false;
this.Show();
this.ShowInTaskbar = true;
}
@ -271,20 +284,12 @@ namespace ScpServer
{
if (btnStartStop.Text == "Start")
{
for (int i = 0; i < 4; i++)
Global.LoadProfile(i);
rootHub.Start();
btnStartStop.Text = "Stop";
}
else if (btnStartStop.Text == "Stop")
{
for (int i = 0; i < 4; i++)
{
Global.setRainbow(i, 0);
Global.setLedAsBatteryIndicator(i, false);
Global.saveColor(i, 64, 128, 128);
}
rootHub.Stop();
btnStartStop.Text = "Start";
}
@ -334,11 +339,14 @@ namespace ScpServer
if (Pads[Index].Text != String.Empty)
{
Pads[Index].Enabled = true;
cbs[Index].Enabled = true;
ebns[Index].Enabled = true;
dbns[Index].Enabled = true;
protexts[Index].Enabled = true;
shortcuts[Index].Enabled = true;
if (Pads[Index].Text != "Connecting...")
{
cbs[Index].Enabled = true;
ebns[Index].Enabled = true;
dbns[Index].Enabled = true;
protexts[Index].Enabled = true;
shortcuts[Index].Enabled = true;
}
// As above
//if (checkFirst && (Pads[Index].Checked && Index != 0))
// checkFirst = false;
@ -559,11 +567,7 @@ namespace ScpServer
{
string[] files = openProfiles.FileNames;
for (int i = 0; i < files.Length; i++)
{
string[] temp = files[i].Split('\\');
files[i] = temp[temp.Length - 1];
File.Copy(openProfiles.FileNames[i], Global.appdatapath + "\\Profiles\\" + files[i], true);
}
File.Copy(openProfiles.FileNames[i], Global.appdatapath + "\\Profiles\\" + Path.GetFileName(files[i]), true);
RefreshProfiles();
}
}
@ -573,27 +577,9 @@ namespace ScpServer
Global.setFormWidth(this.Width);
Global.setFormHeight(this.Height);
Global.Save();
for (int i = 0; i < 4; i++)
{
Global.setRainbow(i, 0);
Global.setLedAsBatteryIndicator(i, false);
Global.saveColor(i, 64, 128, 128);
}
rootHub.Stop();
}
private void ScpForm_Deactivate(object sender, EventArgs e)
{
try { notifyIcon1.Visible = true; }
catch { }
}
private void ScpForm_Activated(object sender, EventArgs e)
{
notifyIcon1.Visible = false;
}
private void StartWindowsCheckBox_CheckedChanged(object sender, EventArgs e)
{
RegistryKey KeyLoc = Registry.CurrentUser.OpenSubKey("SOFTWARE\\Microsoft\\Windows\\CurrentVersion\\Run", true);

File diff suppressed because it is too large Load Diff