Angband
ui-event.h
Go to the documentation of this file.
1 
18 #ifndef INCLUDED_UI_EVENT_H
19 #define INCLUDED_UI_EVENT_H
20 
24 typedef enum
25 {
26  EVT_NONE = 0x0000,
27 
28  /* Basic events */
29  EVT_KBRD = 0x0001, /* Keypress */
30  EVT_MOUSE = 0x0002, /* Mousepress */
31  EVT_RESIZE = 0x0004, /* Display resize */
32 
33  EVT_BUTTON = 0x0008, /* Button press */
34 
35  /* 'Abstract' events */
36  EVT_ESCAPE = 0x0010, /* Get out of this menu */
37  EVT_MOVE = 0x0020, /* Menu movement */
38  EVT_SELECT = 0x0040 /* Menu selection */
40 
41 
45 #define KC_MOD_CONTROL 0x01
46 #define KC_MOD_SHIFT 0x02
47 #define KC_MOD_ALT 0x04
48 #define KC_MOD_META 0x08
49 #define KC_MOD_KEYPAD 0x10
50 
51 
69 #define MODS_INCLUDE_CONTROL(v) \
70  (((v) >= 0x01 && (v) <= 0x1F) ? FALSE : TRUE)
71 
72 #define MODS_INCLUDE_SHIFT(v) \
73  ((((v) >= 0x21 && (v) <= 0x2F) || \
74  ((v) >= 0x3A && (v) <= 0x60) || \
75  ((v) >= 0x7B && (v) <= 0x7E)) ? FALSE : TRUE)
76 
77 
86 #define ENCODE_KTRL(v) \
87  (((v) >= 0x40 && (v) <= 0x5F) ? TRUE : FALSE)
88 
89 
93 #define KTRL(X) \
94  ((X) & 0x1F)
95 
96 
100 #define UN_KTRL(X) \
101  ((X) + 64)
102 
103 
107 #define ARROW_DOWN 0x80
108 #define ARROW_LEFT 0x81
109 #define ARROW_RIGHT 0x82
110 #define ARROW_UP 0x83
111 
112 #define KC_F1 0x84
113 #define KC_F2 0x85
114 #define KC_F3 0x86
115 #define KC_F4 0x87
116 #define KC_F5 0x88
117 #define KC_F6 0x89
118 #define KC_F7 0x8A
119 #define KC_F8 0x8B
120 #define KC_F9 0x8C
121 #define KC_F10 0x8D
122 #define KC_F11 0x8E
123 #define KC_F12 0x8F
124 #define KC_F13 0x90
125 #define KC_F14 0x91
126 #define KC_F15 0x92
127 
128 #define KC_HELP 0x93
129 #define KC_HOME 0x94
130 #define KC_PGUP 0x95
131 #define KC_END 0x96
132 #define KC_PGDOWN 0x97
133 #define KC_INSERT 0x98
134 #define KC_PAUSE 0x99
135 #define KC_BREAK 0x9a
136 #define KC_BEGIN 0x9b
137 #define KC_ENTER 0x9c /* ASCII \r */
138 #define KC_TAB 0x9d /* ASCII \t */
139 #define KC_DELETE 0x9e
140 #define KC_BACKSPACE 0x9f /* ASCII \h */
141 #define ESCAPE 0xE000
142 
143 /* we have up until 0x9F before we start edging into displayable Unicode */
144 /* then we could move into private use area 1, 0xE000 onwards */
145 
149 #define isarrow(c) ((c >= ARROW_DOWN) && (c <= ARROW_UP))
150 
151 
155 typedef u32b keycode_t;
156 
157 
161 struct keypress {
165 };
166 
170 struct mouseclick {
176 };
177 
181 typedef union {
183  struct mouseclick mouse;
184  struct keypress key;
185 } ui_event;
186 
190 #define EVENT_EMPTY { 0 }
191 
192 
193 /*** Functions ***/
194 
198 keycode_t keycode_find_code(const char *str, size_t len);
199 
203 const char *keycode_find_desc(keycode_t kc);
204 
208 void keypress_to_text(char *buf, size_t len, const struct keypress *src,
209  bool expand_backslash);
210 
214 void keypress_from_text(struct keypress *buf, size_t len, const char *str);
215 
220 void keypress_to_readable(char *buf, size_t len, struct keypress src);
221 
222 
223 extern bool char_matches_key(wchar_t c, keycode_t key);
224 
225 
226 #endif /* INCLUDED_UI_EVENT_H */