-
-
Notifications
You must be signed in to change notification settings - Fork 6
/
Copy pathxinput-cffi.lisp
62 lines (52 loc) · 1.39 KB
/
xinput-cffi.lisp
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
(in-package #:org.shirakumo.fraf.gamepad.impl)
(cffi:define-foreign-library xinput
(T (:or "XInput9_1_0.dll" "XInput1_4.dll" "XInput1_3.dll")))
(cffi:defbitfield (xbuttons dword)
(:dpad-u #x0001)
(:dpad-d #x0002)
(:dpad-l #x0004)
(:dpad-r #x0008)
(:start #x0010)
(:select #x0020)
(:l3 #x0040)
(:r3 #x0080)
(:l1 #x0100)
(:r1 #x0200)
(:a #x1000)
(:b #x2000)
(:x #x4000)
(:y #x8000))
(cffi:defcenum (xreturn dword :allow-undeclared-values T)
(:ok #x0000)
(:not-connected #x048F)
(:empty #x10D2))
(cffi:defcstruct (xgamepad :conc-name xgamepad-)
(buttons word)
(left-trigger byte)
(right-trigger byte)
(lx short)
(ly short)
(rx short)
(ry short))
(cffi:defcstruct (xstate :conc-name xstate-)
(packet dword)
(gamepad (:struct xgamepad)))
(cffi:defcstruct (xvibration :conc-name xvibration-)
(left word)
(right word))
(cffi:defcstruct (xcapabilities :conc-name xcapabilities-)
(type byte)
(subtype byte)
(flags word)
(gamepad (:struct xstate))
(vibration (:struct xvibration)))
(cffi:defcfun (get-xcapabilities "XInputGetCapabilities") xreturn
(user-index dword)
(flags dword)
(capabilities :pointer))
(cffi:defcfun (get-xstate "XInputGetState") xreturn
(user-index dword)
(state :pointer))
(cffi:defcfun (set-xstate "XInputSetState") xreturn
(user-index dword)
(vibration :pointer))