source: trunk/src/platform/sdl/sdlinput.cpp @ 2646

Last change on this file since 2646 was 2646, checked in by sam, 9 years ago

build: more Emscripten improvements; keyboard input works properly now.

  • Property svn:keywords set to Id
File size: 16.9 KB
Line 
1//
2// Lol Engine
3//
4// Copyright: (c) 2010-2013 Sam Hocevar <sam@hocevar.net>
5//   This program is free software; you can redistribute it and/or
6//   modify it under the terms of the Do What The Fuck You Want To
7//   Public License, Version 2, as published by Sam Hocevar. See
8//   http://www.wtfpl.net/ for more details.
9//
10
11#if HAVE_CONFIG_H
12#   include "config.h"
13#endif
14
15#if USE_SDL
16#   if HAVE_SDL_SDL_H
17#      include <SDL/SDL.h>
18#   else
19#      include <SDL.h>
20#   endif
21#endif
22
23#include "core.h"
24#include "sdlinput.h"
25
26/* We force joystick polling because no events are received when
27 * there is no SDL display (eg. on the Raspberry Pi). */
28#define SDL_FORCE_POLL_JOYSTICK 1
29
30namespace lol
31{
32
33/*
34 * SDL Input implementation class
35 */
36
37class SdlInputData
38{
39    friend class SdlInput;
40
41private:
42    void Tick(float seconds);
43
44    static ivec2 GetMousePos();
45#if USE_SDL
46    Array<SDL_Joystick *, Stick *> m_joysticks;
47#endif
48};
49
50/*
51 * Public SdlInput class
52 */
53
54SdlInput::SdlInput()
55  : m_data(new SdlInputData())
56{
57#if USE_SDL
58    /* Enable Unicode translation of keyboard events */
59    SDL_EnableUNICODE(1);
60
61    SDL_Init(SDL_INIT_TIMER | SDL_INIT_JOYSTICK);
62
63#   if !EMSCRIPTEN
64#       if SDL_FORCE_POLL_JOYSTICK
65    SDL_JoystickEventState(SDL_QUERY);
66#       else
67    SDL_JoystickEventState(SDL_ENABLE);
68#       endif
69
70    /* Register all the joysticks we can find, and let the input
71     * system decide what it wants to track. */
72    for (int i = 0; i < SDL_NumJoysticks(); i++)
73    {
74        SDL_Joystick *sdlstick = SDL_JoystickOpen(i);
75
76        /* Blacklist some devices:
77         *  - HDAPS, it's not a real joystick.
78         *  - X360 controllers, Xinput handles them better since
79         *    it won't think there is only one trigger axis. */
80        char const *name = SDL_JoystickName(i);
81        if (strstr(name, "HDAPS")
82#       if USE_XINPUT
83             || strstr(name, "XBOX 360 For Windows")
84#       endif
85             || false)
86        {
87            SDL_JoystickClose(sdlstick);
88            continue;
89        }
90
91        Stick *stick = Input::CreateStick();
92        stick->SetAxisCount(SDL_JoystickNumAxes(sdlstick));
93        stick->SetButtonCount(SDL_JoystickNumButtons(sdlstick));
94
95        /* It's possible to remap axes */
96        //stick->RemapAxis(4, 2);
97        //stick->RemapAxis(2, 4);
98
99        m_data->m_joysticks.Push(sdlstick, stick);
100    }
101#   endif
102#endif
103
104    m_gamegroup = GAMEGROUP_BEFORE;
105}
106
107SdlInput::~SdlInput()
108{
109#if USE_SDL && !EMSCRIPTEN
110    /* Unregister all the joysticks we added */
111    while (m_data->m_joysticks.Count())
112    {
113        SDL_JoystickClose(m_data->m_joysticks[0].m1);
114        Input::DestroyStick(m_data->m_joysticks[0].m2);
115        m_data->m_joysticks.Remove(0);
116    }
117#endif
118    delete m_data;
119}
120
121void SdlInput::TickGame(float seconds)
122{
123    Entity::TickGame(seconds);
124
125#if !_WIN32
126    m_data->Tick(seconds);
127#endif
128}
129
130void SdlInput::TickDraw(float seconds)
131{
132    Entity::TickDraw(seconds);
133
134#if _WIN32
135    m_data->Tick(seconds);
136#endif
137}
138
139void SdlInputData::Tick(float seconds)
140{
141#if USE_SDL
142    /* Handle mouse input */
143    ivec2 mouse = SdlInputData::GetMousePos();;
144    Input::SetMousePos(mouse);
145
146    /* Pump all joystick events because no event is coming to us. */
147#   if SDL_FORCE_POLL_JOYSTICK && !EMSCRIPTEN
148    SDL_JoystickUpdate();
149    for (int j = 0; j < m_joysticks.Count(); j++)
150    {
151        for (int i = 0; i < SDL_JoystickNumButtons(m_joysticks[j].m1); i++)
152            m_joysticks[j].m2->SetButton(i, SDL_JoystickGetButton(m_joysticks[j].m1, i));
153        for (int i = 0; i < SDL_JoystickNumAxes(m_joysticks[j].m1); i++)
154            m_joysticks[j].m2->SetAxis(i, (float)SDL_JoystickGetAxis(m_joysticks[j].m1, i) / 32768.f);
155    }
156#   endif
157
158    /* Handle keyboard and WM events */
159    SDL_Event event;
160    while (SDL_PollEvent(&event))
161    {
162        switch (event.type)
163        {
164        case SDL_QUIT:
165            Ticker::Shutdown();
166            break;
167#if 0
168        case SDL_KEYDOWN:
169            if (event.key.keysym.unicode)
170                fprintf(stderr, "%c (0x%04X)\n", event.key.keysym.unicode, event.key.keysym.unicode);
171            break;
172#endif
173        case SDL_MOUSEBUTTONDOWN:
174        case SDL_MOUSEBUTTONUP:
175        {
176            ivec2 newmouse = SdlInputData::GetMousePos();
177            if (newmouse != mouse)
178                Input::SetMousePos(mouse = newmouse);
179            if (event.type == SDL_MOUSEBUTTONDOWN)
180                Input::SetMouseButton(event.button.button - 1);
181            else
182                Input::UnsetMouseButton(event.button.button - 1);
183            break;
184        }
185
186#   if !SDL_FORCE_POLL_JOYSTICK
187        case SDL_JOYAXISMOTION:
188            m_joysticks[event.jaxis.which].m2->SetAxis(event.jaxis.axis, (float)event.jaxis.value / 32768.f);
189            break;
190
191        case SDL_JOYBUTTONUP:
192        case SDL_JOYBUTTONDOWN:
193            m_joysticks[event.jbutton.which].m2->SetButton(event.jbutton.button, event.jbutton.state);
194            break;
195#   endif
196        }
197    }
198
199    /* Send the whole keyboard state to the input system */
200    Array<uint8_t> &lolstate = Input::GetKeyboardState();
201
202#   if SDL_VERSION_ATLEAST(1,3,0)
203    Uint8 *sdlstate = SDL_GetKeyboardState(nullptr);
204#   else
205    Uint8 *sdlstate = SDL_GetKeyState(nullptr);
206#   endif
207
208    lolstate[Key::Unknown] = sdlstate[SDLK_UNKNOWN];
209    lolstate[Key::Backspace] = sdlstate[SDLK_BACKSPACE];
210    lolstate[Key::Tab] = sdlstate[SDLK_TAB];
211    lolstate[Key::Clear] = sdlstate[SDLK_CLEAR];
212    lolstate[Key::Return] = sdlstate[SDLK_RETURN];
213    lolstate[Key::Pause] = sdlstate[SDLK_PAUSE];
214    lolstate[Key::Escape] = sdlstate[SDLK_ESCAPE];
215    lolstate[Key::Space] = sdlstate[SDLK_SPACE];
216    lolstate[Key::Exclaim] = sdlstate[SDLK_EXCLAIM];
217    lolstate[Key::DoubleQuote] = sdlstate[SDLK_QUOTEDBL];
218    lolstate[Key::Hash] = sdlstate[SDLK_HASH];
219    lolstate[Key::Dollar] = sdlstate[SDLK_DOLLAR];
220    lolstate[Key::Ampersand] = sdlstate[SDLK_AMPERSAND];
221    lolstate[Key::Quote] = sdlstate[SDLK_QUOTE];
222    lolstate[Key::LeftParen] = sdlstate[SDLK_LEFTPAREN];
223    lolstate[Key::RightParen] = sdlstate[SDLK_RIGHTPAREN];
224    lolstate[Key::Asterisk] = sdlstate[SDLK_ASTERISK];
225    lolstate[Key::Plus] = sdlstate[SDLK_PLUS];
226    lolstate[Key::Comma] = sdlstate[SDLK_COMMA];
227    lolstate[Key::Minus] = sdlstate[SDLK_MINUS];
228    lolstate[Key::Period] = sdlstate[SDLK_PERIOD];
229    lolstate[Key::Slash] = sdlstate[SDLK_SLASH];
230    lolstate[Key::K0] = sdlstate[SDLK_0];
231    lolstate[Key::K1] = sdlstate[SDLK_1];
232    lolstate[Key::K2] = sdlstate[SDLK_2];
233    lolstate[Key::K3] = sdlstate[SDLK_3];
234    lolstate[Key::K4] = sdlstate[SDLK_4];
235    lolstate[Key::K5] = sdlstate[SDLK_5];
236    lolstate[Key::K6] = sdlstate[SDLK_6];
237    lolstate[Key::K7] = sdlstate[SDLK_7];
238    lolstate[Key::K8] = sdlstate[SDLK_8];
239    lolstate[Key::K9] = sdlstate[SDLK_9];
240    lolstate[Key::Colon] = sdlstate[SDLK_COLON];
241    lolstate[Key::Semicolon] = sdlstate[SDLK_SEMICOLON];
242    lolstate[Key::Less] = sdlstate[SDLK_LESS];
243    lolstate[Key::Equals] = sdlstate[SDLK_EQUALS];
244    lolstate[Key::Greater] = sdlstate[SDLK_GREATER];
245    lolstate[Key::Question] = sdlstate[SDLK_QUESTION];
246    lolstate[Key::At] = sdlstate[SDLK_AT];
247
248    lolstate[Key::LeftBracket] = sdlstate[SDLK_LEFTBRACKET];
249    lolstate[Key::BackSlash] = sdlstate[SDLK_BACKSLASH];
250    lolstate[Key::RightBracket] = sdlstate[SDLK_RIGHTBRACKET];
251    lolstate[Key::Caret] = sdlstate[SDLK_CARET];
252    lolstate[Key::Underscore] = sdlstate[SDLK_UNDERSCORE];
253    lolstate[Key::Backquote] = sdlstate[SDLK_BACKQUOTE];
254    lolstate[Key::A] = sdlstate[SDLK_a];
255    lolstate[Key::B] = sdlstate[SDLK_b];
256    lolstate[Key::C] = sdlstate[SDLK_c];
257    lolstate[Key::D] = sdlstate[SDLK_d];
258    lolstate[Key::E] = sdlstate[SDLK_e];
259    lolstate[Key::F] = sdlstate[SDLK_f];
260    lolstate[Key::G] = sdlstate[SDLK_g];
261    lolstate[Key::H] = sdlstate[SDLK_h];
262    lolstate[Key::I] = sdlstate[SDLK_i];
263    lolstate[Key::J] = sdlstate[SDLK_j];
264    lolstate[Key::K] = sdlstate[SDLK_k];
265    lolstate[Key::L] = sdlstate[SDLK_l];
266    lolstate[Key::M] = sdlstate[SDLK_m];
267    lolstate[Key::N] = sdlstate[SDLK_n];
268    lolstate[Key::O] = sdlstate[SDLK_o];
269    lolstate[Key::P] = sdlstate[SDLK_p];
270    lolstate[Key::Q] = sdlstate[SDLK_q];
271    lolstate[Key::R] = sdlstate[SDLK_r];
272    lolstate[Key::S] = sdlstate[SDLK_s];
273    lolstate[Key::T] = sdlstate[SDLK_t];
274    lolstate[Key::U] = sdlstate[SDLK_u];
275    lolstate[Key::V] = sdlstate[SDLK_v];
276    lolstate[Key::W] = sdlstate[SDLK_w];
277    lolstate[Key::X] = sdlstate[SDLK_x];
278    lolstate[Key::Y] = sdlstate[SDLK_y];
279    lolstate[Key::Z] = sdlstate[SDLK_z];
280    lolstate[Key::Delete] = sdlstate[SDLK_DELETE];
281
282#if SDLK_WORLD_0
283    lolstate[Key::World0] = sdlstate[SDLK_WORLD_0];
284    lolstate[Key::World1] = sdlstate[SDLK_WORLD_1];
285    lolstate[Key::World2] = sdlstate[SDLK_WORLD_2];
286    lolstate[Key::World3] = sdlstate[SDLK_WORLD_3];
287    lolstate[Key::World4] = sdlstate[SDLK_WORLD_4];
288    lolstate[Key::World5] = sdlstate[SDLK_WORLD_5];
289    lolstate[Key::World6] = sdlstate[SDLK_WORLD_6];
290    lolstate[Key::World7] = sdlstate[SDLK_WORLD_7];
291    lolstate[Key::World8] = sdlstate[SDLK_WORLD_8];
292    lolstate[Key::World9] = sdlstate[SDLK_WORLD_9];
293    lolstate[Key::World10] = sdlstate[SDLK_WORLD_10];
294    lolstate[Key::World11] = sdlstate[SDLK_WORLD_11];
295    lolstate[Key::World12] = sdlstate[SDLK_WORLD_12];
296    lolstate[Key::World13] = sdlstate[SDLK_WORLD_13];
297    lolstate[Key::World14] = sdlstate[SDLK_WORLD_14];
298    lolstate[Key::World15] = sdlstate[SDLK_WORLD_15];
299    lolstate[Key::World16] = sdlstate[SDLK_WORLD_16];
300    lolstate[Key::World17] = sdlstate[SDLK_WORLD_17];
301    lolstate[Key::World18] = sdlstate[SDLK_WORLD_18];
302    lolstate[Key::World19] = sdlstate[SDLK_WORLD_19];
303    lolstate[Key::World20] = sdlstate[SDLK_WORLD_20];
304    lolstate[Key::World21] = sdlstate[SDLK_WORLD_21];
305    lolstate[Key::World22] = sdlstate[SDLK_WORLD_22];
306    lolstate[Key::World23] = sdlstate[SDLK_WORLD_23];
307    lolstate[Key::World24] = sdlstate[SDLK_WORLD_24];
308    lolstate[Key::World25] = sdlstate[SDLK_WORLD_25];
309    lolstate[Key::World26] = sdlstate[SDLK_WORLD_26];
310    lolstate[Key::World27] = sdlstate[SDLK_WORLD_27];
311    lolstate[Key::World28] = sdlstate[SDLK_WORLD_28];
312    lolstate[Key::World29] = sdlstate[SDLK_WORLD_29];
313    lolstate[Key::World30] = sdlstate[SDLK_WORLD_30];
314    lolstate[Key::World31] = sdlstate[SDLK_WORLD_31];
315    lolstate[Key::World32] = sdlstate[SDLK_WORLD_32];
316    lolstate[Key::World33] = sdlstate[SDLK_WORLD_33];
317    lolstate[Key::World34] = sdlstate[SDLK_WORLD_34];
318    lolstate[Key::World35] = sdlstate[SDLK_WORLD_35];
319    lolstate[Key::World36] = sdlstate[SDLK_WORLD_36];
320    lolstate[Key::World37] = sdlstate[SDLK_WORLD_37];
321    lolstate[Key::World38] = sdlstate[SDLK_WORLD_38];
322    lolstate[Key::World39] = sdlstate[SDLK_WORLD_39];
323    lolstate[Key::World40] = sdlstate[SDLK_WORLD_40];
324    lolstate[Key::World41] = sdlstate[SDLK_WORLD_41];
325    lolstate[Key::World42] = sdlstate[SDLK_WORLD_42];
326    lolstate[Key::World43] = sdlstate[SDLK_WORLD_43];
327    lolstate[Key::World44] = sdlstate[SDLK_WORLD_44];
328    lolstate[Key::World45] = sdlstate[SDLK_WORLD_45];
329    lolstate[Key::World46] = sdlstate[SDLK_WORLD_46];
330    lolstate[Key::World47] = sdlstate[SDLK_WORLD_47];
331    lolstate[Key::World48] = sdlstate[SDLK_WORLD_48];
332    lolstate[Key::World49] = sdlstate[SDLK_WORLD_49];
333    lolstate[Key::World50] = sdlstate[SDLK_WORLD_50];
334    lolstate[Key::World51] = sdlstate[SDLK_WORLD_51];
335    lolstate[Key::World52] = sdlstate[SDLK_WORLD_52];
336    lolstate[Key::World53] = sdlstate[SDLK_WORLD_53];
337    lolstate[Key::World54] = sdlstate[SDLK_WORLD_54];
338    lolstate[Key::World55] = sdlstate[SDLK_WORLD_55];
339    lolstate[Key::World56] = sdlstate[SDLK_WORLD_56];
340    lolstate[Key::World57] = sdlstate[SDLK_WORLD_57];
341    lolstate[Key::World58] = sdlstate[SDLK_WORLD_58];
342    lolstate[Key::World59] = sdlstate[SDLK_WORLD_59];
343    lolstate[Key::World60] = sdlstate[SDLK_WORLD_60];
344    lolstate[Key::World61] = sdlstate[SDLK_WORLD_61];
345    lolstate[Key::World62] = sdlstate[SDLK_WORLD_62];
346    lolstate[Key::World63] = sdlstate[SDLK_WORLD_63];
347    lolstate[Key::World64] = sdlstate[SDLK_WORLD_64];
348    lolstate[Key::World65] = sdlstate[SDLK_WORLD_65];
349    lolstate[Key::World66] = sdlstate[SDLK_WORLD_66];
350    lolstate[Key::World67] = sdlstate[SDLK_WORLD_67];
351    lolstate[Key::World68] = sdlstate[SDLK_WORLD_68];
352    lolstate[Key::World69] = sdlstate[SDLK_WORLD_69];
353    lolstate[Key::World70] = sdlstate[SDLK_WORLD_70];
354    lolstate[Key::World71] = sdlstate[SDLK_WORLD_71];
355    lolstate[Key::World72] = sdlstate[SDLK_WORLD_72];
356    lolstate[Key::World73] = sdlstate[SDLK_WORLD_73];
357    lolstate[Key::World74] = sdlstate[SDLK_WORLD_74];
358    lolstate[Key::World75] = sdlstate[SDLK_WORLD_75];
359    lolstate[Key::World76] = sdlstate[SDLK_WORLD_76];
360    lolstate[Key::World77] = sdlstate[SDLK_WORLD_77];
361    lolstate[Key::World78] = sdlstate[SDLK_WORLD_78];
362    lolstate[Key::World79] = sdlstate[SDLK_WORLD_79];
363    lolstate[Key::World80] = sdlstate[SDLK_WORLD_80];
364    lolstate[Key::World81] = sdlstate[SDLK_WORLD_81];
365    lolstate[Key::World82] = sdlstate[SDLK_WORLD_82];
366    lolstate[Key::World83] = sdlstate[SDLK_WORLD_83];
367    lolstate[Key::World84] = sdlstate[SDLK_WORLD_84];
368    lolstate[Key::World85] = sdlstate[SDLK_WORLD_85];
369    lolstate[Key::World86] = sdlstate[SDLK_WORLD_86];
370    lolstate[Key::World87] = sdlstate[SDLK_WORLD_87];
371    lolstate[Key::World88] = sdlstate[SDLK_WORLD_88];
372    lolstate[Key::World89] = sdlstate[SDLK_WORLD_89];
373    lolstate[Key::World90] = sdlstate[SDLK_WORLD_90];
374    lolstate[Key::World91] = sdlstate[SDLK_WORLD_91];
375    lolstate[Key::World92] = sdlstate[SDLK_WORLD_92];
376    lolstate[Key::World93] = sdlstate[SDLK_WORLD_93];
377    lolstate[Key::World94] = sdlstate[SDLK_WORLD_94];
378    lolstate[Key::World95] = sdlstate[SDLK_WORLD_95];
379#endif
380
381    lolstate[Key::KP0] = sdlstate[SDLK_KP0];
382    lolstate[Key::KP1] = sdlstate[SDLK_KP1];
383    lolstate[Key::KP2] = sdlstate[SDLK_KP2];
384    lolstate[Key::KP3] = sdlstate[SDLK_KP3];
385    lolstate[Key::KP4] = sdlstate[SDLK_KP4];
386    lolstate[Key::KP5] = sdlstate[SDLK_KP5];
387    lolstate[Key::KP6] = sdlstate[SDLK_KP6];
388    lolstate[Key::KP7] = sdlstate[SDLK_KP7];
389    lolstate[Key::KP8] = sdlstate[SDLK_KP8];
390    lolstate[Key::KP9] = sdlstate[SDLK_KP9];
391    lolstate[Key::KPPeriod] = sdlstate[SDLK_KP_PERIOD];
392    lolstate[Key::KPDivide] = sdlstate[SDLK_KP_DIVIDE];
393    lolstate[Key::KPMultiply] = sdlstate[SDLK_KP_MULTIPLY];
394    lolstate[Key::KPMinus] = sdlstate[SDLK_KP_MINUS];
395    lolstate[Key::KPPlus] = sdlstate[SDLK_KP_PLUS];
396    lolstate[Key::KPEnter] = sdlstate[SDLK_KP_ENTER];
397    lolstate[Key::KPEquals] = sdlstate[SDLK_KP_EQUALS];
398
399    lolstate[Key::Up] = sdlstate[SDLK_UP];
400    lolstate[Key::Down] = sdlstate[SDLK_DOWN];
401    lolstate[Key::Right] = sdlstate[SDLK_RIGHT];
402    lolstate[Key::Left] = sdlstate[SDLK_LEFT];
403    lolstate[Key::Insert] = sdlstate[SDLK_INSERT];
404    lolstate[Key::Home] = sdlstate[SDLK_HOME];
405    lolstate[Key::End] = sdlstate[SDLK_END];
406    lolstate[Key::PageUp] = sdlstate[SDLK_PAGEUP];
407    lolstate[Key::PageDown] = sdlstate[SDLK_PAGEDOWN];
408
409    lolstate[Key::F1] = sdlstate[SDLK_F1];
410    lolstate[Key::F2] = sdlstate[SDLK_F2];
411    lolstate[Key::F3] = sdlstate[SDLK_F3];
412    lolstate[Key::F4] = sdlstate[SDLK_F4];
413    lolstate[Key::F5] = sdlstate[SDLK_F5];
414    lolstate[Key::F6] = sdlstate[SDLK_F6];
415    lolstate[Key::F7] = sdlstate[SDLK_F7];
416    lolstate[Key::F8] = sdlstate[SDLK_F8];
417    lolstate[Key::F9] = sdlstate[SDLK_F9];
418    lolstate[Key::F10] = sdlstate[SDLK_F10];
419    lolstate[Key::F11] = sdlstate[SDLK_F11];
420    lolstate[Key::F12] = sdlstate[SDLK_F12];
421    lolstate[Key::F13] = sdlstate[SDLK_F13];
422    lolstate[Key::F14] = sdlstate[SDLK_F14];
423    lolstate[Key::F15] = sdlstate[SDLK_F15];
424
425    lolstate[Key::NumLock] = sdlstate[SDLK_NUMLOCK];
426    lolstate[Key::CapsLock] = sdlstate[SDLK_CAPSLOCK];
427    lolstate[Key::ScrollLock] = sdlstate[SDLK_SCROLLOCK];
428    lolstate[Key::RightShift] = sdlstate[SDLK_RSHIFT];
429    lolstate[Key::LeftShift] = sdlstate[SDLK_LSHIFT];
430    lolstate[Key::RightCtrl] = sdlstate[SDLK_RCTRL];
431    lolstate[Key::LeftCtrl] = sdlstate[SDLK_LCTRL];
432    lolstate[Key::RightAlt] = sdlstate[SDLK_RALT];
433    lolstate[Key::LeftAlt] = sdlstate[SDLK_LALT];
434    lolstate[Key::RightMeta] = sdlstate[SDLK_RMETA];
435    lolstate[Key::LeftMeta] = sdlstate[SDLK_LMETA];
436    lolstate[Key::LeftSuper] = sdlstate[SDLK_LSUPER];
437    lolstate[Key::RightSuper] = sdlstate[SDLK_RSUPER];
438    lolstate[Key::Mode] = sdlstate[SDLK_MODE];
439    lolstate[Key::Compose] = sdlstate[SDLK_COMPOSE];
440
441    lolstate[Key::Help] = sdlstate[SDLK_HELP];
442    lolstate[Key::Print] = sdlstate[SDLK_PRINT];
443    lolstate[Key::SysReq] = sdlstate[SDLK_SYSREQ];
444    lolstate[Key::Break] = sdlstate[SDLK_BREAK];
445    lolstate[Key::Menu] = sdlstate[SDLK_MENU];
446    lolstate[Key::Power] = sdlstate[SDLK_POWER];
447    lolstate[Key::Euro] = sdlstate[SDLK_EURO];
448    lolstate[Key::Undo] = sdlstate[SDLK_UNDO];
449
450    UNUSED(seconds);
451#endif
452}
453
454ivec2 SdlInputData::GetMousePos()
455{
456    ivec2 ret(-1, -1);
457
458#if USE_SDL
459#   if !EMSCRIPTEN
460    if (SDL_GetAppState() & SDL_APPMOUSEFOCUS)
461#   endif
462    {
463        SDL_GetMouseState(&ret.x, &ret.y);
464        ret.y = Video::GetSize().y - 1 - ret.y;
465    }
466#endif
467    return ret;
468}
469
470} /* namespace lol */
471
Note: See TracBrowser for help on using the repository browser.