Migrate to using scancodes for key presses and SDL_TEXTINPUT for text input

This commit is contained in:
Felix Kaaman 2015-10-30 16:03:54 +01:00
parent 5117629998
commit 458ec6a8b3
12 changed files with 1153 additions and 1059 deletions

View File

@ -13,27 +13,27 @@
For more info on the syntax itself, see http://json.org/ For more info on the syntax itself, see http://json.org/
", ",
"forward": 119, "forward": 26,
"back": 115, "back": 22,
"left": 97, "left": 4,
"right": 100, "right": 7,
"jump": 32, "jump": 44,
"crouch": 306, "crouch": 224,
"sneak": 118, "sneak": 225,
"reload": 114, "reload": 21,
"tools": [49, 50, 51, 52, 53, 54, 55, 56, 57, 48], "tools": [30, 31, 32, 33, 34, 35, 36, 37, 38, 39],
"colorleft": 276, "colorleft": 92,
"colorright": 275, "colorright": 94,
"colorup": 273, "colorup": 90,
"colordown": 274, "colordown": 96,
"chat": 116, "chat": 23,
"teamchat": 121, "teamchat": 28,
"squadchat": 117, "squadchat": 24,
"chatup": 280, "chatup": 82,
"chatdn": 281, "chatdn": 81,
"scores": 9, "scores": 43,
"quit": 27, "quit": 41,
"map": 109, "map": 16,
"team": 44, "team": 54,
"wpn": 46 "wpn": 55
} }

View File

