diff options
-rw-r--r-- | backends/PalmOS/Src/palmevt.cpp | 32 | ||||
-rw-r--r-- | backends/dc/input.cpp | 8 | ||||
-rw-r--r-- | backends/gp32/gp32.cpp | 10 | ||||
-rw-r--r-- | backends/midi/mt32.cpp | 2 | ||||
-rw-r--r-- | backends/morphos/morphos.cpp | 20 | ||||
-rw-r--r-- | backends/sdl/events.cpp | 62 | ||||
-rw-r--r-- | backends/wince/wince-sdl.cpp | 18 | ||||
-rw-r--r-- | backends/x11/x11.cpp | 18 | ||||
-rw-r--r-- | common/system.h | 49 | ||||
-rw-r--r-- | gui/newgui.cpp | 2 | ||||
-rw-r--r-- | kyra/kyra.cpp | 2 | ||||
-rw-r--r-- | queen/input.cpp | 2 | ||||
-rw-r--r-- | queen/journal.cpp | 2 | ||||
-rw-r--r-- | saga/input.cpp | 2 | ||||
-rw-r--r-- | scumm/input.cpp | 2 | ||||
-rw-r--r-- | simon/simon.cpp | 2 | ||||
-rw-r--r-- | sky/control.cpp | 2 | ||||
-rw-r--r-- | sky/intro.cpp | 4 | ||||
-rw-r--r-- | sky/mouse.cpp | 4 | ||||
-rw-r--r-- | sky/sky.cpp | 2 | ||||
-rw-r--r-- | sword1/animation.cpp | 2 | ||||
-rw-r--r-- | sword1/control.cpp | 2 | ||||
-rw-r--r-- | sword1/credits.cpp | 2 | ||||
-rw-r--r-- | sword1/sword1.cpp | 2 | ||||
-rw-r--r-- | sword2/driver/animation.cpp | 2 | ||||
-rw-r--r-- | sword2/sword2.cpp | 2 |
26 files changed, 146 insertions, 111 deletions
diff --git a/backends/PalmOS/Src/palmevt.cpp b/backends/PalmOS/Src/palmevt.cpp index 48ec8ae81a..1fcbf123aa 100644 --- a/backends/PalmOS/Src/palmevt.cpp +++ b/backends/PalmOS/Src/palmevt.cpp @@ -56,7 +56,7 @@ void OSystem_PALMOS::SimulateArrowKeys(Event &event, Int8 iHoriz, Int8 iVert) { y = (y < 0 ) ? 0 : y; y = (y >= _screenHeight ) ? _screenHeight - 1 : y; - event.event_code = EVENT_MOUSEMOVE; + event.type = EVENT_MOUSEMOVE; event.mouse.x = x; event.mouse.y = y; set_mouse_pos(x, y); @@ -126,7 +126,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { Int8 sy = 0; if (keyCurrentState & _keyMouse.bitButLeft) { - event.event_code = EVENT_LBUTTONDOWN; + event.type = EVENT_LBUTTONDOWN; event.mouse.x = _mouseCurState.x; event.mouse.y = _mouseCurState.y; _lastKeyPressed = kLastKeyNone; @@ -165,7 +165,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { // ESC key case vchrLaunch: _lastKeyPressed = kLastKeyNone; - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = 27; event.kbd.ascii = 27; event.kbd.flags = 0; @@ -176,7 +176,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { case vchrMenu: case vchrThumbWheelBack: // Tapwave back button _lastKeyPressed = kLastKeyNone; - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = 319; event.kbd.ascii = 319; event.kbd.flags = 0; @@ -185,7 +185,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { case vchrCalc: if (_lastKeyPressed & kLastKeyCalc) if ((getMillis() - _exit_delay) <= (EXITDELAY)) - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; _exit_delay = getMillis(); _lastKeyPressed = kLastKeyCalc; @@ -197,7 +197,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { #ifndef DISABLE_TAPWAVE case vchrActionRight: #endif - event.event_code = EVENT_RBUTTONDOWN; + event.type = EVENT_RBUTTONDOWN; event.mouse.x = _mouseCurState.x; event.mouse.y = _mouseCurState.y; _lastKeyPressed = kLastKeyNone; @@ -213,11 +213,11 @@ bool OSystem_PALMOS::pollEvent(Event &event) { // wheel case vchrJogUp: - event.event_code = EVENT_WHEELUP; + event.type = EVENT_WHEELUP; return true; case vchrJogDown: - event.event_code = EVENT_WHEELDOWN; + event.type = EVENT_WHEELDOWN; return true; @@ -260,7 +260,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { // ESC key case vchrHard2: _lastKeyPressed = kLastKeyNone; - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = 27; event.kbd.ascii = 27; event.kbd.flags = 0; @@ -269,7 +269,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { // F5 = menu case vchrHard3: _lastKeyPressed = kLastKeyNone; - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = 319; event.kbd.ascii = 319; event.kbd.flags = 0; @@ -321,7 +321,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { b = 0; } else if ((keycode == 'z' && b == KBD_CTRL) || (b == KBD_ALT && keycode == 'x')) { - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; return true; } else if (keycode == 'n' && b == KBD_CTRL) { @@ -344,7 +344,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { #endif } - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = keycode; event.kbd.ascii = keycode; //(keycode>='a' && keycode<='z' && (event.kbd.flags & KBD_SHIFT) ? keycode &~ 0x20 : keycode); event.kbd.flags = b; @@ -367,7 +367,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { return true; _lastEvent = penMoveEvent; - event.event_code = EVENT_MOUSEMOVE; + event.type = EVENT_MOUSEMOVE; event.mouse.x = x; event.mouse.y = y; set_mouse_pos(event.mouse.x, event.mouse.y); @@ -387,7 +387,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { _lastEvent = keyDownEvent; _lastKeyPressed = kLastKeyNone; - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = key; event.kbd.ascii = key; event.kbd.flags = 0; @@ -399,7 +399,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) return true; - event.event_code = EVENT_LBUTTONDOWN; + event.type = EVENT_LBUTTONDOWN; event.mouse.x = x; event.mouse.y = y; set_mouse_pos(event.mouse.x, event.mouse.y); @@ -407,7 +407,7 @@ bool OSystem_PALMOS::pollEvent(Event &event) { case penUpEvent: getCoordinates(&ev, &x, &y); - event.event_code = EVENT_LBUTTONUP; + event.type = EVENT_LBUTTONUP; if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) return true; diff --git a/backends/dc/input.cpp b/backends/dc/input.cpp index a202411f51..5de5115b1f 100644 --- a/backends/dc/input.cpp +++ b/backends/dc/input.cpp @@ -203,13 +203,13 @@ bool OSystem_Dreamcast::pollEvent(Event &event) } event.kbd.ascii = event.kbd.keycode = 0; if(e<0) { - event.event_code = (EventCode)-e; + event.type = (EventType)-e; return true; } else if(e>0) { bool processed = false, down = !(e&(1<<30)); e &= ~(1<<30); if(e < 1000) { - event.event_code = (down? EVENT_KEYDOWN : EVENT_KEYUP); + event.type = (down? EVENT_KEYDOWN : EVENT_KEYUP); event.kbd.keycode = e; event.kbd.ascii = (e>='a' && e<='z' && (event.kbd.flags & KBD_SHIFT)? e &~ 0x20 : e); @@ -221,12 +221,12 @@ bool OSystem_Dreamcast::pollEvent(Event &event) } return processed; } else if(_ms_cur_x != _ms_old_x || _ms_cur_y != _ms_old_y) { - event.event_code = EVENT_MOUSEMOVE; + event.type = EVENT_MOUSEMOVE; _ms_old_x = _ms_cur_x; _ms_old_y = _ms_cur_y; return true; } else { - event.event_code = (EventCode)0; + event.type = (EventType)0; return false; } } diff --git a/backends/gp32/gp32.cpp b/backends/gp32/gp32.cpp index b7b6770ad1..844ec5ace6 100644 --- a/backends/gp32/gp32.cpp +++ b/backends/gp32/gp32.cpp @@ -842,7 +842,7 @@ bool OSystem_GP32::pollEvent(Event &event) { // fixme: make more user-friendly if (key == GPC_VK_NONE) { if (lastevent==EVENT_LBUTTONDOWN) { lastevent=0; - event.event_code = EVENT_LBUTTONUP; + event.type = EVENT_LBUTTONUP; return true; } return false; @@ -855,7 +855,7 @@ bool OSystem_GP32::pollEvent(Event &event) { // fixme: make more user-friendly oldkey=key; eventcount=EVENT_COUNT; - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; if (key & GPC_VK_FL && key & GPC_VK_FR) { // L+R = save state printf("Saving game, please wait..."); @@ -903,12 +903,12 @@ bool OSystem_GP32::pollEvent(Event &event) { // fixme: make more user-friendly if (key & GPC_VK_FA) { lastevent=EVENT_LBUTTONDOWN; - event.event_code = EVENT_LBUTTONDOWN; + event.type = EVENT_LBUTTONDOWN; return true; } if (key & GPC_VK_FB) { lastevent=EVENT_RBUTTONDOWN; - event.event_code = EVENT_RBUTTONDOWN; + event.type = EVENT_RBUTTONDOWN; return true; } @@ -932,7 +932,7 @@ bool OSystem_GP32::pollEvent(Event &event) { // fixme: make more user-friendly if (my>199) my=199; } - event.event_code = EVENT_MOUSEMOVE; + event.type = EVENT_MOUSEMOVE; km.x = event.mouse.x = mx; km.y = event.mouse.y = my; diff --git a/backends/midi/mt32.cpp b/backends/midi/mt32.cpp index 5ca857529c..8bf3807603 100644 --- a/backends/midi/mt32.cpp +++ b/backends/midi/mt32.cpp @@ -113,7 +113,7 @@ public: static int eatSystemEvents() { OSystem::Event event; while (g_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_QUIT: return 1; default: diff --git a/backends/morphos/morphos.cpp b/backends/morphos/morphos.cpp index 1b4e16be5a..5092ead8a7 100644 --- a/backends/morphos/morphos.cpp +++ b/backends/morphos/morphos.cpp @@ -825,7 +825,7 @@ bool OSystem_MorphOS::pollEvent(Event &event) qual |= KBD_CTRL; event.kbd.flags = qual; - event.event_code = (ScummMsg->Code & IECODE_UP_PREFIX) ? EVENT_KEYUP : EVENT_KEYDOWN; + event.type = (ScummMsg->Code & IECODE_UP_PREFIX) ? EVENT_KEYUP : EVENT_KEYDOWN; ScummMsg->Code &= ~IECODE_UP_PREFIX; if (ScummMsg->Code >= RAWKEY_F1 && ScummMsg->Code <= RAWKEY_F10) @@ -849,13 +849,13 @@ bool OSystem_MorphOS::pollEvent(Event &event) /* * Wheelmouse event */ - event.event_code = (ScummMsg->Code == NM_WHEEL_UP) ? EVENT_WHEELUP : EVENT_WHEELDOWN; + event.type = (ScummMsg->Code == NM_WHEEL_UP) ? EVENT_WHEELUP : EVENT_WHEELDOWN; } else if (MapRawKey(&FakedIEvent, &charbuf, 1, NULL) == 1) { if (qual == KBD_CTRL && charbuf == 'z') { - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; break; } else if (qual == KBD_ALT) @@ -870,7 +870,7 @@ bool OSystem_MorphOS::pollEvent(Event &event) } else if (charbuf == 'x') { - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; break; } else if (charbuf == 0x0d) @@ -915,7 +915,7 @@ bool OSystem_MorphOS::pollEvent(Event &event) else if (FullScreenMode) newy = newy <? (ScummScrHeight >> ScummScale)-2; - event.event_code = EVENT_MOUSEMOVE; + event.type = EVENT_MOUSEMOVE; event.mouse.x = newx; event.mouse.y = newy; set_mouse_pos(event.mouse.x, event.mouse.y); @@ -932,19 +932,19 @@ bool OSystem_MorphOS::pollEvent(Event &event) switch (ScummMsg->Code) { case SELECTDOWN: - event.event_code = EVENT_LBUTTONDOWN; + event.type = EVENT_LBUTTONDOWN; break; case SELECTUP: - event.event_code = EVENT_LBUTTONUP; + event.type = EVENT_LBUTTONUP; break; case MENUDOWN: - event.event_code = EVENT_RBUTTONDOWN; + event.type = EVENT_RBUTTONDOWN; break; case MENUUP: - event.event_code = EVENT_RBUTTONUP; + event.type = EVENT_RBUTTONUP; break; default: @@ -957,7 +957,7 @@ bool OSystem_MorphOS::pollEvent(Event &event) } case IDCMP_CLOSEWINDOW: - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; break; } diff --git a/backends/sdl/events.cpp b/backends/sdl/events.cpp index 64da7fb9d4..ca223f51b3 100644 --- a/backends/sdl/events.cpp +++ b/backends/sdl/events.cpp @@ -155,7 +155,7 @@ bool OSystem_SDL::pollEvent(Event &event) { // If the screen mode changed, send an EVENT_SCREEN_CHANGED if (_modeChanged) { _modeChanged = false; - event.event_code = EVENT_SCREEN_CHANGED; + event.type = EVENT_SCREEN_CHANGED; return true; } @@ -222,19 +222,19 @@ bool OSystem_SDL::pollEvent(Event &event) { #ifdef MACOSX // On Macintosh', Cmd-Q quits if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') { - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; return true; } #elif defined(UNIX) // On other unices, Control-Q quits if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'q') { - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; return true; } #else // Ctrl-z and Alt-X quit if ((b == KBD_CTRL && ev.key.keysym.sym == 'z') || (b == KBD_ALT && ev.key.keysym.sym == 'x')) { - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; return true; } #endif @@ -322,26 +322,26 @@ bool OSystem_SDL::pollEvent(Event &event) { #ifdef LINUPY // On Yopy map the End button to quit if ((ev.key.keysym.sym == 293)) { - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; return true; } // Map menu key to f5 (scumm menu) if (ev.key.keysym.sym == 306) { - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = SDLK_F5; event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); return true; } // Map action key to action if (ev.key.keysym.sym == 291) { - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = SDLK_TAB; event.kbd.ascii = mapKey(SDLK_TAB, ev.key.keysym.mod, 0); return true; } // Map OK key to skip cinematic if (ev.key.keysym.sym == 292) { - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = SDLK_ESCAPE; event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0); return true; @@ -351,13 +351,13 @@ bool OSystem_SDL::pollEvent(Event &event) { #ifdef QTOPIA // quit on fn+backspace on zaurus if (ev.key.keysym.sym == 127) { - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; return true; } // map menu key (f11) to f5 (scumm menu) if (ev.key.keysym.sym == SDLK_F11) { - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = SDLK_F5; event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0); } @@ -365,25 +365,25 @@ bool OSystem_SDL::pollEvent(Event &event) { // I wanted to map the calendar button but the calendar comes up // else if (ev.key.keysym.sym == SDLK_SPACE) { - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = SDLK_TAB; event.kbd.ascii = mapKey(SDLK_TAB, ev.key.keysym.mod, 0); } // since we stole space (pause) above we'll rebind it to the tab key on the keyboard else if (ev.key.keysym.sym == SDLK_TAB) { - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = SDLK_SPACE; event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0); } else { // let the events fall through if we didn't change them, this may not be the best way to // set it up, but i'm not sure how sdl would like it if we let if fall through then redid it though. // and yes i have an huge terminal size so i dont wrap soon enough. - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); } #else - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; event.kbd.keycode = ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); #endif @@ -412,7 +412,7 @@ bool OSystem_SDL::pollEvent(Event &event) { return true; case SDL_KEYUP: - event.event_code = EVENT_KEYUP; + event.type = EVENT_KEYUP; event.kbd.keycode = ev.key.keysym.sym; event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); @@ -447,7 +447,7 @@ bool OSystem_SDL::pollEvent(Event &event) { return true; case SDL_MOUSEMOTION: - event.event_code = EVENT_MOUSEMOVE; + event.type = EVENT_MOUSEMOVE; fillMouseEvent(event, ev.motion.x, ev.motion.y); setMousePos(event.mouse.x, event.mouse.y); @@ -455,14 +455,14 @@ bool OSystem_SDL::pollEvent(Event &event) { case SDL_MOUSEBUTTONDOWN: if (ev.button.button == SDL_BUTTON_LEFT) - event.event_code = EVENT_LBUTTONDOWN; + event.type = EVENT_LBUTTONDOWN; else if (ev.button.button == SDL_BUTTON_RIGHT) - event.event_code = EVENT_RBUTTONDOWN; + event.type = EVENT_RBUTTONDOWN; #if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN) else if (ev.button.button == SDL_BUTTON_WHEELUP) - event.event_code = EVENT_WHEELUP; + event.type = EVENT_WHEELUP; else if (ev.button.button == SDL_BUTTON_WHEELDOWN) - event.event_code = EVENT_WHEELDOWN; + event.type = EVENT_WHEELDOWN; #endif else break; @@ -473,9 +473,9 @@ bool OSystem_SDL::pollEvent(Event &event) { case SDL_MOUSEBUTTONUP: if (ev.button.button == SDL_BUTTON_LEFT) - event.event_code = EVENT_LBUTTONUP; + event.type = EVENT_LBUTTONUP; else if (ev.button.button == SDL_BUTTON_RIGHT) - event.event_code = EVENT_RBUTTONUP; + event.type = EVENT_RBUTTONUP; else break; fillMouseEvent(event, ev.button.x, ev.button.y); @@ -484,11 +484,11 @@ bool OSystem_SDL::pollEvent(Event &event) { case SDL_JOYBUTTONDOWN: if (ev.jbutton.button == JOY_BUT_LMOUSE) { - event.event_code = EVENT_LBUTTONDOWN; + event.type = EVENT_LBUTTONDOWN; } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { - event.event_code = EVENT_RBUTTONDOWN; + event.type = EVENT_RBUTTONDOWN; } else { - event.event_code = EVENT_KEYDOWN; + event.type = EVENT_KEYDOWN; switch (ev.jbutton.button) { case JOY_BUT_ESCAPE: event.kbd.keycode = SDLK_ESCAPE; @@ -512,11 +512,11 @@ bool OSystem_SDL::pollEvent(Event &event) { case SDL_JOYBUTTONUP: if (ev.jbutton.button == JOY_BUT_LMOUSE) { - event.event_code = EVENT_LBUTTONUP; + event.type = EVENT_LBUTTONUP; } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { - event.event_code = EVENT_RBUTTONUP; + event.type = EVENT_RBUTTONUP; } else { - event.event_code = EVENT_KEYUP; + event.type = EVENT_KEYUP; switch (ev.jbutton.button) { case JOY_BUT_ESCAPE: event.kbd.keycode = SDLK_ESCAPE; @@ -542,10 +542,10 @@ bool OSystem_SDL::pollEvent(Event &event) { axis = ev.jaxis.value; if ( axis > JOY_DEADZONE) { axis -= JOY_DEADZONE; - event.event_code = EVENT_MOUSEMOVE; + event.type = EVENT_MOUSEMOVE; } else if ( axis < -JOY_DEADZONE ) { axis += JOY_DEADZONE; - event.event_code = EVENT_MOUSEMOVE; + event.type = EVENT_MOUSEMOVE; } else axis = 0; @@ -590,7 +590,7 @@ bool OSystem_SDL::pollEvent(Event &event) { break; case SDL_QUIT: - event.event_code = EVENT_QUIT; + event.type = EVENT_QUIT; return true; } } diff --git a/backends/wince/wince-sdl.cpp b/backends/wince/wince-sdl.cpp index b6fa512773..c159a38a42 100644 --- a/backends/wince/wince-sdl.cpp +++ b/backends/wince/wince-sdl.cpp @@ -1303,7 +1303,7 @@ bool OSystem_WINCE3::pollEvent(Event &event) { // If the screen mode changed, send an EVENT_SCREEN_CHANGED if (_modeChanged) { _modeChanged = false; - event->event_code = EVENT_SCREEN_CHANGED; + event->type = EVENT_SCREEN_CHANGED; return true; } @@ -1313,7 +1313,7 @@ bool OSystem_WINCE3::pollEvent(Event &event) { if (CEActions::Instance()->performMapped(ev.key.keysym.sym, true)) return true; - event->event_code = EVENT_KEYDOWN; + event->type = EVENT_KEYDOWN; event->kbd.keycode = ev.key.keysym.sym; event->kbd.ascii = mapKeyCE(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); @@ -1326,7 +1326,7 @@ bool OSystem_WINCE3::pollEvent(Event &event) { if (CEActions::Instance()->performMapped(ev.key.keysym.sym, false)) return true; - event->event_code = EVENT_KEYUP; + event->type = EVENT_KEYUP; event->kbd.keycode = ev.key.keysym.sym; event->kbd.ascii = mapKeyCE(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode); @@ -1336,16 +1336,16 @@ bool OSystem_WINCE3::pollEvent(Event &event) { return true; case SDL_MOUSEMOTION: - event->event_code = EVENT_MOUSEMOVE; + event->type = EVENT_MOUSEMOVE; fillMouseEvent(*event, ev.motion.x, ev.motion.y); set_mouse_pos(event->mouse.x, event->mouse.y); return true; case SDL_MOUSEBUTTONDOWN: if (ev.button.button == SDL_BUTTON_LEFT) - temp_event.event_code = EVENT_LBUTTONDOWN; + temp_event.type = EVENT_LBUTTONDOWN; else if (ev.button.button == SDL_BUTTON_RIGHT) - temp_event.event_code = EVENT_RBUTTONDOWN; + temp_event.type = EVENT_RBUTTONDOWN; else break; @@ -1371,9 +1371,9 @@ bool OSystem_WINCE3::pollEvent(Event &event) { case SDL_MOUSEBUTTONUP: if (ev.button.button == SDL_BUTTON_LEFT) - temp_event.event_code = EVENT_LBUTTONUP; + temp_event.type = EVENT_LBUTTONUP; else if (ev.button.button == SDL_BUTTON_RIGHT) - temp_event.event_code = EVENT_RBUTTONUP; + temp_event.type = EVENT_RBUTTONUP; else break; @@ -1395,7 +1395,7 @@ bool OSystem_WINCE3::pollEvent(Event &event) { break; case SDL_QUIT: - event->event_code = EVENT_QUIT; + event->type = EVENT_QUIT; return true; } } diff --git a/backends/x11/x11.cpp b/backends/x11/x11.cpp index 2fa8398e29..cdb34dcaf3 100644 --- a/backends/x11/x11.cpp +++ b/backends/x11/x11.cpp @@ -923,7 +923,7 @@ bool OSystem_X11::pollEvent(Event &scumm_event) { } } if (keycode != -1) { - scumm_event.event_code = EVENT_KEYDOWN; + scumm_event.type = EVENT_KEYDOWN; scumm_event.kbd.keycode = keycode; scumm_event.kbd.ascii = (ascii != -1 ? ascii : keycode); scumm_event.kbd.flags = mode; @@ -965,7 +965,7 @@ bool OSystem_X11::pollEvent(Event &scumm_event) { } } if (keycode != -1) { - scumm_event.event_code = EVENT_KEYUP; + scumm_event.type = EVENT_KEYUP; scumm_event.kbd.keycode = keycode; scumm_event.kbd.ascii = (ascii != -1 ? ascii : keycode); scumm_event.kbd.flags = mode; @@ -978,12 +978,12 @@ bool OSystem_X11::pollEvent(Event &scumm_event) { if (report_presses != 0) { if (event.xbutton.button == 1) { if (fake_right_mouse == 0) { - scumm_event.event_code = EVENT_LBUTTONDOWN; + scumm_event.type = EVENT_LBUTTONDOWN; } else { - scumm_event.event_code = EVENT_RBUTTONDOWN; + scumm_event.type = EVENT_RBUTTONDOWN; } } else if (event.xbutton.button == 3) - scumm_event.event_code = EVENT_RBUTTONDOWN; + scumm_event.type = EVENT_RBUTTONDOWN; scumm_event.mouse.x = event.xbutton.x - scumm_x; scumm_event.mouse.y = event.xbutton.y - scumm_y; return true; @@ -994,12 +994,12 @@ bool OSystem_X11::pollEvent(Event &scumm_event) { if (report_presses != 0) { if (event.xbutton.button == 1) { if (fake_right_mouse == 0) { - scumm_event.event_code = EVENT_LBUTTONUP; + scumm_event.type = EVENT_LBUTTONUP; } else { - scumm_event.event_code = EVENT_RBUTTONUP; + scumm_event.type = EVENT_RBUTTONUP; } } else if (event.xbutton.button == 3) - scumm_event.event_code = EVENT_RBUTTONUP; + scumm_event.type = EVENT_RBUTTONUP; scumm_event.mouse.x = event.xbutton.x - scumm_x; scumm_event.mouse.y = event.xbutton.y - scumm_y; return true; @@ -1007,7 +1007,7 @@ bool OSystem_X11::pollEvent(Event &scumm_event) { break; case MotionNotify: - scumm_event.event_code = EVENT_MOUSEMOVE; + scumm_event.type = EVENT_MOUSEMOVE; scumm_event.mouse.x = event.xmotion.x - scumm_x; scumm_event.mouse.y = event.xmotion.y - scumm_y; set_mouse_pos(scumm_event.mouse.x, scumm_event.mouse.y); diff --git a/common/system.h b/common/system.h index 63e642a34c..7f96ec8f46 100644 --- a/common/system.h +++ b/common/system.h @@ -394,10 +394,18 @@ public: /** * The types of events backends may generate. * @see Event + * + * @todo Merge EVENT_LBUTTONDOWN, EVENT_RBUTTONDOWN and EVENT_WHEELDOWN; + * likewiese EVENT_LBUTTONUP, EVENT_RBUTTONUP, EVENT_WHEELUP. + * To do that, we just have to add a field to the Event which + * indicates which button was pressed. */ - enum EventCode { + enum EventType { + /** A key was pressed, details in Event::kbd. */ EVENT_KEYDOWN = 1, + /** A key was released, details in Event::kbd. */ EVENT_KEYUP = 2, + /** The mouse moved, details in Event::mouse. */ EVENT_MOUSEMOVE = 3, EVENT_LBUTTONDOWN = 4, EVENT_LBUTTONUP = 5, @@ -410,19 +418,46 @@ public: EVENT_SCREEN_CHANGED = 11 }; + /** + * Keyboard modifier flags, used for Event::kbd::flags. + */ enum { - KBD_CTRL = 1, - KBD_ALT = 2, - KBD_SHIFT = 4 + KBD_CTRL = 1 << 0, + KBD_ALT = 1 << 1, + KBD_SHIFT = 1 << 2 }; /** * Data structure for an event. A pointer to an instance of Event - * can be passed to pollEvent. + * can be passed to pollEvent. + * @todo Rework/document this structure. It should be made 100% clear which + * field is valid for which event type. + * Implementation wise, we might want to use the classic + * union-of-structs trick. It goes roughly like this: + * struct BasicEvent { + * EventType type; + * }; + * struct MouseMovedEvent : BasicEvent { + * Common::Point pos; + * }; + * struct MouseButtonEvent : MouseMovedEvent { + * int button; + * }; + * struct KeyEvent : BasicEvent { + * ... + * }; + * ... + * union Event { + * EventType type; + * MouseMovedEvent mouse; + * MouseButtonEvent button; + * KeyEvent key; + * ... + * }; */ struct Event { /** The type of the event. */ - EventCode event_code; + EventType type; /** * Keyboard data; only valid for keyboard events (EVENT_KEYDOWN and * EVENT_KEYUP). For all other event types, content is undefined. @@ -521,7 +556,7 @@ public: * Create a new mutex. * @return the newly created mutex, or 0 if an error occured. */ - virtual MutexRef createMutex(void) = 0; + virtual MutexRef createMutex() = 0; /** * Lock the given mutex. diff --git a/gui/newgui.cpp b/gui/newgui.cpp index 32003af657..fb6b2f1784 100644 --- a/gui/newgui.cpp +++ b/gui/newgui.cpp @@ -110,7 +110,7 @@ void NewGui::runLoop() { uint32 time = _system->getMillis(); while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: #if !defined(__PALM_OS__) // init continuous event stream diff --git a/kyra/kyra.cpp b/kyra/kyra.cpp index 5d0056bd75..fb42bbe4c4 100644 --- a/kyra/kyra.cpp +++ b/kyra/kyra.cpp @@ -252,7 +252,7 @@ int KyraEngine::go() { _font->drawStringToPlane("Nothing scripted!", _screen, 320, 200, 85, 189, 136); updateScreen(); while (g_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_QUIT: g_system->quit(); break; diff --git a/queen/input.cpp b/queen/input.cpp index 47bf92737d..ddadd5e35f 100644 --- a/queen/input.cpp +++ b/queen/input.cpp @@ -97,7 +97,7 @@ void Input::delay(uint amount) { do { while (_system->pollEvent(event)) { _idleTime = 0; - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: if (event.kbd.flags == OSystem::KBD_CTRL) { if (event.kbd.keycode == 'd') { diff --git a/queen/journal.cpp b/queen/journal.cpp index 3d77aa4ae8..d246659edc 100644 --- a/queen/journal.cpp +++ b/queen/journal.cpp @@ -63,7 +63,7 @@ void Journal::use() { while (!_quit) { OSystem::Event event; while (system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: handleKeyDown(event.kbd.ascii, event.kbd.keycode); break; diff --git a/saga/input.cpp b/saga/input.cpp index 8a427e38f5..77786a4ea7 100644 --- a/saga/input.cpp +++ b/saga/input.cpp @@ -38,7 +38,7 @@ int SagaEngine::processInput() { Point imousePt; while (g_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: if (event.kbd.flags == OSystem::KBD_CTRL) { if (event.kbd.keycode == 'd') diff --git a/scumm/input.cpp b/scumm/input.cpp index 9780831915..1104a2b8a4 100644 --- a/scumm/input.cpp +++ b/scumm/input.cpp @@ -42,7 +42,7 @@ void ScummEngine::parseEvents() { while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: if (event.kbd.keycode >= '0' && event.kbd.keycode <= '9' && (event.kbd.flags == OSystem::KBD_ALT || diff --git a/simon/simon.cpp b/simon/simon.cpp index 722601f2b6..579f40da05 100644 --- a/simon/simon.cpp +++ b/simon/simon.cpp @@ -4830,7 +4830,7 @@ void SimonEngine::delay(uint amount) { } while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: if (event.kbd.keycode >= '0' && event.kbd.keycode <='9' && (event.kbd.flags == OSystem::KBD_ALT || diff --git a/sky/control.cpp b/sky/control.cpp index 9e5839ddd3..6789afca68 100644 --- a/sky/control.cpp +++ b/sky/control.cpp @@ -1686,7 +1686,7 @@ void Control::delay(unsigned int amount) { do { while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: // Make sure backspace works right (this fixes a small issue on OS X) if (event.kbd.keycode == 8) diff --git a/sky/intro.cpp b/sky/intro.cpp index 5b412a7bc0..2c64f2b07d 100644 --- a/sky/intro.cpp +++ b/sky/intro.cpp @@ -898,10 +898,10 @@ bool Intro::escDelay(uint32 msecs) { int32 nDelay = 0; do { while (_system->pollEvent(event)) { - if (event.event_code == OSystem::EVENT_KEYDOWN) { + if (event.type == OSystem::EVENT_KEYDOWN) { if (event.kbd.keycode == 27) return false; - } else if (event.event_code == OSystem::EVENT_QUIT) { + } else if (event.type == OSystem::EVENT_QUIT) { _quitProg = true; return false; } diff --git a/sky/mouse.cpp b/sky/mouse.cpp index e4a8cc2c4e..472c7590ef 100644 --- a/sky/mouse.cpp +++ b/sky/mouse.cpp @@ -170,8 +170,8 @@ void Mouse::waitMouseNotPressed(void) { while (mousePressed) { _system->delayMillis(20); while (_system->pollEvent(event)) { - if ((event.event_code == OSystem::EVENT_LBUTTONUP) || - (event.event_code == OSystem::EVENT_QUIT)) + if ((event.type == OSystem::EVENT_LBUTTONUP) || + (event.type == OSystem::EVENT_QUIT)) mousePressed = false; } } diff --git a/sky/sky.cpp b/sky/sky.cpp index 13cc4436bc..048044d43f 100644 --- a/sky/sky.cpp +++ b/sky/sky.cpp @@ -453,7 +453,7 @@ void SkyEngine::delay(uint amount) { do { while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: if (event.kbd.flags == OSystem::KBD_CTRL) { if (event.kbd.keycode == 'f') { diff --git a/sword1/animation.cpp b/sword1/animation.cpp index c856b6a411..07788b45f8 100644 --- a/sword1/animation.cpp +++ b/sword1/animation.cpp @@ -141,7 +141,7 @@ void MoviePlayer::play(uint32 id) { frameCount++; OSystem::Event event; while (_sys->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { #ifndef BACKEND_8BIT case OSystem::EVENT_SCREEN_CHANGED: anim->invalidateLookup(true); diff --git a/sword1/control.cpp b/sword1/control.cpp index 989a14b6de..db86a88e0d 100644 --- a/sword1/control.cpp +++ b/sword1/control.cpp @@ -993,7 +993,7 @@ void Control::delay(uint32 msecs) { do { while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: // Make sure backspace works right (this fixes a small issue on OS X) diff --git a/sword1/credits.cpp b/sword1/credits.cpp index 0454bbe163..4e55d75556 100644 --- a/sword1/credits.cpp +++ b/sword1/credits.cpp @@ -273,7 +273,7 @@ void CreditsPlayer::delay(int msecs) { uint32 start = _system->getMillis(); do { while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_QUIT: SwordEngine::_systemVars.engineQuit = true; break; diff --git a/sword1/sword1.cpp b/sword1/sword1.cpp index f5f1f8bad4..86e986dc40 100644 --- a/sword1/sword1.cpp +++ b/sword1/sword1.cpp @@ -1292,7 +1292,7 @@ void SwordEngine::delay(uint amount) { //copied and mutilated from sky.cpp do { while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: // Make sure backspace works right (this fixes a small issue on OS X) diff --git a/sword2/driver/animation.cpp b/sword2/driver/animation.cpp index 69dbc0289a..524f6e09ae 100644 --- a/sword2/driver/animation.cpp +++ b/sword2/driver/animation.cpp @@ -255,7 +255,7 @@ int32 MoviePlayer::play(const char *filename, MovieTextObject *text[], byte *mus OSystem::Event event; while (_sys->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { #ifndef BACKEND_8BIT case OSystem::EVENT_SCREEN_CHANGED: anim->invalidateLookup(true); diff --git a/sword2/sword2.cpp b/sword2/sword2.cpp index b37d820eea..27ce3e0ae3 100644 --- a/sword2/sword2.cpp +++ b/sword2/sword2.cpp @@ -419,7 +419,7 @@ void Sword2Engine::parseEvents() { OSystem::Event event; while (_system->pollEvent(event)) { - switch (event.event_code) { + switch (event.type) { case OSystem::EVENT_KEYDOWN: if (!(_eventFilter & RD_KEYDOWN)) { _keyboardEvent.pending = true; |