2 * This program is free software; you can redistribute it and/or
3 * modify it under the terms of the GNU General Public License
4 * as published by the Free Software Foundation; either version 2
5 * of the License, or (at your option) any later version.
7 * This program is distributed in the hope that it will be useful,
8 * but WITHOUT ANY WARRANTY; without even the implied warranty of
9 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10 * GNU General Public License for more details.
12 * You should have received a copy of the GNU General Public License
13 * along with this program; if not, write to the Free Software Foundation,
14 * Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
22 * These define have its origin at sgi, where all device defines were written down in device.h.
23 * Blender copied the conventions quite some, and expanded it with internal new defines (ton)
26 #ifndef __WM_EVENT_TYPES_H__
27 #define __WM_EVENT_TYPES_H__
32 EVT_DATA_DRAGDROP = 3,
33 EVT_DATA_NDOF_MOTION = 4,
36 /* tablet active, matches GHOST_TTabletMode */
39 EVT_TABLET_STYLUS = 1,
40 EVT_TABLET_ERASER = 2,
46 * \note Also used for #wmKeyMapItem.type which is saved in key-map files,
47 * do not change the values of existing values which can be used in key-maps.
50 /* non-event, for example disabled timer */
53 /* ********** Start of Input devices. ********** */
55 /* MOUSE : 0x000x, 0x001x */
60 /* Extra mouse buttons */
61 BUTTON4MOUSE = 0x0007,
62 BUTTON5MOUSE = 0x0008,
63 /* More mouse buttons - can't use 9 and 10 here (wheel) */
64 BUTTON6MOUSE = 0x0012,
65 BUTTON7MOUSE = 0x0013,
66 /* Extra trackpad gestures */
70 MOUSESMARTZOOM = 0x0017,
72 /* defaults from ghost */
73 WHEELUPMOUSE = 0x000a,
74 WHEELDOWNMOUSE = 0x000b,
75 /* mapped with userdef */
76 WHEELINMOUSE = 0x000c,
77 WHEELOUTMOUSE = 0x000d,
78 /* Successive MOUSEMOVE's are converted to this, so we can easily
79 * ignore all but the most recent MOUSEMOVE (for better performance),
80 * paint and drawing tools however will want to handle these. */
81 INBETWEEN_MOUSEMOVE = 0x0011,
83 /* IME event, GHOST_kEventImeCompositionStart in ghost */
84 WM_IME_COMPOSITE_START = 0x0014,
85 /* IME event, GHOST_kEventImeComposition in ghost */
86 WM_IME_COMPOSITE_EVENT = 0x0015,
87 /* IME event, GHOST_kEventImeCompositionEnd in ghost */
88 WM_IME_COMPOSITE_END = 0x0016,
90 /* Tablet/Pen Specific Events */
91 TABLET_STYLUS = 0x001a,
92 TABLET_ERASER = 0x001b,
94 /* *** Start of keyboard codes. *** */
97 * From 0x0020 to 0x00ff, and 0x012c to 0x0143 for function keys! */
99 EVT_ZEROKEY = 0x0030, /* '0' (48). */
100 EVT_ONEKEY = 0x0031, /* '1' (49). */
101 EVT_TWOKEY = 0x0032, /* '2' (50). */
102 EVT_THREEKEY = 0x0033, /* '3' (51). */
103 EVT_FOURKEY = 0x0034, /* '4' (52). */
104 EVT_FIVEKEY = 0x0035, /* '5' (53). */
105 EVT_SIXKEY = 0x0036, /* '6' (54). */
106 EVT_SEVENKEY = 0x0037, /* '7' (55). */
107 EVT_EIGHTKEY = 0x0038, /* '8' (56). */
108 EVT_NINEKEY = 0x0039, /* '9' (57). */
110 EVT_AKEY = 0x0061, /* 'a' (97). */
111 EVT_BKEY = 0x0062, /* 'b' (98). */
112 EVT_CKEY = 0x0063, /* 'c' (99). */
113 EVT_DKEY = 0x0064, /* 'd' (100). */
114 EVT_EKEY = 0x0065, /* 'e' (101). */
115 EVT_FKEY = 0x0066, /* 'f' (102). */
116 EVT_GKEY = 0x0067, /* 'g' (103). */
117 EVT_HKEY = 0x0068, /* 'h' (104). */
118 EVT_IKEY = 0x0069, /* 'i' (105). */
119 EVT_JKEY = 0x006a, /* 'j' (106). */
120 EVT_KKEY = 0x006b, /* 'k' (107). */
121 EVT_LKEY = 0x006c, /* 'l' (108). */
122 EVT_MKEY = 0x006d, /* 'm' (109). */
123 EVT_NKEY = 0x006e, /* 'n' (110). */
124 EVT_OKEY = 0x006f, /* 'o' (111). */
125 EVT_PKEY = 0x0070, /* 'p' (112). */
126 EVT_QKEY = 0x0071, /* 'q' (113). */
127 EVT_RKEY = 0x0072, /* 'r' (114). */
128 EVT_SKEY = 0x0073, /* 's' (115). */
129 EVT_TKEY = 0x0074, /* 't' (116). */
130 EVT_UKEY = 0x0075, /* 'u' (117). */
131 EVT_VKEY = 0x0076, /* 'v' (118). */
132 EVT_WKEY = 0x0077, /* 'w' (119). */
133 EVT_XKEY = 0x0078, /* 'x' (120). */
134 EVT_YKEY = 0x0079, /* 'y' (121). */
135 EVT_ZKEY = 0x007a, /* 'z' (122). */
137 EVT_LEFTARROWKEY = 0x0089, /* 137 */
138 EVT_DOWNARROWKEY = 0x008a, /* 138 */
139 EVT_RIGHTARROWKEY = 0x008b, /* 139 */
140 EVT_UPARROWKEY = 0x008c, /* 140 */
142 EVT_PAD0 = 0x0096, /* 150 */
143 EVT_PAD1 = 0x0097, /* 151 */
144 EVT_PAD2 = 0x0098, /* 152 */
145 EVT_PAD3 = 0x0099, /* 153 */
146 EVT_PAD4 = 0x009a, /* 154 */
147 EVT_PAD5 = 0x009b, /* 155 */
148 EVT_PAD6 = 0x009c, /* 156 */
149 EVT_PAD7 = 0x009d, /* 157 */
150 EVT_PAD8 = 0x009e, /* 158 */
151 EVT_PAD9 = 0x009f, /* 159 */
153 EVT_PADASTERKEY = 0x00a0, /* 160 */
154 EVT_PADSLASHKEY = 0x00a1, /* 161 */
155 EVT_PADMINUS = 0x00a2, /* 162 */
156 EVT_PADENTER = 0x00a3, /* 163 */
157 EVT_PADPLUSKEY = 0x00a4, /* 164 */
159 EVT_PAUSEKEY = 0x00a5, /* 165 */
160 EVT_INSERTKEY = 0x00a6, /* 166 */
161 EVT_HOMEKEY = 0x00a7, /* 167 */
162 EVT_PAGEUPKEY = 0x00a8, /* 168 */
163 EVT_PAGEDOWNKEY = 0x00a9, /* 169 */
164 EVT_ENDKEY = 0x00aa, /* 170 */
165 /* Note that 'PADPERIOD' is defined out-of-order. */
166 EVT_UNKNOWNKEY = 0x00ab, /* 171 */
167 EVT_OSKEY = 0x00ac, /* 172 */
168 EVT_GRLESSKEY = 0x00ad, /* 173 */
170 EVT_MEDIAPLAY = 0x00ae, /* 174 */
171 EVT_MEDIASTOP = 0x00af, /* 175 */
172 EVT_MEDIAFIRST = 0x00b0, /* 176 */
173 EVT_MEDIALAST = 0x00b1, /* 177 */
175 EVT_APPKEY = 0x00b2, /* 178 */
177 EVT_PADPERIOD = 0x00c7, /* 199 */
179 EVT_CAPSLOCKKEY = 0x00d3, /* 211 */
182 EVT_LEFTCTRLKEY = 0x00d4, /* 212 */
183 EVT_LEFTALTKEY = 0x00d5, /* 213 */
184 EVT_RIGHTALTKEY = 0x00d6, /* 214 */
185 EVT_RIGHTCTRLKEY = 0x00d7, /* 215 */
186 EVT_RIGHTSHIFTKEY = 0x00d8, /* 216 */
187 EVT_LEFTSHIFTKEY = 0x00d9, /* 217 */
188 /* Special characters. */
189 EVT_ESCKEY = 0x00da, /* 218 */
190 EVT_TABKEY = 0x00db, /* 219 */
191 EVT_RETKEY = 0x00dc, /* 220 */
192 EVT_SPACEKEY = 0x00dd, /* 221 */
193 EVT_LINEFEEDKEY = 0x00de, /* 222 */
194 EVT_BACKSPACEKEY = 0x00df, /* 223 */
195 EVT_DELKEY = 0x00e0, /* 224 */
196 EVT_SEMICOLONKEY = 0x00e1, /* 225 */
197 EVT_PERIODKEY = 0x00e2, /* 226 */
198 EVT_COMMAKEY = 0x00e3, /* 227 */
199 EVT_QUOTEKEY = 0x00e4, /* 228 */
200 EVT_ACCENTGRAVEKEY = 0x00e5, /* 229 */
201 EVT_MINUSKEY = 0x00e6, /* 230 */
202 EVT_PLUSKEY = 0x00e7, /* 231 */
203 EVT_SLASHKEY = 0x00e8, /* 232 */
204 EVT_BACKSLASHKEY = 0x00e9, /* 233 */
205 EVT_EQUALKEY = 0x00ea, /* 234 */
206 EVT_LEFTBRACKETKEY = 0x00eb, /* 235 */
207 EVT_RIGHTBRACKETKEY = 0x00ec, /* 236 */
209 EVT_F1KEY = 0x012c, /* 300 */
210 EVT_F2KEY = 0x012d, /* 301 */
211 EVT_F3KEY = 0x012e, /* 302 */
212 EVT_F4KEY = 0x012f, /* 303 */
213 EVT_F5KEY = 0x0130, /* 304 */
214 EVT_F6KEY = 0x0131, /* 305 */
215 EVT_F7KEY = 0x0132, /* 306 */
216 EVT_F8KEY = 0x0133, /* 307 */
217 EVT_F9KEY = 0x0134, /* 308 */
218 EVT_F10KEY = 0x0135, /* 309 */
219 EVT_F11KEY = 0x0136, /* 310 */
220 EVT_F12KEY = 0x0137, /* 311 */
221 EVT_F13KEY = 0x0138, /* 312 */
222 EVT_F14KEY = 0x0139, /* 313 */
223 EVT_F15KEY = 0x013a, /* 314 */
224 EVT_F16KEY = 0x013b, /* 315 */
225 EVT_F17KEY = 0x013c, /* 316 */
226 EVT_F18KEY = 0x013d, /* 317 */
227 EVT_F19KEY = 0x013e, /* 318 */
228 EVT_F20KEY = 0x013f, /* 319 */
229 EVT_F21KEY = 0x0140, /* 320 */
230 EVT_F22KEY = 0x0141, /* 321 */
231 EVT_F23KEY = 0x0142, /* 322 */
232 EVT_F24KEY = 0x0143, /* 323 */
234 /* *** End of keyboard codes. *** */
236 /* NDOF (from SpaceNavigator & friends)
237 * These should be kept in sync with GHOST_NDOFManager.h
238 * Ordering matters, exact values do not. */
239 NDOF_MOTION = 0x0190, /* 400 */
240 /* used internally, never sent */
241 NDOF_BUTTON_NONE = NDOF_MOTION,
242 /* these two are available from any 3Dconnexion device */
255 /* 90 degree rotations */
257 NDOF_BUTTON_ROLL_CCW,
259 NDOF_BUTTON_SPIN_CCW,
261 NDOF_BUTTON_TILT_CCW,
265 NDOF_BUTTON_DOMINANT,
268 /* keyboard emulation */
273 /* general-purpose buttons */
284 /* more general-purpose buttons */
291 /* ********** End of Input devices. ********** */
293 /* ********** Start of Blender internal events. ********** */
295 /* XXX Those are mixed inside keyboard 'area'! */
297 INPUTCHANGE = 0x0103, /* Input connected or disconnected, (259). */
298 WINDEACTIVATE = 0x0104, /* Window is deactivated, focus lost, (260). */
300 TIMER = 0x0110, /* Timer event, passed on to all queues (272). */
301 TIMER0 = 0x0111, /* Timer event, slot for internal use (273). */
302 TIMER1 = 0x0112, /* Timer event, slot for internal use (274). */
303 TIMER2 = 0x0113, /* Timer event, slot for internal use (275). */
304 TIMERJOBS = 0x0114, /* Timer event, jobs system (276). */
305 TIMERAUTOSAVE = 0x0115, /* Timer event, autosave (277). */
306 TIMERREPORT = 0x0116, /* Timer event, reports (278). */
307 TIMERREGION = 0x0117, /* Timer event, region slide in/out (279). */
308 TIMERNOTIFIER = 0x0118, /* Timer event, notifier sender (280). */
309 TIMERF = 0x011F, /* Last timer (287). */
311 /* Actionzones, tweak, gestures: 0x500x, 0x501x */
312 /* Keep in sync with IS_EVENT_ACTIONZONE(...). */
313 EVT_ACTIONZONE_AREA = 0x5000, /* 20480 */
314 EVT_ACTIONZONE_REGION = 0x5001, /* 20481 */
315 EVT_ACTIONZONE_FULLSCREEN = 0x5011, /* 20497 */
317 /* NOTE: these values are saved in keymap files, do not change them but just add new ones */
320 * Sent as additional event with the mouse coordinates
321 * from where the initial click was placed. */
323 /* tweak events for L M R mousebuttons */
324 EVT_TWEAK_L = 0x5002, /* 20482 */
325 EVT_TWEAK_M = 0x5003, /* 20483 */
326 EVT_TWEAK_R = 0x5004, /* 20484 */
327 /* 0x5010 (and lower) should be left to add other tweak types in the future. */
329 /* 0x5011 is taken, see EVT_ACTIONZONE_FULLSCREEN */
331 /* Misc Blender internals: 0x502x */
332 EVT_FILESELECT = 0x5020, /* 20512 */
333 EVT_BUT_OPEN = 0x5021, /* 20513 */
334 EVT_MODAL_MAP = 0x5022, /* 20514 */
335 EVT_DROP = 0x5023, /* 20515 */
336 EVT_BUT_CANCEL = 0x5024, /* 20516 */
338 /* could become gizmo callback */
339 EVT_GIZMO_UPDATE = 0x5025, /* 20517 */
340 /* ********** End of Blender internal events. ********** */
343 /* *********** wmEvent.type helpers. ********** */
345 /* test whether the event is timer event */
346 #define ISTIMER(event_type) ((event_type) >= TIMER && (event_type) <= TIMERF)
348 /* for event checks */
349 /* only used for KM_TEXTINPUT, so assume that we want all user-inputtable ascii codes included */
350 /* UNUSED - see wm_eventmatch - BUG [#30479] */
351 /* #define ISTEXTINPUT(event_type) ((event_type) >= ' ' && (event_type) <= 255) */
352 /* note, an alternative could be to check 'event->utf8_buf' */
354 /* test whether the event is a key on the keyboard */
355 #define ISKEYBOARD(event_type) \
356 (((event_type) >= 0x0020 && (event_type) <= 0x00ff) || \
357 ((event_type) >= 0x012c && (event_type) <= 0x0143))
359 /* test whether the event is a modifier key */
360 #define ISKEYMODIFIER(event_type) \
361 (((event_type) >= EVT_LEFTCTRLKEY && (event_type) <= EVT_LEFTSHIFTKEY) || \
362 (event_type) == EVT_OSKEY)
364 /* test whether the event is a mouse button */
365 #define ISMOUSE(event_type) \
366 (((event_type) >= LEFTMOUSE && (event_type) <= BUTTON7MOUSE) || (event_type) == MOUSESMARTZOOM)
368 #define ISMOUSE_WHEEL(event_type) ((event_type) >= WHEELUPMOUSE && (event_type) <= WHEELOUTMOUSE)
369 #define ISMOUSE_GESTURE(event_type) ((event_type) >= MOUSEPAN && (event_type) <= MOUSEROTATE)
370 #define ISMOUSE_BUTTON(event_type) \
380 /* test whether the event is tweak event */
381 #define ISTWEAK(event_type) ((event_type) >= EVT_TWEAK_L && (event_type) <= EVT_TWEAK_R)
383 /* test whether the event is a NDOF event */
384 #define ISNDOF(event_type) ((event_type) >= NDOF_MOTION && (event_type) < NDOF_LAST)
386 #define IS_EVENT_ACTIONZONE(event_type) \
387 ELEM(event_type, EVT_ACTIONZONE_AREA, EVT_ACTIONZONE_REGION, EVT_ACTIONZONE_FULLSCREEN)
389 /* test whether event type is acceptable as hotkey, excluding modifiers */
390 #define ISHOTKEY(event_type) \
391 ((ISKEYBOARD(event_type) || ISMOUSE(event_type) || ISNDOF(event_type)) && \
392 (ISKEYMODIFIER(event_type) == false))
394 /* internal helpers*/
395 #define _VA_IS_EVENT_MOD2(v, a) (CHECK_TYPE_INLINE(v, wmEvent *), ((v)->a))
396 #define _VA_IS_EVENT_MOD3(v, a, b) (_VA_IS_EVENT_MOD2(v, a) || ((v)->b))
397 #define _VA_IS_EVENT_MOD4(v, a, b, c) (_VA_IS_EVENT_MOD3(v, a, b) || ((v)->c))
398 #define _VA_IS_EVENT_MOD5(v, a, b, c, d) (_VA_IS_EVENT_MOD4(v, a, b, c) || ((v)->d))
400 /* reusable IS_EVENT_MOD(event, shift, ctrl, alt, oskey), macro */
401 #define IS_EVENT_MOD(...) VA_NARGS_CALL_OVERLOAD(_VA_IS_EVENT_MOD, __VA_ARGS__)
403 enum eEventType_Mask {
405 EVT_TYPE_MASK_KEYBOARD_MODIFIER = (1 << 0),
407 EVT_TYPE_MASK_KEYBOARD = (1 << 1),
409 EVT_TYPE_MASK_MOUSE_WHEEL = (1 << 2),
411 EVT_TYPE_MASK_MOUSE_GESTURE = (1 << 3),
412 /* ISMOUSE_GESTURE */
413 EVT_TYPE_MASK_MOUSE_BUTTON = (1 << 4),
415 EVT_TYPE_MASK_MOUSE = (1 << 5),
417 EVT_TYPE_MASK_NDOF = (1 << 6),
419 EVT_TYPE_MASK_TWEAK = (1 << 7),
420 /* IS_EVENT_ACTIONZONE */
421 EVT_TYPE_MASK_ACTIONZONE = (1 << 8),
423 #define EVT_TYPE_MASK_ALL \
424 (EVT_TYPE_MASK_KEYBOARD | EVT_TYPE_MASK_MOUSE | EVT_TYPE_MASK_NDOF | EVT_TYPE_MASK_TWEAK | \
425 EVT_TYPE_MASK_ACTIONZONE)
427 #define EVT_TYPE_MASK_HOTKEY_INCLUDE \
428 (EVT_TYPE_MASK_KEYBOARD | EVT_TYPE_MASK_MOUSE | EVT_TYPE_MASK_NDOF)
429 #define EVT_TYPE_MASK_HOTKEY_EXCLUDE EVT_TYPE_MASK_KEYBOARD_MODIFIER
431 bool WM_event_type_mask_test(const int event_type, const enum eEventType_Mask mask);
433 /* ********** wmEvent.val ********** */
436 /* NOTE: these values are saved in keymap files, do not change them but just add new ones */
438 /* value of tweaks and line gestures, note, KM_ANY (-1) works for this case too */
451 EVT_FILESELECT_FULL_OPEN = 1,
452 EVT_FILESELECT_EXEC = 2,
453 EVT_FILESELECT_CANCEL = 3,
454 EVT_FILESELECT_EXTERNAL_CANCEL = 4,
459 * Used in #wmEvent.val
461 * \note These values are saved in keymap files,
462 * do not change them but just add new ones.
465 GESTURE_MODAL_CANCEL = 1,
466 GESTURE_MODAL_CONFIRM = 2,
468 /** Uses 'deselect' operator property. */
469 GESTURE_MODAL_SELECT = 3,
470 GESTURE_MODAL_DESELECT = 4,
472 /** Circle select: when no mouse button is pressed */
473 GESTURE_MODAL_NOP = 5,
475 /** Circle select: larger brush. */
476 GESTURE_MODAL_CIRCLE_ADD = 6,
477 /** Circle select: smaller brush. */
478 GESTURE_MODAL_CIRCLE_SUB = 7,
480 /** Box select/straight line, activate, use release to detect which button. */
481 GESTURE_MODAL_BEGIN = 8,
483 /** Uses 'zoom_out' operator property. */
484 GESTURE_MODAL_IN = 9,
485 GESTURE_MODAL_OUT = 10,
487 /** circle select: size brush (for trackpad event). */
488 GESTURE_MODAL_CIRCLE_SIZE = 11,
491 #endif /* __WM_EVENT_TYPES_H__ */