2014-06-14 21:14:27 +02:00
|
|
|
|
using System;
|
|
|
|
|
using System.Collections.Generic;
|
|
|
|
|
using System.ComponentModel;
|
|
|
|
|
using System.Data;
|
|
|
|
|
using System.Diagnostics;
|
|
|
|
|
using System.Drawing;
|
|
|
|
|
using System.Linq;
|
2014-06-21 20:00:28 +02:00
|
|
|
|
using System.Runtime.InteropServices;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
using System.Text;
|
|
|
|
|
using System.Threading.Tasks;
|
|
|
|
|
using System.Windows.Forms;
|
2014-11-14 20:44:50 +01:00
|
|
|
|
using DS4Control;
|
|
|
|
|
using DS4Library;
|
|
|
|
|
using System.IO;
|
|
|
|
|
using System.Reflection;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
|
|
|
|
|
namespace ScpServer
|
|
|
|
|
{
|
|
|
|
|
public partial class RecordBox : Form
|
|
|
|
|
{
|
2014-11-14 20:44:50 +01:00
|
|
|
|
private DS4Control.Control scpDevice;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
Stopwatch sw = new Stopwatch();
|
2014-11-14 20:44:50 +01:00
|
|
|
|
Timer ds4 = new Timer();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
public List<int> macros = new List<int>();
|
|
|
|
|
public List<string> macronames = new List<string>();
|
|
|
|
|
KBM360 kbm;
|
2014-11-14 20:44:50 +01:00
|
|
|
|
DS4State cState;
|
|
|
|
|
public bool saved = false;
|
|
|
|
|
List<DS4Controls> dcs = new List<DS4Controls>();
|
|
|
|
|
public RecordBox(KBM360 op, DS4Control.Control bus_device)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
2014-11-14 20:44:50 +01:00
|
|
|
|
scpDevice = bus_device;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
kbm = op;
|
|
|
|
|
InitializeComponent();
|
2014-06-21 20:00:28 +02:00
|
|
|
|
if (op != null)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
if (kbm.macrorepeat)
|
|
|
|
|
cBStyle.SelectedIndex = 1;
|
|
|
|
|
else
|
|
|
|
|
cBStyle.SelectedIndex = 0;
|
2014-11-14 20:44:50 +01:00
|
|
|
|
ds4.Tick += ds4_Tick;
|
|
|
|
|
ds4.Interval = 1;
|
|
|
|
|
dcs.Add(DS4Controls.Cross);
|
|
|
|
|
dcs.Add(DS4Controls.Cross);
|
|
|
|
|
dcs.Add(DS4Controls.Circle);
|
|
|
|
|
dcs.Add(DS4Controls.Square);
|
|
|
|
|
dcs.Add(DS4Controls.Triangle);
|
|
|
|
|
dcs.Add(DS4Controls.Options);
|
|
|
|
|
dcs.Add(DS4Controls.Share);
|
|
|
|
|
dcs.Add(DS4Controls.DpadUp);
|
|
|
|
|
dcs.Add(DS4Controls.DpadDown);
|
|
|
|
|
dcs.Add(DS4Controls.DpadLeft);
|
|
|
|
|
dcs.Add(DS4Controls.DpadRight);
|
|
|
|
|
dcs.Add(DS4Controls.PS);
|
|
|
|
|
dcs.Add(DS4Controls.L1);
|
|
|
|
|
dcs.Add(DS4Controls.R1);
|
|
|
|
|
dcs.Add(DS4Controls.L2);
|
|
|
|
|
dcs.Add(DS4Controls.R2);
|
|
|
|
|
dcs.Add(DS4Controls.L3);
|
|
|
|
|
dcs.Add(DS4Controls.R3);
|
|
|
|
|
dcs.Add(DS4Controls.LXPos);
|
|
|
|
|
dcs.Add(DS4Controls.LXNeg);
|
|
|
|
|
dcs.Add(DS4Controls.LYPos);
|
|
|
|
|
dcs.Add(DS4Controls.LYNeg);
|
|
|
|
|
dcs.Add(DS4Controls.RXPos);
|
|
|
|
|
dcs.Add(DS4Controls.RXNeg);
|
|
|
|
|
dcs.Add(DS4Controls.RYPos);
|
|
|
|
|
dcs.Add(DS4Controls.RYNeg);
|
|
|
|
|
if (kbm.macrostag.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
macros.AddRange(kbm.macrostag);
|
|
|
|
|
LoadMacro();
|
|
|
|
|
saved = true;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void ds4_Tick(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (scpDevice.DS4Controllers[0] != null)
|
|
|
|
|
{
|
|
|
|
|
cState = scpDevice.getDS4State(0);
|
|
|
|
|
if (btnRecord.Text == Properties.Resources.StopText)
|
|
|
|
|
foreach (DS4Controls dc in dcs)
|
|
|
|
|
if (Mapping.getBoolMapping(dc, cState, null, null))
|
|
|
|
|
{
|
|
|
|
|
int value = DS4ControltoInt(dc);
|
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (int i in macros)
|
|
|
|
|
{
|
|
|
|
|
if (i == value)
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
if (macros.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(DS4ControltoX360(dc), 0);
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (count % 2 == 0)
|
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(DS4ControltoX360(dc), 0);
|
|
|
|
|
}
|
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
|
|
|
|
|
}
|
|
|
|
|
else if (!Mapping.getBoolMapping(dc, cState, null, null))
|
|
|
|
|
{
|
|
|
|
|
if (macros.Count != 0)
|
|
|
|
|
{
|
|
|
|
|
int value = DS4ControltoInt(dc);
|
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (int i in macros)
|
|
|
|
|
{
|
|
|
|
|
if (i == value)
|
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
/*for (int i = macros.Count - 1; i >= 0; i--)
|
|
|
|
|
if (macros.Count == 261)
|
|
|
|
|
count++;*/
|
|
|
|
|
if (count % 2 == 1)
|
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(DS4ControltoX360(dc), 1);
|
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static int DS4ControltoInt(DS4Controls ctrl)
|
|
|
|
|
{
|
|
|
|
|
switch (ctrl)
|
|
|
|
|
{
|
|
|
|
|
case DS4Controls.Cross: return 261;
|
|
|
|
|
case DS4Controls.Circle: return 262;
|
|
|
|
|
case DS4Controls.Square: return 263;
|
|
|
|
|
case DS4Controls.Triangle: return 264;
|
|
|
|
|
case DS4Controls.Options: return 265;
|
|
|
|
|
case DS4Controls.Share: return 266;
|
|
|
|
|
case DS4Controls.DpadUp: return 267;
|
|
|
|
|
case DS4Controls.DpadDown: return 268;
|
|
|
|
|
case DS4Controls.DpadLeft: return 269;
|
|
|
|
|
case DS4Controls.DpadRight: return 270;
|
|
|
|
|
case DS4Controls.PS: return 271;
|
|
|
|
|
case DS4Controls.L1: return 272;
|
|
|
|
|
case DS4Controls.R1: return 273;
|
|
|
|
|
case DS4Controls.L2: return 274;
|
|
|
|
|
case DS4Controls.R2: return 275;
|
|
|
|
|
case DS4Controls.L3: return 276;
|
|
|
|
|
case DS4Controls.R3: return 277;
|
|
|
|
|
case DS4Controls.LXPos: return 278;
|
|
|
|
|
case DS4Controls.LXNeg: return 279;
|
|
|
|
|
case DS4Controls.LYPos: return 280;
|
|
|
|
|
case DS4Controls.LYNeg: return 281;
|
|
|
|
|
case DS4Controls.RXPos: return 282;
|
|
|
|
|
case DS4Controls.RXNeg: return 283;
|
|
|
|
|
case DS4Controls.RYPos: return 284;
|
|
|
|
|
case DS4Controls.RYNeg: return 285;
|
|
|
|
|
}
|
|
|
|
|
return 0;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
public static string DS4ControltoX360(DS4Controls ctrl)
|
|
|
|
|
{
|
|
|
|
|
switch (ctrl)
|
|
|
|
|
{
|
|
|
|
|
case DS4Controls.Cross: return "A Button";
|
|
|
|
|
case DS4Controls.Circle: return "B Button";
|
|
|
|
|
case DS4Controls.Square: return "X Button";
|
|
|
|
|
case DS4Controls.Triangle: return "Y Button";
|
|
|
|
|
case DS4Controls.Options: return "Start";
|
|
|
|
|
case DS4Controls.Share: return "Back";
|
|
|
|
|
case DS4Controls.DpadUp: return "Up Button";
|
|
|
|
|
case DS4Controls.DpadDown: return "Down Button";
|
|
|
|
|
case DS4Controls.DpadLeft: return "Left Button";
|
|
|
|
|
case DS4Controls.DpadRight: return "Right Button";
|
|
|
|
|
case DS4Controls.PS: return "Guide";
|
|
|
|
|
case DS4Controls.L1: return "Left Bumper";
|
|
|
|
|
case DS4Controls.R1: return "Right Bumper";
|
|
|
|
|
case DS4Controls.L2: return "Left Trigger";
|
|
|
|
|
case DS4Controls.R2: return "Right Trigger";
|
|
|
|
|
case DS4Controls.L3: return "Left Stick";
|
|
|
|
|
case DS4Controls.R3: return "Right Stick";
|
|
|
|
|
case DS4Controls.LXPos: return "LS Right";
|
|
|
|
|
case DS4Controls.LXNeg: return "LS Left";
|
|
|
|
|
case DS4Controls.LYPos: return "LS Down";
|
|
|
|
|
case DS4Controls.LYNeg: return "LS Up";
|
|
|
|
|
case DS4Controls.RXPos: return "RS Right";
|
|
|
|
|
case DS4Controls.RXNeg: return "RS Left";
|
|
|
|
|
case DS4Controls.RYPos: return "RS Down";
|
|
|
|
|
case DS4Controls.RYNeg: return "RS Up";
|
|
|
|
|
}
|
|
|
|
|
return "None";
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btnRecord_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btnRecord.Text == Properties.Resources.RecordText)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
sw.Start();
|
2014-11-14 20:44:50 +01:00
|
|
|
|
scpDevice.recordingMacro = true;
|
|
|
|
|
saved = false;
|
|
|
|
|
ds4.Start();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
macros.Clear();
|
|
|
|
|
lVMacros.Items.Clear();
|
2014-08-17 00:09:15 +02:00
|
|
|
|
btnRecord.Text = Properties.Resources.StopText;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
EnableControls(false);
|
|
|
|
|
ActiveControl = null;
|
|
|
|
|
lVMacros.Focus();
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
2014-11-14 20:44:50 +01:00
|
|
|
|
scpDevice.recordingMacro = false;
|
|
|
|
|
ds4.Stop();
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btn4th.Text.Contains(Properties.Resources.UpText))
|
2014-06-17 01:43:01 +02:00
|
|
|
|
btn4th_Click(sender, e);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btn5th.Text.Contains(Properties.Resources.UpText))
|
2014-06-17 01:43:01 +02:00
|
|
|
|
btn5th_Click(sender, e);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
sw.Reset();
|
2014-11-14 20:44:50 +01:00
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
lbDelayTip.Visible = true;
|
2014-08-17 00:09:15 +02:00
|
|
|
|
btnRecord.Text = Properties.Resources.RecordText;
|
2014-06-17 01:43:01 +02:00
|
|
|
|
EnableControls(true);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void EnableControls(bool on)
|
|
|
|
|
{
|
|
|
|
|
lVMacros.Enabled = on;
|
2014-11-14 20:44:50 +01:00
|
|
|
|
cBRecordDelays.Enabled = on;
|
|
|
|
|
cBStyle.Enabled = on;
|
2014-06-17 01:43:01 +02:00
|
|
|
|
pnlMouseButtons.Visible = !on;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-06-21 20:00:28 +02:00
|
|
|
|
[DllImport("user32.dll")]
|
|
|
|
|
private static extern short GetAsyncKeyState(Keys key);
|
|
|
|
|
|
2014-06-14 21:14:27 +02:00
|
|
|
|
private void anyKeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btnRecord.Text == Properties.Resources.StopText)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
2014-06-21 20:00:28 +02:00
|
|
|
|
int value = WhichKey(e, 0);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
int count = 0;
|
|
|
|
|
foreach (int i in macros)
|
|
|
|
|
{
|
2014-06-21 20:00:28 +02:00
|
|
|
|
if (i == value)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
count++;
|
|
|
|
|
}
|
|
|
|
|
if (macros.Count == 0)
|
|
|
|
|
{
|
2014-06-21 20:00:28 +02:00
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(((Keys)value).ToString(), 0);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else if (count % 2 == 0)
|
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
2014-06-21 20:00:28 +02:00
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(((Keys)value).ToString(), 0);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
2014-06-17 01:43:01 +02:00
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
2014-06-21 20:00:28 +02:00
|
|
|
|
else if (e.KeyValue == 27)
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private int WhichKey(KeyEventArgs e, int keystate)
|
|
|
|
|
{
|
|
|
|
|
if (keystate == 1)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
2014-06-21 20:00:28 +02:00
|
|
|
|
if (e.KeyCode == Keys.ShiftKey)
|
|
|
|
|
{
|
|
|
|
|
for (int i = macros.Count - 1; i >= 0; i--)
|
|
|
|
|
if (macros[i] == 160)
|
|
|
|
|
return 160;
|
|
|
|
|
else if (macros[i] == 161)
|
|
|
|
|
return 161;
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.ControlKey)
|
|
|
|
|
{
|
|
|
|
|
for (int i = macros.Count - 1; i >= 0; i--)
|
|
|
|
|
if (macros[i] == 162)
|
|
|
|
|
return 162;
|
|
|
|
|
else if (macros[i] == 163)
|
|
|
|
|
return 163;
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.Menu)
|
|
|
|
|
{
|
|
|
|
|
for (int i = macros.Count - 1; i >= 0; i--)
|
|
|
|
|
if (macros[i] == 164)
|
|
|
|
|
return 164;
|
|
|
|
|
else if (macros[i] == 165)
|
|
|
|
|
return 165;
|
|
|
|
|
}
|
|
|
|
|
return e.KeyValue;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
2014-06-21 20:00:28 +02:00
|
|
|
|
else
|
|
|
|
|
if (e.KeyCode == Keys.ShiftKey)
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToBoolean(GetAsyncKeyState(Keys.LShiftKey)))
|
|
|
|
|
return 160;
|
|
|
|
|
if (Convert.ToBoolean(GetAsyncKeyState(Keys.RShiftKey)))
|
|
|
|
|
return 161;
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.ControlKey)
|
|
|
|
|
{
|
|
|
|
|
if (Convert.ToBoolean(GetAsyncKeyState(Keys.LControlKey)))
|
|
|
|
|
return 162;
|
|
|
|
|
if (Convert.ToBoolean(GetAsyncKeyState(Keys.RControlKey)))
|
|
|
|
|
return 163;
|
|
|
|
|
}
|
|
|
|
|
else if (e.KeyCode == Keys.Menu)
|
|
|
|
|
{
|
|
|
|
|
e.Handled = true;
|
|
|
|
|
if (Convert.ToBoolean(GetAsyncKeyState(Keys.LMenu)))
|
|
|
|
|
return 164;
|
|
|
|
|
if (Convert.ToBoolean(GetAsyncKeyState(Keys.RMenu)))
|
|
|
|
|
return 165;
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
return e.KeyValue;
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void anyKeyUp(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btnRecord.Text == Properties.Resources.StopText && macros.Count != 0)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
2014-06-21 20:00:28 +02:00
|
|
|
|
int value = WhichKey(e, 1);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
2014-06-21 20:00:28 +02:00
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(((Keys)value).ToString(), 1);
|
2014-06-17 01:43:01 +02:00
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private void anyMouseDown(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btnRecord.Text == Properties.Resources.StopText)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
|
|
|
|
int value;
|
|
|
|
|
switch (e.Button)
|
|
|
|
|
{
|
|
|
|
|
case System.Windows.Forms.MouseButtons.Left: value = 256; break;
|
|
|
|
|
case System.Windows.Forms.MouseButtons.Right: value = 257; break;
|
|
|
|
|
case System.Windows.Forms.MouseButtons.Middle: value = 258; break;
|
|
|
|
|
case System.Windows.Forms.MouseButtons.XButton1: value = 259; break;
|
|
|
|
|
case System.Windows.Forms.MouseButtons.XButton2: value = 260; break;
|
|
|
|
|
default: value = 0; break;
|
|
|
|
|
}
|
|
|
|
|
if (macros.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(e.Button.ToString() + " Mouse Button", 0);
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(e.Button.ToString() + " Mouse Button", 0);
|
|
|
|
|
}
|
|
|
|
|
if (e.Button == System.Windows.Forms.MouseButtons.XButton1)
|
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].Text = "4th Mouse Button";
|
|
|
|
|
if (e.Button == System.Windows.Forms.MouseButtons.XButton2)
|
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].Text = "5th Mouse Button";
|
2014-06-17 01:43:01 +02:00
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void anyMouseUp(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btnRecord.Text == Properties.Resources.StopText && macros.Count != 0)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
|
|
|
|
int value;
|
|
|
|
|
switch (e.Button)
|
|
|
|
|
{
|
|
|
|
|
case System.Windows.Forms.MouseButtons.Left: value = 256; break;
|
|
|
|
|
case System.Windows.Forms.MouseButtons.Right: value = 257; break;
|
|
|
|
|
case System.Windows.Forms.MouseButtons.Middle: value = 258; break;
|
|
|
|
|
case System.Windows.Forms.MouseButtons.XButton1: value = 259; break;
|
|
|
|
|
case System.Windows.Forms.MouseButtons.XButton2: value = 260; break;
|
|
|
|
|
default: value = 0; break;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
|
|
|
|
lVMacros.Items.Add("Wait " + sw.ElapsedMilliseconds + "ms", 2);
|
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add(e.Button.ToString() + " Mouse Button", 1);
|
|
|
|
|
if (e.Button == System.Windows.Forms.MouseButtons.XButton1)
|
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].Text = "4th Mouse Button";
|
|
|
|
|
if (e.Button == System.Windows.Forms.MouseButtons.XButton2)
|
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].Text = "5th Mouse Button";
|
2014-06-17 01:43:01 +02:00
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
2014-06-17 01:43:01 +02:00
|
|
|
|
|
2014-11-14 20:44:50 +01:00
|
|
|
|
|
|
|
|
|
public void btnSave_Click(object sender, EventArgs e)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
|
|
|
|
if (macros.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
kbm.macrostag = macros;
|
2014-11-14 20:44:50 +01:00
|
|
|
|
macronames.Clear();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
foreach (ListViewItem lvi in lVMacros.Items)
|
|
|
|
|
{
|
|
|
|
|
macronames.Add(lvi.Text);
|
|
|
|
|
}
|
|
|
|
|
kbm.macros = macronames;
|
|
|
|
|
string macro = string.Join(", ", macronames.ToArray());
|
|
|
|
|
kbm.lBMacroOn.Visible = true;
|
|
|
|
|
if (cBStyle.SelectedIndex == 1)
|
|
|
|
|
kbm.macrorepeat = true;
|
|
|
|
|
saved = true;
|
2014-11-14 20:44:50 +01:00
|
|
|
|
if (sender != kbm)
|
|
|
|
|
kbm.Close();
|
|
|
|
|
//Close();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
2014-08-17 00:09:15 +02:00
|
|
|
|
else MessageBox.Show(Properties.Resources.NoMacroRecorded, "DS4Windows", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
2014-11-14 20:44:50 +01:00
|
|
|
|
private void btnSaveP_Click(object sender, EventArgs e)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
2014-11-14 20:44:50 +01:00
|
|
|
|
if (macros.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
Stream stream;
|
|
|
|
|
Console.WriteLine(Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName);
|
|
|
|
|
Console.WriteLine(Global.appdatapath);
|
|
|
|
|
//string path;
|
|
|
|
|
if (Global.appdatapath == Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName)
|
|
|
|
|
savePresets.InitialDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Macros\";
|
|
|
|
|
else
|
|
|
|
|
savePresets.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool" + @"\Macros\";
|
|
|
|
|
if (!Directory.Exists(savePresets.InitialDirectory))
|
|
|
|
|
{
|
|
|
|
|
Directory.CreateDirectory(savePresets.InitialDirectory);
|
|
|
|
|
//savePresets.InitialDirectory = path;
|
|
|
|
|
}
|
|
|
|
|
Console.WriteLine(savePresets.InitialDirectory);
|
|
|
|
|
if (savePresets.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
|
|
|
|
if ((stream = savePresets.OpenFile()) != null)
|
|
|
|
|
{
|
|
|
|
|
string macro = string.Join("/", macros.ToArray());
|
|
|
|
|
StreamWriter sw = new StreamWriter(stream);
|
|
|
|
|
sw.Write(macro);
|
|
|
|
|
sw.Close();
|
|
|
|
|
//stream.Close();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else MessageBox.Show(Properties.Resources.NoMacroRecorded, "DS4Windows", MessageBoxButtons.OK, MessageBoxIcon.Warning);
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
|
2014-11-14 20:44:50 +01:00
|
|
|
|
private void btnLoadP_Click(object sender, EventArgs e)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
2014-11-14 20:44:50 +01:00
|
|
|
|
if (Global.appdatapath == Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName)
|
|
|
|
|
openPresets.InitialDirectory = Directory.GetParent(Assembly.GetExecutingAssembly().Location).FullName + @"\Macros\";
|
|
|
|
|
else
|
|
|
|
|
openPresets.InitialDirectory = Environment.GetFolderPath(Environment.SpecialFolder.ApplicationData) + "\\DS4Tool" + @"\Macros\";
|
|
|
|
|
if (openPresets.ShowDialog() == System.Windows.Forms.DialogResult.OK)
|
2014-06-14 21:14:27 +02:00
|
|
|
|
{
|
2014-11-14 20:44:50 +01:00
|
|
|
|
string file = openPresets.FileName;
|
|
|
|
|
macros.Clear();
|
|
|
|
|
lVMacros.Items.Clear();
|
|
|
|
|
StreamReader sr = new StreamReader(file);
|
|
|
|
|
string[] macs = File.ReadAllText(file).Split('/');
|
|
|
|
|
int temp;
|
|
|
|
|
foreach (string s in macs)
|
|
|
|
|
{
|
|
|
|
|
if (int.TryParse(s, out temp))
|
|
|
|
|
macros.Add(temp);
|
|
|
|
|
}
|
|
|
|
|
LoadMacro();
|
|
|
|
|
sr.Close();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-11-14 20:44:50 +01:00
|
|
|
|
private void lVMacros_MouseHover(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
lVMacros.Focus();
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
2014-06-17 01:43:01 +02:00
|
|
|
|
|
2014-11-14 20:44:50 +01:00
|
|
|
|
private void btnCancel_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
saved = true;
|
|
|
|
|
Close();
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-17 01:43:01 +02:00
|
|
|
|
private void btn4th_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int value = 259;
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btn4th.Text.Contains(Properties.Resources.DownText))
|
2014-06-17 01:43:01 +02:00
|
|
|
|
{
|
|
|
|
|
if (macros.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add("4th Mouse Button", 0);
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
2014-06-17 01:43:01 +02:00
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add("4th Mouse Button", 0);
|
|
|
|
|
}
|
2014-08-17 00:09:15 +02:00
|
|
|
|
btn4th.Text = Properties.Resources.FourthMouseUp;
|
2014-06-17 01:43:01 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
2014-06-17 01:43:01 +02:00
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add("4th Mouse Button", 1);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
btn4th.Text = Properties.Resources.FourthMouseDown;
|
2014-06-17 01:43:01 +02:00
|
|
|
|
}
|
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
private void btn5th_Click(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
int value = 260;
|
2014-08-17 00:09:15 +02:00
|
|
|
|
if (btn5th.Text.Contains(Properties.Resources.DownText))
|
2014-06-17 01:43:01 +02:00
|
|
|
|
{
|
|
|
|
|
if (macros.Count == 0)
|
|
|
|
|
{
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add("5th Mouse Button", 0);
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
2014-06-17 01:43:01 +02:00
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add("5th Mouse Button", 0);
|
|
|
|
|
}
|
2014-08-17 00:09:15 +02:00
|
|
|
|
btn5th.Text = Properties.Resources.FifthMouseUp;
|
2014-06-17 01:43:01 +02:00
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (cBRecordDelays.Checked)
|
|
|
|
|
{
|
|
|
|
|
macros.Add((int)sw.ElapsedMilliseconds + 300);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", sw.ElapsedMilliseconds.ToString()).Replace("*ms*", "ms"), 2);
|
2014-06-17 01:43:01 +02:00
|
|
|
|
sw.Reset();
|
|
|
|
|
sw.Start();
|
|
|
|
|
}
|
|
|
|
|
macros.Add(value);
|
|
|
|
|
lVMacros.Items.Add("5th Mouse Button", 1);
|
2014-08-17 00:09:15 +02:00
|
|
|
|
btn5th.Text = Properties.Resources.FifthMouseDown;
|
2014-06-17 01:43:01 +02:00
|
|
|
|
}
|
|
|
|
|
lVMacros.Items[lVMacros.Items.Count - 1].EnsureVisible();
|
|
|
|
|
}
|
2014-11-14 20:44:50 +01:00
|
|
|
|
|
|
|
|
|
void LoadMacro()
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
if (macros.Count > 0)
|
|
|
|
|
{
|
|
|
|
|
bool[] keydown = new bool[286];
|
|
|
|
|
foreach (int i in macros)
|
|
|
|
|
{
|
|
|
|
|
if (i >= 300) //ints over 300 used to delay
|
|
|
|
|
lVMacros.Items.Add(Properties.Resources.WaitMS.Replace("*number*", (i - 300).ToString()).Replace("*ms*", "ms"), 2);
|
|
|
|
|
else if (!keydown[i])
|
|
|
|
|
{
|
|
|
|
|
//anything above 255 is not a keyvalue
|
|
|
|
|
if (i == 256) lVMacros.Items.Add("Left Mouse Button", 0);
|
|
|
|
|
else if (i == 257) lVMacros.Items.Add("Right Mouse Button", 0);
|
|
|
|
|
else if (i == 258) lVMacros.Items.Add("Middle Mouse Button", 0);
|
|
|
|
|
else if (i == 259) lVMacros.Items.Add("4th Mouse Button", 0);
|
|
|
|
|
else if (i == 260) lVMacros.Items.Add("5th Mouse Button", 0);
|
|
|
|
|
else if (i == 261) lVMacros.Items.Add("A Button", 0);
|
|
|
|
|
else if (i == 262) lVMacros.Items.Add("B Button", 0);
|
|
|
|
|
else if (i == 263) lVMacros.Items.Add("X Button", 0);
|
|
|
|
|
else if (i == 264) lVMacros.Items.Add("Y Button", 0);
|
|
|
|
|
else if (i == 265) lVMacros.Items.Add("Start", 0);
|
|
|
|
|
else if (i == 266) lVMacros.Items.Add("Back", 0);
|
|
|
|
|
else if (i == 267) lVMacros.Items.Add("Up Button", 0);
|
|
|
|
|
else if (i == 268) lVMacros.Items.Add("Down Button", 0);
|
|
|
|
|
else if (i == 269) lVMacros.Items.Add("Left Button", 0);
|
|
|
|
|
else if (i == 270) lVMacros.Items.Add("Right Button", 0);
|
|
|
|
|
else if (i == 271) lVMacros.Items.Add("Guide", 0);
|
|
|
|
|
else if (i == 272) lVMacros.Items.Add("Left Bumper", 0);
|
|
|
|
|
else if (i == 273) lVMacros.Items.Add("Right Bumper", 0);
|
|
|
|
|
else if (i == 274) lVMacros.Items.Add("Left Trigger", 0);
|
|
|
|
|
else if (i == 275) lVMacros.Items.Add("Right Trigger", 0);
|
|
|
|
|
else if (i == 276) lVMacros.Items.Add("Left Stick", 0);
|
|
|
|
|
else if (i == 277) lVMacros.Items.Add("Right Stick", 0);
|
|
|
|
|
else if (i == 278) lVMacros.Items.Add("LS Right", 0);
|
|
|
|
|
else if (i == 279) lVMacros.Items.Add("LS Left", 0);
|
|
|
|
|
else if (i == 280) lVMacros.Items.Add("LS Down", 0);
|
|
|
|
|
else if (i == 281) lVMacros.Items.Add("LS Up", 0);
|
|
|
|
|
else if (i == 282) lVMacros.Items.Add("RS Right", 0);
|
|
|
|
|
else if (i == 283) lVMacros.Items.Add("RS Left", 0);
|
|
|
|
|
else if (i == 284) lVMacros.Items.Add("RS Down", 0);
|
|
|
|
|
else if (i == 285) lVMacros.Items.Add("RS Up", 0);
|
|
|
|
|
else lVMacros.Items.Add(((Keys)i).ToString(), 0);
|
|
|
|
|
keydown[i] = true;
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
if (i == 256) lVMacros.Items.Add("Left Mouse Button", 1);
|
|
|
|
|
else if (i == 257) lVMacros.Items.Add("Right Mouse Button", 1);
|
|
|
|
|
else if (i == 258) lVMacros.Items.Add("Middle Mouse Button", 1);
|
|
|
|
|
else if (i == 259) lVMacros.Items.Add("4th Mouse Button", 1);
|
|
|
|
|
else if (i == 260) lVMacros.Items.Add("5th Mouse Button", 1);
|
|
|
|
|
else if (i == 261) lVMacros.Items.Add("A Button", 1);
|
|
|
|
|
else if (i == 262) lVMacros.Items.Add("B Button", 1);
|
|
|
|
|
else if (i == 263) lVMacros.Items.Add("X Button", 1);
|
|
|
|
|
else if (i == 264) lVMacros.Items.Add("Y Button", 1);
|
|
|
|
|
else if (i == 265) lVMacros.Items.Add("Start", 1);
|
|
|
|
|
else if (i == 266) lVMacros.Items.Add("Back", 1);
|
|
|
|
|
else if (i == 267) lVMacros.Items.Add("Up Button", 1);
|
|
|
|
|
else if (i == 268) lVMacros.Items.Add("Down Button", 1);
|
|
|
|
|
else if (i == 269) lVMacros.Items.Add("Left Button", 1);
|
|
|
|
|
else if (i == 270) lVMacros.Items.Add("Right Button", 1);
|
|
|
|
|
else if (i == 271) lVMacros.Items.Add("Guide", 1);
|
|
|
|
|
else if (i == 272) lVMacros.Items.Add("Left Bumper", 1);
|
|
|
|
|
else if (i == 273) lVMacros.Items.Add("Right Bumper", 1);
|
|
|
|
|
else if (i == 274) lVMacros.Items.Add("Left Trigger", 1);
|
|
|
|
|
else if (i == 275) lVMacros.Items.Add("Right Trigger", 1);
|
|
|
|
|
else if (i == 276) lVMacros.Items.Add("Left Stick", 1);
|
|
|
|
|
else if (i == 277) lVMacros.Items.Add("Right Stick", 1);
|
|
|
|
|
else if (i == 278) lVMacros.Items.Add("LS Right", 1);
|
|
|
|
|
else if (i == 279) lVMacros.Items.Add("LS Left", 1);
|
|
|
|
|
else if (i == 280) lVMacros.Items.Add("LS Down", 1);
|
|
|
|
|
else if (i == 281) lVMacros.Items.Add("LS Up", 1);
|
|
|
|
|
else if (i == 282) lVMacros.Items.Add("RS Right", 1);
|
|
|
|
|
else if (i == 283) lVMacros.Items.Add("RS Left", 1);
|
|
|
|
|
else if (i == 284) lVMacros.Items.Add("RS Down", 1);
|
|
|
|
|
else if (i == 285) lVMacros.Items.Add("RS Up", 1);
|
|
|
|
|
else lVMacros.Items.Add(((Keys)i).ToString(), 1);
|
|
|
|
|
keydown[i] = false;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
for (ushort i = 0; i < keydown.Length; i++)
|
|
|
|
|
{
|
|
|
|
|
if (keydown[i])
|
|
|
|
|
{
|
|
|
|
|
if (i == 256) lVMacros.Items.Add("Left Mouse Button", 1);
|
|
|
|
|
else if (i == 257) lVMacros.Items.Add("Right Mouse Button", 1);
|
|
|
|
|
else if (i == 258) lVMacros.Items.Add("Middle Mouse Button", 1);
|
|
|
|
|
else if (i == 259) lVMacros.Items.Add("4th Mouse Button", 1);
|
|
|
|
|
else if (i == 260) lVMacros.Items.Add("5th Mouse Button", 1);
|
|
|
|
|
else if (i == 261) lVMacros.Items.Add("A Button", 1);
|
|
|
|
|
else if (i == 262) lVMacros.Items.Add("B Button", 1);
|
|
|
|
|
else if (i == 263) lVMacros.Items.Add("X Button", 1);
|
|
|
|
|
else if (i == 264) lVMacros.Items.Add("Y Button", 1);
|
|
|
|
|
else if (i == 265) lVMacros.Items.Add("Start", 1);
|
|
|
|
|
else if (i == 266) lVMacros.Items.Add("Back", 1);
|
|
|
|
|
else if (i == 267) lVMacros.Items.Add("Up Button", 1);
|
|
|
|
|
else if (i == 268) lVMacros.Items.Add("Down Button", 1);
|
|
|
|
|
else if (i == 269) lVMacros.Items.Add("Left Button", 1);
|
|
|
|
|
else if (i == 270) lVMacros.Items.Add("Right Button", 1);
|
|
|
|
|
else if (i == 271) lVMacros.Items.Add("Guide", 1);
|
|
|
|
|
else if (i == 272) lVMacros.Items.Add("Left Bumper", 1);
|
|
|
|
|
else if (i == 273) lVMacros.Items.Add("Right Bumper", 1);
|
|
|
|
|
else if (i == 274) lVMacros.Items.Add("Left Trigger", 1);
|
|
|
|
|
else if (i == 275) lVMacros.Items.Add("Right Trigger", 1);
|
|
|
|
|
else if (i == 276) lVMacros.Items.Add("Left Stick", 1);
|
|
|
|
|
else if (i == 277) lVMacros.Items.Add("Right Stick", 1);
|
|
|
|
|
else if (i == 278) lVMacros.Items.Add("LS Right", 1);
|
|
|
|
|
else if (i == 279) lVMacros.Items.Add("LS Left", 1);
|
|
|
|
|
else if (i == 280) lVMacros.Items.Add("LS Down", 1);
|
|
|
|
|
else if (i == 281) lVMacros.Items.Add("LS Up", 1);
|
|
|
|
|
else if (i == 282) lVMacros.Items.Add("RS Right", 1);
|
|
|
|
|
else if (i == 283) lVMacros.Items.Add("RS Left", 1);
|
|
|
|
|
else if (i == 284) lVMacros.Items.Add("RS Down", 1);
|
|
|
|
|
else if (i == 285) lVMacros.Items.Add("RS Up", 1);
|
|
|
|
|
else lVMacros.Items.Add(((Keys)i).ToString(), 1);
|
|
|
|
|
macros.Add(i);
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
private void RecordBox_FormClosing(object sender, FormClosingEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (!saved && macros.Count > 0)
|
|
|
|
|
if (MessageBox.Show(Properties.Resources.SaveRecordedMacro, "DS4Windows", MessageBoxButtons.YesNo, MessageBoxIcon.Question) == System.Windows.Forms.DialogResult.Yes)
|
|
|
|
|
btnSave_Click(null, null);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
protected override bool IsInputKey(Keys keyData)
|
|
|
|
|
{
|
|
|
|
|
switch (keyData)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Right:
|
|
|
|
|
case Keys.Left:
|
|
|
|
|
case Keys.Up:
|
|
|
|
|
case Keys.Down:
|
|
|
|
|
case Keys.Tab:
|
|
|
|
|
case Keys.MediaPlayPause:
|
|
|
|
|
case Keys.MediaPreviousTrack:
|
|
|
|
|
case Keys.MediaNextTrack:
|
|
|
|
|
return true;
|
|
|
|
|
case Keys.Shift | Keys.Right:
|
|
|
|
|
case Keys.Shift | Keys.Left:
|
|
|
|
|
case Keys.Shift | Keys.Up:
|
|
|
|
|
case Keys.Shift | Keys.Down:
|
|
|
|
|
case Keys.Shift | Keys.Tab:
|
|
|
|
|
case Keys.Shift | Keys.MediaPlayPause:
|
|
|
|
|
case Keys.Shift | Keys.MediaPreviousTrack:
|
|
|
|
|
case Keys.Shift | Keys.MediaNextTrack:
|
|
|
|
|
return true;
|
|
|
|
|
}
|
|
|
|
|
return base.IsInputKey(keyData);
|
|
|
|
|
}
|
|
|
|
|
protected override void OnKeyDown(KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
base.OnKeyDown(e);
|
|
|
|
|
switch (e.KeyCode)
|
|
|
|
|
{
|
|
|
|
|
case Keys.Left:
|
|
|
|
|
case Keys.Right:
|
|
|
|
|
case Keys.Up:
|
|
|
|
|
case Keys.Down:
|
|
|
|
|
case Keys.Tab:
|
|
|
|
|
case Keys.MediaPlayPause:
|
|
|
|
|
case Keys.MediaPreviousTrack:
|
|
|
|
|
case Keys.MediaNextTrack:
|
|
|
|
|
if (e.Shift)
|
|
|
|
|
{
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
else
|
|
|
|
|
{
|
|
|
|
|
}
|
|
|
|
|
break;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
private int selection;
|
|
|
|
|
private void lVMacros_MouseDoubleClick(object sender, MouseEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
if (lVMacros.SelectedIndices[0] >= 0 && lVMacros.SelectedItems[0].ImageIndex == 2)
|
|
|
|
|
{
|
|
|
|
|
TextBox tb = new TextBox();
|
|
|
|
|
tb.KeyDown += nud_KeyDown;
|
|
|
|
|
tb.LostFocus += nud_LostFocus;
|
|
|
|
|
selection = lVMacros.SelectedIndices[0];
|
|
|
|
|
Controls.Add(tb);
|
|
|
|
|
tb.Location = new Point(lVMacros.Location.X + lVMacros.SelectedItems[0].Position.X, lVMacros.Location.Y + lVMacros.SelectedItems[0].Position.Y);
|
|
|
|
|
tb.BringToFront();
|
|
|
|
|
lVMacros.MouseHover -= lVMacros_MouseHover;
|
|
|
|
|
tb.TextChanged += tb_TextChanged;
|
|
|
|
|
tb.Focus();
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void tb_TextChanged(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TextBox tb = (TextBox)sender;
|
|
|
|
|
for (int i = tb.Text.Length - 1; i >= 0; i--)
|
|
|
|
|
if (!Char.IsDigit(tb.Text[i]))
|
|
|
|
|
tb.Text = tb.Text.Remove(i, 1);
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nud_LostFocus(object sender, EventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TextBox tb = (TextBox)sender;
|
|
|
|
|
int i;
|
|
|
|
|
if (!string.IsNullOrEmpty(tb.Text) && int.TryParse(tb.Text, out i))
|
|
|
|
|
{
|
|
|
|
|
lVMacros.Items[selection] = new ListViewItem(Properties.Resources.WaitMS.Replace("*number*", (tb.Text)).Replace("*ms*", "ms"), 2);
|
|
|
|
|
macros[selection] = i + 300;
|
|
|
|
|
saved = false;
|
|
|
|
|
}
|
|
|
|
|
Controls.Remove(tb);
|
|
|
|
|
lVMacros.MouseHover += lVMacros_MouseHover;
|
|
|
|
|
}
|
|
|
|
|
|
|
|
|
|
void nud_KeyDown(object sender, KeyEventArgs e)
|
|
|
|
|
{
|
|
|
|
|
TextBox tb = (TextBox)sender;
|
|
|
|
|
if (e.KeyCode == Keys.Enter && !string.IsNullOrEmpty(tb.Text))
|
|
|
|
|
{
|
|
|
|
|
int i;
|
|
|
|
|
if (int.TryParse(tb.Text, out i))
|
|
|
|
|
{
|
|
|
|
|
lVMacros.Items[selection] = new ListViewItem(Properties.Resources.WaitMS.Replace("*number*", (tb.Text)).Replace("*ms*", "ms"), 2);
|
|
|
|
|
macros[selection] = i + 300;
|
|
|
|
|
saved = false;
|
|
|
|
|
Controls.Remove(tb);
|
|
|
|
|
lVMacros.MouseHover += lVMacros_MouseHover;
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
}
|
|
|
|
|
|
2014-06-14 21:14:27 +02:00
|
|
|
|
}
|
|
|
|
|
}
|