@ -716,6 +716,7 @@ function enter_typing_state()
chat_text.scrollback = true chat_text.scrollback = true
chat_text.cam.start = math.max(1, #chat_text.list - chat_text.cam.height) chat_text.cam.start = math.max(1, #chat_text.list - chat_text.cam.height)
mouse_released = true mouse_released = true
client.text_input_start()
client.mouse_lock_set(false) client.mouse_lock_set(false)
client.mouse_visible_set(true) client.mouse_visible_set(true)
if client.mouse_warp ~= nil then if client.mouse_warp ~= nil then
@ -728,6 +729,7 @@ function discard_typing_state(widget)
if widget.clear_keyrepeat then widget.clear_keyrepeat() end if widget.clear_keyrepeat then widget.clear_keyrepeat() end
chat_text.scrollback = false chat_text.scrollback = false
mouse_released = false mouse_released = false
client.text_input_stop()
client.mouse_lock_set(true) client.mouse_lock_set(true)
client.mouse_visible_set(false) client.mouse_visible_set(false)
if client.mouse_warp ~= nil then if client.mouse_warp ~= nil then
@ -741,7 +743,6 @@ end
function h_key(sym, state, modif, uni) function h_key(sym, state, modif, uni)
local key = sym local key = sym
-- grab screenshot -- grab screenshot
if state and key == BTSK_SCREENSHOT then if state and key == BTSK_SCREENSHOT then
do_screenshot = true do_screenshot = true
@ -797,6 +798,10 @@ function h_key(sym, state, modif, uni)
end end
end end
local function push_text(text)
table.insert(input_events, {GE_TEXT, text})
end
local function push_mouse_button(button, state) local function push_mouse_button(button, state)
table.insert(input_events, {GE_MOUSE_BUTTON, {button=button,down=state}}) table.insert(input_events, {GE_MOUSE_BUTTON, {button=button,down=state}})
end end
@ -828,6 +833,10 @@ end
mouse_poll = {false,false,false,false,false} mouse_poll = {false,false,false,false,false}
mouse_xy = {x=0,y=0,dx=0,dy=0} mouse_xy = {x=0,y=0,dx=0,dy=0}
function h_text(text)
push_text(text)
end
function h_mouse_button(button, state) function h_mouse_button(button, state)
if mouse_poll[button] ~= state then if mouse_poll[button] ~= state then
@ -1220,6 +1229,7 @@ end
client.hook_tick = h_tick_init client.hook_tick = h_tick_init
client.hook_key = h_key client.hook_key = h_key
client.hook_text = h_text
client.hook_mouse_button = h_mouse_button client.hook_mouse_button = h_mouse_button
client.hook_mouse_motion = h_mouse_motion client.hook_mouse_motion = h_mouse_motion
client.hook_window_activate = h_window_activate client.hook_window_activate = h_window_activate

View File

@ -429,6 +429,31 @@ function gui_string_edit(str, insert_position, maxlen, key, modif, uni)
return str return str
end end
function gui_string_delete(str, position)
if position <= 1 then
str = string.sub(str, 2, #str)
else
str = string.sub(str, 1, position - 2) ..
string.sub(str, position, #str)
end
return str
end
function gui_string_append(str, other, position)
if position == 1 then
return other .. str
elseif position == #str then
return str .. other
else
str_len = #str
str = string.sub(str, 1, position - 1) ..
other ..
string.sub(str, position, str_len)
return str
end
end
--[[Create a new scene. --[[Create a new scene.
Each scene contains its own displaylist, buffers, and listeners.]] Each scene contains its own displaylist, buffers, and listeners.]]
function gui_create_scene(width, height, shared_rate) function gui_create_scene(width, height, shared_rate)
@ -929,79 +954,48 @@ function gui_create_scene(width, height, shared_rate)
discard_typing_state(this) discard_typing_state(this)
end end
this.repeating_key = nil
this.repeating_modif = nil
this.repeating_uni = nil
function this.key_repeated()
local state = true
local key = this.repeating_key
local modif = this.repeating_modif
local uni = this.repeating_uni
if key == SDLK_ESCAPE then
this.done_typing()
elseif key == SDLK_RETURN then
if #this.text>0 then this.buffer_register_new() end
this.on_return(key, state, modif)
elseif key == SDLK_LEFT then
this.cursor_backwards()
elseif key == SDLK_RIGHT then
this.cursor_forwards()
elseif key == SDLK_UP then
this.buffer_backwards()
elseif key == SDLK_DOWN then
this.buffer_forwards()
elseif key == SDLK_HOME then
this.cursor_to_text_start()
elseif key == SDLK_END then
this.cursor_to_text_end()
else
local text_len = #this.text
this.text = gui_string_edit(
this.text,
this.cursor_position,
MODE_CHAT_STRMAX,
key,
modif,
uni)
if key ~= SDLK_DELETE then
this.cursor_position = math.max(
1,
this.cursor_position + (#this.text - text_len))
else
this.cursor_position = math.max(1,
this.cursor_position)
end
this.input_buffer.edit(this.text)
end
end
function this.on_key(key, state, modif, uni, dicks) function this.on_key(key, state, modif, uni, dicks)
if this.take_input then if this.take_input then
if state then if state then
this.repeating_key = key if key == SDLK_ESCAPE then
this.repeating_uni = uni this.done_typing()
this.repeating_modif = modif elseif key == SDLK_RETURN then
this.static_alarm{name='key_waitbuf', time=0.45,on_trigger=function() if #this.text>0 then this.buffer_register_new() end
if this.repeating_key ~= nil then this.on_return(key, state, modif)
this.key_repeated() elseif key == SDLK_LEFT then
this.static_alarms['key_repeat'] = this.cursor_backwards()
alarm{time=0.035, loop=true, preserve_accumulator=false, on_trigger=function() elseif key == SDLK_RIGHT then
if this.repeating_key ~= nil then this.cursor_forwards()
this.key_repeated() elseif key == SDLK_UP then
end this.buffer_backwards()
end} elseif key == SDLK_DOWN then
end this.buffer_forwards()
end} elseif key == SDLK_HOME then
this.key_repeated() this.cursor_to_text_start()
elseif state == false then -- this is specifically the key up. there are other key events... elseif key == SDLK_END then
this.clear_keyrepeat() this.cursor_to_text_end()
elseif key == SDLK_BACKSPACE then
this.text = gui_string_delete(this.text, this.cursor_position)
this.cursor_position = math.max(1, this.cursor_position - 1)
this.input_buffer.edit(this.text)
end
end end
end end
end end
this.add_listener(GE_KEY, this.on_key) this.add_listener(GE_KEY, this.on_key)
function this.on_text(text)
if this.take_input then
this.text = gui_string_append(this.text, text, this.cursor_position)
this.cursor_position = math.max(1, this.cursor_position + #text)
this.input_buffer.edit(this.text)
end
end
this.add_listener(GE_TEXT, this.on_text)
this.cursor_position = 1 this.cursor_position = 1
this.input_buffer = collect_new_history_buf() this.input_buffer = collect_new_history_buf()

View File

@ -5,261 +5,268 @@
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation Inc. 51 Franklin St Fifth Floor Boston MA 02110-1301 USA
Sam Lantinga Sam Lantinga
slouken@libsdl.org slouken@libsdl.org
]] ]]
--[[ --[[
part of SDL_keysym.h, converted to Lua by GreaseMonkey in 2012 part of SDL_scancode.h accurate as of SDL 2.0.3
accurate as of libSDL-1.2.so.0.11.3
]] ]]
SDLK_UNKNOWN = 0 SDLK_UNKNOWN = 0
SDLK_FIRST = 0 SDLK_a = 4
SDLK_BACKSPACE = 8 SDLK_b = 5
SDLK_TAB = 9 SDLK_c = 6
SDLK_CLEAR = 12 SDLK_d = 7
SDLK_RETURN = 13 SDLK_e = 8
SDLK_PAUSE = 19 SDLK_f = 9
SDLK_ESCAPE = 27 SDLK_g = 10
SDLK_SPACE = 32 SDLK_h = 11
SDLK_EXCLAIM = 33 SDLK_i = 12
SDLK_QUOTEDBL = 34 SDLK_j = 13
SDLK_HASH = 35 SDLK_k = 14
SDLK_DOLLAR = 36 SDLK_l = 15
SDLK_AMPERSAND = 38 SDLK_m = 16
SDLK_QUOTE = 39 SDLK_n = 17
SDLK_LEFTPAREN = 40 SDLK_o = 18
SDLK_RIGHTPAREN = 41 SDLK_p = 19
SDLK_ASTERISK = 42 SDLK_q = 20
SDLK_PLUS = 43 SDLK_r = 21
SDLK_COMMA = 44 SDLK_s = 22
SDLK_MINUS = 45 SDLK_t = 23
SDLK_PERIOD = 46 SDLK_u = 24
SDLK_SLASH = 47 SDLK_v = 25
SDLK_0 = 48 SDLK_w = 26
SDLK_1 = 49 SDLK_x = 27
SDLK_2 = 50 SDLK_y = 28
SDLK_3 = 51 SDLK_z = 29
SDLK_4 = 52 SDLK_1 = 30
SDLK_5 = 53 SDLK_2 = 31
SDLK_6 = 54 SDLK_3 = 32
SDLK_7 = 55 SDLK_4 = 33
SDLK_8 = 56 SDLK_5 = 34
SDLK_9 = 57 SDLK_6 = 35
SDLK_COLON = 58 SDLK_7 = 36
SDLK_SEMICOLON = 59 SDLK_8 = 37
SDLK_LESS = 60 SDLK_9 = 38
SDLK_EQUALS = 61 SDLK_0 = 39
SDLK_GREATER = 62 SDLK_RETURN = 40
SDLK_QUESTION = 63 SDLK_ESCAPE = 41
SDLK_AT = 64 SDLK_BACKSPACE = 42
SDLK_LEFTBRACKET = 91 SDLK_TAB = 43
SDLK_BACKSLASH = 92 SDLK_SPACE = 44
SDLK_RIGHTBRACKET = 93 SDLK_MINUS = 45
SDLK_CARET = 94 SDLK_EQUALS = 46
SDLK_UNDERSCORE = 95 SDLK_LEFTBRACKET = 47
SDLK_BACKQUOTE = 96 SDLK_RIGHTBRACKET = 48
SDLK_a = 97 SDLK_BACKSLASH = 49
SDLK_b = 98 SDLK_NONUSHASH = 50
SDLK_c = 99 SDLK_SEMICOLON = 51
SDLK_d = 100 SDLK_APOSTROPHE = 52
SDLK_e = 101 SDLK_GRAVE = 53
SDLK_f = 102 SDLK_COMMA = 54
SDLK_g = 103 SDLK_PERIOD = 55
SDLK_h = 104 SDLK_SLASH = 56
SDLK_i = 105 SDLK_CAPSLOCK = 57
SDLK_j = 106 SDLK_F1 = 58
SDLK_k = 107 SDLK_F2 = 59
SDLK_l = 108 SDLK_F3 = 60
SDLK_m = 109 SDLK_F4 = 61
SDLK_n = 110 SDLK_F5 = 62
SDLK_o = 111 SDLK_F6 = 63
SDLK_p = 112 SDLK_F7 = 64
SDLK_q = 113 SDLK_F8 = 65
SDLK_r = 114 SDLK_F9 = 66
SDLK_s = 115 SDLK_F10 = 67
SDLK_t = 116 SDLK_F11 = 68
SDLK_u = 117 SDLK_F12 = 69
SDLK_v = 118 SDLK_PRINTSCREEN = 70
SDLK_w = 119 SDLK_SCROLLLOCK = 71
SDLK_x = 120 SDLK_PAUSE = 72
SDLK_y = 121 SDLK_INSERT = 73
SDLK_z = 122 SDLK_HOME = 74
SDLK_DELETE = 127 SDLK_PAGEUP = 75
SDLK_WORLD_0 = 160 SDLK_DELETE = 76
SDLK_WORLD_1 = 161 SDLK_END = 77
SDLK_WORLD_2 = 162 SDLK_PAGEDOWN = 78
SDLK_WORLD_3 = 163 SDLK_RIGHT = 79
SDLK_WORLD_4 = 164 SDLK_LEFT = 80
SDLK_WORLD_5 = 165 SDLK_DOWN = 81
SDLK_WORLD_6 = 166 SDLK_UP = 82
SDLK_WORLD_7 = 167 SDLK_NUMLOCKCLEAR = 83
SDLK_WORLD_8 = 168 SDLK_KP_DIVIDE = 84
SDLK_WORLD_9 = 169 SDLK_KP_MULTIPLY = 85
SDLK_WORLD_10 = 170 SDLK_KP_MINUS = 86
SDLK_WORLD_11 = 171 SDLK_KP_PLUS = 87
SDLK_WORLD_12 = 172 SDLK_KP_ENTER = 88
SDLK_WORLD_13 = 173 SDLK_KP_1 = 89
SDLK_WORLD_14 = 174 SDLK_KP_2 = 90
SDLK_WORLD_15 = 175 SDLK_KP_3 = 91
SDLK_WORLD_16 = 176 SDLK_KP_4 = 92
SDLK_WORLD_17 = 177 SDLK_KP_5 = 93
SDLK_WORLD_18 = 178 SDLK_KP_6 = 94
SDLK_WORLD_19 = 179 SDLK_KP_7 = 95
SDLK_WORLD_20 = 180 SDLK_KP_8 = 96
SDLK_WORLD_21 = 181 SDLK_KP_9 = 97
SDLK_WORLD_22 = 182 SDLK_KP_0 = 98
SDLK_WORLD_23 = 183 SDLK_KP_PERIOD = 99
SDLK_WORLD_24 = 184 SDLK_NONUSBACKSLASH = 100
SDLK_WORLD_25 = 185 SDLK_APPLICATION = 101
SDLK_WORLD_26 = 186 SDLK_POWER = 102
SDLK_WORLD_27 = 187 SDLK_KP_EQUALS = 103
SDLK_WORLD_28 = 188 SDLK_F13 = 104
SDLK_WORLD_29 = 189 SDLK_F14 = 105
SDLK_WORLD_30 = 190 SDLK_F15 = 106
SDLK_WORLD_31 = 191 SDLK_F16 = 107
SDLK_WORLD_32 = 192 SDLK_F17 = 108
SDLK_WORLD_33 = 193 SDLK_F18 = 109
SDLK_WORLD_34 = 194 SDLK_F19 = 110
SDLK_WORLD_35 = 195 SDLK_F20 = 111
SDLK_WORLD_36 = 196 SDLK_F21 = 112
SDLK_WORLD_37 = 197 SDLK_F22 = 113
SDLK_WORLD_38 = 198 SDLK_F23 = 114
SDLK_WORLD_39 = 199 SDLK_F24 = 115
SDLK_WORLD_40 = 200 SDLK_EXECUTE = 116
SDLK_WORLD_41 = 201 SDLK_HELP = 117
SDLK_WORLD_42 = 202 SDLK_MENU = 118
SDLK_WORLD_43 = 203 SDLK_SELECT = 119
SDLK_WORLD_44 = 204 SDLK_STOP = 120
SDLK_WORLD_45 = 205 SDLK_AGAIN = 121
SDLK_WORLD_46 = 206 SDLK_UNDO = 122
SDLK_WORLD_47 = 207 SDLK_CUT = 123
SDLK_WORLD_48 = 208 SDLK_COPY = 124
SDLK_WORLD_49 = 209 SDLK_PASTE = 125
SDLK_WORLD_50 = 210 SDLK_FIND = 126
SDLK_WORLD_51 = 211 SDLK_MUTE = 127
SDLK_WORLD_52 = 212 SDLK_VOLUMEUP = 128
SDLK_WORLD_53 = 213 SDLK_VOLUMEDOWN = 129
SDLK_WORLD_54 = 214 SDLK_KP_COMMA = 133
SDLK_WORLD_55 = 215 SDLK_KP_EQUALSAS400 = 134
SDLK_WORLD_56 = 216 SDLK_INTERNATIONAL1 = 135
SDLK_WORLD_57 = 217 SDLK_INTERNATIONAL2 = 136
SDLK_WORLD_58 = 218 SDLK_INTERNATIONAL3 = 137
SDLK_WORLD_59 = 219 SDLK_INTERNATIONAL4 = 138
SDLK_WORLD_60 = 220 SDLK_INTERNATIONAL5 = 139
SDLK_WORLD_61 = 221 SDLK_INTERNATIONAL6 = 140
SDLK_WORLD_62 = 222 SDLK_INTERNATIONAL7 = 141
SDLK_WORLD_63 = 223 SDLK_INTERNATIONAL8 = 142
SDLK_WORLD_64 = 224 SDLK_INTERNATIONAL9 = 143
SDLK_WORLD_65 = 225 SDLK_LANG1 = 144
SDLK_WORLD_66 = 226 SDLK_LANG2 = 145
SDLK_WORLD_67 = 227 SDLK_LANG3 = 146
SDLK_WORLD_68 = 228 SDLK_LANG4 = 147
SDLK_WORLD_69 = 229 SDLK_LANG5 = 148
SDLK_WORLD_70 = 230 SDLK_LANG6 = 149
SDLK_WORLD_71 = 231 SDLK_LANG7 = 150
SDLK_WORLD_72 = 232 SDLK_LANG8 = 151
SDLK_WORLD_73 = 233 SDLK_LANG9 = 152
SDLK_WORLD_74 = 234 SDLK_ALTERASE = 153
SDLK_WORLD_75 = 235 SDLK_SYSREQ = 154
SDLK_WORLD_76 = 236 SDLK_CANCEL = 155
SDLK_WORLD_77 = 237 SDLK_CLEAR = 156
SDLK_WORLD_78 = 238 SDLK_PRIOR = 157
SDLK_WORLD_79 = 239 SDLK_RETURN2 = 158
SDLK_WORLD_80 = 240 SDLK_SEPARATOR = 159
SDLK_WORLD_81 = 241 SDLK_OUT = 160
SDLK_WORLD_82 = 242 SDLK_OPER = 161
SDLK_WORLD_83 = 243 SDLK_CLEARAGAIN = 162
SDLK_WORLD_84 = 244 SDLK_CRSEL = 163
SDLK_WORLD_85 = 245 SDLK_EXSEL = 164
SDLK_WORLD_86 = 246 SDLK_KP_00 = 176
SDLK_WORLD_87 = 247 SDLK_KP_000 = 177
SDLK_WORLD_88 = 248 SDLK_THOUSANDSSEPARATOR = 178
SDLK_WORLD_89 = 249 SDLK_DECIMALSEPARATOR = 179
SDLK_WORLD_90 = 250 SDLK_CURRENCYUNIT = 180
SDLK_WORLD_91 = 251 SDLK_CURRENCYSUBUNIT = 181
SDLK_WORLD_92 = 252 SDLK_KP_LEFTPAREN = 182
SDLK_WORLD_93 = 253 SDLK_KP_RIGHTPAREN = 183
SDLK_WORLD_94 = 254 SDLK_KP_LEFTBRACE = 184
SDLK_WORLD_95 = 255 SDLK_KP_RIGHTBRACE = 185
SDLK_KP0 = 256 SDLK_KP_TAB = 186
SDLK_KP1 = 257 SDLK_KP_BACKSPACE = 187
SDLK_KP2 = 258 SDLK_KP_A = 188
SDLK_KP3 = 259 SDLK_KP_B = 189
SDLK_KP4 = 260 SDLK_KP_C = 190
SDLK_KP5 = 261 SDLK_KP_D = 191
SDLK_KP6 = 262 SDLK_KP_E = 192
SDLK_KP7 = 263 SDLK_KP_F = 193
SDLK_KP8 = 264 SDLK_KP_XOR = 194
SDLK_KP9 = 265 SDLK_KP_POWER = 195
SDLK_KP_PERIOD = 266 SDLK_KP_PERCENT = 196
SDLK_KP_DIVIDE = 267 SDLK_KP_LESS = 197
SDLK_KP_MULTIPLY = 268 SDLK_KP_GREATER = 198
SDLK_KP_MINUS = 269 SDLK_KP_AMPERSAND = 199
SDLK_KP_PLUS = 270 SDLK_KP_DBLAMPERSAND = 200
SDLK_KP_ENTER = 271 SDLK_KP_VERTICALBAR = 201
SDLK_KP_EQUALS = 272 SDLK_KP_DBLVERTICALBAR = 202
SDLK_UP = 273 SDLK_KP_COLON = 203
SDLK_DOWN = 274 SDLK_KP_HASH = 204
SDLK_RIGHT = 275 SDLK_KP_SPACE = 205
SDLK_LEFT = 276 SDLK_KP_AT = 206
SDLK_INSERT = 277 SDLK_KP_EXCLAM = 207
SDLK_HOME = 278 SDLK_KP_MEMSTORE = 208
SDLK_END = 279 SDLK_KP_MEMRECALL = 209
SDLK_PAGEUP = 280 SDLK_KP_MEMCLEAR = 210
SDLK_PAGEDOWN = 281 SDLK_KP_MEMADD = 211
SDLK_F1 = 282 SDLK_KP_MEMSUBTRACT = 212
SDLK_F2 = 283 SDLK_KP_MEMMULTIPLY = 213
SDLK_F3 = 284 SDLK_KP_MEMDIVIDE = 214
SDLK_F4 = 285 SDLK_KP_PLUSMINUS = 215
SDLK_F5 = 286 SDLK_KP_CLEAR = 216
SDLK_F6 = 287 SDLK_KP_CLEARENTRY = 217
SDLK_F7 = 288 SDLK_KP_BINARY = 218
SDLK_F8 = 289 SDLK_KP_OCTAL = 219
SDLK_F9 = 290 SDLK_KP_DECIMAL = 220
SDLK_F10 = 291 SDLK_KP_HEXADECIMAL = 221
SDLK_F11 = 292 SDLK_LCTRL = 224
SDLK_F12 = 293 SDLK_LSHIFT = 225
SDLK_F13 = 294 SDLK_LALT = 226
SDLK_F14 = 295 SDLK_LGUI = 227
SDLK_F15 = 296 SDLK_RCTRL = 228
SDLK_NUMLOCK = 300 SDLK_RSHIFT = 229
SDLK_CAPSLOCK = 301 SDLK_RALT = 230
SDLK_SCROLLOCK = 302 SDLK_RGUI = 231
SDLK_RSHIFT = 303 SDLK_MODE = 257
SDLK_LSHIFT = 304 SDLK_AUDIONEXT = 258
SDLK_RCTRL = 305 SDLK_AUDIOPREV = 259
SDLK_LCTRL = 306 SDLK_AUDIOSTOP = 260
SDLK_RALT = 307 SDLK_AUDIOPLAY = 261
SDLK_LALT = 308 SDLK_AUDIOMUTE = 262
SDLK_RMETA = 309 SDLK_MEDIASELECT = 263
SDLK_LMETA = 310 SDLK_WWW = 264
SDLK_LSUPER = 311 SDLK_MAIL = 265
SDLK_RSUPER = 312 SDLK_CALCULATOR = 266
SDLK_MODE = 313 SDLK_COMPUTER = 267
SDLK_COMPOSE = 314 SDLK_AC_SEARCH = 268
SDLK_HELP = 315 SDLK_AC_HOME = 269
SDLK_PRINT = 316 SDLK_AC_BACK = 270
SDLK_SYSREQ = 317 SDLK_AC_FORWARD = 271
SDLK_BREAK = 318 SDLK_AC_STOP = 272
SDLK_MENU = 319 SDLK_AC_REFRESH = 273
SDLK_POWER = 320 SDLK_AC_BOOKMARKS = 274
SDLK_EURO = 321 SDLK_BRIGHTNESSDOWN = 275
SDLK_UNDO = 322 SDLK_BRIGHTNESSUP = 276
SDLK_DISPLAYSWITCH = 277
SDLK_KBDILLUMTOGGLE = 278
SDLK_KBDILLUMDOWN = 279
SDLK_KBDILLUMUP = 280
SDLK_EJECT = 281
SDLK_SLEEP = 282
SDLK_APP1 = 283
SDLK_APP2 = 284
-- not sure where this is defined, it was copied from the man page -- not sure where this is defined it was copied from the man page
KMOD_NONE = 0x0000 KMOD_NONE = 0x0000
KMOD_LSHIFT = 0x0001 KMOD_LSHIFT = 0x0001
KMOD_RSHIFT = 0x0002 KMOD_RSHIFT = 0x0002

View File

@ -301,17 +301,22 @@ GE_SHARED_ALARM = 2
-- callback passes in {key(int), state(bool), modif(int bitmask)} -- callback passes in {key(int), state(bool), modif(int bitmask)}
GE_KEY = 3 GE_KEY = 3
-- TEXT:
-- User submitted text to the OS by pressing key(s).
-- callback passes in {text(string)}
GE_TEXT = 4
-- BUTTON: -- BUTTON:
-- User pressed or released a mapped button. -- User pressed or released a mapped button.
-- callback passes in {key(int), button{name(string), desc(string)}, state(bool), modif(int bitmask)} -- callback passes in {key(int), button{name(string), desc(string)}, state(bool), modif(int bitmask)}
GE_BUTTON = 4 GE_BUTTON = 5
-- MOUSE: -- MOUSE:
-- Mouse movement: x, y, dx, dy. -- Mouse movement: x, y, dx, dy.
-- callback passes in {x(number), y(number), dx(number), dy(number)} -- callback passes in {x(number), y(number), dx(number), dy(number)}
GE_MOUSE = 5 GE_MOUSE = 6
-- MOUSE_BUTTON: -- MOUSE_BUTTON:
-- Mouse button is pressed or released. -- Mouse button is pressed or released.
-- callback passes in {button(int), down(bool)} -- callback passes in {button(int), down(bool)}
GE_MOUSE_BUTTON = 6 GE_MOUSE_BUTTON = 7

View File

@ -197,6 +197,17 @@ if client then
sb_ctl.gfx_api_prerender() sb_ctl.gfx_api_prerender()
end end
function client.hook_text(...)
if not sb_list[sb_ctl.gfx_select] then return end
local f = sb_list[sb_ctl.gfx_select].client.hook_text
if f then
sb_ctl.gfx_api_push(sb_ctl.gfx_select)
f(...)
sb_ctl.gfx_api_pop()
end
sb_ctl.gfx_api_prerender()
end
function client.hook_mouse_button(...) function client.hook_mouse_button(...)
if not sb_list[sb_ctl.gfx_select] then return end if not sb_list[sb_ctl.gfx_select] then return end
local f = sb_list[sb_ctl.gfx_select].client.hook_mouse_button local f = sb_list[sb_ctl.gfx_select].client.hook_mouse_button

View File

@ -5,261 +5,268 @@
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation Inc. 51 Franklin St Fifth Floor Boston MA 02110-1301 USA
Sam Lantinga Sam Lantinga
slouken@libsdl.org slouken@libsdl.org
]] ]]
--[[ --[[
part of SDL_keysym.h, converted to Lua by GreaseMonkey in 2012 part of SDL_scancode.h accurate as of SDL 2.0.3
accurate as of libSDL-1.2.so.0.11.3
]] ]]
SDLK_UNKNOWN = 0 SDLK_UNKNOWN = 0
SDLK_FIRST = 0 SDLK_a = 4
SDLK_BACKSPACE = 8 SDLK_b = 5
SDLK_TAB = 9 SDLK_c = 6
SDLK_CLEAR = 12 SDLK_d = 7
SDLK_RETURN = 13 SDLK_e = 8
SDLK_PAUSE = 19 SDLK_f = 9
SDLK_ESCAPE = 27 SDLK_g = 10
SDLK_SPACE = 32 SDLK_h = 11
SDLK_EXCLAIM = 33 SDLK_i = 12
SDLK_QUOTEDBL = 34 SDLK_j = 13
SDLK_HASH = 35 SDLK_k = 14
SDLK_DOLLAR = 36 SDLK_l = 15
SDLK_AMPERSAND = 38 SDLK_m = 16
SDLK_QUOTE = 39 SDLK_n = 17
SDLK_LEFTPAREN = 40 SDLK_o = 18
SDLK_RIGHTPAREN = 41 SDLK_p = 19
SDLK_ASTERISK = 42 SDLK_q = 20
SDLK_PLUS = 43 SDLK_r = 21
SDLK_COMMA = 44 SDLK_s = 22
SDLK_MINUS = 45 SDLK_t = 23
SDLK_PERIOD = 46 SDLK_u = 24
SDLK_SLASH = 47 SDLK_v = 25
SDLK_0 = 48 SDLK_w = 26
SDLK_1 = 49 SDLK_x = 27
SDLK_2 = 50 SDLK_y = 28
SDLK_3 = 51 SDLK_z = 29
SDLK_4 = 52 SDLK_1 = 30
SDLK_5 = 53 SDLK_2 = 31
SDLK_6 = 54 SDLK_3 = 32
SDLK_7 = 55 SDLK_4 = 33
SDLK_8 = 56 SDLK_5 = 34
SDLK_9 = 57 SDLK_6 = 35
SDLK_COLON = 58 SDLK_7 = 36
SDLK_SEMICOLON = 59 SDLK_8 = 37
SDLK_LESS = 60 SDLK_9 = 38
SDLK_EQUALS = 61 SDLK_0 = 39
SDLK_GREATER = 62 SDLK_RETURN = 40
SDLK_QUESTION = 63 SDLK_ESCAPE = 41
SDLK_AT = 64 SDLK_BACKSPACE = 42
SDLK_LEFTBRACKET = 91 SDLK_TAB = 43
SDLK_BACKSLASH = 92 SDLK_SPACE = 44
SDLK_RIGHTBRACKET = 93 SDLK_MINUS = 45
SDLK_CARET = 94 SDLK_EQUALS = 46
SDLK_UNDERSCORE = 95 SDLK_LEFTBRACKET = 47
SDLK_BACKQUOTE = 96 SDLK_RIGHTBRACKET = 48
SDLK_a = 97 SDLK_BACKSLASH = 49
SDLK_b = 98 SDLK_NONUSHASH = 50
SDLK_c = 99 SDLK_SEMICOLON = 51
SDLK_d = 100 SDLK_APOSTROPHE = 52
SDLK_e = 101 SDLK_GRAVE = 53
SDLK_f = 102 SDLK_COMMA = 54
SDLK_g = 103 SDLK_PERIOD = 55
SDLK_h = 104 SDLK_SLASH = 56
SDLK_i = 105 SDLK_CAPSLOCK = 57
SDLK_j = 106 SDLK_F1 = 58
SDLK_k = 107 SDLK_F2 = 59
SDLK_l = 108 SDLK_F3 = 60
SDLK_m = 109 SDLK_F4 = 61
SDLK_n = 110 SDLK_F5 = 62
SDLK_o = 111 SDLK_F6 = 63
SDLK_p = 112 SDLK_F7 = 64
SDLK_q = 113 SDLK_F8 = 65
SDLK_r = 114 SDLK_F9 = 66
SDLK_s = 115 SDLK_F10 = 67
SDLK_t = 116 SDLK_F11 = 68
SDLK_u = 117 SDLK_F12 = 69
SDLK_v = 118 SDLK_PRINTSCREEN = 70
SDLK_w = 119 SDLK_SCROLLLOCK = 71
SDLK_x = 120 SDLK_PAUSE = 72
SDLK_y = 121 SDLK_INSERT = 73
SDLK_z = 122 SDLK_HOME = 74
SDLK_DELETE = 127 SDLK_PAGEUP = 75
SDLK_WORLD_0 = 160 SDLK_DELETE = 76
SDLK_WORLD_1 = 161 SDLK_END = 77
SDLK_WORLD_2 = 162 SDLK_PAGEDOWN = 78
SDLK_WORLD_3 = 163 SDLK_RIGHT = 79
SDLK_WORLD_4 = 164 SDLK_LEFT = 80
SDLK_WORLD_5 = 165 SDLK_DOWN = 81
SDLK_WORLD_6 = 166 SDLK_UP = 82
SDLK_WORLD_7 = 167 SDLK_NUMLOCKCLEAR = 83
SDLK_WORLD_8 = 168 SDLK_KP_DIVIDE = 84
SDLK_WORLD_9 = 169 SDLK_KP_MULTIPLY = 85
SDLK_WORLD_10 = 170 SDLK_KP_MINUS = 86
SDLK_WORLD_11 = 171 SDLK_KP_PLUS = 87
SDLK_WORLD_12 = 172 SDLK_KP_ENTER = 88
SDLK_WORLD_13 = 173 SDLK_KP_1 = 89
SDLK_WORLD_14 = 174 SDLK_KP_2 = 90
SDLK_WORLD_15 = 175 SDLK_KP_3 = 91
SDLK_WORLD_16 = 176 SDLK_KP_4 = 92
SDLK_WORLD_17 = 177 SDLK_KP_5 = 93
SDLK_WORLD_18 = 178 SDLK_KP_6 = 94
SDLK_WORLD_19 = 179 SDLK_KP_7 = 95
SDLK_WORLD_20 = 180 SDLK_KP_8 = 96
SDLK_WORLD_21 = 181 SDLK_KP_9 = 97
SDLK_WORLD_22 = 182 SDLK_KP_0 = 98
SDLK_WORLD_23 = 183 SDLK_KP_PERIOD = 99
SDLK_WORLD_24 = 184 SDLK_NONUSBACKSLASH = 100
SDLK_WORLD_25 = 185 SDLK_APPLICATION = 101
SDLK_WORLD_26 = 186 SDLK_POWER = 102
SDLK_WORLD_27 = 187 SDLK_KP_EQUALS = 103
SDLK_WORLD_28 = 188 SDLK_F13 = 104
SDLK_WORLD_29 = 189 SDLK_F14 = 105
SDLK_WORLD_30 = 190 SDLK_F15 = 106
SDLK_WORLD_31 = 191 SDLK_F16 = 107
SDLK_WORLD_32 = 192 SDLK_F17 = 108
SDLK_WORLD_33 = 193 SDLK_F18 = 109
SDLK_WORLD_34 = 194 SDLK_F19 = 110
SDLK_WORLD_35 = 195 SDLK_F20 = 111
SDLK_WORLD_36 = 196 SDLK_F21 = 112
SDLK_WORLD_37 = 197 SDLK_F22 = 113
SDLK_WORLD_38 = 198 SDLK_F23 = 114
SDLK_WORLD_39 = 199 SDLK_F24 = 115
SDLK_WORLD_40 = 200 SDLK_EXECUTE = 116
SDLK_WORLD_41 = 201 SDLK_HELP = 117
SDLK_WORLD_42 = 202 SDLK_MENU = 118
SDLK_WORLD_43 = 203 SDLK_SELECT = 119
SDLK_WORLD_44 = 204 SDLK_STOP = 120
SDLK_WORLD_45 = 205 SDLK_AGAIN = 121
SDLK_WORLD_46 = 206 SDLK_UNDO = 122
SDLK_WORLD_47 = 207 SDLK_CUT = 123
SDLK_WORLD_48 = 208 SDLK_COPY = 124
SDLK_WORLD_49 = 209 SDLK_PASTE = 125
SDLK_WORLD_50 = 210 SDLK_FIND = 126
SDLK_WORLD_51 = 211 SDLK_MUTE = 127
SDLK_WORLD_52 = 212 SDLK_VOLUMEUP = 128
SDLK_WORLD_53 = 213 SDLK_VOLUMEDOWN = 129
SDLK_WORLD_54 = 214 SDLK_KP_COMMA = 133
SDLK_WORLD_55 = 215 SDLK_KP_EQUALSAS400 = 134
SDLK_WORLD_56 = 216 SDLK_INTERNATIONAL1 = 135
SDLK_WORLD_57 = 217 SDLK_INTERNATIONAL2 = 136
SDLK_WORLD_58 = 218 SDLK_INTERNATIONAL3 = 137
SDLK_WORLD_59 = 219 SDLK_INTERNATIONAL4 = 138
SDLK_WORLD_60 = 220 SDLK_INTERNATIONAL5 = 139
SDLK_WORLD_61 = 221 SDLK_INTERNATIONAL6 = 140
SDLK_WORLD_62 = 222 SDLK_INTERNATIONAL7 = 141
SDLK_WORLD_63 = 223 SDLK_INTERNATIONAL8 = 142
SDLK_WORLD_64 = 224 SDLK_INTERNATIONAL9 = 143
SDLK_WORLD_65 = 225 SDLK_LANG1 = 144
SDLK_WORLD_66 = 226 SDLK_LANG2 = 145
SDLK_WORLD_67 = 227 SDLK_LANG3 = 146
SDLK_WORLD_68 = 228 SDLK_LANG4 = 147
SDLK_WORLD_69 = 229 SDLK_LANG5 = 148
SDLK_WORLD_70 = 230 SDLK_LANG6 = 149
SDLK_WORLD_71 = 231 SDLK_LANG7 = 150
SDLK_WORLD_72 = 232 SDLK_LANG8 = 151
SDLK_WORLD_73 = 233 SDLK_LANG9 = 152
SDLK_WORLD_74 = 234 SDLK_ALTERASE = 153
SDLK_WORLD_75 = 235 SDLK_SYSREQ = 154
SDLK_WORLD_76 = 236 SDLK_CANCEL = 155
SDLK_WORLD_77 = 237 SDLK_CLEAR = 156
SDLK_WORLD_78 = 238 SDLK_PRIOR = 157
SDLK_WORLD_79 = 239 SDLK_RETURN2 = 158
SDLK_WORLD_80 = 240 SDLK_SEPARATOR = 159
SDLK_WORLD_81 = 241 SDLK_OUT = 160
SDLK_WORLD_82 = 242 SDLK_OPER = 161
SDLK_WORLD_83 = 243 SDLK_CLEARAGAIN = 162
SDLK_WORLD_84 = 244 SDLK_CRSEL = 163
SDLK_WORLD_85 = 245 SDLK_EXSEL = 164
SDLK_WORLD_86 = 246 SDLK_KP_00 = 176
SDLK_WORLD_87 = 247 SDLK_KP_000 = 177
SDLK_WORLD_88 = 248 SDLK_THOUSANDSSEPARATOR = 178
SDLK_WORLD_89 = 249 SDLK_DECIMALSEPARATOR = 179
SDLK_WORLD_90 = 250 SDLK_CURRENCYUNIT = 180
SDLK_WORLD_91 = 251 SDLK_CURRENCYSUBUNIT = 181
SDLK_WORLD_92 = 252 SDLK_KP_LEFTPAREN = 182
SDLK_WORLD_93 = 253 SDLK_KP_RIGHTPAREN = 183
SDLK_WORLD_94 = 254 SDLK_KP_LEFTBRACE = 184
SDLK_WORLD_95 = 255 SDLK_KP_RIGHTBRACE = 185
SDLK_KP0 = 256 SDLK_KP_TAB = 186
SDLK_KP1 = 257 SDLK_KP_BACKSPACE = 187
SDLK_KP2 = 258 SDLK_KP_A = 188
SDLK_KP3 = 259 SDLK_KP_B = 189
SDLK_KP4 = 260 SDLK_KP_C = 190
SDLK_KP5 = 261 SDLK_KP_D = 191
SDLK_KP6 = 262 SDLK_KP_E = 192
SDLK_KP7 = 263 SDLK_KP_F = 193
SDLK_KP8 = 264 SDLK_KP_XOR = 194
SDLK_KP9 = 265 SDLK_KP_POWER = 195
SDLK_KP_PERIOD = 266 SDLK_KP_PERCENT = 196
SDLK_KP_DIVIDE = 267 SDLK_KP_LESS = 197
SDLK_KP_MULTIPLY = 268 SDLK_KP_GREATER = 198
SDLK_KP_MINUS = 269 SDLK_KP_AMPERSAND = 199
SDLK_KP_PLUS = 270 SDLK_KP_DBLAMPERSAND = 200
SDLK_KP_ENTER = 271 SDLK_KP_VERTICALBAR = 201
SDLK_KP_EQUALS = 272 SDLK_KP_DBLVERTICALBAR = 202
SDLK_UP = 273 SDLK_KP_COLON = 203
SDLK_DOWN = 274 SDLK_KP_HASH = 204
SDLK_RIGHT = 275 SDLK_KP_SPACE = 205
SDLK_LEFT = 276 SDLK_KP_AT = 206
SDLK_INSERT = 277 SDLK_KP_EXCLAM = 207
SDLK_HOME = 278 SDLK_KP_MEMSTORE = 208
SDLK_END = 279 SDLK_KP_MEMRECALL = 209
SDLK_PAGEUP = 280 SDLK_KP_MEMCLEAR = 210
SDLK_PAGEDOWN = 281 SDLK_KP_MEMADD = 211
SDLK_F1 = 282 SDLK_KP_MEMSUBTRACT = 212
SDLK_F2 = 283 SDLK_KP_MEMMULTIPLY = 213
SDLK_F3 = 284 SDLK_KP_MEMDIVIDE = 214
SDLK_F4 = 285 SDLK_KP_PLUSMINUS = 215
SDLK_F5 = 286 SDLK_KP_CLEAR = 216
SDLK_F6 = 287 SDLK_KP_CLEARENTRY = 217
SDLK_F7 = 288 SDLK_KP_BINARY = 218
SDLK_F8 = 289 SDLK_KP_OCTAL = 219
SDLK_F9 = 290 SDLK_KP_DECIMAL = 220
SDLK_F10 = 291 SDLK_KP_HEXADECIMAL = 221
SDLK_F11 = 292 SDLK_LCTRL = 224
SDLK_F12 = 293 SDLK_LSHIFT = 225
SDLK_F13 = 294 SDLK_LALT = 226
SDLK_F14 = 295 SDLK_LGUI = 227
SDLK_F15 = 296 SDLK_RCTRL = 228
SDLK_NUMLOCK = 300 SDLK_RSHIFT = 229
SDLK_CAPSLOCK = 301 SDLK_RALT = 230
SDLK_SCROLLOCK = 302 SDLK_RGUI = 231
SDLK_RSHIFT = 303 SDLK_MODE = 257
SDLK_LSHIFT = 304 SDLK_AUDIONEXT = 258
SDLK_RCTRL = 305 SDLK_AUDIOPREV = 259
SDLK_LCTRL = 306 SDLK_AUDIOSTOP = 260
SDLK_RALT = 307 SDLK_AUDIOPLAY = 261
SDLK_LALT = 308 SDLK_AUDIOMUTE = 262
SDLK_RMETA = 309 SDLK_MEDIASELECT = 263
SDLK_LMETA = 310 SDLK_WWW = 264
SDLK_LSUPER = 311 SDLK_MAIL = 265
SDLK_RSUPER = 312 SDLK_CALCULATOR = 266
SDLK_MODE = 313 SDLK_COMPUTER = 267
SDLK_COMPOSE = 314 SDLK_AC_SEARCH = 268
SDLK_HELP = 315 SDLK_AC_HOME = 269
SDLK_PRINT = 316 SDLK_AC_BACK = 270
SDLK_SYSREQ = 317 SDLK_AC_FORWARD = 271
SDLK_BREAK = 318 SDLK_AC_STOP = 272
SDLK_MENU = 319 SDLK_AC_REFRESH = 273
SDLK_POWER = 320 SDLK_AC_BOOKMARKS = 274
SDLK_EURO = 321 SDLK_BRIGHTNESSDOWN = 275
SDLK_UNDO = 322 SDLK_BRIGHTNESSUP = 276
SDLK_DISPLAYSWITCH = 277
SDLK_KBDILLUMTOGGLE = 278
SDLK_KBDILLUMDOWN = 279
SDLK_KBDILLUMUP = 280
SDLK_EJECT = 281
SDLK_SLEEP = 282
SDLK_APP1 = 283
SDLK_APP2 = 284
-- not sure where this is defined, it was copied from the man page -- not sure where this is defined it was copied from the man page
KMOD_NONE = 0x0000 KMOD_NONE = 0x0000
KMOD_LSHIFT = 0x0001 KMOD_LSHIFT = 0x0001
KMOD_RSHIFT = 0x0002 KMOD_RSHIFT = 0x0002

