event.h
Engine/source/platform/input/event.h
Library-wide input events.
Classes:
Generic input event.
Handles input device plug-ins.
Public Defines
AddInputVirtualMap(description, type, code) ->addVirtualMap( #description, type, code );
INPUTMGR() <>::instance()
Returns the InputEventManager singleton.
SI_ANY() 0xff
Wildcard match used by the input system.
Public Enumerations
InputActionType { SI_MAKE = 0x01 SI_BREAK = 0x02 SI_MOVE = 0x03 SI_REPEAT = 0x04 SI_VALUE = 0x05 }
Device Event Action Types.
InputDeviceTypesEnum { UnknownDeviceType MouseDeviceType KeyboardDeviceType JoystickDeviceType GamepadDeviceType XInputDeviceType NUM_INPUT_DEVICE_TYPES INPUT_DEVICE_PLUGIN_DEVICES_START = NUM_INPUT_DEVICE_TYPES }
InputEventType { SI_UNKNOWN = 0x01 SI_BUTTON = 0x02 SI_POV = 0x03 SI_AXIS = 0x04 SI_POS = 0x05 SI_ROT = 0x06 SI_INT = 0x07 SI_FLOAT = 0x08 SI_KEY = 0x0A }
Device Event Types.
InputModifiers { SI_LSHIFT = BIT(0) SI_RSHIFT = BIT(1) SI_SHIFT = (SI_LSHIFT|SI_RSHIFT) SI_LCTRL = BIT(2) SI_RCTRL = BIT(3) SI_CTRL = (SI_LCTRL|SI_RCTRL) SI_LALT = BIT(4) SI_RALT = BIT(5) SI_ALT = (SI_LALT|SI_RALT) SI_MAC_LOPT = BIT(6) SI_MAC_ROPT = BIT(7) SI_MAC_OPT = (SI_MAC_LOPT|SI_MAC_ROPT) SI_COPYPASTE = SI_CTRL SI_MULTISELECT = SI_CTRL SI_RANGESELECT = SI_SHIFT SI_PRIMARY_ALT = SI_ALT SI_PRIMARY_CTRL = SI_CTRL SI_WORDJUMP = SI_CTRL SI_LINEJUMP = SI_ALT SI_DOCJUMP = SI_CTRL }
InputObjectInstancesEnum { KEY_NULL = 0x000 KEY_BACKSPACE = 0x001 KEY_TAB = 0x002 KEY_RETURN = 0x003 KEY_CONTROL = 0x004 KEY_ALT = 0x005 KEY_SHIFT = 0x006 KEY_PAUSE = 0x007 KEY_CAPSLOCK = 0x008 KEY_ESCAPE = 0x009 KEY_SPACE = 0x00a KEY_PAGE_DOWN = 0x00b KEY_PAGE_UP = 0x00c KEY_END = 0x00d KEY_HOME = 0x00e KEY_LEFT = 0x00f KEY_UP = 0x010 KEY_RIGHT = 0x011 KEY_DOWN = 0x012 KEY_PRINT = 0x013 KEY_INSERT = 0x014 KEY_DELETE = 0x015 KEY_HELP = 0x016 KEY_0 = 0x017 KEY_1 = 0x018 KEY_2 = 0x019 KEY_3 = 0x01a KEY_4 = 0x01b KEY_5 = 0x01c KEY_6 = 0x01d KEY_7 = 0x01e KEY_8 = 0x01f KEY_9 = 0x020 KEY_A = 0x021 KEY_B = 0x022 KEY_C = 0x023 KEY_D = 0x024 KEY_E = 0x025 KEY_F = 0x026 KEY_G = 0x027 KEY_H = 0x028 KEY_I = 0x029 KEY_J = 0x02a KEY_K = 0x02b KEY_L = 0x02c KEY_M = 0x02d KEY_N = 0x02e KEY_O = 0x02f KEY_P = 0x030 KEY_Q = 0x031 KEY_R = 0x032 KEY_S = 0x033 KEY_T = 0x034 KEY_U = 0x035 KEY_V = 0x036 KEY_W = 0x037 KEY_X = 0x038 KEY_Y = 0x039 KEY_Z = 0x03a KEY_TILDE = 0x03b KEY_MINUS = 0x03c KEY_EQUALS = 0x03d KEY_LBRACKET = 0x03e KEY_RBRACKET = 0x03f KEY_BACKSLASH = 0x040 KEY_SEMICOLON = 0x041 KEY_APOSTROPHE = 0x042 KEY_COMMA = 0x043 KEY_PERIOD = 0x044 KEY_SLASH = 0x045 KEY_NUMPAD0 = 0x046 KEY_NUMPAD1 = 0x047 KEY_NUMPAD2 = 0x048 KEY_NUMPAD3 = 0x049 KEY_NUMPAD4 = 0x04a KEY_NUMPAD5 = 0x04b KEY_NUMPAD6 = 0x04c KEY_NUMPAD7 = 0x04d KEY_NUMPAD8 = 0x04e KEY_NUMPAD9 = 0x04f KEY_MULTIPLY = 0x050 KEY_ADD = 0x051 KEY_SEPARATOR = 0x052 KEY_SUBTRACT = 0x053 KEY_DECIMAL = 0x054 KEY_DIVIDE = 0x055 KEY_NUMPADENTER = 0x056 KEY_F1 = 0x057 KEY_F2 = 0x058 KEY_F3 = 0x059 KEY_F4 = 0x05a KEY_F5 = 0x05b KEY_F6 = 0x05c KEY_F7 = 0x05d KEY_F8 = 0x05e KEY_F9 = 0x05f KEY_F10 = 0x060 KEY_F11 = 0x061 KEY_F12 = 0x062 KEY_F13 = 0x063 KEY_F14 = 0x064 KEY_F15 = 0x065 KEY_F16 = 0x066 KEY_F17 = 0x067 KEY_F18 = 0x068 KEY_F19 = 0x069 KEY_F20 = 0x06a KEY_F21 = 0x06b KEY_F22 = 0x06c KEY_F23 = 0x06d KEY_F24 = 0x06e KEY_NUMLOCK = 0x06f KEY_SCROLLLOCK = 0x070 KEY_LCONTROL = 0x071 KEY_RCONTROL = 0x072 KEY_LALT = 0x073 KEY_RALT = 0x074 KEY_LSHIFT = 0x075 KEY_RSHIFT = 0x076 KEY_WIN_LWINDOW = 0x077 KEY_WIN_RWINDOW = 0x078 KEY_WIN_APPS = 0x079 KEY_OEM_102 = 0x080 KEY_MAC_OPT = 0x090 KEY_MAC_LOPT = 0x091 KEY_MAC_ROPT = 0x092 KEY_BUTTON0 = 0x0100 KEY_BUTTON1 = 0x0101 KEY_BUTTON2 = 0x0102 KEY_BUTTON3 = 0x0103 KEY_BUTTON4 = 0x0104 KEY_BUTTON5 = 0x0105 KEY_BUTTON6 = 0x0106 KEY_BUTTON7 = 0x0107 KEY_BUTTON8 = 0x0108 KEY_BUTTON9 = 0x0109 KEY_BUTTON10 = 0x010A KEY_BUTTON11 = 0x010B KEY_BUTTON12 = 0x010C KEY_BUTTON13 = 0x010D KEY_BUTTON14 = 0x010E KEY_BUTTON15 = 0x010F KEY_BUTTON16 = 0x0110 KEY_BUTTON17 = 0x0111 KEY_BUTTON18 = 0x0112 KEY_BUTTON19 = 0x0113 KEY_BUTTON20 = 0x0114 KEY_BUTTON21 = 0x0115 KEY_BUTTON22 = 0x0116 KEY_BUTTON23 = 0x0117 KEY_BUTTON24 = 0x0118 KEY_BUTTON25 = 0x0119 KEY_BUTTON26 = 0x011A KEY_BUTTON27 = 0x011B KEY_BUTTON28 = 0x011C KEY_BUTTON29 = 0x011D KEY_BUTTON30 = 0x011E KEY_BUTTON31 = 0x011F KEY_BUTTON32 = 0x0120 KEY_BUTTON33 = 0x0121 KEY_BUTTON34 = 0x0122 KEY_BUTTON35 = 0x0123 KEY_BUTTON36 = 0x0124 KEY_BUTTON37 = 0x0125 KEY_BUTTON38 = 0x0126 KEY_BUTTON39 = 0x0127 KEY_BUTTON40 = 0x0128 KEY_BUTTON41 = 0x0129 KEY_BUTTON42 = 0x012A KEY_BUTTON43 = 0x012B KEY_BUTTON44 = 0x012C KEY_BUTTON45 = 0x012D KEY_BUTTON46 = 0x012E KEY_BUTTON47 = 0x012F KEY_ANYKEY = 0xfffe SI_XPOV = 0x204 SI_YPOV = 0x205 SI_UPOV = 0x206 SI_DPOV = 0x207 SI_LPOV = 0x208 SI_RPOV = 0x209 SI_XAXIS = 0x20B SI_YAXIS = 0x20C SI_ZAXIS = 0x20D SI_RXAXIS = 0x20E SI_RYAXIS = 0x20F SI_RZAXIS = 0x210 SI_SLIDER = 0x211 SI_XPOV2 = 0x212 SI_YPOV2 = 0x213 SI_UPOV2 = 0x214 SI_DPOV2 = 0x215 SI_LPOV2 = 0x216 SI_RPOV2 = 0x217 SI_POVMASK = 0x218 SI_POVMASK2 = 0x219 SI_XBALL = 0x21A SI_YBALL = 0x21B SI_XBALL2 = 0x21C SI_YBALL2 = 0x21D XI_CONNECT = 0x300 XI_THUMBLX = 0x301 XI_THUMBLY = 0x302 XI_THUMBRX = 0x303 XI_THUMBRY = 0x304 XI_LEFT_TRIGGER = 0x305 XI_RIGHT_TRIGGER = 0x306 XI_START = 0x311 XI_BACK = 0x312 XI_LEFT_THUMB = 0x313 XI_RIGHT_THUMB = 0x314 XI_LEFT_SHOULDER = 0x315 XI_RIGHT_SHOULDER = 0x316 XI_A = 0x317 XI_B = 0x318 XI_X = 0x319 XI_Y = 0x31A XI_GUIDE = 0x31B INPUT_DEVICE_PLUGIN_CODES_START = 0x400 }
Public Typedefs
Detailed Description
Library-wide input events.
All external events are converted into system events, which are defined in this file.
Public Defines
AddInputVirtualMap(description, type, code) ->addVirtualMap( #description, type, code );
INPUTMGR() <>::instance()
Returns the InputEventManager singleton.
SI_ANY() 0xff
Wildcard match used by the input system.
Public Enumerations
InputActionType
Enumerator
- SI_MAKE = 0x01
Button was depressed.
- SI_BREAK = 0x02
Button was released.
- SI_MOVE = 0x03
An axis moved.
- SI_REPEAT = 0x04
A key repeat occurred. Happens in between a SI_MAKE and SI_BREAK.
- SI_VALUE = 0x05
A value of some type. Matched with SI_FLOAT or SI_INT.
Device Event Action Types.
InputDeviceTypesEnum
Enumerator
- UnknownDeviceType
- MouseDeviceType
- KeyboardDeviceType
- JoystickDeviceType
- GamepadDeviceType
- XInputDeviceType
- NUM_INPUT_DEVICE_TYPES
- INPUT_DEVICE_PLUGIN_DEVICES_START = NUM_INPUT_DEVICE_TYPES
InputEventType
Enumerator
- SI_UNKNOWN = 0x01
- SI_BUTTON = 0x02
- SI_POV = 0x03
- SI_AXIS = 0x04
- SI_POS = 0x05
- SI_ROT = 0x06
- SI_INT = 0x07
- SI_FLOAT = 0x08
- SI_KEY = 0x0A
Device Event Types.
InputModifiers
Enumerator
- SI_LSHIFT = BIT(0)
shift and ctrl are the same between platforms.
- SI_RSHIFT = BIT(1)
- SI_SHIFT = (SI_LSHIFT|SI_RSHIFT)
- SI_LCTRL = BIT(2)
- SI_RCTRL = BIT(3)
- SI_CTRL = (SI_LCTRL|SI_RCTRL)
- SI_LALT = BIT(4)
win altkey, mapped to mac cmdkey.
- SI_RALT = BIT(5)
- SI_ALT = (SI_LALT|SI_RALT)
- SI_MAC_LOPT = BIT(6)
mac optionkey
- SI_MAC_ROPT = BIT(7)
- SI_MAC_OPT = (SI_MAC_LOPT|SI_MAC_ROPT)
- SI_COPYPASTE = SI_CTRL
modifier keys used for common operations
- SI_MULTISELECT = SI_CTRL
- SI_RANGESELECT = SI_SHIFT
- SI_PRIMARY_ALT = SI_ALT
- SI_PRIMARY_CTRL = SI_CTRL
- SI_WORDJUMP = SI_CTRL
modfier key used in conjunction w/ arrow keys to move cursor to next word
- SI_LINEJUMP = SI_ALT
modifier key used in conjunction w/ arrow keys to move cursor to beginning / end of line
- SI_DOCJUMP = SI_CTRL
modifier key used in conjunction w/ home & end to jump to the top or bottom of a document
InputObjectInstancesEnum
Enumerator
- KEY_NULL = 0x000
Invalid KeyCode.
- KEY_BACKSPACE = 0x001
- KEY_TAB = 0x002
- KEY_RETURN = 0x003
- KEY_CONTROL = 0x004
- KEY_ALT = 0x005
- KEY_SHIFT = 0x006
- KEY_PAUSE = 0x007
- KEY_CAPSLOCK = 0x008
- KEY_ESCAPE = 0x009
- KEY_SPACE = 0x00a
- KEY_PAGE_DOWN = 0x00b
- KEY_PAGE_UP = 0x00c
- KEY_END = 0x00d
- KEY_HOME = 0x00e
- KEY_LEFT = 0x00f
- KEY_UP = 0x010
- KEY_RIGHT = 0x011
- KEY_DOWN = 0x012
- KEY_PRINT = 0x013
- KEY_INSERT = 0x014
- KEY_DELETE = 0x015
- KEY_HELP = 0x016
- KEY_0 = 0x017
- KEY_1 = 0x018
- KEY_2 = 0x019
- KEY_3 = 0x01a
- KEY_4 = 0x01b
- KEY_5 = 0x01c
- KEY_6 = 0x01d
- KEY_7 = 0x01e
- KEY_8 = 0x01f
- KEY_9 = 0x020
- KEY_A = 0x021
- KEY_B = 0x022
- KEY_C = 0x023
- KEY_D = 0x024
- KEY_E = 0x025
- KEY_F = 0x026
- KEY_G = 0x027
- KEY_H = 0x028
- KEY_I = 0x029
- KEY_J = 0x02a
- KEY_K = 0x02b
- KEY_L = 0x02c
- KEY_M = 0x02d
- KEY_N = 0x02e
- KEY_O = 0x02f
- KEY_P = 0x030
- KEY_Q = 0x031
- KEY_R = 0x032
- KEY_S = 0x033
- KEY_T = 0x034
- KEY_U = 0x035
- KEY_V = 0x036
- KEY_W = 0x037
- KEY_X = 0x038
- KEY_Y = 0x039
- KEY_Z = 0x03a
- KEY_TILDE = 0x03b
- KEY_MINUS = 0x03c
- KEY_EQUALS = 0x03d
- KEY_LBRACKET = 0x03e
- KEY_RBRACKET = 0x03f
- KEY_BACKSLASH = 0x040
- KEY_SEMICOLON = 0x041
- KEY_APOSTROPHE = 0x042
- KEY_COMMA = 0x043
- KEY_PERIOD = 0x044
- KEY_SLASH = 0x045
- KEY_NUMPAD0 = 0x046
- KEY_NUMPAD1 = 0x047
- KEY_NUMPAD2 = 0x048
- KEY_NUMPAD3 = 0x049
- KEY_NUMPAD4 = 0x04a
- KEY_NUMPAD5 = 0x04b
- KEY_NUMPAD6 = 0x04c
- KEY_NUMPAD7 = 0x04d
- KEY_NUMPAD8 = 0x04e
- KEY_NUMPAD9 = 0x04f
- KEY_MULTIPLY = 0x050
- KEY_ADD = 0x051
- KEY_SEPARATOR = 0x052
- KEY_SUBTRACT = 0x053
- KEY_DECIMAL = 0x054
- KEY_DIVIDE = 0x055
- KEY_NUMPADENTER = 0x056
- KEY_F1 = 0x057
- KEY_F2 = 0x058
- KEY_F3 = 0x059
- KEY_F4 = 0x05a
- KEY_F5 = 0x05b
- KEY_F6 = 0x05c
- KEY_F7 = 0x05d
- KEY_F8 = 0x05e
- KEY_F9 = 0x05f
- KEY_F10 = 0x060
- KEY_F11 = 0x061
- KEY_F12 = 0x062
- KEY_F13 = 0x063
- KEY_F14 = 0x064
- KEY_F15 = 0x065
- KEY_F16 = 0x066
- KEY_F17 = 0x067
- KEY_F18 = 0x068
- KEY_F19 = 0x069
- KEY_F20 = 0x06a
- KEY_F21 = 0x06b
- KEY_F22 = 0x06c
- KEY_F23 = 0x06d
- KEY_F24 = 0x06e
- KEY_NUMLOCK = 0x06f
- KEY_SCROLLLOCK = 0x070
- KEY_LCONTROL = 0x071
- KEY_RCONTROL = 0x072
- KEY_LALT = 0x073
- KEY_RALT = 0x074
- KEY_LSHIFT = 0x075
- KEY_RSHIFT = 0x076
- KEY_WIN_LWINDOW = 0x077
- KEY_WIN_RWINDOW = 0x078
- KEY_WIN_APPS = 0x079
- KEY_OEM_102 = 0x080
- KEY_MAC_OPT = 0x090
- KEY_MAC_LOPT = 0x091
- KEY_MAC_ROPT = 0x092
- KEY_BUTTON0 = 0x0100
- KEY_BUTTON1 = 0x0101
- KEY_BUTTON2 = 0x0102
- KEY_BUTTON3 = 0x0103
- KEY_BUTTON4 = 0x0104
- KEY_BUTTON5 = 0x0105
- KEY_BUTTON6 = 0x0106
- KEY_BUTTON7 = 0x0107
- KEY_BUTTON8 = 0x0108
- KEY_BUTTON9 = 0x0109
- KEY_BUTTON10 = 0x010A
- KEY_BUTTON11 = 0x010B
- KEY_BUTTON12 = 0x010C
- KEY_BUTTON13 = 0x010D
- KEY_BUTTON14 = 0x010E
- KEY_BUTTON15 = 0x010F
- KEY_BUTTON16 = 0x0110
- KEY_BUTTON17 = 0x0111
- KEY_BUTTON18 = 0x0112
- KEY_BUTTON19 = 0x0113
- KEY_BUTTON20 = 0x0114
- KEY_BUTTON21 = 0x0115
- KEY_BUTTON22 = 0x0116
- KEY_BUTTON23 = 0x0117
- KEY_BUTTON24 = 0x0118
- KEY_BUTTON25 = 0x0119
- KEY_BUTTON26 = 0x011A
- KEY_BUTTON27 = 0x011B
- KEY_BUTTON28 = 0x011C
- KEY_BUTTON29 = 0x011D
- KEY_BUTTON30 = 0x011E
- KEY_BUTTON31 = 0x011F
- KEY_BUTTON32 = 0x0120
- KEY_BUTTON33 = 0x0121
- KEY_BUTTON34 = 0x0122
- KEY_BUTTON35 = 0x0123
- KEY_BUTTON36 = 0x0124
- KEY_BUTTON37 = 0x0125
- KEY_BUTTON38 = 0x0126
- KEY_BUTTON39 = 0x0127
- KEY_BUTTON40 = 0x0128
- KEY_BUTTON41 = 0x0129
- KEY_BUTTON42 = 0x012A
- KEY_BUTTON43 = 0x012B
- KEY_BUTTON44 = 0x012C
- KEY_BUTTON45 = 0x012D
- KEY_BUTTON46 = 0x012E
- KEY_BUTTON47 = 0x012F
- KEY_ANYKEY = 0xfffe
- SI_XPOV = 0x204
Joystick event codes.
- SI_YPOV = 0x205
- SI_UPOV = 0x206
- SI_DPOV = 0x207
- SI_LPOV = 0x208
- SI_RPOV = 0x209
- SI_XAXIS = 0x20B
- SI_YAXIS = 0x20C
- SI_ZAXIS = 0x20D
- SI_RXAXIS = 0x20E
- SI_RYAXIS = 0x20F
- SI_RZAXIS = 0x210
- SI_SLIDER = 0x211
- SI_XPOV2 = 0x212
- SI_YPOV2 = 0x213
- SI_UPOV2 = 0x214
- SI_DPOV2 = 0x215
- SI_LPOV2 = 0x216
- SI_RPOV2 = 0x217
- SI_POVMASK = 0x218
- SI_POVMASK2 = 0x219
- SI_XBALL = 0x21A
Trackball event codes.
- SI_YBALL = 0x21B
- SI_XBALL2 = 0x21C
- SI_YBALL2 = 0x21D
- XI_CONNECT = 0x300
- XI_THUMBLX = 0x301
- XI_THUMBLY = 0x302
- XI_THUMBRX = 0x303
- XI_THUMBRY = 0x304
- XI_LEFT_TRIGGER = 0x305
- XI_RIGHT_TRIGGER = 0x306
- XI_START = 0x311
- XI_BACK = 0x312
- XI_LEFT_THUMB = 0x313
- XI_RIGHT_THUMB = 0x314
- XI_LEFT_SHOULDER = 0x315
- XI_RIGHT_SHOULDER = 0x316
- XI_A = 0x317
- XI_B = 0x318
- XI_X = 0x319
- XI_Y = 0x31A
- XI_GUIDE = 0x31B
- INPUT_DEVICE_PLUGIN_CODES_START = 0x400
Public Typedefs
typedef U32 InputDeviceTypes
Input device types.
typedef U32 InputObjectInstances
Input event constants:
1 2//----------------------------------------------------------------------------- 3// Copyright (c) 2012 GarageGames, LLC 4// 5// Permission is hereby granted, free of charge, to any person obtaining a copy 6// of this software and associated documentation files (the "Software"), to 7// deal in the Software without restriction, including without limitation the 8// rights to use, copy, modify, merge, publish, distribute, sublicense, and/or 9// sell copies of the Software, and to permit persons to whom the Software is 10// furnished to do so, subject to the following conditions: 11// 12// The above copyright notice and this permission notice shall be included in 13// all copies or substantial portions of the Software. 14// 15// THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR 16// IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, 17// FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE 18// AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER 19// LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING 20// FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS 21// IN THE SOFTWARE. 22//----------------------------------------------------------------------------- 23/// @file 24/// Library-wide input events 25/// 26/// All external events are converted into system events, which are defined 27/// in this file. 28 29/// 30#ifndef _EVENT_H_ 31#define _EVENT_H_ 32 33#include "platform/types.h" 34#include "platform/input/IInputDevice.h" 35#include "core/util/journal/journaledSignal.h" 36#include "core/util/tSingleton.h" 37#include "core/util/tDictionary.h" 38#include "core/tSimpleHashTable.h" 39 40#define AddInputVirtualMap( description, type, code ) \ 41 INPUTMGR->addVirtualMap( #description, type, code ); 42 43/// @defgroup input_constants Input system constants 44/// @{ 45 46/// Input event constants: 47typedef U32 InputObjectInstances; 48enum InputObjectInstancesEnum 49{ 50 KEY_NULL = 0x000, ///< Invalid KeyCode 51 KEY_BACKSPACE = 0x001, 52 KEY_TAB = 0x002, 53 KEY_RETURN = 0x003, 54 KEY_CONTROL = 0x004, 55 KEY_ALT = 0x005, 56 KEY_SHIFT = 0x006, 57 KEY_PAUSE = 0x007, 58 KEY_CAPSLOCK = 0x008, 59 KEY_ESCAPE = 0x009, 60 KEY_SPACE = 0x00a, 61 KEY_PAGE_DOWN = 0x00b, 62 KEY_PAGE_UP = 0x00c, 63 KEY_END = 0x00d, 64 KEY_HOME = 0x00e, 65 KEY_LEFT = 0x00f, 66 KEY_UP = 0x010, 67 KEY_RIGHT = 0x011, 68 KEY_DOWN = 0x012, 69 KEY_PRINT = 0x013, 70 KEY_INSERT = 0x014, 71 KEY_DELETE = 0x015, 72 KEY_HELP = 0x016, 73 74 KEY_0 = 0x017, 75 KEY_1 = 0x018, 76 KEY_2 = 0x019, 77 KEY_3 = 0x01a, 78 KEY_4 = 0x01b, 79 KEY_5 = 0x01c, 80 KEY_6 = 0x01d, 81 KEY_7 = 0x01e, 82 KEY_8 = 0x01f, 83 KEY_9 = 0x020, 84 85 KEY_A = 0x021, 86 KEY_B = 0x022, 87 KEY_C = 0x023, 88 KEY_D = 0x024, 89 KEY_E = 0x025, 90 KEY_F = 0x026, 91 KEY_G = 0x027, 92 KEY_H = 0x028, 93 KEY_I = 0x029, 94 KEY_J = 0x02a, 95 KEY_K = 0x02b, 96 KEY_L = 0x02c, 97 KEY_M = 0x02d, 98 KEY_N = 0x02e, 99 KEY_O = 0x02f, 100 KEY_P = 0x030, 101 KEY_Q = 0x031, 102 KEY_R = 0x032, 103 KEY_S = 0x033, 104 KEY_T = 0x034, 105 KEY_U = 0x035, 106 KEY_V = 0x036, 107 KEY_W = 0x037, 108 KEY_X = 0x038, 109 KEY_Y = 0x039, 110 KEY_Z = 0x03a, 111 112 KEY_TILDE = 0x03b, 113 KEY_MINUS = 0x03c, 114 KEY_EQUALS = 0x03d, 115 KEY_LBRACKET = 0x03e, 116 KEY_RBRACKET = 0x03f, 117 KEY_BACKSLASH = 0x040, 118 KEY_SEMICOLON = 0x041, 119 KEY_APOSTROPHE = 0x042, 120 KEY_COMMA = 0x043, 121 KEY_PERIOD = 0x044, 122 KEY_SLASH = 0x045, 123 KEY_NUMPAD0 = 0x046, 124 KEY_NUMPAD1 = 0x047, 125 KEY_NUMPAD2 = 0x048, 126 KEY_NUMPAD3 = 0x049, 127 KEY_NUMPAD4 = 0x04a, 128 KEY_NUMPAD5 = 0x04b, 129 KEY_NUMPAD6 = 0x04c, 130 KEY_NUMPAD7 = 0x04d, 131 KEY_NUMPAD8 = 0x04e, 132 KEY_NUMPAD9 = 0x04f, 133 KEY_MULTIPLY = 0x050, 134 KEY_ADD = 0x051, 135 KEY_SEPARATOR = 0x052, 136 KEY_SUBTRACT = 0x053, 137 KEY_DECIMAL = 0x054, 138 KEY_DIVIDE = 0x055, 139 KEY_NUMPADENTER = 0x056, 140 141 KEY_F1 = 0x057, 142 KEY_F2 = 0x058, 143 KEY_F3 = 0x059, 144 KEY_F4 = 0x05a, 145 KEY_F5 = 0x05b, 146 KEY_F6 = 0x05c, 147 KEY_F7 = 0x05d, 148 KEY_F8 = 0x05e, 149 KEY_F9 = 0x05f, 150 KEY_F10 = 0x060, 151 KEY_F11 = 0x061, 152 KEY_F12 = 0x062, 153 KEY_F13 = 0x063, 154 KEY_F14 = 0x064, 155 KEY_F15 = 0x065, 156 KEY_F16 = 0x066, 157 KEY_F17 = 0x067, 158 KEY_F18 = 0x068, 159 KEY_F19 = 0x069, 160 KEY_F20 = 0x06a, 161 KEY_F21 = 0x06b, 162 KEY_F22 = 0x06c, 163 KEY_F23 = 0x06d, 164 KEY_F24 = 0x06e, 165 166 KEY_NUMLOCK = 0x06f, 167 KEY_SCROLLLOCK = 0x070, 168 KEY_LCONTROL = 0x071, 169 KEY_RCONTROL = 0x072, 170 KEY_LALT = 0x073, 171 KEY_RALT = 0x074, 172 KEY_LSHIFT = 0x075, 173 KEY_RSHIFT = 0x076, 174 KEY_WIN_LWINDOW = 0x077, 175 KEY_WIN_RWINDOW = 0x078, 176 KEY_WIN_APPS = 0x079, 177 KEY_OEM_102 = 0x080, 178 179 KEY_MAC_OPT = 0x090, 180 KEY_MAC_LOPT = 0x091, 181 KEY_MAC_ROPT = 0x092, 182 183 KEY_BUTTON0 = 0x0100, 184 KEY_BUTTON1 = 0x0101, 185 KEY_BUTTON2 = 0x0102, 186 KEY_BUTTON3 = 0x0103, 187 KEY_BUTTON4 = 0x0104, 188 KEY_BUTTON5 = 0x0105, 189 KEY_BUTTON6 = 0x0106, 190 KEY_BUTTON7 = 0x0107, 191 KEY_BUTTON8 = 0x0108, 192 KEY_BUTTON9 = 0x0109, 193 KEY_BUTTON10 = 0x010A, 194 KEY_BUTTON11 = 0x010B, 195 KEY_BUTTON12 = 0x010C, 196 KEY_BUTTON13 = 0x010D, 197 KEY_BUTTON14 = 0x010E, 198 KEY_BUTTON15 = 0x010F, 199 KEY_BUTTON16 = 0x0110, 200 KEY_BUTTON17 = 0x0111, 201 KEY_BUTTON18 = 0x0112, 202 KEY_BUTTON19 = 0x0113, 203 KEY_BUTTON20 = 0x0114, 204 KEY_BUTTON21 = 0x0115, 205 KEY_BUTTON22 = 0x0116, 206 KEY_BUTTON23 = 0x0117, 207 KEY_BUTTON24 = 0x0118, 208 KEY_BUTTON25 = 0x0119, 209 KEY_BUTTON26 = 0x011A, 210 KEY_BUTTON27 = 0x011B, 211 KEY_BUTTON28 = 0x011C, 212 KEY_BUTTON29 = 0x011D, 213 KEY_BUTTON30 = 0x011E, 214 KEY_BUTTON31 = 0x011F, 215 KEY_BUTTON32 = 0x0120, 216 KEY_BUTTON33 = 0x0121, 217 KEY_BUTTON34 = 0x0122, 218 KEY_BUTTON35 = 0x0123, 219 KEY_BUTTON36 = 0x0124, 220 KEY_BUTTON37 = 0x0125, 221 KEY_BUTTON38 = 0x0126, 222 KEY_BUTTON39 = 0x0127, 223 KEY_BUTTON40 = 0x0128, 224 KEY_BUTTON41 = 0x0129, 225 KEY_BUTTON42 = 0x012A, 226 KEY_BUTTON43 = 0x012B, 227 KEY_BUTTON44 = 0x012C, 228 KEY_BUTTON45 = 0x012D, 229 KEY_BUTTON46 = 0x012E, 230 KEY_BUTTON47 = 0x012F, 231 KEY_ANYKEY = 0xfffe, 232 233 /// Joystick event codes. 234 SI_XPOV = 0x204, 235 SI_YPOV = 0x205, 236 SI_UPOV = 0x206, 237 SI_DPOV = 0x207, 238 SI_LPOV = 0x208, 239 SI_RPOV = 0x209, 240 SI_XAXIS = 0x20B, 241 SI_YAXIS = 0x20C, 242 SI_ZAXIS = 0x20D, 243 SI_RXAXIS = 0x20E, 244 SI_RYAXIS = 0x20F, 245 SI_RZAXIS = 0x210, 246 SI_SLIDER = 0x211, 247 SI_XPOV2 = 0x212, 248 SI_YPOV2 = 0x213, 249 SI_UPOV2 = 0x214, 250 SI_DPOV2 = 0x215, 251 SI_LPOV2 = 0x216, 252 SI_RPOV2 = 0x217, 253 SI_POVMASK = 0x218, 254 SI_POVMASK2 = 0x219, 255 256 /// Trackball event codes. 257 SI_XBALL = 0x21A, 258 SI_YBALL = 0x21B, 259 SI_XBALL2 = 0x21C, 260 SI_YBALL2 = 0x21D, 261 262 XI_CONNECT = 0x300, 263 XI_THUMBLX = 0x301, 264 XI_THUMBLY = 0x302, 265 XI_THUMBRX = 0x303, 266 XI_THUMBRY = 0x304, 267 XI_LEFT_TRIGGER = 0x305, 268 XI_RIGHT_TRIGGER = 0x306, 269 270 /*XI_DPAD_UP = 0x307, 271 XI_DPAD_DOWN = 0x308, 272 XI_DPAD_LEFT = 0x309, 273 XI_DPAD_RIGHT = 0x310,*/ 274 275 XI_START = 0x311, 276 XI_BACK = 0x312, 277 XI_LEFT_THUMB = 0x313, 278 XI_RIGHT_THUMB = 0x314, 279 XI_LEFT_SHOULDER = 0x315, 280 XI_RIGHT_SHOULDER = 0x316, 281 282 XI_A = 0x317, 283 XI_B = 0x318, 284 XI_X = 0x319, 285 XI_Y = 0x31A, 286 XI_GUIDE = 0x31B, 287 288 INPUT_DEVICE_PLUGIN_CODES_START = 0x400, 289}; 290 291/// Input device types 292typedef U32 InputDeviceTypes; 293enum InputDeviceTypesEnum 294{ 295 UnknownDeviceType, 296 MouseDeviceType, 297 KeyboardDeviceType, 298 JoystickDeviceType, 299 GamepadDeviceType, 300 XInputDeviceType, 301 302 NUM_INPUT_DEVICE_TYPES, 303 304 INPUT_DEVICE_PLUGIN_DEVICES_START = NUM_INPUT_DEVICE_TYPES, 305}; 306 307/// Device Event Action Types 308enum InputActionType 309{ 310 /// Button was depressed. 311 SI_MAKE = 0x01, 312 313 /// Button was released. 314 SI_BREAK = 0x02, 315 316 /// An axis moved. 317 SI_MOVE = 0x03, 318 319 /// A key repeat occurred. Happens in between a SI_MAKE and SI_BREAK. 320 SI_REPEAT = 0x04, 321 322 /// A value of some type. Matched with SI_FLOAT or SI_INT. 323 SI_VALUE = 0x05, 324}; 325 326///Device Event Types 327enum InputEventType 328{ 329 SI_UNKNOWN = 0x01, 330 SI_BUTTON = 0x02, // Button press/release 331 SI_POV = 0x03, // Point of View hat 332 SI_AXIS = 0x04, // Axis in range -1.0..1.0 333 SI_POS = 0x05, // Absolute position value (Point3F) 334 SI_ROT = 0x06, // Absolute rotation value (QuatF) 335 SI_INT = 0x07, // Integer value (S32) 336 SI_FLOAT = 0x08, // Float value (F32) 337 SI_KEY = 0x0A, // Keyboard key 338}; 339 340/// Wildcard match used by the input system. 341#define SI_ANY 0xff 342 343// Modifier Keys 344enum InputModifiers 345{ 346 /// shift and ctrl are the same between platforms. 347 SI_LSHIFT = BIT(0), 348 SI_RSHIFT = BIT(1), 349 SI_SHIFT = (SI_LSHIFT</a>|<a href="/coding/group/group__input__constants/#group__input__constants_1ggae87906764558c3f3650510499da72fafa46eee670cbeffa606fa12ed0825b4afb">SI_RSHIFT), 350 SI_LCTRL = BIT(2), 351 SI_RCTRL = BIT(3), 352 SI_CTRL = (SI_LCTRL</a>|<a href="/coding/group/group__input__constants/#group__input__constants_1ggae87906764558c3f3650510499da72fafa85fe9c7e58c341530a1828aeb7e628f8">SI_RCTRL), 353 354 /// win altkey, mapped to mac cmdkey. 355 SI_LALT = BIT(4), 356 SI_RALT = BIT(5), 357 SI_ALT = (SI_LALT</a>|<a href="/coding/group/group__input__constants/#group__input__constants_1ggae87906764558c3f3650510499da72fafa7458aeb51ed4957ae5e71a50a309e9f3">SI_RALT), 358 359 /// mac optionkey 360 SI_MAC_LOPT = BIT(6), 361 SI_MAC_ROPT = BIT(7), 362 SI_MAC_OPT = (SI_MAC_LOPT</a>|<a href="/coding/group/group__input__constants/#group__input__constants_1ggae87906764558c3f3650510499da72fafa4453d88f4745ad634672f6b785f60073">SI_MAC_ROPT), 363 364 /// modifier keys used for common operations 365#if defined(TORQUE_OS_MAC) 366 SI_COPYPASTE = SI_ALT, 367 SI_MULTISELECT = SI_ALT, 368 SI_RANGESELECT = SI_SHIFT, 369 SI_PRIMARY_ALT = SI_MAC_OPT, ///< Primary key used for toggling into alternates of commands. 370 SI_PRIMARY_CTRL = SI_ALT, ///< Primary key used for triggering commands. 371#else 372 SI_COPYPASTE = SI_CTRL, 373 SI_MULTISELECT = SI_CTRL, 374 SI_RANGESELECT = SI_SHIFT, 375 SI_PRIMARY_ALT = SI_ALT, 376 SI_PRIMARY_CTRL = SI_CTRL, 377#endif 378 /// modfier key used in conjunction w/ arrow keys to move cursor to next word 379#if defined(TORQUE_OS_MAC) 380 SI_WORDJUMP = SI_MAC_OPT, 381#else 382 SI_WORDJUMP = SI_CTRL, 383#endif 384 /// modifier key used in conjunction w/ arrow keys to move cursor to beginning / end of line 385 SI_LINEJUMP = SI_ALT, 386 387 /// modifier key used in conjunction w/ home & end to jump to the top or bottom of a document 388#if defined(TORQUE_OS_MAC) 389 SI_DOCJUMP = SI_ANY, 390#else 391 SI_DOCJUMP = SI_CTRL, 392#endif 393}; 394 395/// @} 396 397 398/// Generic input event. 399struct InputEventInfo 400{ 401 InputEventInfo() 402 { 403 deviceInst = 0; 404 fValue = 0.f; 405 fValue2 = 0.f; 406 fValue3 = 0.f; 407 fValue4 = 0.f; 408 iValue = 0; 409 deviceType = (InputDeviceTypes)0; 410 objType = (InputEventType)0; 411 ascii = 0; 412 objInst = (InputObjectInstances)0; 413 action = (InputActionType)0; 414 modifier = (InputModifiers)0; 415 } 416 417 /// Device instance: joystick0, joystick1, etc 418 U32 deviceInst; 419 420 /// Value typically ranges from -1.0 to 1.0, but doesn't have to. 421 /// It depends on the context. 422 F32 fValue; 423 424 /// Extended float values (often used for absolute rotation Quat) 425 F32 fValue2; 426 F32 fValue3; 427 F32 fValue4; 428 429 /// Signed integer value 430 S32 iValue; 431 432 /// What was the action? (MAKE/BREAK/MOVE) 433 InputActionType action; 434 InputDeviceTypes deviceType; 435 InputEventType objType; 436 InputObjectInstances objInst; 437 438 /// ASCII character code if this is a keyboard event. 439 U16 ascii; 440 441 /// Modifiers to action: SI_LSHIFT, SI_LCTRL, etc. 442 U32 modifier; 443 444 inline void postToSignal(InputEvent &ie) 445 { 446 ie.trigger(deviceInst, fValue, fValue2, fValue3, fValue4, iValue, deviceType, objType, ascii, objInst, action, modifier); 447 } 448}; 449 450class Point3F; 451class QuatF; 452 453/// Handles input device plug-ins 454class InputEventManager 455{ 456public: 457 struct VirtualMapData 458 { 459 StringTableEntry desc; 460 InputEventType type; 461 InputObjectInstances code; 462 }; 463 464public: 465 InputEventManager(); 466 virtual ~InputEventManager(); 467 468 /// Get the next device type code 469 U32 getNextDeviceType(); 470 471 /// Get the next device action code 472 U32 getNextDeviceCode(); 473 474 void registerDevice(IInputDevice* device); 475 void unregisterDevice(IInputDevice* device); 476 477 /// Check if the given device name is a registered device. 478 /// The given name can optionally include an instance number on the end. 479 bool isRegisteredDevice(const char* name); 480 481 /// Check if the given device type is a registered device. 482 bool isRegisteredDevice(U32 type); 483 484 /// Same as above but also provides the found device type and actual 485 // device name length. Used by ActionMap::getDeviceTypeAndInstance() 486 bool isRegisteredDeviceWithAttributes(const char* name, U32& deviceType, U32&nameLen); 487 488 /// Returns the name of a registered device given its type 489 const char* getRegisteredDeviceName(U32 type); 490 491 void start(); 492 void stop(); 493 494 void process(); 495 496 // Add to the virtual map table 497 void addVirtualMap(const char* description, InputEventType type, InputObjectInstances code); 498 499 // Find a virtual map entry based on the text description 500 VirtualMapData* findVirtualMap(const char* description); 501 502 // Find a virtual map entry's description based on the action code 503 const char* findVirtualMapDescFromCode(U32 code); 504 505 /// Build an input event based on a single iValue 506 void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, S32 iValue); 507 508 /// Build an input event based on a single fValue 509 void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, F32 fValue); 510 511 /// Build an input event based on a Point3F 512 void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, Point3F& pValue); 513 514 /// Build an input event based on a QuatF 515 void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, QuatF& qValue); 516 517 /// Build an input event based on a AngAxisF 518 void buildInputEvent(U32 deviceType, U32 deviceInst, InputEventType objType, InputObjectInstances objInst, InputActionType action, AngAxisF& qValue); 519 520protected: 521 U32 mNextDeviceTypeCode; 522 U32 mNextDeviceCode; 523 524 Vector<IInputDevice*> mDeviceList; 525 526 // Holds description to VirtualMapData struct 527 SimpleHashTable<VirtualMapData> mVirtualMap; 528 529 // Used to look up a description based on a VirtualMapData.code 530 HashTable<U32, VirtualMapData> mActionCodeMap; 531 532protected: 533 void buildVirtualMap(); 534 535public: 536 // For ManagedSingleton. 537 static const char* getSingletonName() { return "InputEventManager"; } 538}; 539 540/// Returns the InputEventManager singleton. 541#define INPUTMGR ManagedSingleton<InputEventManager>::instance() 542 543 544#endif 545