From c52929f5fae05355cd3818ec44699fd79c602546 Mon Sep 17 00:00:00 2001 From: jays2kings Date: Tue, 6 May 2014 14:49:18 -0400 Subject: [PATCH] Made keystrokes more akin to phyiscally pressing (holding down actually repeats the key), removed repeat option due to this Edit Profile button shows new if controller has no profile, other small UI changes --- DS4Control/InputMethods.cs | 28 ++++++++++++--- DS4Control/Mapping.cs | 71 ++++++++++++++++++++++++++++++++----- DS4Control/ScpUtil.cs | 12 +++---- DS4Tool/KBM360.Designer.cs | 57 ++++++++++++++--------------- DS4Tool/Options.Designer.cs | 23 ++++++------ DS4Tool/Options.cs | 6 +++- DS4Tool/ScpForm.cs | 56 ++++++++++++++++++++--------- 7 files changed, 176 insertions(+), 77 deletions(-) diff --git a/DS4Control/InputMethods.cs b/DS4Control/InputMethods.cs index 956f90b..4eb28a6 100644 --- a/DS4Control/InputMethods.cs +++ b/DS4Control/InputMethods.cs @@ -158,7 +158,7 @@ namespace DS4Control sendInputs[0].Type = INPUT_KEYBOARD; sendInputs[0].Data.Keyboard.ExtraInfo = IntPtr.Zero; sendInputs[0].Data.Keyboard.Flags = KEYEVENTF_SCANCODE; - sendInputs[0].Data.Keyboard.Scan = MapVirtualKey(key, MAPVK_VK_TO_VSC); ; + sendInputs[0].Data.Keyboard.Scan = MapVirtualKey(key, MAPVK_VK_TO_VSC); sendInputs[0].Data.Keyboard.Time = 0; sendInputs[0].Data.Keyboard.Vk = key; uint result = SendInput(1, sendInputs, Marshal.SizeOf(sendInputs[0])); @@ -171,7 +171,7 @@ namespace DS4Control { sendInputs[0].Type = INPUT_KEYBOARD; sendInputs[0].Data.Keyboard.ExtraInfo = IntPtr.Zero; - sendInputs[0].Data.Keyboard.Flags = 0; + sendInputs[0].Data.Keyboard.Flags = 1; sendInputs[0].Data.Keyboard.Scan = 0; sendInputs[0].Data.Keyboard.Time = 0; sendInputs[0].Data.Keyboard.Vk = key; @@ -199,7 +199,7 @@ namespace DS4Control { sendInputs[0].Type = INPUT_KEYBOARD; sendInputs[0].Data.Keyboard.ExtraInfo = IntPtr.Zero; - sendInputs[0].Data.Keyboard.Flags = KEYEVENTF_KEYUP; + sendInputs[0].Data.Keyboard.Flags = KEYEVENTF_EXTENDEDKEY | KEYEVENTF_KEYUP; sendInputs[0].Data.Keyboard.Scan = 0; sendInputs[0].Data.Keyboard.Time = 0; sendInputs[0].Data.Keyboard.Vk = key; @@ -275,13 +275,31 @@ namespace DS4Control MOUSEEVENTF_RIGHTDOWN = 8, MOUSEEVENTF_RIGHTUP = 16, MOUSEEVENTF_MIDDLEDOWN = 32, MOUSEEVENTF_MIDDLEUP = 64, MOUSEEVENTF_XBUTTONDOWN = 128, MOUSEEVENTF_XBUTTONUP = 256, - KEYEVENTF_KEYUP = 2, MOUSEEVENTF_WHEEL = 0x0800, MOUSEEVENTF_HWHEEL = 0x1000, + KEYEVENTF_EXTENDEDKEY = 1, KEYEVENTF_KEYUP = 2, MOUSEEVENTF_WHEEL = 0x0800, MOUSEEVENTF_HWHEEL = 0x1000, MOUSEEVENTF_MIDDLEWDOWN = 0x0020, MOUSEEVENTF_MIDDLEWUP = 0x0040, - KEYEVENTF_SCANCODE = 0x0008, MAPVK_VK_TO_VSC = 0; + KEYEVENTF_SCANCODE = 0x0008, MAPVK_VK_TO_VSC = 0, KEYEVENTF_UNICODE = 0x0004; [DllImport("user32.dll", SetLastError = true)] private static extern uint SendInput(uint numberOfInputs, INPUT[] inputs, int sizeOfInputs); [DllImport("user32.dll", CharSet = CharSet.Auto)] private static extern ushort MapVirtualKey(uint uCode, uint uMapType); + [DllImport("user32.dll", SetLastError = true)] + static extern void keybd_event(byte bVk, byte bScan, int dwFlags, int dwExtraInfo); + //Not used, just here + public static void DownKeys(ushort key) + { + keybd_event((byte)key, 0, (int)0, 0); + } + + public static void PressKeys(ushort key) + { + keybd_event((byte)key, 0, (int)KEYEVENTF_EXTENDEDKEY, 0); + } + + public static void ReleaseKeys(ushort key) + { + keybd_event((byte)key, 0, (int)KEYEVENTF_KEYUP, 0); + } } + } diff --git a/DS4Control/Mapping.cs b/DS4Control/Mapping.cs index bb9c35a..2ef55d4 100644 --- a/DS4Control/Mapping.cs +++ b/DS4Control/Mapping.cs @@ -3,6 +3,7 @@ using System.Collections.Generic; using System.Linq; using System.Text; using DS4Library; +using System.Threading; namespace DS4Control { public class Mapping @@ -44,6 +45,9 @@ namespace DS4Control private 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.Now; + private static bool pressagain = false; + private static int wheel = 0, keyshelddown = 0; public static void Commit(int device) { SyntheticState state = deviceState[device]; @@ -81,11 +85,33 @@ namespace DS4Control 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.Now; + 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) + { InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, -100); + oldnow = DateTime.Now; + wheel = -100; + } + if (globalState.currentClicks.wDownCount == 0 && globalState.previousClicks.wDownCount != 0) + wheel = 0; + + if (wheel != 0) //Continue mouse wheel movement + { + DateTime now = DateTime.Now; + if (now >= oldnow + TimeSpan.FromMilliseconds(100) && !pressagain) + { + oldnow = now; + InputMethods.MouseEvent(InputMethods.MOUSEEVENTF_WHEEL, wheel); + } + } // Merge and synthesize all key presses/releases that are present in this device's mapping. // TODO what about the rest? e.g. repeat keys really ought to be on some set schedule @@ -108,29 +134,56 @@ namespace DS4Control if (gkp.current.vkCount + gkp.current.scanCodeCount != 0 && gkp.previous.vkCount + gkp.previous.scanCodeCount == 0) { if (gkp.current.scanCodeCount != 0) + { + oldnow = DateTime.Now; InputMethods.performSCKeyPress(kvp.Key); + pressagain = false; + keyshelddown = kvp.Key; + } else + { + oldnow = DateTime.Now; InputMethods.performKeyPress(kvp.Key); + pressagain = false; + keyshelddown = kvp.Key; + } } else if (gkp.current.repeatCount != 0 || // repeat or SC/VK transition ((gkp.previous.scanCodeCount == 0) != (gkp.current.scanCodeCount == 0))) { - if (gkp.previous.scanCodeCount != 0) // use the last type of VK/SC - InputMethods.performSCKeyRelease(kvp.Key); - else - InputMethods.performKeyRelease(kvp.Key); + if (keyshelddown == kvp.Key) + { + DateTime now = DateTime.Now; + if (now >= oldnow + TimeSpan.FromMilliseconds(500) && !pressagain) + { + oldnow = now; + pressagain = true; + } + if (pressagain && gkp.current.scanCodeCount != 0) + { + InputMethods.performSCKeyPress(kvp.Key); + Thread.Sleep(25); + } + else if (pressagain) + { + InputMethods.performKeyPress(kvp.Key); + Thread.Sleep(25); + } + } - if (gkp.current.scanCodeCount != 0) - InputMethods.performSCKeyPress(kvp.Key); - else - InputMethods.performKeyPress(kvp.Key); } else if (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 + { InputMethods.performSCKeyRelease(kvp.Key); + pressagain = false; + } else + { InputMethods.performKeyRelease(kvp.Key); + pressagain = false; + } } } globalState.SavePrevious(false); @@ -321,7 +374,7 @@ namespace DS4Control kp.current.scanCodeCount++; else kp.current.vkCount++; - if (keyType.HasFlag(DS4KeyType.Repeat)) + //if (keyType.HasFlag(DS4KeyType.Repeat)) kp.current.repeatCount++; } } diff --git a/DS4Control/ScpUtil.cs b/DS4Control/ScpUtil.cs index c2bfde2..5bd1d35 100644 --- a/DS4Control/ScpUtil.cs +++ b/DS4Control/ScpUtil.cs @@ -511,8 +511,8 @@ namespace DS4Control keyType += DS4KeyType.Unbound; } { - if (button.ForeColor == System.Drawing.Color.Red) - keyType += DS4KeyType.Repeat; + /*if (button.ForeColor == System.Drawing.Color.Red) + keyType += DS4KeyType.Repeat;*/ if (button.Font.Bold) keyType += DS4KeyType.ScanCode; } @@ -730,11 +730,11 @@ namespace DS4Control keyType |= DS4KeyType.ScanCode; button.Font = new System.Drawing.Font(button.Font, System.Drawing.FontStyle.Bold); } - if (Item.InnerText.Contains(DS4KeyType.Repeat.ToString())) + /*if (Item.InnerText.Contains(DS4KeyType.Repeat.ToString())) { keyType |= DS4KeyType.Repeat; button.ForeColor = System.Drawing.Color.Red; - } + }*/ } if (keyType != DS4KeyType.None) customMapKeyTypes.Add(getDS4ControlsByName(Item.Name), keyType); @@ -870,8 +870,8 @@ 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.Repeat.ToString())) + //keyType |= DS4KeyType.Repeat; if (item.InnerText.Contains(DS4KeyType.Unbound.ToString())) keyType |= DS4KeyType.Unbound; if (keyType != DS4KeyType.None) diff --git a/DS4Tool/KBM360.Designer.cs b/DS4Tool/KBM360.Designer.cs index 57a2873..902ac33 100644 --- a/DS4Tool/KBM360.Designer.cs +++ b/DS4Tool/KBM360.Designer.cs @@ -111,6 +111,7 @@ this.btnX = new System.Windows.Forms.Button(); this.btnZ = new System.Windows.Forms.Button(); this.btnRALT = new System.Windows.Forms.Button(); + this.button36 = new System.Windows.Forms.Button(); this.btnWINDOWS = new System.Windows.Forms.Button(); this.btnLALT = new System.Windows.Forms.Button(); this.btnRCTRL = new System.Windows.Forms.Button(); @@ -182,7 +183,6 @@ this.button21 = new System.Windows.Forms.Button(); this.button3 = new System.Windows.Forms.Button(); this.pictureBox1 = new System.Windows.Forms.PictureBox(); - this.button36 = new System.Windows.Forms.Button(); this.tabControl1.SuspendLayout(); this.tabKBM.SuspendLayout(); ((System.ComponentModel.ISupportInitialize)(this.pictureBox2)).BeginInit(); @@ -205,7 +205,6 @@ // this.tabKBM.Controls.Add(this.label2); this.tabKBM.Controls.Add(this.cbScanCode); - this.tabKBM.Controls.Add(this.cbRepeat); this.tabKBM.Controls.Add(this.button7); this.tabKBM.Controls.Add(this.button5); this.tabKBM.Controls.Add(this.button4); @@ -328,6 +327,7 @@ this.tabKBM.Controls.Add(this.btnLEFTMOUSE); this.tabKBM.Controls.Add(this.btnQ); this.tabKBM.Controls.Add(this.pictureBox2); + this.tabKBM.Controls.Add(this.cbRepeat); this.tabKBM.Location = new System.Drawing.Point(4, 22); this.tabKBM.Name = "tabKBM"; this.tabKBM.Padding = new System.Windows.Forms.Padding(3); @@ -350,24 +350,25 @@ // cbScanCode // this.cbScanCode.AutoSize = true; - this.cbScanCode.Location = new System.Drawing.Point(762, 155); + this.cbScanCode.Location = new System.Drawing.Point(692, 149); this.cbScanCode.Name = "cbScanCode"; this.cbScanCode.RightToLeft = System.Windows.Forms.RightToLeft.Yes; - this.cbScanCode.Size = new System.Drawing.Size(79, 17); + this.cbScanCode.Size = new System.Drawing.Size(54, 30); this.cbScanCode.TabIndex = 163; - this.cbScanCode.Text = "Scan Code"; + this.cbScanCode.Text = "Scan \r\nCode"; this.cbScanCode.UseVisualStyleBackColor = true; // // cbRepeat // this.cbRepeat.AutoSize = true; - this.cbRepeat.Location = new System.Drawing.Point(695, 155); + this.cbRepeat.Location = new System.Drawing.Point(786, 5); this.cbRepeat.Name = "cbRepeat"; this.cbRepeat.RightToLeft = System.Windows.Forms.RightToLeft.Yes; this.cbRepeat.Size = new System.Drawing.Size(61, 17); this.cbRepeat.TabIndex = 163; this.cbRepeat.Text = "Repeat"; this.cbRepeat.UseVisualStyleBackColor = true; + this.cbRepeat.Visible = false; // // button7 // @@ -1152,6 +1153,16 @@ this.btnRALT.Text = "RAlt"; this.btnRALT.UseVisualStyleBackColor = true; // + // button36 + // + this.button36.Location = new System.Drawing.Point(299, 152); + this.button36.Name = "button36"; + this.button36.Size = new System.Drawing.Size(42, 24); + this.button36.TabIndex = 86; + this.button36.Tag = "92"; + this.button36.Text = "RWin"; + this.button36.UseVisualStyleBackColor = true; + // // btnWINDOWS // this.btnWINDOWS.Location = new System.Drawing.Point(107, 152); @@ -1434,7 +1445,7 @@ // // bTNRIGHTMOUSE // - this.bTNRIGHTMOUSE.Location = new System.Drawing.Point(809, 49); + this.bTNRIGHTMOUSE.Location = new System.Drawing.Point(809, 62); this.bTNRIGHTMOUSE.Name = "bTNRIGHTMOUSE"; this.bTNRIGHTMOUSE.Size = new System.Drawing.Size(24, 24); this.bTNRIGHTMOUSE.TabIndex = 61; @@ -1454,7 +1465,7 @@ // // button32 // - this.button32.Location = new System.Drawing.Point(779, 74); + this.button32.Location = new System.Drawing.Point(779, 87); this.button32.Name = "button32"; this.button32.Size = new System.Drawing.Size(24, 21); this.button32.TabIndex = 59; @@ -1464,7 +1475,7 @@ // // button31 // - this.button31.Location = new System.Drawing.Point(779, 26); + this.button31.Location = new System.Drawing.Point(779, 39); this.button31.Name = "button31"; this.button31.Size = new System.Drawing.Size(24, 22); this.button31.TabIndex = 59; @@ -1474,7 +1485,7 @@ // // btnMIDDLEMOUSE // - this.btnMIDDLEMOUSE.Location = new System.Drawing.Point(779, 49); + this.btnMIDDLEMOUSE.Location = new System.Drawing.Point(779, 62); this.btnMIDDLEMOUSE.Name = "btnMIDDLEMOUSE"; this.btnMIDDLEMOUSE.Size = new System.Drawing.Size(24, 24); this.btnMIDDLEMOUSE.TabIndex = 59; @@ -1494,7 +1505,7 @@ // // button33 // - this.button33.Location = new System.Drawing.Point(814, 114); + this.button33.Location = new System.Drawing.Point(814, 127); this.button33.Name = "button33"; this.button33.Size = new System.Drawing.Size(19, 24); this.button33.TabIndex = 58; @@ -1504,7 +1515,7 @@ // // button30 // - this.button30.Location = new System.Drawing.Point(749, 113); + this.button30.Location = new System.Drawing.Point(749, 126); this.button30.Name = "button30"; this.button30.Size = new System.Drawing.Size(19, 24); this.button30.TabIndex = 58; @@ -1514,7 +1525,7 @@ // // bnMOUSERIGHT // - this.bnMOUSERIGHT.Location = new System.Drawing.Point(823, 87); + this.bnMOUSERIGHT.Location = new System.Drawing.Point(823, 97); this.bnMOUSERIGHT.Name = "bnMOUSERIGHT"; this.bnMOUSERIGHT.Size = new System.Drawing.Size(24, 24); this.bnMOUSERIGHT.TabIndex = 58; @@ -1524,7 +1535,7 @@ // // bnMOUSELEFT // - this.bnMOUSELEFT.Location = new System.Drawing.Point(732, 87); + this.bnMOUSELEFT.Location = new System.Drawing.Point(732, 98); this.bnMOUSELEFT.Name = "bnMOUSELEFT"; this.bnMOUSELEFT.Size = new System.Drawing.Size(24, 24); this.bnMOUSELEFT.TabIndex = 58; @@ -1534,7 +1545,7 @@ // // bnMOUSEDOWN // - this.bnMOUSEDOWN.Location = new System.Drawing.Point(779, 129); + this.bnMOUSEDOWN.Location = new System.Drawing.Point(779, 147); this.bnMOUSEDOWN.Name = "bnMOUSEDOWN"; this.bnMOUSEDOWN.Size = new System.Drawing.Size(24, 24); this.bnMOUSEDOWN.TabIndex = 58; @@ -1544,7 +1555,7 @@ // // bnMOUSEUP // - this.bnMOUSEUP.Location = new System.Drawing.Point(779, 0); + this.bnMOUSEUP.Location = new System.Drawing.Point(779, 5); this.bnMOUSEUP.Name = "bnMOUSEUP"; this.bnMOUSEUP.Size = new System.Drawing.Size(24, 24); this.bnMOUSEUP.TabIndex = 58; @@ -1554,7 +1565,7 @@ // // btnLEFTMOUSE // - this.btnLEFTMOUSE.Location = new System.Drawing.Point(749, 49); + this.btnLEFTMOUSE.Location = new System.Drawing.Point(749, 62); this.btnLEFTMOUSE.Name = "btnLEFTMOUSE"; this.btnLEFTMOUSE.Size = new System.Drawing.Size(24, 24); this.btnLEFTMOUSE.TabIndex = 58; @@ -1575,7 +1586,7 @@ // pictureBox2 // this.pictureBox2.Image = global::ScpServer.Properties.Resources.mouse; - this.pictureBox2.Location = new System.Drawing.Point(743, 8); + this.pictureBox2.Location = new System.Drawing.Point(743, 21); this.pictureBox2.Name = "pictureBox2"; this.pictureBox2.Size = new System.Drawing.Size(97, 140); this.pictureBox2.SizeMode = System.Windows.Forms.PictureBoxSizeMode.AutoSize; @@ -1890,16 +1901,6 @@ this.pictureBox1.TabIndex = 107; this.pictureBox1.TabStop = false; // - // button36 - // - this.button36.Location = new System.Drawing.Point(299, 152); - this.button36.Name = "button36"; - this.button36.Size = new System.Drawing.Size(42, 24); - this.button36.TabIndex = 86; - this.button36.Tag = "92"; - this.button36.Text = "RWin"; - this.button36.UseVisualStyleBackColor = true; - // // KBM360 // this.AutoScaleDimensions = new System.Drawing.SizeF(6F, 13F); diff --git a/DS4Tool/Options.Designer.cs b/DS4Tool/Options.Designer.cs index 32ef9c0..1483649 100644 --- a/DS4Tool/Options.Designer.cs +++ b/DS4Tool/Options.Designer.cs @@ -523,12 +523,12 @@ this.flushHIDQueue.Anchor = ((System.Windows.Forms.AnchorStyles)((System.Windows.Forms.AnchorStyles.Bottom | System.Windows.Forms.AnchorStyles.Left))); this.flushHIDQueue.AutoSize = true; this.flushHIDQueue.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F); - this.flushHIDQueue.Location = new System.Drawing.Point(311, 12); + this.flushHIDQueue.Location = new System.Drawing.Point(311, 5); this.flushHIDQueue.Name = "flushHIDQueue"; this.flushHIDQueue.RightToLeft = System.Windows.Forms.RightToLeft.Yes; - this.flushHIDQueue.Size = new System.Drawing.Size(106, 17); + this.flushHIDQueue.Size = new System.Drawing.Size(112, 30); this.flushHIDQueue.TabIndex = 80; - this.flushHIDQueue.Text = "Flush HID queue"; + this.flushHIDQueue.Text = "Flush HID queue\r\nafter each reading\r\n"; this.flushHIDQueue.UseVisualStyleBackColor = true; this.flushHIDQueue.CheckedChanged += new System.EventHandler(this.flushHIDQueue_CheckedChanged); // @@ -717,7 +717,7 @@ this.bnR2.FlatAppearance.MouseOverBackColor = System.Drawing.SystemColors.Control; this.bnR2.FlatStyle = System.Windows.Forms.FlatStyle.Flat; this.bnR2.ForeColor = System.Drawing.SystemColors.WindowText; - this.bnR2.Location = new System.Drawing.Point(176, 1); + this.bnR2.Location = new System.Drawing.Point(177, 3); this.bnR2.Name = "bnR2"; this.bnR2.Size = new System.Drawing.Size(40, 13); this.bnR2.TabIndex = 89; @@ -1791,9 +1791,9 @@ this.leftMotorLabel.AutoSize = true; this.leftMotorLabel.Location = new System.Drawing.Point(264, 109); this.leftMotorLabel.Name = "leftMotorLabel"; - this.leftMotorLabel.Size = new System.Drawing.Size(38, 13); + this.leftMotorLabel.Size = new System.Drawing.Size(32, 13); this.leftMotorLabel.TabIndex = 93; - this.leftMotorLabel.Text = "Heavy"; + this.leftMotorLabel.Text = "Right"; // // rightMotorLabel // @@ -1801,15 +1801,15 @@ this.rightMotorLabel.AutoSize = true; this.rightMotorLabel.Location = new System.Drawing.Point(165, 109); this.rightMotorLabel.Name = "rightMotorLabel"; - this.rightMotorLabel.Size = new System.Drawing.Size(30, 13); + this.rightMotorLabel.Size = new System.Drawing.Size(25, 13); this.rightMotorLabel.TabIndex = 94; - this.rightMotorLabel.Text = "Light"; + this.rightMotorLabel.Text = "Left"; // // lBButtonMouseSens // this.lBButtonMouseSens.AutoSize = true; 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(7, 13); + this.lBButtonMouseSens.Location = new System.Drawing.Point(4, 13); this.lBButtonMouseSens.Name = "lBButtonMouseSens"; this.lBButtonMouseSens.Size = new System.Drawing.Size(137, 13); this.lBButtonMouseSens.TabIndex = 87; @@ -1892,9 +1892,9 @@ this.lBControllerOff.Font = new System.Drawing.Font("Microsoft Sans Serif", 8.25F, System.Drawing.FontStyle.Regular, System.Drawing.GraphicsUnit.Point, ((byte)(0))); this.lBControllerOff.Location = new System.Drawing.Point(4, 45); this.lBControllerOff.Name = "lBControllerOff"; - this.lBControllerOff.Size = new System.Drawing.Size(96, 13); + this.lBControllerOff.Size = new System.Drawing.Size(84, 13); this.lBControllerOff.TabIndex = 81; - this.lBControllerOff.Text = "Controller Auto-Off:"; + this.lBControllerOff.Text = "Idle Disconnect:"; // // tBMouseSens // @@ -1916,6 +1916,7 @@ this.tBProfile.Size = new System.Drawing.Size(255, 20); this.tBProfile.TabIndex = 83; this.tBProfile.Text = ""; + this.tBProfile.Click += new System.EventHandler(this.tBProfile_Click); this.tBProfile.TextChanged += new System.EventHandler(this.tBProfile_TextChanged); this.tBProfile.Enter += new System.EventHandler(this.tBProfile_Enter); this.tBProfile.KeyDown += new System.Windows.Forms.KeyEventHandler(this.tbProfile_EnterDown); diff --git a/DS4Tool/Options.cs b/DS4Tool/Options.cs index 66bebfe..04bbf89 100644 --- a/DS4Tool/Options.cs +++ b/DS4Tool/Options.cs @@ -340,7 +340,6 @@ namespace ScpServer { Global.saveRumbleBoost(device, (byte)rumbleBoostBar.Value); scpDevice.setRumble((byte)numUDHeavyRumble.Value, (byte)numUDLightRumble.Value, device); - } private void numUDLightRumble_ValueChanged(object sender, EventArgs e) @@ -737,5 +736,10 @@ namespace ScpServer { Global.setRightTriggerMiddle(device, (double)numUDR2.Value); } + + private void tBProfile_Click(object sender, EventArgs e) + { + + } } } diff --git a/DS4Tool/ScpForm.cs b/DS4Tool/ScpForm.cs index 3f09869..6faf545 100644 --- a/DS4Tool/ScpForm.cs +++ b/DS4Tool/ScpForm.cs @@ -156,8 +156,16 @@ namespace ScpServer cbs[i].SelectedIndex = j; ((ToolStripMenuItem)shortcuts[i].DropDownItems[j]).Checked = true; Global.setAProfile(i, cbs[i].Text); + shortcuts[i].Text = "Edit Profile for Controller " + (i + 1); + ebns[i].Text = "Edit"; break; } + else + { + cbs[i].Text = "(No Profile Found)"; + shortcuts[i].Text = "Make Profile for Controller " + (i + 1); + ebns[i].Text = "New"; + } cbs[i].Items.Add("+New Profile"); shortcuts[i].DropDownItems.Add("-"); shortcuts[i].DropDownItems.Add("+New Profile"); @@ -293,7 +301,11 @@ namespace ScpServer int i = Int32.Parse(bn.Tag.ToString()); if (OptionsDialog[i] == null) { - Options opt = OptionsDialog[i] = new Options(rootHub, i, cbs[i].Text, this); + Options opt; + if (cbs[i].Text == "(No Profile Found)") + opt = OptionsDialog[i] = new Options(rootHub, i, "", this); + else + opt = OptionsDialog[i] = new Options(rootHub, i, cbs[i].Text, this); opt.Text = "Options for Controller " + (i + 1); opt.Icon = this.Icon; opt.FormClosed += delegate @@ -302,7 +314,6 @@ namespace ScpServer }; opt.Show(); } - } private void editMenu_Click(object sender, EventArgs e) { @@ -310,23 +321,32 @@ namespace ScpServer int i = Int32.Parse(em.Tag.ToString()); if (OptionsDialog[i] == null) { - foreach (ToolStripMenuItem t in em.DropDownItems) - //if (!(t is ToolStripSeparator) - if (((ToolStripMenuItem)t).Checked) + if (em.Text == "Make Profile for Controller " + (i + 1)) + { + Options opt = OptionsDialog[i] = new Options(rootHub, i, "", this); + opt.Text = "Options for Controller " + (i + 1); + opt.Icon = this.Icon; + opt.FormClosed += delegate { - Options opt = OptionsDialog[i] = new Options(rootHub, i, ((ToolStripMenuItem)t).Text, this); - opt.Text = "Options for Controller " + (i + 1); - opt.Icon = this.Icon; - opt.FormClosed += delegate + OptionsDialog[i] = null; + }; + opt.Show(); + } + else + foreach (ToolStripMenuItem t in em.DropDownItems) + if (((ToolStripMenuItem)t).Checked) { - OptionsDialog[i] = null; - }; - opt.Show(); - break; - } + Options opt = OptionsDialog[i] = new Options(rootHub, i, ((ToolStripMenuItem)t).Text, this); + opt.Text = "Options for Controller " + (i + 1); + opt.Icon = this.Icon; + opt.FormClosed += delegate + { + OptionsDialog[i] = null; + }; + opt.Show(); + break; + } } - //else - //OptionsDialog[i].Focus(); } private void Enable_Controls(int device, bool on) { @@ -403,6 +423,7 @@ namespace ScpServer if (!(shortcuts[tdevice].DropDownItems[i] is ToolStripSeparator)) ((ToolStripMenuItem)shortcuts[tdevice].DropDownItems[i]).Checked = false; ((ToolStripMenuItem)shortcuts[tdevice].DropDownItems[cb.SelectedIndex]).Checked = true; + shortcuts[tdevice].Text = "Edit Profile for Controller " + (tdevice + 1); Global.setAProfile(tdevice, cb.Items[cb.SelectedIndex].ToString()); Global.Save(); Global.LoadProfile(tdevice); @@ -422,7 +443,7 @@ namespace ScpServer opt.Show(); } } - if (cb.Text == "") + if (cb.Text == "(No Profile Found)") ebns[tdevice].Text = "New"; else ebns[tdevice].Text = "Edit"; @@ -453,6 +474,7 @@ namespace ScpServer if (!(shortcuts[tdevice].DropDownItems[i] is ToolStripSeparator)) ((ToolStripMenuItem)tS.DropDownItems[i]).Checked = false; ((ToolStripMenuItem)e.ClickedItem).Checked = true; + shortcuts[tdevice].Text = "Edit Profile for Controller " + (tdevice + 1); cbs[tdevice].SelectedIndex = tS.DropDownItems.IndexOf(e.ClickedItem); Global.setAProfile(tdevice, e.ClickedItem.Text); Global.Save();