View File

@ -5,261 +5,268 @@
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation Inc. 51 Franklin St Fifth Floor Boston MA 02110-1301 USA
Sam Lantinga Sam Lantinga
slouken@libsdl.org slouken@libsdl.org
]] ]]
--[[ --[[
part of SDL_keysym.h, converted to Lua by GreaseMonkey in 2012 part of SDL_scancode.h accurate as of SDL 2.0.3
accurate as of libSDL-1.2.so.0.11.3
]] ]]
SDLK_UNKNOWN = 0 SDLK_UNKNOWN = 0
SDLK_FIRST = 0 SDLK_a = 4
SDLK_BACKSPACE = 8 SDLK_b = 5
SDLK_TAB = 9 SDLK_c = 6
SDLK_CLEAR = 12 SDLK_d = 7
SDLK_RETURN = 13 SDLK_e = 8
SDLK_PAUSE = 19 SDLK_f = 9
SDLK_ESCAPE = 27 SDLK_g = 10
SDLK_SPACE = 32 SDLK_h = 11
SDLK_EXCLAIM = 33 SDLK_i = 12
SDLK_QUOTEDBL = 34 SDLK_j = 13
SDLK_HASH = 35 SDLK_k = 14
SDLK_DOLLAR = 36 SDLK_l = 15
SDLK_AMPERSAND = 38 SDLK_m = 16
SDLK_QUOTE = 39 SDLK_n = 17
SDLK_LEFTPAREN = 40 SDLK_o = 18
SDLK_RIGHTPAREN = 41 SDLK_p = 19
SDLK_ASTERISK = 42 SDLK_q = 20
SDLK_PLUS = 43 SDLK_r = 21
SDLK_COMMA = 44 SDLK_s = 22
SDLK_MINUS = 45 SDLK_t = 23
SDLK_PERIOD = 46 SDLK_u = 24
SDLK_SLASH = 47 SDLK_v = 25
SDLK_0 = 48 SDLK_w = 26
SDLK_1 = 49 SDLK_x = 27
SDLK_2 = 50 SDLK_y = 28
SDLK_3 = 51 SDLK_z = 29
SDLK_4 = 52 SDLK_1 = 30
SDLK_5 = 53 SDLK_2 = 31
SDLK_6 = 54 SDLK_3 = 32
SDLK_7 = 55 SDLK_4 = 33
SDLK_8 = 56 SDLK_5 = 34
SDLK_9 = 57 SDLK_6 = 35
SDLK_COLON = 58 SDLK_7 = 36
SDLK_SEMICOLON = 59 SDLK_8 = 37
SDLK_LESS = 60 SDLK_9 = 38
SDLK_EQUALS = 61 SDLK_0 = 39
SDLK_GREATER = 62 SDLK_RETURN = 40
SDLK_QUESTION = 63 SDLK_ESCAPE = 41
SDLK_AT = 64 SDLK_BACKSPACE = 42
SDLK_LEFTBRACKET = 91 SDLK_TAB = 43
SDLK_BACKSLASH = 92 SDLK_SPACE = 44
SDLK_RIGHTBRACKET = 93 SDLK_MINUS = 45
SDLK_CARET = 94 SDLK_EQUALS = 46
SDLK_UNDERSCORE = 95 SDLK_LEFTBRACKET = 47
SDLK_BACKQUOTE = 96 SDLK_RIGHTBRACKET = 48
SDLK_a = 97 SDLK_BACKSLASH = 49
SDLK_b = 98 SDLK_NONUSHASH = 50
SDLK_c = 99 SDLK_SEMICOLON = 51
SDLK_d = 100 SDLK_APOSTROPHE = 52
SDLK_e = 101 SDLK_GRAVE = 53
SDLK_f = 102 SDLK_COMMA = 54
SDLK_g = 103 SDLK_PERIOD = 55
SDLK_h = 104 SDLK_SLASH = 56
SDLK_i = 105 SDLK_CAPSLOCK = 57
SDLK_j = 106 SDLK_F1 = 58
SDLK_k = 107 SDLK_F2 = 59
SDLK_l = 108 SDLK_F3 = 60
SDLK_m = 109 SDLK_F4 = 61
SDLK_n = 110 SDLK_F5 = 62
SDLK_o = 111 SDLK_F6 = 63
SDLK_p = 112 SDLK_F7 = 64
SDLK_q = 113 SDLK_F8 = 65
SDLK_r = 114 SDLK_F9 = 66
SDLK_s = 115 SDLK_F10 = 67
SDLK_t = 116 SDLK_F11 = 68
SDLK_u = 117 SDLK_F12 = 69
SDLK_v = 118 SDLK_PRINTSCREEN = 70
SDLK_w = 119 SDLK_SCROLLLOCK = 71
SDLK_x = 120 SDLK_PAUSE = 72
SDLK_y = 121 SDLK_INSERT = 73
SDLK_z = 122 SDLK_HOME = 74
SDLK_DELETE = 127 SDLK_PAGEUP = 75
SDLK_WORLD_0 = 160 SDLK_DELETE = 76
SDLK_WORLD_1 = 161 SDLK_END = 77
SDLK_WORLD_2 = 162 SDLK_PAGEDOWN = 78
SDLK_WORLD_3 = 163 SDLK_RIGHT = 79
SDLK_WORLD_4 = 164 SDLK_LEFT = 80
SDLK_WORLD_5 = 165 SDLK_DOWN = 81
SDLK_WORLD_6 = 166 SDLK_UP = 82
SDLK_WORLD_7 = 167 SDLK_NUMLOCKCLEAR = 83
SDLK_WORLD_8 = 168 SDLK_KP_DIVIDE = 84
SDLK_WORLD_9 = 169 SDLK_KP_MULTIPLY = 85
SDLK_WORLD_10 = 170 SDLK_KP_MINUS = 86
SDLK_WORLD_11 = 171 SDLK_KP_PLUS = 87
SDLK_WORLD_12 = 172 SDLK_KP_ENTER = 88
SDLK_WORLD_13 = 173 SDLK_KP_1 = 89
SDLK_WORLD_14 = 174 SDLK_KP_2 = 90
SDLK_WORLD_15 = 175 SDLK_KP_3 = 91
SDLK_WORLD_16 = 176 SDLK_KP_4 = 92
SDLK_WORLD_17 = 177 SDLK_KP_5 = 93
SDLK_WORLD_18 = 178 SDLK_KP_6 = 94
SDLK_WORLD_19 = 179 SDLK_KP_7 = 95
SDLK_WORLD_20 = 180 SDLK_KP_8 = 96
SDLK_WORLD_21 = 181 SDLK_KP_9 = 97
SDLK_WORLD_22 = 182 SDLK_KP_0 = 98
SDLK_WORLD_23 = 183 SDLK_KP_PERIOD = 99
SDLK_WORLD_24 = 184 SDLK_NONUSBACKSLASH = 100
SDLK_WORLD_25 = 185 SDLK_APPLICATION = 101
SDLK_WORLD_26 = 186 SDLK_POWER = 102
SDLK_WORLD_27 = 187 SDLK_KP_EQUALS = 103
SDLK_WORLD_28 = 188 SDLK_F13 = 104
SDLK_WORLD_29 = 189 SDLK_F14 = 105
SDLK_WORLD_30 = 190 SDLK_F15 = 106
SDLK_WORLD_31 = 191 SDLK_F16 = 107
SDLK_WORLD_32 = 192 SDLK_F17 = 108
SDLK_WORLD_33 = 193 SDLK_F18 = 109
SDLK_WORLD_34 = 194 SDLK_F19 = 110
SDLK_WORLD_35 = 195 SDLK_F20 = 111
SDLK_WORLD_36 = 196 SDLK_F21 = 112
SDLK_WORLD_37 = 197 SDLK_F22 = 113
SDLK_WORLD_38 = 198 SDLK_F23 = 114
SDLK_WORLD_39 = 199 SDLK_F24 = 115
SDLK_WORLD_40 = 200 SDLK_EXECUTE = 116
SDLK_WORLD_41 = 201 SDLK_HELP = 117
SDLK_WORLD_42 = 202 SDLK_MENU = 118
SDLK_WORLD_43 = 203 SDLK_SELECT = 119
SDLK_WORLD_44 = 204 SDLK_STOP = 120
SDLK_WORLD_45 = 205 SDLK_AGAIN = 121
SDLK_WORLD_46 = 206 SDLK_UNDO = 122
SDLK_WORLD_47 = 207 SDLK_CUT = 123
SDLK_WORLD_48 = 208 SDLK_COPY = 124
SDLK_WORLD_49 = 209 SDLK_PASTE = 125
SDLK_WORLD_50 = 210 SDLK_FIND = 126
SDLK_WORLD_51 = 211 SDLK_MUTE = 127
SDLK_WORLD_52 = 212 SDLK_VOLUMEUP = 128
SDLK_WORLD_53 = 213 SDLK_VOLUMEDOWN = 129
SDLK_WORLD_54 = 214 SDLK_KP_COMMA = 133
SDLK_WORLD_55 = 215 SDLK_KP_EQUALSAS400 = 134
SDLK_WORLD_56 = 216 SDLK_INTERNATIONAL1 = 135
SDLK_WORLD_57 = 217 SDLK_INTERNATIONAL2 = 136
SDLK_WORLD_58 = 218 SDLK_INTERNATIONAL3 = 137
SDLK_WORLD_59 = 219 SDLK_INTERNATIONAL4 = 138
SDLK_WORLD_60 = 220 SDLK_INTERNATIONAL5 = 139
SDLK_WORLD_61 = 221 SDLK_INTERNATIONAL6 = 140
SDLK_WORLD_62 = 222 SDLK_INTERNATIONAL7 = 141
SDLK_WORLD_63 = 223 SDLK_INTERNATIONAL8 = 142
SDLK_WORLD_64 = 224 SDLK_INTERNATIONAL9 = 143
SDLK_WORLD_65 = 225 SDLK_LANG1 = 144
SDLK_WORLD_66 = 226 SDLK_LANG2 = 145
SDLK_WORLD_67 = 227 SDLK_LANG3 = 146
SDLK_WORLD_68 = 228 SDLK_LANG4 = 147
SDLK_WORLD_69 = 229 SDLK_LANG5 = 148
SDLK_WORLD_70 = 230 SDLK_LANG6 = 149
SDLK_WORLD_71 = 231 SDLK_LANG7 = 150
SDLK_WORLD_72 = 232 SDLK_LANG8 = 151
SDLK_WORLD_73 = 233 SDLK_LANG9 = 152
SDLK_WORLD_74 = 234 SDLK_ALTERASE = 153
SDLK_WORLD_75 = 235 SDLK_SYSREQ = 154
SDLK_WORLD_76 = 236 SDLK_CANCEL = 155
SDLK_WORLD_77 = 237 SDLK_CLEAR = 156
SDLK_WORLD_78 = 238 SDLK_PRIOR = 157
SDLK_WORLD_79 = 239 SDLK_RETURN2 = 158
SDLK_WORLD_80 = 240 SDLK_SEPARATOR = 159
SDLK_WORLD_81 = 241 SDLK_OUT = 160
SDLK_WORLD_82 = 242 SDLK_OPER = 161
SDLK_WORLD_83 = 243 SDLK_CLEARAGAIN = 162
SDLK_WORLD_84 = 244 SDLK_CRSEL = 163
SDLK_WORLD_85 = 245 SDLK_EXSEL = 164
SDLK_WORLD_86 = 246 SDLK_KP_00 = 176
SDLK_WORLD_87 = 247 SDLK_KP_000 = 177
SDLK_WORLD_88 = 248 SDLK_THOUSANDSSEPARATOR = 178
SDLK_WORLD_89 = 249 SDLK_DECIMALSEPARATOR = 179
SDLK_WORLD_90 = 250 SDLK_CURRENCYUNIT = 180
SDLK_WORLD_91 = 251 SDLK_CURRENCYSUBUNIT = 181
SDLK_WORLD_92 = 252 SDLK_KP_LEFTPAREN = 182
SDLK_WORLD_93 = 253 SDLK_KP_RIGHTPAREN = 183
SDLK_WORLD_94 = 254 SDLK_KP_LEFTBRACE = 184
SDLK_WORLD_95 = 255 SDLK_KP_RIGHTBRACE = 185
SDLK_KP0 = 256 SDLK_KP_TAB = 186
SDLK_KP1 = 257 SDLK_KP_BACKSPACE = 187
SDLK_KP2 = 258 SDLK_KP_A = 188
SDLK_KP3 = 259 SDLK_KP_B = 189
SDLK_KP4 = 260 SDLK_KP_C = 190
SDLK_KP5 = 261 SDLK_KP_D = 191
SDLK_KP6 = 262 SDLK_KP_E = 192
SDLK_KP7 = 263 SDLK_KP_F = 193
SDLK_KP8 = 264 SDLK_KP_XOR = 194
SDLK_KP9 = 265 SDLK_KP_POWER = 195
SDLK_KP_PERIOD = 266 SDLK_KP_PERCENT = 196
SDLK_KP_DIVIDE = 267 SDLK_KP_LESS = 197
SDLK_KP_MULTIPLY = 268 SDLK_KP_GREATER = 198
SDLK_KP_MINUS = 269 SDLK_KP_AMPERSAND = 199
SDLK_KP_PLUS = 270 SDLK_KP_DBLAMPERSAND = 200
SDLK_KP_ENTER = 271 SDLK_KP_VERTICALBAR = 201
SDLK_KP_EQUALS = 272 SDLK_KP_DBLVERTICALBAR = 202
SDLK_UP = 273 SDLK_KP_COLON = 203
SDLK_DOWN = 274 SDLK_KP_HASH = 204
SDLK_RIGHT = 275 SDLK_KP_SPACE = 205
SDLK_LEFT = 276 SDLK_KP_AT = 206
SDLK_INSERT = 277 SDLK_KP_EXCLAM = 207
SDLK_HOME = 278 SDLK_KP_MEMSTORE = 208
SDLK_END = 279 SDLK_KP_MEMRECALL = 209
SDLK_PAGEUP = 280 SDLK_KP_MEMCLEAR = 210
SDLK_PAGEDOWN = 281 SDLK_KP_MEMADD = 211
SDLK_F1 = 282 SDLK_KP_MEMSUBTRACT = 212
SDLK_F2 = 283 SDLK_KP_MEMMULTIPLY = 213
SDLK_F3 = 284 SDLK_KP_MEMDIVIDE = 214
SDLK_F4 = 285 SDLK_KP_PLUSMINUS = 215
SDLK_F5 = 286 SDLK_KP_CLEAR = 216
SDLK_F6 = 287 SDLK_KP_CLEARENTRY = 217
SDLK_F7 = 288 SDLK_KP_BINARY = 218
SDLK_F8 = 289 SDLK_KP_OCTAL = 219
SDLK_F9 = 290 SDLK_KP_DECIMAL = 220
SDLK_F10 = 291 SDLK_KP_HEXADECIMAL = 221
SDLK_F11 = 292 SDLK_LCTRL = 224
SDLK_F12 = 293 SDLK_LSHIFT = 225
SDLK_F13 = 294 SDLK_LALT = 226
SDLK_F14 = 295 SDLK_LGUI = 227
SDLK_F15 = 296 SDLK_RCTRL = 228
SDLK_NUMLOCK = 300 SDLK_RSHIFT = 229
SDLK_CAPSLOCK = 301 SDLK_RALT = 230
SDLK_SCROLLOCK = 302 SDLK_RGUI = 231
SDLK_RSHIFT = 303 SDLK_MODE = 257
SDLK_LSHIFT = 304 SDLK_AUDIONEXT = 258
SDLK_RCTRL = 305 SDLK_AUDIOPREV = 259
SDLK_LCTRL = 306 SDLK_AUDIOSTOP = 260
SDLK_RALT = 307 SDLK_AUDIOPLAY = 261
SDLK_LALT = 308 SDLK_AUDIOMUTE = 262
SDLK_RMETA = 309 SDLK_MEDIASELECT = 263
SDLK_LMETA = 310 SDLK_WWW = 264
SDLK_LSUPER = 311 SDLK_MAIL = 265
SDLK_RSUPER = 312 SDLK_CALCULATOR = 266
SDLK_MODE = 313 SDLK_COMPUTER = 267
SDLK_COMPOSE = 314 SDLK_AC_SEARCH = 268
SDLK_HELP = 315 SDLK_AC_HOME = 269
SDLK_PRINT = 316 SDLK_AC_BACK = 270
SDLK_SYSREQ = 317 SDLK_AC_FORWARD = 271
SDLK_BREAK = 318 SDLK_AC_STOP = 272
SDLK_MENU = 319 SDLK_AC_REFRESH = 273
SDLK_POWER = 320 SDLK_AC_BOOKMARKS = 274
SDLK_EURO = 321 SDLK_BRIGHTNESSDOWN = 275
SDLK_UNDO = 322 SDLK_BRIGHTNESSUP = 276
SDLK_DISPLAYSWITCH = 277
SDLK_KBDILLUMTOGGLE = 278
SDLK_KBDILLUMDOWN = 279
SDLK_KBDILLUMUP = 280
SDLK_EJECT = 281
SDLK_SLEEP = 282
SDLK_APP1 = 283
SDLK_APP2 = 284
-- not sure where this is defined, it was copied from the man page -- not sure where this is defined it was copied from the man page
KMOD_NONE = 0x0000 KMOD_NONE = 0x0000
KMOD_LSHIFT = 0x0001 KMOD_LSHIFT = 0x0001
KMOD_RSHIFT = 0x0002 KMOD_RSHIFT = 0x0002

