| @@ -93,7 +93,7 @@ liblolcore_sources = \ | |||
| gpu/rendercontext.cpp \ | |||
| \ | |||
| input/input.cpp input/input.h input/input_internal.h input/keys.h \ | |||
| input/scancodes.h input/controller.cpp input/controller.h \ | |||
| input/controller.cpp input/controller.h \ | |||
| \ | |||
| gpu/defaultmaterial.lolfx \ | |||
| gpu/tile.lolfx gpu/palette.lolfx gpu/line.lolfx \ | |||
| @@ -28,40 +28,57 @@ array<String> InputDevice::GetAvailableDevices() | |||
| return result; | |||
| } | |||
| void InputDeviceInternal::AddKey(const char* name) | |||
| void InputDeviceInternal::AddKey(int index, const char* name) | |||
| { | |||
| m_keynames.Push(name); | |||
| m_keys.Push(false); | |||
| if (index == -1) | |||
| index = m_keynames.Count(); | |||
| while (index >= m_keynames.Count()) | |||
| { | |||
| m_keynames.Push(name); | |||
| m_keys.Push(false); | |||
| } | |||
| m_keynames.Last() = name; | |||
| } | |||
| void InputDeviceInternal::AddAxis(const char* name, float sensitivity) | |||
| void InputDeviceInternal::AddAxis(int index, const char* name, float sensitivity) | |||
| { | |||
| m_axisnames.Push(name); | |||
| m_axis.Push(0.0f, sensitivity); | |||
| if (index == -1) | |||
| index = m_axisnames.Count(); | |||
| while (index >= m_axisnames.Count()) | |||
| { | |||
| m_axisnames.Push(name); | |||
| m_axis.Push(0.0f, 1.0f); | |||
| } | |||
| m_axisnames.Last() = name; | |||
| m_axis.Last().m1 = 0.0f; | |||
| m_axis.Last().m2 = sensitivity; | |||
| } | |||
| void InputDeviceInternal::AddCursor(const char* name) | |||
| void InputDeviceInternal::AddCursor(int index, const char* name) | |||
| { | |||
| m_cursornames.Push(name); | |||
| m_cursors.Push(vec2::zero, ivec2::zero); | |||
| if (index == -1) | |||
| index = m_cursornames.Count(); | |||
| while (index >= m_cursornames.Count()) | |||
| { | |||
| m_cursornames.Push(name); | |||
| m_cursors.Push(vec2::zero, ivec2::zero); | |||
| } | |||
| m_cursornames.Last() = name; | |||
| } | |||
| InputDeviceInternal* InputDeviceInternal::CreateStandardKeyboard() | |||
| { | |||
| InputDeviceInternal* keyboard = new InputDeviceInternal(g_name_keyboard.C()); | |||
| #if USE_OLD_SDL | |||
| /* TODO: deprecate this */ | |||
| # define KEY_FUNC(key, value) \ | |||
| keyboard->AddKey(#key); | |||
| /* Register all scancodes known to SDL (from the USB standard) */ | |||
| # define _SC(id, str, name) keyboard->AddKey(id, #name); | |||
| # include "input/keys.h" | |||
| # undef KEY_FUNC | |||
| #else | |||
| /* "value" is unused, what matters is the index. */ | |||
| # define _SC(value, str, name) \ | |||
| keyboard->AddKey(#name); | |||
| # include "input/scancodes.h" | |||
| #endif | |||
| return keyboard; | |||
| } | |||
| @@ -13,22 +13,60 @@ | |||
| namespace lol | |||
| { | |||
| /** Internal class (not public) that allows to construct an InputDevice dynamically, when the keys, axis and cursors are not known at compile time */ | |||
| /** Internal class (not public) that allows to construct an InputDevice | |||
| * dynamically, when the keys, axis and cursors are not known at | |||
| * compile time. */ | |||
| class InputDeviceInternal : InputDevice | |||
| { | |||
| public: | |||
| InputDeviceInternal(const char* name) : InputDevice(name) { } | |||
| inline InputDeviceInternal(char const * name) : InputDevice(name) { } | |||
| void AddKey(const char* name); | |||
| void AddAxis(const char* name, float sensitivity = 1.0f); | |||
| void AddCursor(const char* name); | |||
| void AddKey(int id, char const * name); | |||
| void SetKey(int index, bool state) { m_keys[index] = state; } | |||
| void SetAxis(int index, float value) { m_axis[index].m1 = value; } | |||
| void SetCursor(int index, const vec2& position, const ivec2& pixel) { m_cursors[index].m1 = position; m_cursors[index].m2 = pixel; } | |||
| ivec2 GetCursorPixelPos(int index) { return m_cursors[index].m2; } | |||
| inline void AddKey(char const * name) | |||
| { | |||
| AddKey(-1, name); | |||
| } | |||
| static bool GetMouseCapture() { return m_capturemouse; } | |||
| void AddAxis(int id, char const * name, float sensitivity = 1.0f); | |||
| inline void AddAxis(char const * name, float sensitivity = 1.0f) | |||
| { | |||
| AddAxis(-1, name, sensitivity); | |||
| } | |||
| void AddCursor(int id, char const * name); | |||
| inline void AddCursor(char const * name) | |||
| { | |||
| AddCursor(-1, name); | |||
| } | |||
| void SetKey(int id, bool state) | |||
| { | |||
| m_keys[id] = state; | |||
| } | |||
| void SetAxis(int id, float value) | |||
| { | |||
| m_axis[id].m1 = value; | |||
| } | |||
| void SetCursor(int id, vec2 const & position, ivec2 const & pixel) | |||
| { | |||
| m_cursors[id].m1 = position; | |||
| m_cursors[id].m2 = pixel; | |||
| } | |||
| ivec2 GetCursorPixelPos(int id) | |||
| { | |||
| return m_cursors[id].m2; | |||
| } | |||
| static bool GetMouseCapture() | |||
| { | |||
| return m_capturemouse; | |||
| } | |||
| static InputDeviceInternal* CreateStandardKeyboard(); | |||
| static InputDeviceInternal* CreateStandardMouse(); | |||
| @@ -2,265 +2,286 @@ | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2013 Benjamin Litzelmann | |||
| // (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License) Version 2) as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // | |||
| #if defined KEY_FUNC | |||
| /* A list of typical keyboard scancodes, along with a user-friendly | |||
| * name and, if possible, a string representation. */ | |||
| #if !defined _SC | |||
| # error scancode.h included without the _SC macro | |||
| #endif | |||
| _SC(0, "", Unknown) | |||
| /* Usage page 0x07 */ | |||
| _SC(4, "A", A) | |||
| _SC(5, "B", B) | |||
| _SC(6, "C", C) | |||
| _SC(7, "D", D) | |||
| _SC(8, "E", E) | |||
| _SC(9, "F", F) | |||
| _SC(10, "G", G) | |||
| _SC(11, "H", H) | |||
| _SC(12, "I", I) | |||
| _SC(13, "J", J) | |||
| _SC(14, "K", K) | |||
| _SC(15, "L", L) | |||
| _SC(16, "M", M) | |||
| _SC(17, "N", N) | |||
| _SC(18, "O", O) | |||
| _SC(19, "P", P) | |||
| _SC(20, "Q", Q) | |||
| _SC(21, "R", R) | |||
| _SC(22, "S", S) | |||
| _SC(23, "T", T) | |||
| _SC(24, "U", U) | |||
| _SC(25, "V", V) | |||
| _SC(26, "W", W) | |||
| _SC(27, "X", X) | |||
| _SC(28, "Y", Y) | |||
| _SC(29, "Z", Z) | |||
| _SC(30, "1", 1) | |||
| _SC(31, "2", 2) | |||
| _SC(32, "3", 3) | |||
| _SC(33, "4", 4) | |||
| _SC(34, "5", 5) | |||
| _SC(35, "6", 6) | |||
| _SC(36, "7", 7) | |||
| _SC(37, "8", 8) | |||
| _SC(38, "9", 9) | |||
| _SC(39, "0", 0) | |||
| _SC(40, "\n", Return) | |||
| _SC(41, "\x1b", Escape) | |||
| _SC(42, "\b", Backspace) | |||
| _SC(43, "\t", Tab) | |||
| _SC(44, " ", Space) | |||
| _SC(45, "-", Minus) | |||
| _SC(46, "=", Equals) | |||
| _SC(47, "<", LeftBracket) | |||
| _SC(48, ">", RightBracket) | |||
| _SC(49, "\\", Backslash) | |||
| _SC(50, "", NonUSHash) | |||
| _SC(51, ";", Semicolon) | |||
| _SC(52, "\'", Apostrophe) | |||
| _SC(53, "`", Grave) | |||
| _SC(54, ",", Comma) | |||
| _SC(55, ".", Period) | |||
| _SC(56, "/", Slash) | |||
| _SC(57, "", CapsLock) | |||
| _SC(58, "", F1) | |||
| _SC(59, "", F2) | |||
| _SC(60, "", F3) | |||
| _SC(61, "", F4) | |||
| _SC(62, "", F5) | |||
| _SC(63, "", F6) | |||
| _SC(64, "", F7) | |||
| _SC(65, "", F8) | |||
| _SC(66, "", F9) | |||
| _SC(67, "", F10) | |||
| _SC(68, "", F11) | |||
| _SC(69, "", F12) | |||
| _SC(70, "", PrintScreen) | |||
| _SC(71, "", ScrollLock) | |||
| _SC(72, "", Pause) | |||
| _SC(73, "", Insert) | |||
| _SC(74, "", Home) | |||
| _SC(75, "", PageUp) | |||
| _SC(76, "", Delete) | |||
| _SC(77, "", End) | |||
| _SC(78, "", PageDown) | |||
| _SC(79, "", Right) | |||
| _SC(80, "", Left) | |||
| _SC(81, "", Down) | |||
| _SC(82, "", Up) | |||
| _SC(83, "", NumLockClear) | |||
| _SC(84, "/", KP_Divide) | |||
| _SC(85, "*", KP_Multiply) | |||
| _SC(86, "-", KP_Minus) | |||
| _SC(87, "+", KP_Plus) | |||
| _SC(88, "", KP_Enter) | |||
| _SC(89, "1", KP_1) | |||
| _SC(90, "2", KP_2) | |||
| _SC(91, "3", KP_3) | |||
| _SC(92, "4", KP_4) | |||
| _SC(93, "5", KP_5) | |||
| _SC(94, "6", KP_6) | |||
| _SC(95, "7", KP_7) | |||
| _SC(96, "8", KP_8) | |||
| _SC(97, "9", KP_9) | |||
| _SC(98, "0", KP_0) | |||
| _SC(99, ".", KP_Period) | |||
| _SC(100, "", NonUSBackslash) | |||
| _SC(101, "", Application) | |||
| _SC(102, "^", Power) | |||
| _SC(103, "=", KP_Equals) | |||
| _SC(104, "", F13) | |||
| _SC(105, "", F14) | |||
| _SC(106, "", F15) | |||
| _SC(107, "", F16) | |||
| _SC(108, "", F17) | |||
| _SC(109, "", F18) | |||
| _SC(110, "", F19) | |||
| _SC(111, "", F20) | |||
| _SC(112, "", F21) | |||
| _SC(113, "", F22) | |||
| _SC(114, "", F23) | |||
| _SC(115, "", F24) | |||
| _SC(116, "", Execute) | |||
| _SC(117, "", Help) | |||
| _SC(118, "", Menu) | |||
| _SC(119, "", Select) | |||
| _SC(120, "", Stop) | |||
| _SC(121, "", Again) | |||
| _SC(122, "", Undo) | |||
| _SC(123, "", Cut) | |||
| _SC(124, "", Copy) | |||
| _SC(125, "", Paste) | |||
| _SC(126, "", Find) | |||
| _SC(127, "", Mute) | |||
| _SC(128, "", VolumeUp) | |||
| _SC(129, "", VolumeDOwn) | |||
| _SC(133, "", KP_Comma) | |||
| _SC(134, "", KP_EqualsAS400) | |||
| _SC(135, "", International1) | |||
| _SC(136, "", International2) | |||
| _SC(137, "", International3) | |||
| _SC(138, "", International4) | |||
| _SC(139, "", International5) | |||
| _SC(140, "", International6) | |||
| _SC(141, "", International7) | |||
| _SC(142, "", International8) | |||
| _SC(143, "", International9) | |||
| _SC(144, "", Lang1) | |||
| _SC(145, "", Lang2) | |||
| _SC(146, "", Lang3) | |||
| _SC(147, "", Lang4) | |||
| _SC(148, "", Lang5) | |||
| _SC(149, "", Lang6) | |||
| _SC(150, "", Lang7) | |||
| _SC(151, "", Lang8) | |||
| _SC(152, "", Lang9) | |||
| _SC(153, "", AltErase) | |||
| _SC(154, "", SysReq) | |||
| _SC(155, "", Cancel) | |||
| _SC(156, "", Clear) | |||
| _SC(157, "", Prior) | |||
| _SC(158, "", Return2) | |||
| _SC(159, "", Separator) | |||
| _SC(160, "", Out) | |||
| _SC(161, "", Oper) | |||
| _SC(162, "", ClearAgain) | |||
| _SC(163, "", CrSel) | |||
| _SC(164, "", ExSel) | |||
| _SC(176, "", KP_00) | |||
| _SC(177, "", KP_000) | |||
| _SC(178, "", ThousandsSeparator) | |||
| _SC(179, "", DecimalSeparator) | |||
| _SC(180, "", CurrencyUnit) | |||
| _SC(181, "", CurrencySubunit) | |||
| _SC(182, "(", KP_LeftParen) | |||
| _SC(183, ")", KP_RightParen) | |||
| _SC(184, "{", KP_LeftBrace) | |||
| _SC(185, "}", KP_RightBrace) | |||
| _SC(186, "\t", KP_Tab) | |||
| _SC(187, "", KP_Backspace) | |||
| _SC(188, "A", KP_A) | |||
| _SC(189, "B", KP_B) | |||
| _SC(190, "C", KP_C) | |||
| _SC(191, "D", KP_D) | |||
| _SC(192, "E", KP_E) | |||
| _SC(193, "F", KP_F) | |||
| _SC(194, "", KP_Xor) | |||
| _SC(195, "^", KP_Power) | |||
| _SC(196, "%", KP_Percent) | |||
| _SC(197, "<", KP_Less) | |||
| _SC(198, ">", KP_Greater) | |||
| _SC(199, "&", KP_Ampersand) | |||
| _SC(200, "&&", KP_DblAmpersand) | |||
| _SC(201, "|", KP_VerticalBar) | |||
| _SC(202, "||", KP_DblVerticalBar) | |||
| _SC(203, ":", KP_Colon) | |||
| _SC(204, "#", KP_Hash) | |||
| _SC(205, " ", KP_Space) | |||
| _SC(206, "@", KP_At) | |||
| _SC(207, "!", KP_Exclam) | |||
| _SC(208, "", KP_MemStore) | |||
| _SC(209, "", KP_MemRecall) | |||
| _SC(210, "", KP_MemClear) | |||
| _SC(211, "", KP_MemAdd) | |||
| _SC(212, "", KP_MemSubtract) | |||
| _SC(213, "", KP_MemMultiply) | |||
| _SC(214, "", KP_MemDivide) | |||
| _SC(215, "", KP_PlusMinus) | |||
| _SC(216, "", KP_Clear) | |||
| _SC(217, "", KP_ClearEntry) | |||
| _SC(218, "", KP_Binary) | |||
| _SC(219, "", KP_Octal) | |||
| _SC(220, "", KP_Decimal) | |||
| _SC(221, "", KP_Hexadecimal) | |||
| /* ASCII mapped keys */ | |||
| KEY_FUNC(Unknown, 0) | |||
| KEY_FUNC(First, 0) | |||
| KEY_FUNC(Backspace, 8) | |||
| KEY_FUNC(Tab, (int)'\t') | |||
| KEY_FUNC(Clear, 12) | |||
| KEY_FUNC(Return, 13) | |||
| KEY_FUNC(Pause, 19) | |||
| KEY_FUNC(Escape, 27) | |||
| KEY_FUNC(Space, (int)' ') | |||
| KEY_FUNC(Exclaim, (int)'!') | |||
| KEY_FUNC(DoubleQuote, (int)'"') | |||
| KEY_FUNC(Hash, (int)'#') | |||
| KEY_FUNC(Dollar, (int)'$') | |||
| KEY_FUNC(Ampersand, (int)'&') | |||
| KEY_FUNC(Quote, (int)'\'') | |||
| KEY_FUNC(LeftParen, (int)'(') | |||
| KEY_FUNC(RightParen, (int)')') | |||
| KEY_FUNC(Asterisk, (int)'*') | |||
| KEY_FUNC(Plus, (int)'+') | |||
| KEY_FUNC(Comma, (int)',') | |||
| KEY_FUNC(Minus, (int)'-') | |||
| KEY_FUNC(Period, (int)'.') | |||
| KEY_FUNC(Slash, (int)'/') | |||
| KEY_FUNC(K0, (int)'0') | |||
| KEY_FUNC(K1, (int)'1') | |||
| KEY_FUNC(K2, (int)'2') | |||
| KEY_FUNC(K3, (int)'3') | |||
| KEY_FUNC(K4, (int)'4') | |||
| KEY_FUNC(K5, (int)'5') | |||
| KEY_FUNC(K6, (int)'6') | |||
| KEY_FUNC(K7, (int)'7') | |||
| KEY_FUNC(K8, (int)'8') | |||
| KEY_FUNC(K9, (int)'9') | |||
| KEY_FUNC(Colon, (int)':') | |||
| KEY_FUNC(Semicolon, (int)';') | |||
| KEY_FUNC(Less, (int)'<') | |||
| KEY_FUNC(Equals, (int)'=') | |||
| KEY_FUNC(Greater, (int)'>') | |||
| KEY_FUNC(Question, (int)'?') | |||
| KEY_FUNC(At, (int)'@') | |||
| /* XXX: SDL decides to skip uppercase characters */ | |||
| KEY_FUNC(LeftBracket, (int)'[') | |||
| KEY_FUNC(BackSlash, (int)'\\') | |||
| KEY_FUNC(RightBracket, (int)']') | |||
| KEY_FUNC(Caret, (int)'^') | |||
| KEY_FUNC(Underscore, (int)'_') | |||
| KEY_FUNC(Backquote, (int)'`') | |||
| KEY_FUNC(A, (int)'a') | |||
| KEY_FUNC(B, (int)'b') | |||
| KEY_FUNC(C, (int)'c') | |||
| KEY_FUNC(D, (int)'d') | |||
| KEY_FUNC(E, (int)'e') | |||
| KEY_FUNC(F, (int)'f') | |||
| KEY_FUNC(G, (int)'g') | |||
| KEY_FUNC(H, (int)'h') | |||
| KEY_FUNC(I, (int)'i') | |||
| KEY_FUNC(J, (int)'j') | |||
| KEY_FUNC(K, (int)'k') | |||
| KEY_FUNC(L, (int)'l') | |||
| KEY_FUNC(M, (int)'m') | |||
| KEY_FUNC(N, (int)'n') | |||
| KEY_FUNC(O, (int)'o') | |||
| KEY_FUNC(P, (int)'p') | |||
| KEY_FUNC(Q, (int)'q') | |||
| KEY_FUNC(R, (int)'r') | |||
| KEY_FUNC(S, (int)'s') | |||
| KEY_FUNC(T, (int)'t') | |||
| KEY_FUNC(U, (int)'u') | |||
| KEY_FUNC(V, (int)'v') | |||
| KEY_FUNC(W, (int)'w') | |||
| KEY_FUNC(X, (int)'x') | |||
| KEY_FUNC(Y, (int)'y') | |||
| KEY_FUNC(Z, (int)'z') | |||
| KEY_FUNC(Delete, 127) | |||
| _SC(224, "", LCtrl) | |||
| _SC(225, "", LShift) | |||
| _SC(226, "", LAlt) | |||
| _SC(227, "", LGui) | |||
| _SC(228, "", RCtrl) | |||
| _SC(229, "", RShift) | |||
| _SC(230, "", RAlt) | |||
| _SC(231, "", RGui) | |||
| /* International keyboard syms */ | |||
| #ifndef KEY_DISABLE_WORLD | |||
| KEY_FUNC(World0, 160) /* 0xA0 */ | |||
| KEY_FUNC(World1, 161) | |||
| KEY_FUNC(World2, 162) | |||
| KEY_FUNC(World3, 163) | |||
| KEY_FUNC(World4, 164) | |||
| KEY_FUNC(World5, 165) | |||
| KEY_FUNC(World6, 166) | |||
| KEY_FUNC(World7, 167) | |||
| KEY_FUNC(World8, 168) | |||
| KEY_FUNC(World9, 169) | |||
| KEY_FUNC(World10, 170) | |||
| KEY_FUNC(World11, 171) | |||
| KEY_FUNC(World12, 172) | |||
| KEY_FUNC(World13, 173) | |||
| KEY_FUNC(World14, 174) | |||
| KEY_FUNC(World15, 175) | |||
| KEY_FUNC(World16, 176) | |||
| KEY_FUNC(World17, 177) | |||
| KEY_FUNC(World18, 178) | |||
| KEY_FUNC(World19, 179) | |||
| KEY_FUNC(World20, 180) | |||
| KEY_FUNC(World21, 181) | |||
| KEY_FUNC(World22, 182) | |||
| KEY_FUNC(World23, 183) | |||
| KEY_FUNC(World24, 184) | |||
| KEY_FUNC(World25, 185) | |||
| KEY_FUNC(World26, 186) | |||
| KEY_FUNC(World27, 187) | |||
| KEY_FUNC(World28, 188) | |||
| KEY_FUNC(World29, 189) | |||
| KEY_FUNC(World30, 190) | |||
| KEY_FUNC(World31, 191) | |||
| KEY_FUNC(World32, 192) | |||
| KEY_FUNC(World33, 193) | |||
| KEY_FUNC(World34, 194) | |||
| KEY_FUNC(World35, 195) | |||
| KEY_FUNC(World36, 196) | |||
| KEY_FUNC(World37, 197) | |||
| KEY_FUNC(World38, 198) | |||
| KEY_FUNC(World39, 199) | |||
| KEY_FUNC(World40, 200) | |||
| KEY_FUNC(World41, 201) | |||
| KEY_FUNC(World42, 202) | |||
| KEY_FUNC(World43, 203) | |||
| KEY_FUNC(World44, 204) | |||
| KEY_FUNC(World45, 205) | |||
| KEY_FUNC(World46, 206) | |||
| KEY_FUNC(World47, 207) | |||
| KEY_FUNC(World48, 208) | |||
| KEY_FUNC(World49, 209) | |||
| KEY_FUNC(World50, 210) | |||
| KEY_FUNC(World51, 211) | |||
| KEY_FUNC(World52, 212) | |||
| KEY_FUNC(World53, 213) | |||
| KEY_FUNC(World54, 214) | |||
| KEY_FUNC(World55, 215) | |||
| KEY_FUNC(World56, 216) | |||
| KEY_FUNC(World57, 217) | |||
| KEY_FUNC(World58, 218) | |||
| KEY_FUNC(World59, 219) | |||
| KEY_FUNC(World60, 220) | |||
| KEY_FUNC(World61, 221) | |||
| KEY_FUNC(World62, 222) | |||
| KEY_FUNC(World63, 223) | |||
| KEY_FUNC(World64, 224) | |||
| KEY_FUNC(World65, 225) | |||
| KEY_FUNC(World66, 226) | |||
| KEY_FUNC(World67, 227) | |||
| KEY_FUNC(World68, 228) | |||
| KEY_FUNC(World69, 229) | |||
| KEY_FUNC(World70, 230) | |||
| KEY_FUNC(World71, 231) | |||
| KEY_FUNC(World72, 232) | |||
| KEY_FUNC(World73, 233) | |||
| KEY_FUNC(World74, 234) | |||
| KEY_FUNC(World75, 235) | |||
| KEY_FUNC(World76, 236) | |||
| KEY_FUNC(World77, 237) | |||
| KEY_FUNC(World78, 238) | |||
| KEY_FUNC(World79, 239) | |||
| KEY_FUNC(World80, 240) | |||
| KEY_FUNC(World81, 241) | |||
| KEY_FUNC(World82, 242) | |||
| KEY_FUNC(World83, 243) | |||
| KEY_FUNC(World84, 244) | |||
| KEY_FUNC(World85, 245) | |||
| KEY_FUNC(World86, 246) | |||
| KEY_FUNC(World87, 247) | |||
| KEY_FUNC(World88, 248) | |||
| KEY_FUNC(World89, 249) | |||
| KEY_FUNC(World90, 250) | |||
| KEY_FUNC(World91, 251) | |||
| KEY_FUNC(World92, 252) | |||
| KEY_FUNC(World93, 253) | |||
| KEY_FUNC(World94, 254) | |||
| KEY_FUNC(World95, 255) /* 0xFF */ | |||
| #endif // !KEY_DISABLE_WORLD | |||
| _SC(257, "", Mode) | |||
| /* Numeric keypad */ | |||
| KEY_FUNC(KP0, 256) | |||
| KEY_FUNC(KP1, 257) | |||
| KEY_FUNC(KP2, 258) | |||
| KEY_FUNC(KP3, 259) | |||
| KEY_FUNC(KP4, 260) | |||
| KEY_FUNC(KP5, 261) | |||
| KEY_FUNC(KP6, 262) | |||
| KEY_FUNC(KP7, 263) | |||
| KEY_FUNC(KP8, 264) | |||
| KEY_FUNC(KP9, 265) | |||
| KEY_FUNC(KPPeriod, 266) | |||
| KEY_FUNC(KPDivide, 267) | |||
| KEY_FUNC(KPMultiply, 268) | |||
| KEY_FUNC(KPMinus, 269) | |||
| KEY_FUNC(KPPlus, 270) | |||
| KEY_FUNC(KPEnter, 271) | |||
| KEY_FUNC(KPEquals, 272) | |||
| /* Usage page 0x0c */ | |||
| /* Arrows + Home/End pad */ | |||
| KEY_FUNC(Up, 273) | |||
| KEY_FUNC(Down, 274) | |||
| KEY_FUNC(Right, 275) | |||
| KEY_FUNC(Left, 276) | |||
| KEY_FUNC(Insert, 277) | |||
| KEY_FUNC(Home, 278) | |||
| KEY_FUNC(End, 279) | |||
| KEY_FUNC(PageUp, 280) | |||
| KEY_FUNC(PageDown, 281) | |||
| _SC(258, "", AudioNext) | |||
| _SC(259, "", AudioPrev) | |||
| _SC(260, "", AudioStop) | |||
| _SC(261, "", AudioPlay) | |||
| _SC(262, "", AudioMute) | |||
| _SC(263, "", MediaSelect) | |||
| _SC(264, "", WWW) | |||
| _SC(265, "", Mail) | |||
| _SC(266, "", Calculator) | |||
| _SC(267, "", Computer) | |||
| _SC(268, "", AC_Search) | |||
| _SC(269, "", AC_Home) | |||
| _SC(270, "", AC_Back) | |||
| _SC(271, "", AC_Forward) | |||
| _SC(272, "", AC_Stop) | |||
| _SC(273, "", AC_Refresh) | |||
| _SC(274, "", AC_Bookmarks) | |||
| /* Function keys */ | |||
| KEY_FUNC(F1, 282) | |||
| KEY_FUNC(F2, 283) | |||
| KEY_FUNC(F3, 284) | |||
| KEY_FUNC(F4, 285) | |||
| KEY_FUNC(F5, 286) | |||
| KEY_FUNC(F6, 287) | |||
| KEY_FUNC(F7, 288) | |||
| KEY_FUNC(F8, 289) | |||
| KEY_FUNC(F9, 290) | |||
| KEY_FUNC(F10, 291) | |||
| KEY_FUNC(F11, 292) | |||
| KEY_FUNC(F12, 293) | |||
| KEY_FUNC(F13, 294) | |||
| KEY_FUNC(F14, 295) | |||
| KEY_FUNC(F15, 296) | |||
| /* Extra SDL scancodes */ | |||
| /* Modifier keys */ | |||
| KEY_FUNC(NumLock, 300) | |||
| KEY_FUNC(CapsLock, 301) | |||
| KEY_FUNC(ScrollLock, 302) | |||
| KEY_FUNC(RightShift, 303) | |||
| KEY_FUNC(LeftShift, 304) | |||
| KEY_FUNC(RightCtrl, 305) | |||
| KEY_FUNC(LeftCtrl, 306) | |||
| KEY_FUNC(RightAlt, 307) | |||
| KEY_FUNC(LeftAlt, 308) | |||
| KEY_FUNC(RightMeta, 309) | |||
| KEY_FUNC(LeftMeta, 310) | |||
| KEY_FUNC(LeftSuper, 311) /* Left "Windows" key */ | |||
| KEY_FUNC(RightSuper, 312) /* Right "Windows" key */ | |||
| KEY_FUNC(Mode, 313) /* "Alt Gr" key */ | |||
| KEY_FUNC(Compose, 314) /* Multi-key compose key */ | |||
| _SC(275, "", BrightnessDown) | |||
| _SC(276, "", BrightnessUp) | |||
| _SC(277, "", DisplaySwitch) | |||
| _SC(278, "", KbdIllumToggle) | |||
| _SC(279, "", KbdIllumDown) | |||
| _SC(280, "", KbdIllumUp) | |||
| _SC(281, "", Eject) | |||
| _SC(282, "", Sleep) | |||
| /* Miscellaneous function keys */ | |||
| KEY_FUNC(Help, 315) | |||
| KEY_FUNC(Print, 316) | |||
| KEY_FUNC(SysReq, 317) | |||
| KEY_FUNC(Break, 318) | |||
| KEY_FUNC(Menu, 319) | |||
| KEY_FUNC(Power, 320) /* Power Macintosh power key */ | |||
| KEY_FUNC(Euro, 321) /* Some european keyboards */ | |||
| KEY_FUNC(Undo, 322) /* Atari keyboard has Undo */ | |||
| _SC(283, "", App1) | |||
| _SC(284, "", App2) | |||
| /* Add any other keys here, but ensure Last value matches the last + 1 */ | |||
| KEY_FUNC(Last, 323) | |||
| #undef _SC | |||
| #endif // KEY_FUNC | |||
| @@ -1,287 +0,0 @@ | |||
| // | |||
| // Lol Engine | |||
| // | |||
| // Copyright: (c) 2010-2013 Benjamin Litzelmann | |||
| // (c) 2010-2014 Sam Hocevar <sam@hocevar.net> | |||
| // | |||
| // This program is free software; you can redistribute it and/or | |||
| // modify it under the terms of the Do What The Fuck You Want To | |||
| // Public License) Version 2) as published by Sam Hocevar. See | |||
| // http://www.wtfpl.net/ for more details. | |||
| // | |||
| /* A list of typical keyboard scancodes, along with a user-friendly | |||
| * name and, if possible, a string representation. */ | |||
| #if !defined _SC | |||
| # error scancode.h included without the _SC macro | |||
| #endif | |||
| _SC(0, "", Unknown) | |||
| /* Usage page 0x07 */ | |||
| _SC(4, "A", A) | |||
| _SC(5, "B", B) | |||
| _SC(6, "C", C) | |||
| _SC(7, "D", D) | |||
| _SC(8, "E", E) | |||
| _SC(9, "F", F) | |||
| _SC(10, "G", G) | |||
| _SC(11, "H", H) | |||
| _SC(12, "I", I) | |||
| _SC(13, "J", J) | |||
| _SC(14, "K", K) | |||
| _SC(15, "L", L) | |||
| _SC(16, "M", M) | |||
| _SC(17, "N", N) | |||
| _SC(18, "O", O) | |||
| _SC(19, "P", P) | |||
| _SC(20, "Q", Q) | |||
| _SC(21, "R", R) | |||
| _SC(22, "S", S) | |||
| _SC(23, "T", T) | |||
| _SC(24, "U", U) | |||
| _SC(25, "V", V) | |||
| _SC(26, "W", W) | |||
| _SC(27, "X", X) | |||
| _SC(28, "Y", Y) | |||
| _SC(29, "Z", Z) | |||
| _SC(30, "1", 1) | |||
| _SC(31, "2", 2) | |||
| _SC(32, "3", 3) | |||
| _SC(33, "4", 4) | |||
| _SC(34, "5", 5) | |||
| _SC(35, "6", 6) | |||
| _SC(36, "7", 7) | |||
| _SC(37, "8", 8) | |||
| _SC(38, "9", 9) | |||
| _SC(39, "0", 0) | |||
| _SC(40, "", Return) | |||
| _SC(41, "", Escape) | |||
| _SC(42, "", Backspace) | |||
| _SC(43, "\t", Tab) | |||
| _SC(44, " ", Space) | |||
| _SC(45, "-", Minus) | |||
| _SC(46, "=", Equals) | |||
| _SC(47, "<", LeftBracket) | |||
| _SC(48, ">", RightBracket) | |||
| _SC(49, "\\", Backslash) | |||
| _SC(50, "", NonUSHash) | |||
| _SC(51, ";", Semicolon) | |||
| _SC(52, "\'", Apostrophe) | |||
| _SC(53, "`", Grave) | |||
| _SC(54, ",", Comma) | |||
| _SC(55, ".", Period) | |||
| _SC(56, "/", Slash) | |||
| _SC(57, "", CapsLock) | |||
| _SC(58, "", F1) | |||
| _SC(59, "", F2) | |||
| _SC(60, "", F3) | |||
| _SC(61, "", F4) | |||
| _SC(62, "", F5) | |||
| _SC(63, "", F6) | |||
| _SC(64, "", F7) | |||
| _SC(65, "", F8) | |||
| _SC(66, "", F9) | |||
| _SC(67, "", F10) | |||
| _SC(68, "", F11) | |||
| _SC(69, "", F12) | |||
| _SC(70, "", PrintScreen) | |||
| _SC(71, "", ScrollLock) | |||
| _SC(72, "", Pause) | |||
| _SC(73, "", Insert) | |||
| _SC(74, "", Home) | |||
| _SC(75, "", PageUp) | |||
| _SC(76, "", Delete) | |||
| _SC(77, "", End) | |||
| _SC(78, "", PageDown) | |||
| _SC(79, "", Right) | |||
| _SC(80, "", Left) | |||
| _SC(81, "", Down) | |||
| _SC(82, "", Up) | |||
| _SC(83, "", NumLockClear) | |||
| _SC(84, "/", KP_Divide) | |||
| _SC(85, "*", KP_Multiply) | |||
| _SC(86, "-", KP_Minus) | |||
| _SC(87, "+", KP_Plus) | |||
| _SC(88, "", KP_Enter) | |||
| _SC(89, "1", KP_1) | |||
| _SC(90, "2", KP_2) | |||
| _SC(91, "3", KP_3) | |||
| _SC(92, "4", KP_4) | |||
| _SC(93, "5", KP_5) | |||
| _SC(94, "6", KP_6) | |||
| _SC(95, "7", KP_7) | |||
| _SC(96, "8", KP_8) | |||
| _SC(97, "9", KP_9) | |||
| _SC(98, "0", KP_0) | |||
| _SC(99, ".", KP_Period) | |||
| _SC(100, "", NonUSBackslash) | |||
| _SC(101, "", Application) | |||
| _SC(102, "^", Power) | |||
| _SC(103, "=", KP_Equals) | |||
| _SC(104, "", F13) | |||
| _SC(105, "", F14) | |||
| _SC(106, "", F15) | |||
| _SC(107, "", F16) | |||
| _SC(108, "", F17) | |||
| _SC(109, "", F18) | |||
| _SC(110, "", F19) | |||
| _SC(111, "", F20) | |||
| _SC(112, "", F21) | |||
| _SC(113, "", F22) | |||
| _SC(114, "", F23) | |||
| _SC(115, "", F24) | |||
| _SC(116, "", Execute) | |||
| _SC(117, "", Help) | |||
| _SC(118, "", Menu) | |||
| _SC(119, "", Select) | |||
| _SC(120, "", Stop) | |||
| _SC(121, "", Again) | |||
| _SC(122, "", Undo) | |||
| _SC(123, "", Cut) | |||
| _SC(124, "", Copy) | |||
| _SC(125, "", Paste) | |||
| _SC(126, "", Find) | |||
| _SC(127, "", Mute) | |||
| _SC(128, "", VolumeUp) | |||
| _SC(129, "", VolumeDOwn) | |||
| _SC(133, "", KP_Comma) | |||
| _SC(134, "", KP_EqualsAS400) | |||
| _SC(135, "", International1) | |||
| _SC(136, "", International2) | |||
| _SC(137, "", International3) | |||
| _SC(138, "", International4) | |||
| _SC(139, "", International5) | |||
| _SC(140, "", International6) | |||
| _SC(141, "", International7) | |||
| _SC(142, "", International8) | |||
| _SC(143, "", International9) | |||
| _SC(144, "", Lang1) | |||
| _SC(145, "", Lang2) | |||
| _SC(146, "", Lang3) | |||
| _SC(147, "", Lang4) | |||
| _SC(148, "", Lang5) | |||
| _SC(149, "", Lang6) | |||
| _SC(150, "", Lang7) | |||
| _SC(151, "", Lang8) | |||
| _SC(152, "", Lang9) | |||
| _SC(153, "", AltErase) | |||
| _SC(154, "", SysReq) | |||
| _SC(155, "", Cancel) | |||
| _SC(156, "", Clear) | |||
| _SC(157, "", Prior) | |||
| _SC(158, "", Return2) | |||
| _SC(159, "", Separator) | |||
| _SC(160, "", Out) | |||
| _SC(161, "", Oper) | |||
| _SC(162, "", ClearAgain) | |||
| _SC(163, "", CrSel) | |||
| _SC(164, "", ExSel) | |||
| _SC(176, "", KP_00) | |||
| _SC(177, "", KP_000) | |||
| _SC(178, "", ThousandsSeparator) | |||
| _SC(179, "", DecimalSeparator) | |||
| _SC(180, "", CurrencyUnit) | |||
| _SC(181, "", CurrencySubunit) | |||
| _SC(182, "(", KP_LeftParen) | |||
| _SC(183, ")", KP_RightParen) | |||
| _SC(184, "{", KP_LeftBrace) | |||
| _SC(185, "}", KP_RightBrace) | |||
| _SC(186, "\t", KP_Tab) | |||
| _SC(187, "", KP_Backspace) | |||
| _SC(188, "A", KP_A) | |||
| _SC(189, "B", KP_B) | |||
| _SC(190, "C", KP_C) | |||
| _SC(191, "D", KP_D) | |||
| _SC(192, "E", KP_E) | |||
| _SC(193, "F", KP_F) | |||
| _SC(194, "", KP_Xor) | |||
| _SC(195, "^", KP_Power) | |||
| _SC(196, "%", KP_Percent) | |||
| _SC(197, "<", KP_Less) | |||
| _SC(198, ">", KP_Greater) | |||
| _SC(199, "&", KP_Ampersand) | |||
| _SC(200, "&&", KP_DblAmpersand) | |||
| _SC(201, "|", KP_VerticalBar) | |||
| _SC(202, "||", KP_DblVerticalBar) | |||
| _SC(203, ":", KP_Colon) | |||
| _SC(204, "#", KP_Hash) | |||
| _SC(205, " ", KP_Space) | |||
| _SC(206, "@", KP_At) | |||
| _SC(207, "!", KP_Exclam) | |||
| _SC(208, "", KP_MemStore) | |||
| _SC(209, "", KP_MemRecall) | |||
| _SC(210, "", KP_MemClear) | |||
| _SC(211, "", KP_MemAdd) | |||
| _SC(212, "", KP_MemSubtract) | |||
| _SC(213, "", KP_MemMultiply) | |||
| _SC(214, "", KP_MemDivide) | |||
| _SC(215, "", KP_PlusMinus) | |||
| _SC(216, "", KP_Clear) | |||
| _SC(217, "", KP_ClearEntry) | |||
| _SC(218, "", KP_Binary) | |||
| _SC(219, "", KP_Octal) | |||
| _SC(220, "", KP_Decimal) | |||
| _SC(221, "", KP_Hexadecimal) | |||
| _SC(224, "", LCtrl) | |||
| _SC(225, "", LShift) | |||
| _SC(226, "", LAlt) | |||
| _SC(227, "", LGui) | |||
| _SC(228, "", RCtrl) | |||
| _SC(229, "", RShift) | |||
| _SC(230, "", RAlt) | |||
| _SC(231, "", RGui) | |||
| _SC(257, "", Mode) | |||
| /* Usage page 0x0c */ | |||
| _SC(258, "", AudioNext) | |||
| _SC(259, "", AudioPrev) | |||
| _SC(260, "", AudioStop) | |||
| _SC(261, "", AudioPlay) | |||
| _SC(262, "", AudioMute) | |||
| _SC(263, "", MediaSelect) | |||
| _SC(264, "", WWW) | |||
| _SC(265, "", Mail) | |||
| _SC(266, "", Calculator) | |||
| _SC(267, "", Computer) | |||
| _SC(268, "", AC_Search) | |||
| _SC(269, "", AC_Home) | |||
| _SC(270, "", AC_Back) | |||
| _SC(271, "", AC_Forward) | |||
| _SC(272, "", AC_Stop) | |||
| _SC(273, "", AC_Refresh) | |||
| _SC(274, "", AC_Bookmarks) | |||
| /* Extra SDL scancodes */ | |||
| _SC(275, "", BrightnessDown) | |||
| _SC(276, "", BrightnessUp) | |||
| _SC(277, "", DisplaySwitch) | |||
| _SC(278, "", KbdIllumToggle) | |||
| _SC(279, "", KbdIllumDown) | |||
| _SC(280, "", KbdIllumUp) | |||
| _SC(281, "", Eject) | |||
| _SC(282, "", Sleep) | |||
| _SC(283, "", App1) | |||
| _SC(284, "", App2) | |||
| #undef _SC | |||
| @@ -285,7 +285,6 @@ | |||
| <ClInclude Include="input\input.h" /> | |||
| <ClInclude Include="input\input_internal.h" /> | |||
| <ClInclude Include="input\keys.h" /> | |||
| <ClInclude Include="input\scancodes.h" /> | |||
| <ClInclude Include="light.h" /> | |||
| <ClInclude Include="loldebug.h" /> | |||
| <ClInclude Include="lolgl.h" /> | |||
| @@ -738,9 +738,6 @@ | |||
| <ClInclude Include="input\keys.h"> | |||
| <Filter>input</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="input\scancodes.h"> | |||
| <Filter>input</Filter> | |||
| </ClInclude> | |||
| <ClInclude Include="input\controller.h"> | |||
| <Filter>input</Filter> | |||
| </ClInclude> | |||
| @@ -181,7 +181,7 @@ SdlApp::~SdlApp() | |||
| SDL_Quit(); | |||
| #elif USE_OLD_SDL | |||
| if (data->m_window) | |||
| SDL_DestroySurface(data->m_window); | |||
| SDL_FreeSurface(data->m_window); | |||
| SDL_Quit(); | |||
| #endif | |||
| @@ -37,6 +37,20 @@ | |||
| namespace lol | |||
| { | |||
| #if USE_OLD_SDL | |||
| /* Quick and dirty for now... This is deprecated anyway. */ | |||
| static int sdl12_to_scancode(int ch, int sc) | |||
| { | |||
| if (ch >= 'a' && ch <= 'z') | |||
| ch = ch - 'a' + 'A'; | |||
| # define _SC(id, str, name) if (ch == str[0]) return id; | |||
| # include "input/keys.h" | |||
| return 0; | |||
| } | |||
| #endif | |||
| /* | |||
| * SDL Input implementation class | |||
| */ | |||
| @@ -199,12 +213,21 @@ void SdlInputData::Tick(float seconds) | |||
| case SDL_QUIT: | |||
| Ticker::Shutdown(); | |||
| break; | |||
| #if 0 | |||
| case SDL_KEYDOWN: | |||
| if (event.key.keysym.unicode) | |||
| fprintf(stderr, "%c (0x%04X)\n", event.key.keysym.unicode, event.key.keysym.unicode); | |||
| break; | |||
| case SDL_KEYUP: | |||
| #if USE_OLD_SDL | |||
| if (int sc = sdl12_to_scancode(event.key.keysym.sym, | |||
| event.key.keysym.scancode)) | |||
| #else | |||
| if (int sc = event.key.keysym.scancode) | |||
| #endif | |||
| m_keyboard->SetKey(sc, event.type == SDL_KEYDOWN); | |||
| else | |||
| Log::Error("unknown keypress (sym 0x%02x, scancode %0d)\n", | |||
| event.key.keysym.sym, event.key.keysym.scancode); | |||
| break; | |||
| case SDL_MOUSEBUTTONDOWN: | |||
| case SDL_MOUSEBUTTONUP: | |||
| { | |||
| @@ -280,25 +303,6 @@ void SdlInputData::Tick(float seconds) | |||
| m_prevmouse = mouse; | |||
| # if USE_SDL | |||
| Uint8 const *sdlstate = SDL_GetKeyboardState(nullptr); | |||
| int keyindex = 0; | |||
| # define _SC(value, str, name) \ | |||
| m_keyboard->SetKey(keyindex++, sdlstate[value] != 0); | |||
| # include "input/scancodes.h" | |||
| # elif USE_OLD_SDL | |||
| Uint8 *sdlstate = SDL_GetKeyState(nullptr); | |||
| int keyindex = 0; | |||
| # define KEY_FUNC(name, index) \ | |||
| m_keyboard->SetKey(keyindex++, sdlstate[index] != 0); | |||
| /* FIXME: we ignore SDLK_WORLD_0, which means our list of | |||
| * keys and SDL's list of keys could be out of sync. */ | |||
| # include "input/keys.h" | |||
| # undef KEY_FUNC | |||
| # endif | |||
| #else | |||
| UNUSED(seconds); | |||
| #endif //USE_SDL | |||