diff options
author | Chris Apers | 2007-01-21 14:15:35 +0000 |
---|---|---|
committer | Chris Apers | 2007-01-21 14:15:35 +0000 |
commit | dd03b8f84b50fd466f4543cd6e9d54518d3c3f17 (patch) | |
tree | 8d9aa07f278a7de956fcb6717b6e82f45794762e /backends/platform/PalmOS | |
parent | 0147a831805d326d6d9b9db68925a19c46c26a2d (diff) | |
download | scummvm-rg350-dd03b8f84b50fd466f4543cd6e9d54518d3c3f17.tar.gz scummvm-rg350-dd03b8f84b50fd466f4543cd6e9d54518d3c3f17.tar.bz2 scummvm-rg350-dd03b8f84b50fd466f4543cd6e9d54518d3c3f17.zip |
Cleanup event code
Added key up for mouse buttons so that we can control Gobliiins and Touche properly
svn-id: r25147
Diffstat (limited to 'backends/platform/PalmOS')
-rw-r--r-- | backends/platform/PalmOS/Src/base_event.cpp | 54 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/be_base.cpp | 11 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/be_base.h | 13 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/be_os5.cpp | 4 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/be_zodiac.cpp | 10 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/os5_event.cpp | 60 | ||||
-rw-r--r-- | backends/platform/PalmOS/Src/zodiac_event.cpp | 30 |
7 files changed, 77 insertions, 105 deletions
diff --git a/backends/platform/PalmOS/Src/base_event.cpp b/backends/platform/PalmOS/Src/base_event.cpp index 91800e7f8b..b46a3c83ec 100644 --- a/backends/platform/PalmOS/Src/base_event.cpp +++ b/backends/platform/PalmOS/Src/base_event.cpp @@ -106,7 +106,9 @@ bool OSystem_PalmBase::pollEvent(Event &event) { if (getMillis() >= (_keyMouseRepeat + _keyMouseDelay)) { _keyMouseRepeat = getMillis(); - if (gVars->arrowKeys) { + if (gVars->arrowKeys) { + event.kbd.keycode = 0; + if (keyCurrentState & _keyMouse.bitUp) event.kbd.keycode = 273; else if (keyCurrentState & _keyMouse.bitDown) @@ -115,12 +117,13 @@ bool OSystem_PalmBase::pollEvent(Event &event) { event.kbd.keycode = 276; else if (keyCurrentState & _keyMouse.bitRight) event.kbd.keycode = 275; - else if (keyCurrentState & _keyMouse.bitButLeft) - event.kbd.keycode = chrLineFeed; - event.type = EVENT_KEYDOWN; - event.kbd.ascii = event.kbd.keycode; - event.kbd.flags = 0; + if (event.kbd.keycode) { + event.type = EVENT_KEYDOWN; + event.kbd.ascii = event.kbd.keycode; + event.kbd.flags = 0; + return true; + } } else { Int8 sx = 0; @@ -139,28 +142,13 @@ bool OSystem_PalmBase::pollEvent(Event &event) { if (sx || sy) { simulate_mouse(event, sx, sy, &x, &y); event.type = EVENT_MOUSEMOVE; - _lastKey = kKeyMouseMove; - - } else { - x = _mouseCurState.x; - y = _mouseCurState.y; + event.mouse.x = x; + event.mouse.y = y; + warpMouse(x, y); - if (keyCurrentState & _keyMouse.bitButLeft) { - event.type = EVENT_LBUTTONDOWN; - _lastKey = kKeyMouseLButton; - - } else if (_lastKey == kKeyMouseLButton) { - event.type = EVENT_LBUTTONUP; - _lastKey = kKeyNone; - } + return true; } - - event.mouse.x = x; - event.mouse.y = y; - warpMouse(x, y); - // updateCD(); } - return true; } } @@ -168,7 +156,6 @@ bool OSystem_PalmBase::pollEvent(Event &event) { switch (ev.data.keyDown.chr) { // ESC key case vchrLaunch: - _lastKey = kKeyNone; event.type = EVENT_KEYDOWN; event.kbd.keycode = 27; event.kbd.ascii = 27; @@ -177,7 +164,6 @@ bool OSystem_PalmBase::pollEvent(Event &event) { // F5 = menu case vchrMenu: - _lastKey = kKeyNone; event.type = EVENT_KEYDOWN; event.kbd.keycode = 319; event.kbd.ascii = 319; @@ -192,14 +178,12 @@ bool OSystem_PalmBase::pollEvent(Event &event) { // case vchrBrightness: // volume control on Zodiac, let other backends disable it case vchrContrast: // do nothing - _lastKey = kKeyNone; return true; } } if (check_event(event, &ev)) return true; - _lastKey = kKeyNone; // prevent crash when alarm is raised handled = ((ev.eType == keyDownEvent) && @@ -219,10 +203,9 @@ bool OSystem_PalmBase::pollEvent(Event &event) { if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) return false; - if (_lastEvent != penMoveEvent && (abs(y - event.mouse.y) <= 2 || abs(x - event.mouse.x) <= 2)) // move only if + if (abs(y - event.mouse.y) <= 2 || abs(x - event.mouse.x) <= 2) return false; - _lastEvent = penMoveEvent; event.type = EVENT_MOUSEMOVE; event.mouse.x = x; event.mouse.y = y; @@ -244,11 +227,10 @@ bool OSystem_PalmBase::pollEvent(Event &event) { event.kbd.ascii = num; event.kbd.flags = 0; - _lastEvent = keyDownEvent; + _wasKey = true; return true; } - _lastEvent = penDownEvent; if (y > _screenHeight || y < 0 || x > _screenWidth || x < 0) return false; @@ -329,7 +311,7 @@ bool OSystem_PalmBase::pollEvent(Event &event) { } // other keys - _lastEvent = keyDownEvent; + _wasKey = true; event.type = EVENT_KEYDOWN; event.kbd.keycode = key; event.kbd.ascii = key; @@ -337,9 +319,9 @@ bool OSystem_PalmBase::pollEvent(Event &event) { return true; default: - if (_lastEvent == keyDownEvent) { + if (_wasKey) { event.type = EVENT_KEYUP; - _lastEvent = nilEvent; + _wasKey = false; return true; } return false; diff --git a/backends/platform/PalmOS/Src/be_base.cpp b/backends/platform/PalmOS/Src/be_base.cpp index b1e16c62ee..8776376ee5 100644 --- a/backends/platform/PalmOS/Src/be_base.cpp +++ b/backends/platform/PalmOS/Src/be_base.cpp @@ -51,8 +51,7 @@ OSystem_PalmBase::OSystem_PalmBase() { _screenP = NULL; _screenPitch = gVars->screenPitch; - _lastEvent = nilEvent; - _lastKey = kKeyNone; + _wasKey = false; _lastKeyModifier = kModifierNone; _lastKeyRepeat = 100; _useNumPad = false; @@ -89,13 +88,11 @@ void OSystem_PalmBase::initBackend() { _keyMouse.bitUp = keyBitPageUp; _keyMouse.bitDown = keyBitPageDown; - _keyMouse.bitLeft = keyBitHard1; - _keyMouse.bitRight = keyBitHard2; - _keyMouse.bitButLeft= keyBitHard3; - _keyMouse.hasMore = false; + _keyMouse.bitLeft = keyBitHard2; + _keyMouse.bitRight = keyBitHard3; int_initBackend(); - _keyMouseMask = (_keyMouse.bitUp | _keyMouse.bitDown | _keyMouse.bitLeft | _keyMouse.bitRight | _keyMouse.bitButLeft); + _keyMouseMask = (_keyMouse.bitUp | _keyMouse.bitDown | _keyMouse.bitLeft | _keyMouse.bitRight); // Create the savefile manager, if none exists yet (we check for this to // allow subclasses to provide their own). diff --git a/backends/platform/PalmOS/Src/be_base.h b/backends/platform/PalmOS/Src/be_base.h index 3d13666772..1418d69b6c 100644 --- a/backends/platform/PalmOS/Src/be_base.h +++ b/backends/platform/PalmOS/Src/be_base.h @@ -110,14 +110,6 @@ protected: virtual void draw_osd(UInt16 id, Int32 x, Int32 y, Boolean show, UInt8 color = 0); enum { - kKeyNone = 0, - kKeyMouseMove = 1 << 0, - kKeyMouseLButton = 1 << 1, - - kKeyCalc = 1 << 30, - kKeyAny = 1 << 31 - }; - enum { MAX_MOUSE_W = 80, MAX_MOUSE_H = 80 }; @@ -159,8 +151,6 @@ protected: UInt32 bitDown; UInt32 bitLeft; UInt32 bitRight; - UInt32 bitButLeft; - Boolean hasMore; } _keyMouse; bool _mouseVisible; @@ -173,8 +163,7 @@ protected: byte *_mouseDataP, *_mouseBackupP; - eventsEnum _lastEvent; - WChar _lastKey; + eventsEnum _wasKey; UInt8 _lastKeyModifier; UInt32 _lastKeyRepeat; Boolean _useNumPad, _showBatLow; diff --git a/backends/platform/PalmOS/Src/be_os5.cpp b/backends/platform/PalmOS/Src/be_os5.cpp index d8abf979e3..74551607b7 100644 --- a/backends/platform/PalmOS/Src/be_os5.cpp +++ b/backends/platform/PalmOS/Src/be_os5.cpp @@ -83,16 +83,12 @@ void OSystem_PalmOS5::int_initBackend() { _keyMouse.bitDown = keyBitPageDown; _keyMouse.bitLeft = keyBitNavLeft; _keyMouse.bitRight = keyBitNavRight; - _keyMouse.bitButLeft= keyBitNavSelect; - _keyMouse.hasMore = true; } else if (OPTIONS_TST(kOpt5WayNavigatorV2)) { _keyMouse.bitUp = keyBitRockerUp|keyBitPageUp; _keyMouse.bitDown = keyBitRockerDown|keyBitPageDown; _keyMouse.bitLeft = keyBitRockerLeft; _keyMouse.bitRight = keyBitRockerRight; - _keyMouse.bitButLeft= keyBitRockerCenter; - _keyMouse.hasMore = true; } } diff --git a/backends/platform/PalmOS/Src/be_zodiac.cpp b/backends/platform/PalmOS/Src/be_zodiac.cpp index 61b28bccae..ce4dfa6013 100644 --- a/backends/platform/PalmOS/Src/be_zodiac.cpp +++ b/backends/platform/PalmOS/Src/be_zodiac.cpp @@ -33,12 +33,10 @@ OSystem_PalmZodiac::OSystem_PalmZodiac() : OSystem_PalmOS5Ex() { } void OSystem_PalmZodiac::int_initBackend() { - _keyMouse.bitUp = keyBitRockerUp; - _keyMouse.bitDown = keyBitRockerDown; - _keyMouse.bitLeft = keyBitRockerLeft; - _keyMouse.bitRight = keyBitRockerRight; - _keyMouse.bitButLeft= keyBitRockerCenter; - _keyMouse.hasMore = true; + _keyMouse.bitUp = keyBitRockerUp; + _keyMouse.bitDown = keyBitRockerDown; + _keyMouse.bitLeft = keyBitRockerLeft; + _keyMouse.bitRight = keyBitRockerRight; } void OSystem_PalmZodiac::calc_rect(Boolean fullscreen) { diff --git a/backends/platform/PalmOS/Src/os5_event.cpp b/backends/platform/PalmOS/Src/os5_event.cpp index a1b07a0460..1e1c8c393e 100644 --- a/backends/platform/PalmOS/Src/os5_event.cpp +++ b/backends/platform/PalmOS/Src/os5_event.cpp @@ -38,40 +38,48 @@ void OSystem_PalmOS5::get_coordinates(EventPtr ev, Coord &x, Coord &y) { } bool OSystem_PalmOS5::check_event(Event &event, EventPtr ev) { - if (ev->eType == keyDownEvent) { + if (ev->eType == keyUpEvent) { switch (ev->data.keyDown.chr) { + case vchrHard3: + event.type = EVENT_LBUTTONUP; + event.mouse.x = _mouseCurState.x; + event.mouse.y = _mouseCurState.y; + return true; + case vchrHard4: - _lastKey = kKeyNone; - event.type = EVENT_RBUTTONDOWN; + event.type = EVENT_RBUTTONUP; event.mouse.x = _mouseCurState.x; event.mouse.y = _mouseCurState.y; return true; } - - if (_keyMouse.hasMore) { - switch (ev->data.keyDown.chr) { - // hot swap gfx -// case 0x1B04: - case vchrHard1: - printf("swap\n"); - if (OPTIONS_TST(kOptCollapsible)) - hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE); - return false; // not a key -// case 0x1B05: - case vchrHard2: - setFeatureState(kFeatureAspectRatioCorrection, 0); + } else if (ev->eType == keyDownEvent) { + switch (ev->data.keyDown.chr) { + + // hot swap gfx +// case 0x1B04: + case vchrHard1: + printf("swap\n"); + if (OPTIONS_TST(kOptCollapsible)) + hotswap_gfx_mode(_mode == GFX_WIDE ? GFX_NORMAL: GFX_WIDE); return false; // not a key - - // F5 = menu - case vchrHard3: - _lastKey = kKeyNone; - event.type = EVENT_KEYDOWN; - event.kbd.keycode = 319; - event.kbd.ascii = 319; - event.kbd.flags = 0; - return true; - } + +// case 0x1B05: + case vchrHard2: + setFeatureState(kFeatureAspectRatioCorrection, 0); + return false; // not a key + + case vchrHard3: + event.type = EVENT_RBUTTONDOWN; + event.mouse.x = _mouseCurState.x; + event.mouse.y = _mouseCurState.y; + return true; + + case vchrHard4: + event.type = EVENT_RBUTTONDOWN; + event.mouse.x = _mouseCurState.x; + event.mouse.y = _mouseCurState.y; + return true; } } diff --git a/backends/platform/PalmOS/Src/zodiac_event.cpp b/backends/platform/PalmOS/Src/zodiac_event.cpp index 9dd0fc3e78..fd664ae940 100644 --- a/backends/platform/PalmOS/Src/zodiac_event.cpp +++ b/backends/platform/PalmOS/Src/zodiac_event.cpp @@ -25,11 +25,25 @@ #include "be_zodiac.h" bool OSystem_PalmZodiac::check_event(Event &event, EventPtr ev) { - if (ev->eType == keyDownEvent) { + if (ev->eType == keyUpEvent) { + switch (ev->data.keyDown.chr) { + case vchrActionLeft: + event.type = EVENT_LBUTTONUP; + event.mouse.x = _mouseCurState.x; + event.mouse.y = _mouseCurState.y; + return true; + + case vchrActionRight: + event.type = EVENT_RBUTTONUP; + event.mouse.x = _mouseCurState.x; + event.mouse.y = _mouseCurState.y; + return true; + } + + } else if (ev->eType == keyDownEvent) { switch (ev->data.keyDown.chr) { // F5 = menu case vchrThumbWheelBack: - _lastKey = kKeyNone; event.type = EVENT_KEYDOWN; event.kbd.keycode = 319; event.kbd.ascii = 319; @@ -45,14 +59,12 @@ bool OSystem_PalmZodiac::check_event(Event &event, EventPtr ev) { return false; // not a key case vchrActionLeft: - _lastKey = kKeyMouseLButton; event.type = EVENT_LBUTTONDOWN; event.mouse.x = _mouseCurState.x; event.mouse.y = _mouseCurState.y; return true; case vchrActionRight: - _lastKey = kKeyNone; event.type = EVENT_RBUTTONDOWN; event.mouse.x = _mouseCurState.x; event.mouse.y = _mouseCurState.y; @@ -81,16 +93,6 @@ bool OSystem_PalmZodiac::check_event(Event &event, EventPtr ev) { break; } - } else if (_overlayVisible) { - switch (_lastKey) { - case kKeyMouseLButton: - _lastKey = kKeyNone; - event.type = EVENT_LBUTTONUP; - event.mouse.x = _mouseCurState.x; - event.mouse.y = _mouseCurState.y; - return true; - - } } return false; |