View File

@ -5,261 +5,268 @@
This library is free software; you can redistribute it and/or This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version. version 2.1 of the License or (at your option) any later version.
This library is distributed in the hope that it will be useful, This library is distributed in the hope that it will be useful
but WITHOUT ANY WARRANTY; without even the implied warranty of but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
Lesser General Public License for more details. Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software License along with this library; if not write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA Foundation Inc. 51 Franklin St Fifth Floor Boston MA 02110-1301 USA
Sam Lantinga Sam Lantinga
slouken@libsdl.org slouken@libsdl.org
]] ]]
--[[ --[[
part of SDL_keysym.h, converted to Lua by GreaseMonkey in 2012 part of SDL_scancode.h accurate as of SDL 2.0.3
accurate as of libSDL-1.2.so.0.11.3
]] ]]
SDLK_UNKNOWN = 0 SDLK_UNKNOWN = 0
SDLK_FIRST = 0 SDLK_a = 4
SDLK_BACKSPACE = 8 SDLK_b = 5
SDLK_TAB = 9 SDLK_c = 6
SDLK_CLEAR = 12 SDLK_d = 7
SDLK_RETURN = 13 SDLK_e = 8
SDLK_PAUSE = 19 SDLK_f = 9
SDLK_ESCAPE = 27 SDLK_g = 10
SDLK_SPACE = 32 SDLK_h = 11
SDLK_EXCLAIM = 33 SDLK_i = 12
SDLK_QUOTEDBL = 34 SDLK_j = 13
SDLK_HASH = 35 SDLK_k = 14
SDLK_DOLLAR = 36 SDLK_l = 15
SDLK_AMPERSAND = 38 SDLK_m = 16
SDLK_QUOTE = 39 SDLK_n = 17
SDLK_LEFTPAREN = 40 SDLK_o = 18
SDLK_RIGHTPAREN = 41 SDLK_p = 19
SDLK_ASTERISK = 42 SDLK_q = 20
SDLK_PLUS = 43 SDLK_r = 21
SDLK_COMMA = 44 SDLK_s = 22
SDLK_MINUS = 45 SDLK_t = 23
SDLK_PERIOD = 46 SDLK_u = 24
SDLK_SLASH = 47 SDLK_v = 25
SDLK_0 = 48 SDLK_w = 26
SDLK_1 = 49 SDLK_x = 27
SDLK_2 = 50 SDLK_y = 28
SDLK_3 = 51 SDLK_z = 29
SDLK_4 = 52 SDLK_1 = 30
SDLK_5 = 53 SDLK_2 = 31
SDLK_6 = 54 SDLK_3 = 32
SDLK_7 = 55 SDLK_4 = 33
SDLK_8 = 56 SDLK_5 = 34
SDLK_9 = 57 SDLK_6 = 35
SDLK_COLON = 58 SDLK_7 = 36
SDLK_SEMICOLON = 59 SDLK_8 = 37
SDLK_LESS = 60 SDLK_9 = 38
SDLK_EQUALS = 61 SDLK_0 = 39
SDLK_GREATER = 62 SDLK_RETURN = 40
SDLK_QUESTION = 63 SDLK_ESCAPE = 41
SDLK_AT = 64 SDLK_BACKSPACE = 42
SDLK_LEFTBRACKET = 91 SDLK_TAB = 43
SDLK_BACKSLASH = 92 SDLK_SPACE = 44
SDLK_RIGHTBRACKET = 93 SDLK_MINUS = 45
SDLK_CARET = 94 SDLK_EQUALS = 46
SDLK_UNDERSCORE = 95 SDLK_LEFTBRACKET = 47
SDLK_BACKQUOTE = 96 SDLK_RIGHTBRACKET = 48
SDLK_a = 97 SDLK_BACKSLASH = 49
SDLK_b = 98 SDLK_NONUSHASH = 50
SDLK_c = 99 SDLK_SEMICOLON = 51
SDLK_d = 100 SDLK_APOSTROPHE = 52
SDLK_e = 101 SDLK_GRAVE = 53
SDLK_f = 102 SDLK_COMMA = 54
SDLK_g = 103 SDLK_PERIOD = 55
SDLK_h = 104 SDLK_SLASH = 56
SDLK_i = 105 SDLK_CAPSLOCK = 57
SDLK_j = 106 SDLK_F1 = 58
SDLK_k = 107 SDLK_F2 = 59
SDLK_l = 108 SDLK_F3 = 60
SDLK_m = 109 SDLK_F4 = 61
SDLK_n = 110 SDLK_F5 = 62
SDLK_o = 111 SDLK_F6 = 63
SDLK_p = 112 SDLK_F7 = 64
SDLK_q = 113 SDLK_F8 = 65
SDLK_r = 114 SDLK_F9 = 66
SDLK_s = 115 SDLK_F10 = 67
SDLK_t = 116 SDLK_F11 = 68
SDLK_u = 117 SDLK_F12 = 69
SDLK_v = 118 SDLK_PRINTSCREEN = 70
SDLK_w = 119 SDLK_SCROLLLOCK = 71
SDLK_x = 120 SDLK_PAUSE = 72
SDLK_y = 121 SDLK_INSERT = 73
SDLK_z = 122 SDLK_HOME = 74
SDLK_DELETE = 127 SDLK_PAGEUP = 75
SDLK_WORLD_0 = 160 SDLK_DELETE = 76
SDLK_WORLD_1 = 161 SDLK_END = 77
SDLK_WORLD_2 = 162 SDLK_PAGEDOWN = 78
SDLK_WORLD_3 = 163 SDLK_RIGHT = 79
SDLK_WORLD_4 = 164 SDLK_LEFT = 80
SDLK_WORLD_5 = 165 SDLK_DOWN = 81
SDLK_WORLD_6 = 166 SDLK_UP = 82
SDLK_WORLD_7 = 167 SDLK_NUMLOCKCLEAR = 83
SDLK_WORLD_8 = 168 SDLK_KP_DIVIDE = 84
SDLK_WORLD_9 = 169 SDLK_KP_MULTIPLY = 85
SDLK_WORLD_10 = 170 SDLK_KP_MINUS = 86
SDLK_WORLD_11 = 171 SDLK_KP_PLUS = 87
SDLK_WORLD_12 = 172 SDLK_KP_ENTER = 88
SDLK_WORLD_13 = 173 SDLK_KP_1 = 89
SDLK_WORLD_14 = 174 SDLK_KP_2 = 90
SDLK_WORLD_15 = 175 SDLK_KP_3 = 91
SDLK_WORLD_16 = 176 SDLK_KP_4 = 92
SDLK_WORLD_17 = 177 SDLK_KP_5 = 93
SDLK_WORLD_18 = 178 SDLK_KP_6 = 94
SDLK_WORLD_19 = 179 SDLK_KP_7 = 95
SDLK_WORLD_20 = 180 SDLK_KP_8 = 96
SDLK_WORLD_21 = 181 SDLK_KP_9 = 97
SDLK_WORLD_22 = 182 SDLK_KP_0 = 98
SDLK_WORLD_23 = 183 SDLK_KP_PERIOD = 99
SDLK_WORLD_24 = 184 SDLK_NONUSBACKSLASH = 100
SDLK_WORLD_25 = 185 SDLK_APPLICATION = 101
SDLK_WORLD_26 = 186 SDLK_POWER = 102
SDLK_WORLD_27 = 187 SDLK_KP_EQUALS = 103
SDLK_WORLD_28 = 188 SDLK_F13 = 104
SDLK_WORLD_29 = 189 SDLK_F14 = 105
SDLK_WORLD_30 = 190 SDLK_F15 = 106
SDLK_WORLD_31 = 191 SDLK_F16 = 107
SDLK_WORLD_32 = 192 SDLK_F17 = 108
SDLK_WORLD_33 = 193 SDLK_F18 = 109
SDLK_WORLD_34 = 194 SDLK_F19 = 110
SDLK_WORLD_35 = 195 SDLK_F20 = 111
SDLK_WORLD_36 = 196 SDLK_F21 = 112
SDLK_WORLD_37 = 197 SDLK_F22 = 113
SDLK_WORLD_38 = 198 SDLK_F23 = 114
SDLK_WORLD_39 = 199 SDLK_F24 = 115
SDLK_WORLD_40 = 200 SDLK_EXECUTE = 116
SDLK_WORLD_41 = 201 SDLK_HELP = 117
SDLK_WORLD_42 = 202 SDLK_MENU = 118
SDLK_WORLD_43 = 203 SDLK_SELECT = 119
SDLK_WORLD_44 = 204 SDLK_STOP = 120
SDLK_WORLD_45 = 205 SDLK_AGAIN = 121
SDLK_WORLD_46 = 206 SDLK_UNDO = 122
SDLK_WORLD_47 = 207 SDLK_CUT = 123
SDLK_WORLD_48 = 208 SDLK_COPY = 124
SDLK_WORLD_49 = 209 SDLK_PASTE = 125
SDLK_WORLD_50 = 210 SDLK_FIND = 126
SDLK_WORLD_51 = 211 SDLK_MUTE = 127
SDLK_WORLD_52 = 212 SDLK_VOLUMEUP = 128
SDLK_WORLD_53 = 213 SDLK_VOLUMEDOWN = 129
SDLK_WORLD_54 = 214 SDLK_KP_COMMA = 133
SDLK_WORLD_55 = 215 SDLK_KP_EQUALSAS400 = 134
SDLK_WORLD_56 = 216 SDLK_INTERNATIONAL1 = 135
SDLK_WORLD_57 = 217 SDLK_INTERNATIONAL2 = 136
SDLK_WORLD_58 = 218 SDLK_INTERNATIONAL3 = 137
SDLK_WORLD_59 = 219 SDLK_INTERNATIONAL4 = 138
SDLK_WORLD_60 = 220 SDLK_INTERNATIONAL5 = 139
SDLK_WORLD_61 = 221 SDLK_INTERNATIONAL6 = 140
SDLK_WORLD_62 = 222 SDLK_INTERNATIONAL7 = 141
SDLK_WORLD_63 = 223 SDLK_INTERNATIONAL8 = 142
SDLK_WORLD_64 = 224 SDLK_INTERNATIONAL9 = 143
SDLK_WORLD_65 = 225 SDLK_LANG1 = 144
SDLK_WORLD_66 = 226 SDLK_LANG2 = 145
SDLK_WORLD_67 = 227 SDLK_LANG3 = 146
SDLK_WORLD_68 = 228 SDLK_LANG4 = 147
SDLK_WORLD_69 = 229 SDLK_LANG5 = 148
SDLK_WORLD_70 = 230 SDLK_LANG6 = 149
SDLK_WORLD_71 = 231 SDLK_LANG7 = 150
SDLK_WORLD_72 = 232 SDLK_LANG8 = 151
SDLK_WORLD_73 = 233 SDLK_LANG9 = 152
SDLK_WORLD_74 = 234 SDLK_ALTERASE = 153
SDLK_WORLD_75 = 235 SDLK_SYSREQ = 154
SDLK_WORLD_76 = 236 SDLK_CANCEL = 155
SDLK_WORLD_77 = 237 SDLK_CLEAR = 156
SDLK_WORLD_78 = 238 SDLK_PRIOR = 157
SDLK_WORLD_79 = 239 SDLK_RETURN2 = 158
SDLK_WORLD_80 = 240 SDLK_SEPARATOR = 159
SDLK_WORLD_81 = 241 SDLK_OUT = 160
SDLK_WORLD_82 = 242 SDLK_OPER = 161
SDLK_WORLD_83 = 243 SDLK_CLEARAGAIN = 162
SDLK_WORLD_84 = 244 SDLK_CRSEL = 163
SDLK_WORLD_85 = 245 SDLK_EXSEL = 164
SDLK_WORLD_86 = 246 SDLK_KP_00 = 176
SDLK_WORLD_87 = 247 SDLK_KP_000 = 177
SDLK_WORLD_88 = 248 SDLK_THOUSANDSSEPARATOR = 178
SDLK_WORLD_89 = 249 SDLK_DECIMALSEPARATOR = 179
SDLK_WORLD_90 = 250 SDLK_CURRENCYUNIT = 180
SDLK_WORLD_91 = 251 SDLK_CURRENCYSUBUNIT = 181
SDLK_WORLD_92 = 252 SDLK_KP_LEFTPAREN = 182
SDLK_WORLD_93 = 253 SDLK_KP_RIGHTPAREN = 183
SDLK_WORLD_94 = 254 SDLK_KP_LEFTBRACE = 184
SDLK_WORLD_95 = 255 SDLK_KP_RIGHTBRACE = 185
SDLK_KP0 = 256 SDLK_KP_TAB = 186
SDLK_KP1 = 257 SDLK_KP_BACKSPACE = 187
SDLK_KP2 = 258 SDLK_KP_A = 188
SDLK_KP3 = 259 SDLK_KP_B = 189
SDLK_KP4 = 260 SDLK_KP_C = 190
SDLK_KP5 = 261 SDLK_KP_D = 191
SDLK_KP6 = 262 SDLK_KP_E = 192
SDLK_KP7 = 263 SDLK_KP_F = 193
SDLK_KP8 = 264 SDLK_KP_XOR = 194
SDLK_KP9 = 265 SDLK_KP_POWER = 195
SDLK_KP_PERIOD = 266 SDLK_KP_PERCENT = 196
SDLK_KP_DIVIDE = 267 SDLK_KP_LESS = 197
SDLK_KP_MULTIPLY = 268 SDLK_KP_GREATER = 198
SDLK_KP_MINUS = 269 SDLK_KP_AMPERSAND = 199
SDLK_KP_PLUS = 270 SDLK_KP_DBLAMPERSAND = 200
SDLK_KP_ENTER = 271 SDLK_KP_VERTICALBAR = 201
SDLK_KP_EQUALS = 272 SDLK_KP_DBLVERTICALBAR = 202
SDLK_UP = 273 SDLK_KP_COLON = 203
SDLK_DOWN = 274 SDLK_KP_HASH = 204
SDLK_RIGHT = 275 SDLK_KP_SPACE = 205
SDLK_LEFT = 276 SDLK_KP_AT = 206
SDLK_INSERT = 277 SDLK_KP_EXCLAM = 207
SDLK_HOME = 278 SDLK_KP_MEMSTORE = 208
SDLK_END = 279 SDLK_KP_MEMRECALL = 209
SDLK_PAGEUP = 280 SDLK_KP_MEMCLEAR = 210
SDLK_PAGEDOWN = 281 SDLK_KP_MEMADD = 211
SDLK_F1 = 282 SDLK_KP_MEMSUBTRACT = 212
SDLK_F2 = 283 SDLK_KP_MEMMULTIPLY = 213
SDLK_F3 = 284 SDLK_KP_MEMDIVIDE = 214
SDLK_F4 = 285 SDLK_KP_PLUSMINUS = 215
SDLK_F5 = 286 SDLK_KP_CLEAR = 216
SDLK_F6 = 287 SDLK_KP_CLEARENTRY = 217
SDLK_F7 = 288 SDLK_KP_BINARY = 218
SDLK_F8 = 289 SDLK_KP_OCTAL = 219
SDLK_F9 = 290 SDLK_KP_DECIMAL = 220
SDLK_F10 = 291 SDLK_KP_HEXADECIMAL = 221
SDLK_F11 = 292 SDLK_LCTRL = 224
SDLK_F12 = 293 SDLK_LSHIFT = 225
SDLK_F13 = 294 SDLK_LALT = 226
SDLK_F14 = 295 SDLK_LGUI = 227
SDLK_F15 = 296 SDLK_RCTRL = 228
SDLK_NUMLOCK = 300 SDLK_RSHIFT = 229
SDLK_CAPSLOCK = 301 SDLK_RALT = 230
SDLK_SCROLLOCK = 302 SDLK_RGUI = 231
SDLK_RSHIFT = 303 SDLK_MODE = 257
SDLK_LSHIFT = 304 SDLK_AUDIONEXT = 258
SDLK_RCTRL = 305 SDLK_AUDIOPREV = 259
SDLK_LCTRL = 306 SDLK_AUDIOSTOP = 260
SDLK_RALT = 307 SDLK_AUDIOPLAY = 261
SDLK_LALT = 308 SDLK_AUDIOMUTE = 262
SDLK_RMETA = 309 SDLK_MEDIASELECT = 263
SDLK_LMETA = 310 SDLK_WWW = 264
SDLK_LSUPER = 311 SDLK_MAIL = 265
SDLK_RSUPER = 312 SDLK_CALCULATOR = 266
SDLK_MODE = 313 SDLK_COMPUTER = 267
SDLK_COMPOSE = 314 SDLK_AC_SEARCH = 268
SDLK_HELP = 315 SDLK_AC_HOME = 269
SDLK_PRINT = 316 SDLK_AC_BACK = 270
SDLK_SYSREQ = 317 SDLK_AC_FORWARD = 271
SDLK_BREAK = 318 SDLK_AC_STOP = 272
SDLK_MENU = 319 SDLK_AC_REFRESH = 273
SDLK_POWER = 320 SDLK_AC_BOOKMARKS = 274
SDLK_EURO = 321 SDLK_BRIGHTNESSDOWN = 275
SDLK_UNDO = 322 SDLK_BRIGHTNESSUP = 276
SDLK_DISPLAYSWITCH = 277
SDLK_KBDILLUMTOGGLE = 278
SDLK_KBDILLUMDOWN = 279
SDLK_KBDILLUMUP = 280
SDLK_EJECT = 281
SDLK_SLEEP = 282
SDLK_APP1 = 283
SDLK_APP2 = 284
-- not sure where this is defined, it was copied from the man page -- not sure where this is defined it was copied from the man page
KMOD_NONE = 0x0000 KMOD_NONE = 0x0000
KMOD_LSHIFT = 0x0001 KMOD_LSHIFT = 0x0001
KMOD_RSHIFT = 0x0002 KMOD_RSHIFT = 0x0002
@ -277,4 +284,3 @@ KMOD_CTRL = (KMOD_LCTRL+KMOD_RCTRL)
KMOD_SHIFT = (KMOD_LSHIFT+KMOD_RSHIFT) KMOD_SHIFT = (KMOD_LSHIFT+KMOD_RSHIFT)
KMOD_ALT = (KMOD_LALT+KMOD_RALT) KMOD_ALT = (KMOD_LALT+KMOD_RALT)
KMOD_META = (KMOD_LMETA+KMOD_RMETA) KMOD_META = (KMOD_LMETA+KMOD_RMETA)

