-
-
Notifications
You must be signed in to change notification settings - Fork 46
/
input.lisp
81 lines (58 loc) · 2.57 KB
/
input.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
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
(in-package #:org.shirakumo.fraf.trial)
(define-global +input-source+ :keyboard)
(define-event input-event (event))
(define-event keyboard-event (input-event))
(define-event digital-event (input-event))
(define-event press-event (input-event))
(define-event release-event (input-event))
(defgeneric button (digital-event))
(define-event key-event (keyboard-event digital-event)
(key arg! :reader key :reader button) (repeat NIL :reader repeat-p) (modifiers ()))
(defmethod print-object ((event key-event) stream)
(print-unreadable-object (event stream :type T)
(format stream "~s" (key event))))
(define-event key-press (key-event press-event))
(define-event key-release (key-event release-event))
(define-event text-entered (keyboard-event)
text (replace NIL :reader replace-p))
(defmethod print-object ((event text-entered) stream)
(print-unreadable-object (event stream :type T)
(format stream "~s" (text event))))
(define-event mouse-event (input-event)
pos)
(define-event mouse-button-event (mouse-event digital-event)
button)
(defmethod print-object ((event mouse-button-event) stream)
(print-unreadable-object (event stream :type T)
(format stream "~s" (button event))))
(define-event mouse-press (mouse-button-event press-event))
(define-event mouse-release (mouse-button-event release-event))
(define-event mouse-double-click (mouse-button-event))
(define-event mouse-scroll (mouse-event)
delta)
(defmethod print-object ((event mouse-scroll) stream)
(print-unreadable-object (event stream :type T)
(format stream "~a" (delta event))))
(define-event mouse-move (mouse-event)
old-pos)
(defmethod print-object ((event mouse-move) stream)
(print-unreadable-object (event stream :type T)
(format stream "~a => ~a" (old-pos event) (pos event))))
(define-event file-drop-event (mouse-event)
paths)
(define-event gamepad-event (input-event)
device)
(define-event gamepad-button-event (gamepad-event digital-event)
button)
(defmethod print-object ((event gamepad-button-event) stream)
(print-unreadable-object (event stream :type T)
(format stream "~a ~s" (device event) (button event))))
(define-event gamepad-press (gamepad-button-event press-event))
(define-event gamepad-release (gamepad-button-event release-event))
(define-event gamepad-move (gamepad-event)
axis old-pos pos)
(defmethod print-object ((event gamepad-move) stream)
(print-unreadable-object (event stream :type T)
(format stream "~a ~s ~3f" (device event) (axis event) (pos event))))
(define-event gamepad-added (gamepad-event))
(define-event gamepad-removed (gamepad-event))