From c0b095d793cf2ffa71830cc7d1ebb153ac70eccb Mon Sep 17 00:00:00 2001 From: rsn8887 Date: Sat, 18 Feb 2017 12:25:47 -0600 Subject: SDL: Cleanup, replaced _km.multiplier with #define --- backends/events/dinguxsdl/dinguxsdl-events.cpp | 28 ++++---- backends/events/gph/gph-events.cpp | 74 +++++++++++----------- .../events/linuxmotosdl/linuxmotosdl-events.cpp | 30 ++++----- backends/events/maemosdl/maemosdl-events.cpp | 4 +- backends/events/openpandora/op-events.cpp | 14 ++-- backends/events/ps3sdl/ps3sdl-events.cpp | 8 +-- backends/events/sdl/sdl-events.cpp | 68 ++++++++++---------- backends/events/sdl/sdl-events.h | 3 +- backends/events/symbiansdl/symbiansdl-events.cpp | 36 +++++------ backends/events/wincesdl/wincesdl-events.cpp | 4 +- 10 files changed, 135 insertions(+), 134 deletions(-) (limited to 'backends') diff --git a/backends/events/dinguxsdl/dinguxsdl-events.cpp b/backends/events/dinguxsdl/dinguxsdl-events.cpp index f61023206b..7730e8f915 100644 --- a/backends/events/dinguxsdl/dinguxsdl-events.cpp +++ b/backends/events/dinguxsdl/dinguxsdl-events.cpp @@ -72,54 +72,54 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { if (ev.key.keysym.sym == PAD_UP) { if (ev.type == SDL_KEYDOWN) { - _km.y_vel = -1 * _km.multiplier; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0 * _km.multiplier; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == PAD_DOWN) { if (ev.type == SDL_KEYDOWN) { - _km.y_vel = 1 * _km.multiplier; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0 * _km.multiplier; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == PAD_LEFT) { if (ev.type == SDL_KEYDOWN) { - _km.x_vel = -1 * _km.multiplier; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0 * _km.multiplier; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == PAD_RIGHT) { if (ev.type == SDL_KEYDOWN) { - _km.x_vel = 1 * _km.multiplier; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0 * _km.multiplier; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == BUT_Y) { // left mouse button @@ -129,7 +129,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_LBUTTONUP; } - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == BUT_B) { // right mouse button @@ -139,7 +139,7 @@ bool DINGUXSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_RBUTTONUP; } - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == BUT_X) { // '.' skip dialogue diff --git a/backends/events/gph/gph-events.cpp b/backends/events/gph/gph-events.cpp index 06acfa489e..d59d0bead5 100644 --- a/backends/events/gph/gph-events.cpp +++ b/backends/events/gph/gph-events.cpp @@ -230,116 +230,116 @@ bool GPHEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { switch (ev.jbutton.button) { case BUTTON_UP: if (_km.y_down_count != 2) { - _km.y_vel = -1 * _km.multiplier; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = -4 * _km.multiplier; + _km.y_vel = -4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_DOWN: if (_km.y_down_count != 2) { - _km.y_vel = 1 * _km.multiplier; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 4 * _km.multiplier; + _km.y_vel = 4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_LEFT: if (_km.x_down_count != 2) { - _km.x_vel = -1 * _km.multiplier; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = -4 * _km.multiplier; + _km.x_vel = -4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_RIGHT: if (_km.x_down_count != 3) { - _km.x_vel = 1 * _km.multiplier; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 4 * _km.multiplier; + _km.x_vel = 4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_UPLEFT: if (_km.x_down_count != 2) { - _km.x_vel = -1 * _km.multiplier; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = -4 * _km.multiplier; + _km.x_vel = -4 * MULTIPLIER; } if (_km.y_down_count != 2) { - _km.y_vel = -1 * _km.multiplier; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = -4 * _km.multiplier; + _km.y_vel = -4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_UPRIGHT: if (_km.x_down_count != 2) { - _km.x_vel = 1 * _km.multiplier; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 4 * _km.multiplier; + _km.x_vel = 4 * MULTIPLIER; } if (_km.y_down_count != 2) { - _km.y_vel = -1 * _km.multiplier; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = -4 * _km.multiplier; + _km.y_vel = -4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_DOWNLEFT: if (_km.x_down_count != 2) { - _km.x_vel = -1 * _km.multiplier; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = -4 * _km.multiplier; + _km.x_vel = -4 * MULTIPLIER; } if (_km.y_down_count != 2) { - _km.y_vel = 1 * _km.multiplier; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 4 * _km.multiplier; + _km.y_vel = 4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_DOWNRIGHT: if (_km.x_down_count != 2) { - _km.x_vel = 1 * _km.multiplier; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 4 * _km.multiplier; + _km.x_vel = 4 * MULTIPLIER; } if (_km.y_down_count != 2) { - _km.y_vel = 1 * _km.multiplier; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 4 * _km.multiplier; + _km.y_vel = 4 * MULTIPLIER; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_B: case BUTTON_CLICK: event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_X: event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_L: BUTTON_STATE_L = true; @@ -454,16 +454,16 @@ bool GPHEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { _km.x_vel = 0; _km.x_down_count = 0; event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_B: case BUTTON_CLICK: event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_X: event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BUTTON_L: BUTTON_STATE_L = false; diff --git a/backends/events/linuxmotosdl/linuxmotosdl-events.cpp b/backends/events/linuxmotosdl/linuxmotosdl-events.cpp index 3f29cc93fe..00453a036c 100644 --- a/backends/events/linuxmotosdl/linuxmotosdl-events.cpp +++ b/backends/events/linuxmotosdl/linuxmotosdl-events.cpp @@ -130,53 +130,53 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { // Joystick to Mouse else if (ev.key.keysym.sym == SDLK_LEFT) { if (ev.type == SDL_KEYDOWN) { - _km.x_vel = -1 * _km.multiplier; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0 * _km.multiplier; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_RIGHT) { if (ev.type == SDL_KEYDOWN) { - _km.x_vel = 1 * _km.multiplier; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0 * _km.multiplier; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_DOWN) { if (ev.type == SDL_KEYDOWN) { - _km.y_vel = 1 * _km.multiplier; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0 * _km.multiplier; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_UP) { if (ev.type == SDL_KEYDOWN) { - _km.y_vel = -1 * _km.multiplier; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0 * _km.multiplier; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_RETURN) { @@ -187,7 +187,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_LBUTTONUP; } - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_PLUS) { @@ -197,7 +197,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { } else { event.type = Common::EVENT_RBUTTONUP; } - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else if (ev.key.keysym.sym == SDLK_MINUS) { @@ -208,7 +208,7 @@ bool LinuxmotoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { event.type = Common::EVENT_LBUTTONUP; } - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } else { diff --git a/backends/events/maemosdl/maemosdl-events.cpp b/backends/events/maemosdl/maemosdl-events.cpp index a1f2f4123c..e864c7d81c 100644 --- a/backends/events/maemosdl/maemosdl-events.cpp +++ b/backends/events/maemosdl/maemosdl-events.cpp @@ -96,7 +96,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { } } else if (ev.key.keysym.sym == SDLK_F7) { event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); debug(9, "remapping to right click down"); return true; } else if (ev.key.keysym.sym == SDLK_F8) { @@ -134,7 +134,7 @@ bool MaemoSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { } } else if (ev.key.keysym.sym == SDLK_F7) { event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); debug(9, "remapping to right click up"); return true; } else if (ev.key.keysym.sym == SDLK_F8) { diff --git a/backends/events/openpandora/op-events.cpp b/backends/events/openpandora/op-events.cpp index dbfcc4ed2c..abb1458d66 100644 --- a/backends/events/openpandora/op-events.cpp +++ b/backends/events/openpandora/op-events.cpp @@ -126,18 +126,18 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (ev.key.keysym.sym) { case SDLK_LEFT: event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_RIGHT: event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; #if defined(SDL_BUTTON_MIDDLE) case SDLK_UP: event.type = (ev.type == SDL_KEYDOWN) ? Common::EVENT_MBUTTONDOWN : Common::EVENT_MBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; #endif @@ -150,12 +150,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (ev.key.keysym.sym) { case SDLK_HOME: event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_END: event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_PAGEDOWN: @@ -188,12 +188,12 @@ bool OPEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (ev.key.keysym.sym) { case SDLK_HOME: event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_END: event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; break; case SDLK_PAGEDOWN: diff --git a/backends/events/ps3sdl/ps3sdl-events.cpp b/backends/events/ps3sdl/ps3sdl-events.cpp index bad0160b9d..01cdc2f0f6 100644 --- a/backends/events/ps3sdl/ps3sdl-events.cpp +++ b/backends/events/ps3sdl/ps3sdl-events.cpp @@ -60,11 +60,11 @@ bool PS3SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) switch (ev.jbutton.button) { case BTN_CROSS: // Left mouse button event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BTN_CIRCLE: // Right mouse button event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BTN_TRIANGLE: // Game menu event.type = Common::EVENT_KEYDOWN; @@ -98,11 +98,11 @@ bool PS3SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { switch (ev.jbutton.button) { case BTN_CROSS: // Left mouse button event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BTN_CIRCLE: // Right mouse button event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); break; case BTN_TRIANGLE: // Game menu event.type = Common::EVENT_KEYUP; diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp index dccdef971b..378e0370fb 100644 --- a/backends/events/sdl/sdl-events.cpp +++ b/backends/events/sdl/sdl-events.cpp @@ -179,8 +179,8 @@ void SdlEventSource::processMouseEvent(Common::Event &event, int x, int y) { } // Update the "keyboard mouse" coords - _km.x = x * _km.multiplier; - _km.y = y * _km.multiplier; + _km.x = x * MULTIPLIER; + _km.y = y * MULTIPLIER; } bool SdlEventSource::handleKbdMouse(Common::Event &event) { @@ -207,36 +207,36 @@ bool SdlEventSource::handleKbdMouse(Common::Event &event) { if (_km.x_down_count) { if (curTime > _km.x_down_time + 300) { if (_km.x_vel > 0) - _km.x_vel += _km.multiplier; + _km.x_vel += MULTIPLIER; else - _km.x_vel -= _km.multiplier; + _km.x_vel -= MULTIPLIER; } else if (curTime > _km.x_down_time + 200) { if (_km.x_vel > 0) - _km.x_vel = 5 * _km.multiplier; + _km.x_vel = 5 * MULTIPLIER; else - _km.x_vel = -5 * _km.multiplier; + _km.x_vel = -5 * MULTIPLIER; } } if (_km.y_down_count) { if (curTime > _km.y_down_time + 300) { if (_km.y_vel > 0) - _km.y_vel += _km.multiplier; + _km.y_vel += MULTIPLIER; else - _km.y_vel -= _km.multiplier; + _km.y_vel -= MULTIPLIER; } else if (curTime > _km.y_down_time + 200) { if (_km.y_vel > 0) - _km.y_vel = 5 * _km.multiplier; + _km.y_vel = 5 * MULTIPLIER; else - _km.y_vel = -5 * _km.multiplier; + _km.y_vel = -5 * MULTIPLIER; } } - // The modifier key makes the mouse movement slower - // The extra factor of delay/25 makes velocities - // independent of kbdMouse update rate - // all velovities were originally chosen - // at a delay of 25, so that is the reference - // operator order is important to avoid overflow + // - The modifier key makes the mouse movement slower + // - The extra factor "delay/25" ensures velocities + // are independent of the kbdMouse update rate + // - all velocities were originally chosen + // at a delay of 25, so that is the reference used here + // - note: operator order is important to avoid overflow if (_km.modifier) { _km.x += ((_km.x_vel / 10) * ((int16)_km.delay_time)) / 25; _km.y += ((_km.y_vel / 10) * ((int16)_km.delay_time)) / 25; @@ -247,31 +247,31 @@ bool SdlEventSource::handleKbdMouse(Common::Event &event) { if (_km.x < 0) { _km.x = 0; - _km.x_vel = -1 * _km.multiplier; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; - } else if (_km.x > _km.x_max * _km.multiplier) { - _km.x = _km.x_max * _km.multiplier; - _km.x_vel = 1 * _km.multiplier; + } else if (_km.x > _km.x_max * MULTIPLIER) { + _km.x = _km.x_max * MULTIPLIER; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } if (_km.y < 0) { _km.y = 0; - _km.y_vel = -1 * _km.multiplier; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; - } else if (_km.y > _km.y_max * _km.multiplier) { - _km.y = _km.y_max * _km.multiplier; - _km.y_vel = 1 * _km.multiplier; + } else if (_km.y > _km.y_max * MULTIPLIER) { + _km.y = _km.y_max * MULTIPLIER; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } if (_graphicsManager) { - _graphicsManager->getWindow()->warpMouseInWindow((Uint16)(_km.x / _km.multiplier), (Uint16)(_km.y / _km.multiplier)); + _graphicsManager->getWindow()->warpMouseInWindow((Uint16)(_km.x / MULTIPLIER), (Uint16)(_km.y / MULTIPLIER)); } if (_km.x != oldKmX || _km.y != oldKmY) { event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; } } @@ -517,7 +517,7 @@ bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) { // with a mouse wheel event. However, SDL2 does not supply // these, thus we use whatever we got last time. It seems // these are always stored in _km.x, _km.y. - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); if (yDir < 0) { event.type = Common::EVENT_WHEELDOWN; return true; @@ -744,10 +744,10 @@ bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) { bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { if (ev.jbutton.button == JOY_BUT_LMOUSE) { event.type = Common::EVENT_LBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { event.type = Common::EVENT_RBUTTONDOWN; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); } else { event.type = Common::EVENT_KEYDOWN; switch (ev.jbutton.button) { @@ -775,10 +775,10 @@ bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) { bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) { if (ev.jbutton.button == JOY_BUT_LMOUSE) { event.type = Common::EVENT_LBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); } else if (ev.jbutton.button == JOY_BUT_RMOUSE) { event.type = Common::EVENT_RBUTTONUP; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); } else { event.type = Common::EVENT_KEYUP; switch (ev.jbutton.button) { @@ -808,7 +808,7 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { int axis = ev.jaxis.value; #ifdef JOY_ANALOG // conversion factor between keyboard mouse and joy axis value - int vel_to_axis = (1500 / _km.multiplier); + int vel_to_axis = (1500 / MULTIPLIER); #else if (axis > JOY_DEADZONE) { axis -= JOY_DEADZONE; @@ -824,7 +824,7 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { _km.x_down_count = 0; #else if (axis != 0) { - _km.x_vel = (axis > 0) ? 1 * _km.multiplier:-1 * _km.multiplier; + _km.x_vel = (axis > 0) ? 1 * MULTIPLIER:-1 * MULTIPLIER; _km.x_down_count = 1; } else { _km.x_vel = 0; @@ -840,7 +840,7 @@ bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) { _km.y_down_count = 0; #else if (axis != 0) { - _km.y_vel = (-axis > 0) ? 1 * _km.multiplier: -1 * _km.multiplier; + _km.y_vel = (-axis > 0) ? 1 * MULTIPLIER: -1 * MULTIPLIER; _km.y_down_count = 1; } else { _km.y_vel = 0; diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h index c1d6057dac..334bf8acfc 100644 --- a/backends/events/sdl/sdl-events.h +++ b/backends/events/sdl/sdl-events.h @@ -28,6 +28,8 @@ #include "common/events.h" +// multiplier used to increase resolution for keyboard/joystick mouse +#define MULTIPLIER 16 /** * The SDL event source. @@ -59,7 +61,6 @@ protected: struct KbdMouse { int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count; - static const int16 multiplier = 16; uint32 last_time, delay_time, x_down_time, y_down_time; bool modifier; }; diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp index 6f736bd45d..9272cbaf9d 100644 --- a/backends/events/symbiansdl/symbiansdl-events.cpp +++ b/backends/events/symbiansdl/symbiansdl-events.cpp @@ -56,76 +56,76 @@ bool SymbianSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) { switch (loop) { case GUI::ACTION_UP: if (ev.type == SDL_KEYDOWN) { - _km.y_vel = -1 * _km.multiplier; + _km.y_vel = -1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0 * _km.multiplier; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_DOWN: if (ev.type == SDL_KEYDOWN) { - _km.y_vel = 1 * _km.multiplier; + _km.y_vel = 1 * MULTIPLIER; _km.y_down_count = 1; } else { - _km.y_vel = 0 * _km.multiplier; + _km.y_vel = 0 * MULTIPLIER; _km.y_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_LEFT: if (ev.type == SDL_KEYDOWN) { - _km.x_vel = -1 * _km.multiplier; + _km.x_vel = -1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0 * _km.multiplier; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_RIGHT: if (ev.type == SDL_KEYDOWN) { - _km.x_vel = 1 * _km.multiplier; + _km.x_vel = 1 * MULTIPLIER; _km.x_down_count = 1; } else { - _km.x_vel = 0 * _km.multiplier; + _km.x_vel = 0 * MULTIPLIER; _km.x_down_count = 0; } event.type = Common::EVENT_MOUSEMOVE; - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_LEFTCLICK: event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP); - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_RIGHTCLICK: event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP); - processMouseEvent(event, _km.x / _km.multiplier, _km.y / _km.multiplier); + processMouseEvent(event, _km.x / MULTIPLIER, _km.y / MULTIPLIER); return true; case GUI::ACTION_ZONE: if (ev.type == SDL_KEYDOWN) { for (int i = 0; i < TOTAL_ZONES; i++) - if ( (_km.x / _km.multiplier) >= _zones[i].x && (_km.y / _km.multiplier) >= _zones[i].y && - (_km.x / _km.multiplier) <= _zones[i].x + _zones[i].width && (_km.y / _km.multiplier <= _zones[i].y + _zones[i].height + if ( (_km.x / MULTIPLIER) >= _zones[i].x && (_km.y / MULTIPLIER) >= _zones[i].y && + (_km.x / MULTIPLIER) <= _zones[i].x + _zones[i].width && (_km.y / MULTIPLIER <= _zones[i].y + _zones[i].height ) { - _mouseXZone[i] = _km.x / _km.multiplier; - _mouseYZone[i] = _km.y / _km.multiplier; + _mouseXZone[i] = _km.x / MULTIPLIER; + _mouseYZone[i] = _km.y / MULTIPLIER; break; } _currentZone++; diff --git a/backends/events/wincesdl/wincesdl-events.cpp b/backends/events/wincesdl/wincesdl-events.cpp index f37ee71702..7001d5fec6 100644 --- a/backends/events/wincesdl/wincesdl-events.cpp +++ b/backends/events/wincesdl/wincesdl-events.cpp @@ -48,8 +48,8 @@ void WINCESdlEventSource::processMouseEvent(Common::Event &event, int x, int y) event.mouse.y = y; // Update the "keyboard mouse" coords - _km.x = event.mouse.x * _km.multiplier; - _km.y = event.mouse.y * _km.multiplier; + _km.x = event.mouse.x * MULTIPLIER; + _km.y = event.mouse.y * MULTIPLIER; // Adjust for the screen scaling if (_graphicsMan->_zoomDown) -- cgit v1.2.3