View File

@ -213,9 +213,10 @@ struct icelua_entry icelua_client[] = {
{icelua_fn_client_mk_set_title, "mk_set_title"}, {icelua_fn_client_mk_set_title, "mk_set_title"},
{icelua_fn_client_mk_sys_execv, "mk_sys_execv"}, {icelua_fn_client_mk_sys_execv, "mk_sys_execv"},
{icelua_fn_client_text_input_start, "text_input_start"},
{icelua_fn_client_text_input_stop, "text_input_stop"},
{icelua_fn_client_mouse_lock_set, "mouse_lock_set"}, {icelua_fn_client_mouse_lock_set, "mouse_lock_set"},
{icelua_fn_client_mouse_visible_set, "mouse_visible_set"}, {icelua_fn_client_mouse_visible_set, "mouse_visible_set"},
{icelua_fn_client_mouse_visible_set, "mouse_visible_set"},
{icelua_fn_client_mouse_warp, "mouse_warp"}, {icelua_fn_client_mouse_warp, "mouse_warp"},
{icelua_fn_client_map_enable_autorender, "map_enable_autorender"}, {icelua_fn_client_map_enable_autorender, "map_enable_autorender"},
{icelua_fn_client_map_enable_ao, "map_enable_ao"}, {icelua_fn_client_map_enable_ao, "map_enable_ao"},

View File

@ -16,6 +16,28 @@
*/ */
// client functions // client functions
int icelua_fn_client_text_input_start(lua_State *L)
{
#ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else
SDL_StartTextInput();
#endif
return 0;
}
int icelua_fn_client_text_input_stop(lua_State *L)
{
#ifdef DEDI
return luaL_error(L, "EDOOFUS: why the hell is this being called in the dedi version?");
#else
SDL_StopTextInput();
#endif
return 0;
}
int icelua_fn_client_mouse_lock_set(lua_State *L) int icelua_fn_client_mouse_lock_set(lua_State *L)
{ {
int top = icelua_assert_stack(L, 1, 1); int top = icelua_assert_stack(L, 1, 1);

View File

@ -114,7 +114,6 @@ int platform_init(void)
int video_init(void) int video_init(void)
{ {
SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_RED_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_GREEN_SIZE, 8);
SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8); SDL_GL_SetAttribute(SDL_GL_BLUE_SIZE, 8);
@ -130,7 +129,6 @@ int video_init(void)
SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, screen_antialiasing_level); SDL_GL_SetAttribute(SDL_GL_MULTISAMPLESAMPLES, screen_antialiasing_level);
} }
window = SDL_CreateWindow("iceball", window = SDL_CreateWindow("iceball",
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
SDL_WINDOWPOS_UNDEFINED, SDL_WINDOWPOS_UNDEFINED,
@ -139,6 +137,8 @@ int video_init(void)
if(window == NULL) if(window == NULL)
return error_sdl("SDL_CreateWindow"); return error_sdl("SDL_CreateWindow");
SDL_StopTextInput();
gl_context = SDL_GL_CreateContext(window); gl_context = SDL_GL_CreateContext(window);
if(gl_context == NULL) if(gl_context == NULL)
@ -265,8 +265,6 @@ static int ib_client_render_hook(void) {
} }
static int ib_client_key_hook(SDL_Event ev) { static int ib_client_key_hook(SDL_Event ev) {
// inform Lua client
lua_getglobal(lstate_client, "client"); lua_getglobal(lstate_client, "client");
lua_getfield(lstate_client, -1, "hook_key"); lua_getfield(lstate_client, -1, "hook_key");
lua_remove(lstate_client, -2); lua_remove(lstate_client, -2);
@ -276,11 +274,11 @@ static int ib_client_key_hook(SDL_Event ev) {
return 0; return 0;
} }
char ch = ev.key.keysym.sym; int ch = ev.key.keysym.scancode;
//if ((ev.key.keysym.unicode & 0xFF80) == 0) //if ((ev.key.keysym.unicode & 0xFF80) == 0)
// ch = ev.key.keysym.unicode & 0x1FF; // ch = ev.key.keysym.unicode & 0x1FF;
lua_pushinteger(lstate_client, ev.key.keysym.sym); lua_pushinteger(lstate_client, ch);
lua_pushboolean(lstate_client, (ev.type == SDL_KEYDOWN)); lua_pushboolean(lstate_client, (ev.type == SDL_KEYDOWN));
lua_pushinteger(lstate_client, (int) (ev.key.keysym.mod)); lua_pushinteger(lstate_client, (int) (ev.key.keysym.mod));
lua_pushinteger(lstate_client, ch); lua_pushinteger(lstate_client, ch);
@ -294,6 +292,29 @@ static int ib_client_key_hook(SDL_Event ev) {
return 0; return 0;
} }
static int ib_client_text_hook(SDL_Event ev) {
lua_getglobal(lstate_client, "client");
lua_getfield(lstate_client, -1, "hook_text");
lua_remove(lstate_client, -2);
if (lua_isnil(lstate_client, -1)) {
// not hooked? ignore!
lua_pop(lstate_client, 1);
return 0;
}
char *str = ev.text.text;
lua_pushstring(lstate_client, str);
if (lua_pcall(lstate_client, 1, 0, 0) != 0) {
printf("Lua Client Error (text): %s\n", lua_tostring(lstate_client, -1));
lua_pop(lstate_client, 1);
return 1;
}
return 0;
}
static int ib_client_mouse_press_hook(SDL_Event ev) { static int ib_client_mouse_press_hook(SDL_Event ev) {
lua_getglobal(lstate_client, "client"); lua_getglobal(lstate_client, "client");
lua_getfield(lstate_client, -1, "hook_mouse_button"); lua_getfield(lstate_client, -1, "hook_mouse_button");
@ -461,6 +482,9 @@ int poll_events(void)
case SDL_KEYDOWN: case SDL_KEYDOWN:
quitflag = ib_client_key_hook(ev); quitflag = ib_client_key_hook(ev);
break; break;
case SDL_TEXTINPUT:
quitflag = ib_client_text_hook(ev);
break;
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
quitflag = ib_client_mouse_press_hook(ev); quitflag = ib_client_mouse_press_hook(ev);