forked from sruon/ffxivlib
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathKeyBindList.cs
63 lines (56 loc) · 1.61 KB
/
KeyBindList.cs
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
using System;
using System.Collections.Generic;
using System.Runtime.InteropServices;
namespace ffxivlib
{
public static class KeyBinds
{
public static void sendAction(KeyBind bind)
{
SendKeyInput instance = SendKeyInput.GetInstance ();
SendKeyInput.VKKeys key = 0;
switch (bind.keyBindString [0])
{
case '=':
key = SendKeyInput.VKKeys.OEM_PLUS;
break;
case ',':
key = SendKeyInput.VKKeys.OEM_COMMA;
break;
case '-':
key = SendKeyInput.VKKeys.OEM_MINUS;
break;
case '.':
key = SendKeyInput.VKKeys.OEM_PERIOD;
break;
default:
key = (SendKeyInput.VKKeys)bind.keyBindString [0];
break;
}
if (bind.keyBindModifier == "Shift")
instance.ToggleKeyState (SendKeyInput.VKKeys.SHIFT, true);
if (bind.keyBindModifier == "CTRL")
instance.ToggleKeyState (SendKeyInput.VKKeys.CONTROL, true);
instance.SendKeyPress (key);
if (bind.keyBindModifier == "Shift")
instance.ToggleKeyState (SendKeyInput.VKKeys.SHIFT, false);
if (bind.keyBindModifier == "CTRL")
instance.ToggleKeyState (SendKeyInput.VKKeys.CONTROL, false);
}
}
public partial class FFXIVLIB
{
public IEnumerable<KeyBind> GetKeyBinds(int id)
{
var bindList = new List<KeyBind> ();
IntPtr pointer = _mr.ResolvePointerPath (Constants.HOTBARPTR);
pointer += (Constants.HOTBAROFFSET * id);
for (int i = 0; i < 12; ++i) {
IntPtr newPointer = pointer + (Marshal.SizeOf (typeof(KeyBind.KeyBindInfo)) * i);
var temp = new KeyBind(_mr.CreateStructFromAddress<KeyBind.KeyBindInfo> (newPointer), newPointer);
bindList.Add (temp);
}
return bindList;
}
}
}