aboutsummaryrefslogtreecommitdiff
path: root/backends/events
diff options
context:
space:
mode:
authorMax Horn2010-11-28 14:56:31 +0000
committerMax Horn2010-11-28 14:56:31 +0000
commit7760077cf530c35c969f9286145d9a36d0440d70 (patch)
tree34c67abbacefa26792ca77fc9f5360c77a34663d /backends/events
parent284b49aabc54590e1444f06561a815c2a3c5de7e (diff)
parent74a53df11b51fa4956745c086b2e6351b8383568 (diff)
downloadscummvm-rg350-7760077cf530c35c969f9286145d9a36d0440d70.tar.gz
scummvm-rg350-7760077cf530c35c969f9286145d9a36d0440d70.tar.bz2
scummvm-rg350-7760077cf530c35c969f9286145d9a36d0440d70.zip
Merging the gsoc2010-opengl branch
svn-id: r54518
Diffstat (limited to 'backends/events')
-rw-r--r--backends/events/dinguxsdl/dinguxsdl-events.cpp226
-rw-r--r--backends/events/dinguxsdl/dinguxsdl-events.h47
-rw-r--r--backends/events/gp2xsdl/gp2xsdl-events.cpp494
-rw-r--r--backends/events/gp2xsdl/gp2xsdl-events.h60
-rw-r--r--backends/events/linuxmotosdl/linuxmotosdl-events.cpp227
-rw-r--r--backends/events/linuxmotosdl/linuxmotosdl-events.h43
-rw-r--r--backends/events/samsungtvsdl/samsungtvsdl-events.cpp78
-rw-r--r--backends/events/samsungtvsdl/samsungtvsdl-events.h42
-rw-r--r--backends/events/sdl/sdl-events.cpp569
-rw-r--r--backends/events/sdl/sdl-events.h138
-rw-r--r--backends/events/symbiansdl/symbiansdl-events.cpp201
-rw-r--r--backends/events/symbiansdl/symbiansdl-events.h59
12 files changed, 2184 insertions, 0 deletions
diff --git a/backends/events/dinguxsdl/dinguxsdl-events.cpp b/backends/events/dinguxsdl/dinguxsdl-events.cpp
new file mode 100644
index 0000000000..1eed96acfe
--- /dev/null
+++ b/backends/events/dinguxsdl/dinguxsdl-events.cpp
@@ -0,0 +1,226 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if defined(DINGUX)
+
+#include "backends/events/dinguxsdl/dinguxsdl-events.h"
+#include "graphics/scaler/aspect.h" // for aspect2Real
+
+#define PAD_UP SDLK_UP
+#define PAD_DOWN SDLK_DOWN
+#define PAD_LEFT SDLK_LEFT
+#define PAD_RIGHT SDLK_RIGHT
+#define BUT_A SDLK_LCTRL
+#define BUT_B SDLK_LALT
+#define BUT_X SDLK_SPACE
+#define BUT_Y SDLK_LSHIFT
+#define BUT_SELECT SDLK_ESCAPE
+#define BUT_START SDLK_RETURN
+#define TRIG_L SDLK_TAB
+#define TRIG_R SDLK_BACKSPACE
+
+static int mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
+ if (key >= SDLK_F1 && key <= SDLK_F9) {
+ return key - SDLK_F1 + Common::ASCII_F1;
+ } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
+ return key - SDLK_KP0 + '0';
+ } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
+ return key;
+ } else if (unicode) {
+ return unicode;
+ } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) {
+ return key & ~0x20;
+ } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
+ return 0;
+ }
+ return key;
+}
+
+DINGUXSdlEventSource::DINGUXSdlEventSource() : SdlEventSource() {
+ ;
+}
+
+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.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == PAD_DOWN) {
+ if (ev.type == SDL_KEYDOWN) {
+ _km.y_vel = 1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == PAD_LEFT) {
+ if (ev.type == SDL_KEYDOWN) {
+ _km.x_vel = -1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == PAD_RIGHT) {
+ if (ev.type == SDL_KEYDOWN) {
+ _km.x_vel = 1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == BUT_Y) { // left mouse button
+ if (ev.type == SDL_KEYDOWN) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ } else {
+ event.type = Common::EVENT_LBUTTONUP;
+ }
+
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == BUT_B) { // right mouse button
+ if (ev.type == SDL_KEYDOWN) {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ } else {
+ event.type = Common::EVENT_RBUTTONUP;
+ }
+
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == BUT_X) { // '.' skip dialogue
+ ev.key.keysym.sym = SDLK_PERIOD;
+ ev.key.keysym.mod = (SDLMod)0;
+ ev.key.keysym.unicode = '.';
+ } else if (ev.key.keysym.sym == TRIG_L) { // global menu
+ ev.key.keysym.sym = SDLK_F5;
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = Common::ASCII_F5;
+ event.kbd.flags = Common::KBD_CTRL;
+
+ if (ev.type == SDL_KEYDOWN) {
+ event.type = Common::EVENT_KEYDOWN;
+ } else {
+ event.type = Common::EVENT_KEYUP;
+ }
+
+ return true;
+ } else if (ev.key.keysym.sym == BUT_A) { // key '0'
+ ev.key.keysym.sym = SDLK_0;
+
+ event.kbd.keycode = Common::KEYCODE_0;
+ event.kbd.ascii = '0';
+ event.kbd.flags = 0;
+
+ if (ev.type == SDL_KEYDOWN) {
+ event.type = Common::EVENT_KEYDOWN;
+ } else {
+ event.type = Common::EVENT_KEYUP;
+ }
+
+ return true;
+ } else if (ev.key.keysym.sym == BUT_SELECT) { // virtual keyboard
+ ev.key.keysym.sym = SDLK_F7;
+
+ } else if (ev.key.keysym.sym == BUT_START) { // F5, menu in some games
+ ev.key.keysym.sym = SDLK_F5;
+
+ } else if (ev.key.keysym.sym == TRIG_R) { // ESC
+ ev.key.keysym.sym = SDLK_ESCAPE;
+ } else {
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+ }
+
+ return false;
+}
+
+void DINGUXSdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
+ if (_grpMan->getVideoMode()->mode == GFX_HALF && !(_grpMan->isOverlayVisible())) {
+ event.mouse.x = x * 2;
+ event.mouse.y = y * 2;
+ } else {
+ event.mouse.x = x;
+ event.mouse.y = y;
+ }
+
+ // Update the "keyboard mouse" coords
+ _km.x = x;
+ _km.y = y;
+
+ // Adjust for the screen scaling
+ if (!(_grpMan->isOverlayVisible())) {
+ event.mouse.x /= (_grpMan->getVideoMode())->scaleFactor;
+ event.mouse.y /= (_grpMan->getVideoMode())->scaleFactor;
+#if 0
+ if (_grpMan->getVideoMode()->aspectRatioCorrection)
+ event.mouse.y = aspect2Real(event.mouse.y);
+#endif
+ }
+}
+
+void DINGUXSdlEventSource::warpMouse(int x, int y) {
+ int mouse_cur_x = _grpMan->getMouseCurState()->x;
+ int mouse_cur_y = _grpMan->getMouseCurState()->y;
+
+ if ((mouse_cur_x != x) || (mouse_cur_y != y)) {
+ if (_grpMan->getVideoMode()->mode == GFX_HALF && !(_grpMan->isOverlayVisible())) {
+ x = x / 2;
+ y = y / 2;
+ }
+ }
+ SDL_WarpMouse(x, y);
+}
+
+void DINGUXSdlEventSource::setCurrentGraphMan(DINGUXSdlGraphicsManager *_graphicManager) {
+ _grpMan = _graphicManager;
+}
+
+#endif /* DINGUX */
diff --git a/backends/events/dinguxsdl/dinguxsdl-events.h b/backends/events/dinguxsdl/dinguxsdl-events.h
new file mode 100644
index 0000000000..f269fcf358
--- /dev/null
+++ b/backends/events/dinguxsdl/dinguxsdl-events.h
@@ -0,0 +1,47 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifndef BACKENDS_EVENTS_SDL_DINGUX_H
+#define BACKENDS_EVENTS_SDL_DINGUX_H
+#if defined(DINGUX)
+
+#include "backends/platform/dingux/dingux.h"
+#include "backends/events/dinguxsdl/dinguxsdl-events.h"
+
+class DINGUXSdlEventSource : public SdlEventSource {
+public:
+ DINGUXSdlEventSource();
+ void setCurrentGraphMan(DINGUXSdlGraphicsManager *_graphicManager);
+
+protected:
+ DINGUXSdlGraphicsManager *_grpMan;
+
+ bool remapKey(SDL_Event &ev, Common::Event &event);
+ void fillMouseEvent(Common::Event &event, int x, int y);
+ void warpMouse(int x, int y);
+};
+
+#endif /* DINGUX */
+#endif /* BACKENDS_EVENTS_SDL_DINGUX_H */
diff --git a/backends/events/gp2xsdl/gp2xsdl-events.cpp b/backends/events/gp2xsdl/gp2xsdl-events.cpp
new file mode 100644
index 0000000000..f52007e746
--- /dev/null
+++ b/backends/events/gp2xsdl/gp2xsdl-events.cpp
@@ -0,0 +1,494 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if defined(GP2X) || defined(GP2XWIZ)
+
+#include "backends/events/gp2xsdl/gp2xsdl-events.h"
+#if defined(GP2X)
+#include "backends/platform/gp2x/gp2x-hw.h"
+#include "backends/graphics/gp2xsdl/gp2xsdl-graphics.h"
+#else
+#include "backends/platform/gp2xwiz/gp2xwiz-hw.h"
+#endif
+
+#include "backends/platform/sdl/sdl.h"
+
+// FIXME move joystick defines out and replace with confile file options
+// we should really allow users to map any key to a joystick button using the keymapper.
+#define JOY_DEADZONE 2200
+
+#define JOY_XAXIS 0
+#define JOY_YAXIS 1
+
+/* Quick default button states for modifiers. */
+int BUTTON_STATE_L = false;
+
+enum {
+ /* DPAD/Stick */
+ BUTTON_UP = 0,
+ BUTTON_UPLEFT = 1,
+ BUTTON_LEFT = 2,
+ BUTTON_DOWNLEFT = 3,
+ BUTTON_DOWN = 4,
+ BUTTON_DOWNRIGHT = 5,
+ BUTTON_RIGHT = 6,
+ BUTTON_UPRIGHT = 7,
+ /* Joystick Buttons */
+ BUTTON_MENU = 8, // Start on F100 GP2X
+ BUTTON_SELECT = 9,
+ BUTTON_L = 10,
+ BUTTON_R = 11,
+ BUTTON_A = 12,
+ BUTTON_B = 13,
+ BUTTON_X = 14,
+ BUTTON_Y = 15,
+ BUTTON_VOLUP = 16,
+ BUTTON_VOLDOWN = 17,
+ BUTTON_CLICK = 18
+};
+
+enum {
+ /* Unused Joystick Buttons on the GP2X */
+ BUTTON_HOME = 51,
+ BUTTON_HOLD = 52,
+ BUTTON_HELP = 53,
+ BUTTON_HELP2 = 54
+};
+
+enum {
+ /* Touchscreen TapMode */
+ TAPMODE_LEFT = 0,
+ TAPMODE_RIGHT = 1,
+ TAPMODE_HOVER = 2
+};
+
+GP2XSdlEventManager::GP2XSdlEventManager(Common::EventSource *boss)
+ :
+ _buttonStateL(false),
+ SdlEventManager(boss) {
+
+}
+
+void GP2XSdlEventManager::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
+ event.kbd.flags = 0;
+
+ if (mod & KMOD_SHIFT)
+ event.kbd.flags |= Common::KBD_SHIFT;
+ if (mod & KMOD_ALT)
+ event.kbd.flags |= Common::KBD_ALT;
+ if (mod & KMOD_CTRL)
+ event.kbd.flags |= Common::KBD_CTRL;
+
+ // Sticky flags
+ if (mod & KMOD_NUM)
+ event.kbd.flags |= Common::KBD_NUM;
+ if (mod & KMOD_CAPS)
+ event.kbd.flags |= Common::KBD_CAPS;
+}
+
+void GP2XSdlEventManager::moveStick() {
+ bool stickBtn[32];
+
+ memcpy(stickBtn, _stickBtn, sizeof(stickBtn));
+
+ if ((stickBtn[0])||(stickBtn[2])||(stickBtn[4])||(stickBtn[6]))
+ stickBtn[1] = stickBtn[3] = stickBtn[5] = stickBtn[7] = 0;
+
+ if ((stickBtn[1])||(stickBtn[2])||(stickBtn[3])) {
+ if (_km.x_down_count!=2) {
+ _km.x_vel = -1;
+ _km.x_down_count = 1;
+ } else
+ _km.x_vel = -4;
+ } else if ((stickBtn[5])||(stickBtn[6])||(stickBtn[7])) {
+ if (_km.x_down_count!=2) {
+ _km.x_vel = 1;
+ _km.x_down_count = 1;
+ } else
+ _km.x_vel = 4;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+
+ if ((stickBtn[0])||(stickBtn[1])||(stickBtn[7])) {
+ if (_km.y_down_count!=2) {
+ _km.y_vel = -1;
+ _km.y_down_count = 1;
+ } else
+ _km.y_vel = -4;
+ } else if ((stickBtn[3])||(stickBtn[4])||(stickBtn[5])) {
+ if (_km.y_down_count!=2) {
+ _km.y_vel = 1;
+ _km.y_down_count = 1;
+ } else
+ _km.y_vel = 4;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+}
+
+/* GP2X Input mappings.
+Single Button
+
+Movement:
+
+GP2X_BUTTON_UP Cursor Up
+GP2X_BUTTON_DOWN Cursor Down
+GP2X_BUTTON_LEFT Cursor Left
+GP2X_BUTTON_RIGHT Cursor Right
+
+GP2X_BUTTON_UPLEFT Cursor Up Left
+GP2X_BUTTON_UPRIGHT Cursor Up Right
+GP2X_BUTTON_DOWNLEFT Cursor Down Left
+GP2X_BUTTON_DOWNRIGHT Cursor Down Right
+
+Button Emulation:
+
+GP2X_BUTTON_CLICK Left Mouse Click (GP2X only)
+GP2X_BUTTON_A . (Period)
+GP2X_BUTTON_B Left Mouse Click
+GP2X_BUTTON_Y Space Bar
+GP2X_BUTTON_X Right Mouse Click
+GP2X_BUTTON_L Combo Modifier (Left Trigger)
+GP2X_BUTTON_R Return (Right Trigger)
+GP2X_BUTTON_MENU F5 (Game Menu)
+GP2X_BUTTON_SELECT Escape
+GP2X_BUTTON_VOLUP /dev/mixer Global Volume Up
+GP2X_BUTTON_VOLDOWN /dev/mixer Global Volume Down
+
+Combos:
+
+GP2X_BUTTON_VOLUP & GP2X_BUTTON_VOLDOWN 0 (For Monkey 2 CP) or Virtual Keyboard if enabled
+GP2X_BUTTON_L & GP2X_BUTTON_SELECT Common::EVENT_QUIT (Calls Sync() to make sure SD is flushed)
+GP2X_BUTTON_L & GP2X_BUTTON_MENU Common::EVENT_MAINMENU (ScummVM Global Main Menu)
+GP2X_BUTTON_L & GP2X_BUTTON_A Common::EVENT_PREDICTIVE_DIALOG for predictive text entry box (AGI games)
+GP2X_BUTTON_L & GP2X_BUTTON_Y Toggles setZoomOnMouse() for larger then 320*240 games to scale to the point + raduis. (GP2X only)
+*/
+
+bool GP2XSdlEventManager::handleKeyDown(SDL_Event &ev, Common::Event &event) {
+ SDLModToOSystemKeyFlags(SDL_GetModState(), event);
+
+ if (remapKey(ev, event))
+ return true;
+
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+
+ return true;
+}
+
+bool GP2XSdlEventManager::handleKeyUp(SDL_Event &ev, Common::Event &event) {
+ if (remapKey(ev, event))
+ return true;
+
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+
+ // Ctrl-Alt-<key> will change the GFX mode
+ SDLModToOSystemKeyFlags(SDL_GetModState(), event);
+
+ // Set the scroll lock sticky flag
+ if (_scrollLock)
+ event.kbd.flags |= Common::KBD_SCRL;
+
+ if (isScalerHotkey(event))
+ // Swallow these key up events
+ return false;
+
+ return true;
+}
+
+bool GP2XSdlEventManager::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
+
+ _stickBtn[ev.jbutton.button] = 1;
+ event.kbd.flags = 0;
+
+ switch (ev.jbutton.button) {
+ case BUTTON_UP:
+ case BUTTON_UPLEFT:
+ case BUTTON_LEFT:
+ case BUTTON_DOWNLEFT:
+ case BUTTON_DOWN:
+ case BUTTON_DOWNRIGHT:
+ case BUTTON_RIGHT:
+ case BUTTON_UPRIGHT:
+ moveStick();
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+ break;
+ case BUTTON_B:
+ case BUTTON_CLICK:
+ if (BUTTON_STATE_L == true) {
+ ((GP2XSdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->toogleZoomOnMouse();
+ fillMouseEvent(event, _km.x, _km.y);
+ } else {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ fillMouseEvent(event, _km.x, _km.y);
+ }
+ break;
+ case BUTTON_X:
+ event.type = Common::EVENT_RBUTTONDOWN;
+ fillMouseEvent(event, _km.x, _km.y);
+ break;
+ case BUTTON_L:
+ BUTTON_STATE_L = true;
+ break;
+ case BUTTON_R:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+#ifdef ENABLE_VKEYBD
+ event.kbd.keycode = Common::KEYCODE_F7;
+ event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0);
+#else
+ event.kbd.keycode = Common::KEYCODE_0;
+ event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0);
+#endif
+ } else {
+ event.kbd.keycode = Common::KEYCODE_RETURN;
+ event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_SELECT:
+ case BUTTON_HOME:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_QUIT;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_A:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_PREDICTIVE_DIALOG;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_PERIOD;
+ event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_Y:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+ GPH::ToggleTapMode();
+ if (GPH::tapmodeLevel == TAPMODE_LEFT) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Left Click");
+ } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Right Click");
+ } else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode' - Hover (No Click)");
+ }
+ } else {
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_MENU:
+ case BUTTON_HELP:
+ event.type = Common::EVENT_KEYDOWN;
+ if (BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_MAINMENU;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_VOLUP:
+ GP2X_HW::mixerMoveVolume(2);
+ if (GP2X_HW::volumeLevel == 100) {
+ g_system->displayMessageOnOSD("Maximum Volume");
+ } else {
+ g_system->displayMessageOnOSD("Increasing Volume");
+ }
+ break;
+
+ case BUTTON_VOLDOWN:
+ GP2X_HW::mixerMoveVolume(1);
+ if (GP2X_HW::volumeLevel == 0) {
+ g_system->displayMessageOnOSD("Minimal Volume");
+ } else {
+ g_system->displayMessageOnOSD("Decreasing Volume");
+ }
+ break;
+ case BUTTON_HOLD:
+ event.type = Common::EVENT_QUIT;
+ break;
+ case BUTTON_HELP2:
+ GPH::ToggleTapMode();
+ if (GPH::tapmodeLevel == TAPMODE_LEFT) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Left Click");
+ } else if (GPH::tapmodeLevel == TAPMODE_RIGHT) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Right Click");
+ } else if (GPH::tapmodeLevel == TAPMODE_HOVER) {
+ g_system->displayMessageOnOSD("Touchscreen 'Tap Mode': Hover (No Click)");
+ }
+ break;
+ }
+ return true;
+}
+
+bool GP2XSdlEventManager::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
+ _stickBtn[ev.jbutton.button] = 0;
+ event.kbd.flags = 0;
+
+ switch (ev.jbutton.button) {
+ case BUTTON_UP:
+ case BUTTON_UPLEFT:
+ case BUTTON_LEFT:
+ case BUTTON_DOWNLEFT:
+ case BUTTON_DOWN:
+ case BUTTON_DOWNRIGHT:
+ case BUTTON_RIGHT:
+ case BUTTON_UPRIGHT:
+ moveStick();
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+ break;
+ case BUTTON_B:
+ case BUTTON_CLICK:
+ if (BUTTON_STATE_L == true) {
+ break;
+ } else {
+ event.type = Common::EVENT_LBUTTONUP;
+ fillMouseEvent(event, _km.x, _km.y);
+ }
+ break;
+ case BUTTON_X:
+ event.type = Common::EVENT_RBUTTONUP;
+ fillMouseEvent(event, _km.x, _km.y);
+ break;
+ case BUTTON_L:
+ BUTTON_STATE_L = false;
+ break;
+ case BUTTON_SELECT:
+ case BUTTON_HOME:
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ break;
+ case BUTTON_A:
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_PERIOD;
+ event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+ break;
+ case BUTTON_Y:
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ break;
+ case BUTTON_MENU:
+ case BUTTON_HELP:
+ event.type = Common::EVENT_KEYUP;
+ if (BUTTON_STATE_L == true) {
+ event.type = Common::EVENT_MAINMENU;
+ } else {
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_R:
+ event.type = Common::EVENT_KEYUP;
+ if (BUTTON_STATE_L == true) {
+#ifdef ENABLE_VKEYBD
+ event.kbd.keycode = Common::KEYCODE_F7;
+ event.kbd.ascii = mapKey(SDLK_F7, ev.key.keysym.mod, 0);
+#else
+ event.kbd.keycode = Common::KEYCODE_0;
+ event.kbd.ascii = mapKey(SDLK_0, ev.key.keysym.mod, 0);
+#endif
+ } else {
+ event.kbd.keycode = Common::KEYCODE_RETURN;
+ event.kbd.ascii = mapKey(SDLK_RETURN, ev.key.keysym.mod, 0);
+ }
+ break;
+ case BUTTON_VOLUP:
+ break;
+ case BUTTON_VOLDOWN:
+ break;
+ case BUTTON_HOLD:
+ break;
+ case BUTTON_HELP2:
+ break;
+ }
+ return true;
+}
+
+bool GP2XSdlEventManager::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
+ int axis = ev.jaxis.value;
+ if ( axis > JOY_DEADZONE) {
+ axis -= JOY_DEADZONE;
+ event.type = Common::EVENT_MOUSEMOVE;
+ } else if ( axis < -JOY_DEADZONE ) {
+ axis += JOY_DEADZONE;
+ event.type = Common::EVENT_MOUSEMOVE;
+ } else
+ axis = 0;
+
+ if ( ev.jaxis.axis == JOY_XAXIS) {
+#ifdef JOY_ANALOG
+ _km.x_vel = axis/2000;
+ _km.x_down_count = 0;
+#else
+ if (axis != 0) {
+ _km.x_vel = (axis > 0) ? 1:-1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+#endif
+
+ } else if (ev.jaxis.axis == JOY_YAXIS) {
+#ifndef JOY_INVERT_Y
+ axis = -axis;
+#endif
+#ifdef JOY_ANALOG
+ _km.y_vel = -axis / 2000;
+ _km.y_down_count = 0;
+#else
+ if (axis != 0) {
+ _km.y_vel = (-axis > 0) ? 1: -1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+#endif
+ }
+
+ fillMouseEvent(event, _km.x, _km.y);
+ return true;
+}
+
+bool GP2XSdlEventManager::remapKey(SDL_Event &ev, Common::Event &event) {
+ return false;
+}
+
+
+#endif
diff --git a/backends/events/gp2xsdl/gp2xsdl-events.h b/backends/events/gp2xsdl/gp2xsdl-events.h
new file mode 100644
index 0000000000..dbbdb2993b
--- /dev/null
+++ b/backends/events/gp2xsdl/gp2xsdl-events.h
@@ -0,0 +1,60 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SDL_GP2X_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SDL_GP2X_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+/**
+ * SDL events manager for GP2X and GP2XWIZ
+ */
+class GP2XSdlEventManager : public SdlEventManager {
+public:
+ GP2XSdlEventManager(Common::EventSource *boss);
+
+protected:
+ bool _stickBtn[32];
+
+ /** Button state for L button modifier */
+ bool _buttonStateL;
+
+ /**
+ * Handles the stick movement
+ */
+ void moveStick();
+
+ virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleKeyUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
+ virtual bool GP2XSdlEventManager::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
+
+ virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
+
+ virtual bool GP2XSdlEventManager::remapKey(SDL_Event &ev, Common::Event &event);
+};
+
+#endif
diff --git a/backends/events/linuxmotosdl/linuxmotosdl-events.cpp b/backends/events/linuxmotosdl/linuxmotosdl-events.cpp
new file mode 100644
index 0000000000..abd8ad2da8
--- /dev/null
+++ b/backends/events/linuxmotosdl/linuxmotosdl-events.cpp
@@ -0,0 +1,227 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if defined(LINUXMOTO)
+
+#include "backends/events/linuxmotosdl/linuxmotosdl-events.h"
+#include "backends/platform/linuxmoto/linuxmoto-sdl.h"
+
+enum {
+ GFX_HALF = 12
+};
+
+LinuxmotoSdlEventManager::LinuxmotoSdlEventManager(Common::EventSource *boss)
+ :
+ SdlEventManager(boss) {
+
+}
+
+void LinuxmotoSdlEventManager::preprocessEvents(SDL_Event *event) {
+ if (event->type == SDL_ACTIVEEVENT) {
+ if (event->active.state == SDL_APPINPUTFOCUS && !event->active.gain) {
+ ((OSystem_SDL* )g_system)->getMixerManager()->suspendAudio();
+ for (;;) {
+ if (!SDL_WaitEvent(event)) {
+ SDL_Delay(10);
+ continue;
+ }
+ if (event->type == SDL_QUIT)
+ return;
+ if (event->type != SDL_ACTIVEEVENT)
+ continue;
+ if (event->active.state == SDL_APPINPUTFOCUS && event->active.gain) {
+ ((OSystem_SDL* )g_system)->getMixerManager()->resumeAudio();
+ return;
+ }
+ }
+ }
+ }
+}
+
+bool LinuxmotoSdlEventManager::remapKey(SDL_Event &ev, Common::Event &event) {
+ if (false) {}
+
+ // Motorol A1200/E6/A1600 remapkey by Lubomyr
+#ifdef MOTOEZX
+ // Quit on MOD+Camera Key on A1200
+ if (ev.key.keysym.sym == SDLK_e) {
+ event.type = Common::EVENT_QUIT;
+ return true;
+ }
+ // '1' Bypass security protection - MOD+Call key
+ if (ev.key.keysym.sym == SDLK_f) {
+ ev.key.keysym.sym = SDLK_1;
+ }
+ // F5 Game Menu - Call key
+ else if (ev.key.keysym.sym == SDLK_SPACE) {
+ ev.key.keysym.sym = SDLK_F5;
+ }
+ // VirtualKeyboard - Camera key
+ else if (ev.key.keysym.sym == SDLK_PAUSE) {
+ ev.key.keysym.sym = SDLK_F7;
+ }
+ // Enter - mod+fire key
+ else if (ev.key.keysym.sym == SDLK_b) {
+ ev.key.keysym.sym = SDLK_RETURN;
+ }
+ // '3' - mod+up key
+ else if (ev.key.keysym.sym == SDLK_j) {
+ ev.key.keysym.sym = SDLK_3;
+ }
+ // '6' - mod+up key
+ else if (ev.key.keysym.sym == SDLK_i) {
+ ev.key.keysym.sym = SDLK_6;
+ }
+ // 'y' - mod+right key
+ else if (ev.key.keysym.sym == SDLK_g) {
+ ev.key.keysym.sym = SDLK_y;
+ }
+ // 'n' - mod+right key
+ else if (ev.key.keysym.sym == SDLK_h) {
+ ev.key.keysym.sym = SDLK_n;
+ }
+ // mod+vol'+' -> volume'+'
+ else if (ev.key.keysym.sym == SDLK_c) {
+ ev.key.keysym.sym = SDLK_RIGHTBRACKET;
+ }
+ // mod+vol'-' -> volume'-'
+ else if (ev.key.keysym.sym == SDLK_d) {
+ ev.key.keysym.sym = SDLK_LEFTBRACKET;
+ }
+#endif
+
+#ifdef MOTOMAGX
+ // Quit on Clr
+ if (ev.key.keysym.sym == SDLK_BACKSPACE) {
+ event.type = Common::EVENT_QUIT;
+ return true;
+ }
+ // Game Menu - Left Soft key
+ else if (ev.key.keysym.sym == SDLK_F9) {
+ ev.key.keysym.sym = SDLK_F5;
+ }
+ // VirtualKeyboard - Right Soft key
+ else if (ev.key.keysym.sym == SDLK_F11) {
+ ev.key.keysym.sym = SDLK_F7;
+ }
+#endif
+
+// Joystick to Mouse
+ else if (ev.key.keysym.sym == SDLK_LEFT) {
+ if (ev.type == SDL_KEYDOWN) {
+ _km.x_vel = -1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_RIGHT) {
+ if (ev.type == SDL_KEYDOWN) {
+ _km.x_vel = 1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_DOWN) {
+ if (ev.type == SDL_KEYDOWN) {
+ _km.y_vel = 1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_UP) {
+ if (ev.type == SDL_KEYDOWN) {
+ _km.y_vel = -1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_RETURN) {
+ // Joystick center to pressing Left Mouse
+ if (ev.key.type == SDL_KEYDOWN) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ } else {
+ event.type = Common::EVENT_LBUTTONUP;
+ }
+
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_PLUS) {
+ // Volume Up to pressing Right Mouse
+ if (ev.key.type == SDL_KEYDOWN ) {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ } else {
+ event.type = Common::EVENT_RBUTTONUP;
+ }
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_MINUS) {
+ // Volume Down to pressing Left Mouse
+ if (ev.key.type == SDL_KEYDOWN) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ } else {
+ event.type = Common::EVENT_LBUTTONUP;
+ }
+
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+ } 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.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+ }
+
+ return false;
+}
+
+#endif
diff --git a/backends/events/linuxmotosdl/linuxmotosdl-events.h b/backends/events/linuxmotosdl/linuxmotosdl-events.h
new file mode 100644
index 0000000000..414db080ed
--- /dev/null
+++ b/backends/events/linuxmotosdl/linuxmotosdl-events.h
@@ -0,0 +1,43 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SDL_LINUXMOTO_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SDL_LINUXMOTO_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+/**
+ * SDL events manager for LINUXMOTO
+ */
+class LinuxmotoSdlEventManager : public SdlEventManager {
+public:
+ LinuxmotoSdlEventManager(Common::EventSource *boss);
+
+protected:
+ virtual void preprocessEvents(SDL_Event *event);
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+};
+
+#endif
diff --git a/backends/events/samsungtvsdl/samsungtvsdl-events.cpp b/backends/events/samsungtvsdl/samsungtvsdl-events.cpp
new file mode 100644
index 0000000000..d1c35d3a5a
--- /dev/null
+++ b/backends/events/samsungtvsdl/samsungtvsdl-events.cpp
@@ -0,0 +1,78 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifdef SAMSUNGTV
+
+#include "backends/events/samsungtvsdl/samsungtvsdl-events.h"
+
+SamsungTVSdlEventManager::SamsungTVSdlEventManager(Common::EventSource *boss)
+ :
+ SdlEventManager(boss) {
+
+}
+
+bool SamsungTVSdlEventManager::remapKey(SDL_Event &ev, Common::Event &event) {
+ switch (ev.type) {
+ case SDL_KEYDOWN:{
+ if (ev.key.keysym.sym == SDLK_POWER) {
+ event.type = Common::EVENT_QUIT;
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_F1 && ev.key.keysym.scancode == 20) {
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = Common::ASCII_F5;
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_F2 && ev.key.keysym.scancode == 21) {
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = Common::KEYCODE_F7;
+ event.kbd.ascii = Common::ASCII_F7;
+ return true;
+ }
+ break;
+ }
+ case SDL_KEYUP: {
+ if (ev.key.keysym.sym == SDLK_POWER) {
+ event.type = Common::EVENT_QUIT;
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_F1 && ev.key.keysym.scancode == 20) {
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = Common::ASCII_F5;
+ return true;
+ } else if (ev.key.keysym.sym == SDLK_F2 && ev.key.keysym.scancode == 21) {
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = Common::KEYCODE_F7;
+ event.kbd.ascii = Common::ASCII_F7;
+ return true;
+ }
+ break;
+ }
+ }
+
+ // Invoke parent implementation of this method
+ return SdlEventManager::remapKey(ev, event);
+}
+
+#endif
diff --git a/backends/events/samsungtvsdl/samsungtvsdl-events.h b/backends/events/samsungtvsdl/samsungtvsdl-events.h
new file mode 100644
index 0000000000..10e1eb84bb
--- /dev/null
+++ b/backends/events/samsungtvsdl/samsungtvsdl-events.h
@@ -0,0 +1,42 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SDL_SAMSUNGTV_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SDL_SAMSUNGTV_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+/**
+ * SDL events manager for Samsung TV
+ */
+class SamsungTVSdlEventManager : public SdlEventManager {
+public:
+ SamsungTVSdlEventManager(Common::EventSource *boss);
+
+protected:
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+};
+
+#endif
diff --git a/backends/events/sdl/sdl-events.cpp b/backends/events/sdl/sdl-events.cpp
new file mode 100644
index 0000000000..379e77a48d
--- /dev/null
+++ b/backends/events/sdl/sdl-events.cpp
@@ -0,0 +1,569 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if defined(SDL_BACKEND)
+
+// Disable symbol overrides so that we can use system headers.
+#define FORBIDDEN_SYMBOL_EXCEPTION_FILE
+
+#include "backends/events/sdl/sdl-events.h"
+#include "backends/platform/sdl/sdl.h"
+#include "common/config-manager.h"
+
+// FIXME move joystick defines out and replace with confile file options
+// we should really allow users to map any key to a joystick button
+#define JOY_DEADZONE 3200
+
+#ifndef __SYMBIAN32__ // Symbian wants dialog joystick i.e cursor for movement/selection
+ #define JOY_ANALOG
+#endif
+
+// #define JOY_INVERT_Y
+#define JOY_XAXIS 0
+#define JOY_YAXIS 1
+// buttons
+#define JOY_BUT_LMOUSE 0
+#define JOY_BUT_RMOUSE 2
+#define JOY_BUT_ESCAPE 3
+#define JOY_BUT_PERIOD 1
+#define JOY_BUT_SPACE 4
+#define JOY_BUT_F5 5
+
+SdlEventSource::SdlEventSource()
+ : _scrollLock(false), _joystick(0), _lastScreenID(0), EventSource() {
+ // Reset mouse state
+ memset(&_km, 0, sizeof(_km));
+
+ int joystick_num = ConfMan.getInt("joystick_num");
+ if (joystick_num > -1) {
+ // Initialize SDL joystick subsystem
+ if (SDL_InitSubSystem(SDL_INIT_JOYSTICK) == -1) {
+ error("Could not initialize SDL: %s", SDL_GetError());
+ }
+
+ // Enable joystick
+ if (SDL_NumJoysticks() > 0) {
+ printf("Using joystick: %s\n", SDL_JoystickName(0));
+ _joystick = SDL_JoystickOpen(joystick_num);
+ }
+ }
+}
+
+SdlEventSource::~SdlEventSource() {
+ if (_joystick)
+ SDL_JoystickClose(_joystick);
+}
+
+int SdlEventSource::mapKey(SDLKey key, SDLMod mod, Uint16 unicode) {
+ if (key >= SDLK_F1 && key <= SDLK_F9) {
+ return key - SDLK_F1 + Common::ASCII_F1;
+ } else if (key >= SDLK_KP0 && key <= SDLK_KP9) {
+ return key - SDLK_KP0 + '0';
+ } else if (key >= SDLK_UP && key <= SDLK_PAGEDOWN) {
+ return key;
+ } else if (unicode) {
+ return unicode;
+ } else if (key >= 'a' && key <= 'z' && (mod & KMOD_SHIFT)) {
+ return key & ~0x20;
+ } else if (key >= SDLK_NUMLOCK && key <= SDLK_EURO) {
+ return 0;
+ }
+ return key;
+}
+
+void SdlEventSource::fillMouseEvent(Common::Event &event, int x, int y) {
+ event.mouse.x = x;
+ event.mouse.y = y;
+
+ // Update the "keyboard mouse" coords
+ _km.x = x;
+ _km.y = y;
+}
+
+void SdlEventSource::handleKbdMouse() {
+ uint32 curTime = g_system->getMillis();
+ if (curTime >= _km.last_time + _km.delay_time) {
+ _km.last_time = curTime;
+ if (_km.x_down_count == 1) {
+ _km.x_down_time = curTime;
+ _km.x_down_count = 2;
+ }
+ if (_km.y_down_count == 1) {
+ _km.y_down_time = curTime;
+ _km.y_down_count = 2;
+ }
+
+ if (_km.x_vel || _km.y_vel) {
+ if (_km.x_down_count) {
+ if (curTime > _km.x_down_time + _km.delay_time * 12) {
+ if (_km.x_vel > 0)
+ _km.x_vel++;
+ else
+ _km.x_vel--;
+ } else if (curTime > _km.x_down_time + _km.delay_time * 8) {
+ if (_km.x_vel > 0)
+ _km.x_vel = 5;
+ else
+ _km.x_vel = -5;
+ }
+ }
+ if (_km.y_down_count) {
+ if (curTime > _km.y_down_time + _km.delay_time * 12) {
+ if (_km.y_vel > 0)
+ _km.y_vel++;
+ else
+ _km.y_vel--;
+ } else if (curTime > _km.y_down_time + _km.delay_time * 8) {
+ if (_km.y_vel > 0)
+ _km.y_vel = 5;
+ else
+ _km.y_vel = -5;
+ }
+ }
+
+ _km.x += _km.x_vel;
+ _km.y += _km.y_vel;
+
+ if (_km.x < 0) {
+ _km.x = 0;
+ _km.x_vel = -1;
+ _km.x_down_count = 1;
+ } else if (_km.x > _km.x_max) {
+ _km.x = _km.x_max;
+ _km.x_vel = 1;
+ _km.x_down_count = 1;
+ }
+
+ if (_km.y < 0) {
+ _km.y = 0;
+ _km.y_vel = -1;
+ _km.y_down_count = 1;
+ } else if (_km.y > _km.y_max) {
+ _km.y = _km.y_max;
+ _km.y_vel = 1;
+ _km.y_down_count = 1;
+ }
+
+ SDL_WarpMouse((Uint16)_km.x, (Uint16)_km.y);
+ }
+ }
+}
+
+void SdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
+
+ event.kbd.flags = 0;
+
+#ifdef LINUPY
+ // Yopy has no ALT key, steal the SHIFT key
+ // (which isn't used much anyway)
+ if (mod & KMOD_SHIFT)
+ event.kbd.flags |= Common::KBD_ALT;
+#else
+ if (mod & KMOD_SHIFT)
+ event.kbd.flags |= Common::KBD_SHIFT;
+ if (mod & KMOD_ALT)
+ event.kbd.flags |= Common::KBD_ALT;
+#endif
+ if (mod & KMOD_CTRL)
+ event.kbd.flags |= Common::KBD_CTRL;
+
+ // Sticky flags
+ if (mod & KMOD_NUM)
+ event.kbd.flags |= Common::KBD_NUM;
+ if (mod & KMOD_CAPS)
+ event.kbd.flags |= Common::KBD_CAPS;
+}
+
+bool SdlEventSource::pollEvent(Common::Event &event) {
+ handleKbdMouse();
+
+ // If the screen changed, send an Common::EVENT_SCREEN_CHANGED
+ int screenID = ((OSystem_SDL *)g_system)->getGraphicsManager()->getScreenChangeID();
+ if (screenID != _lastScreenID) {
+ _lastScreenID = screenID;
+ event.type = Common::EVENT_SCREEN_CHANGED;
+ return true;
+ }
+
+ SDL_Event ev;
+ ev.type = SDL_NOEVENT;
+ while (SDL_PollEvent(&ev)) {
+ preprocessEvents(&ev);
+ if (dispatchSDLEvent(ev, event))
+ return true;
+ }
+ return false;
+}
+
+bool SdlEventSource::dispatchSDLEvent(SDL_Event &ev, Common::Event &event) {
+ switch (ev.type) {
+ case SDL_KEYDOWN:
+ return handleKeyDown(ev, event);
+ case SDL_KEYUP:
+ return handleKeyUp(ev, event);
+ case SDL_MOUSEMOTION:
+ return handleMouseMotion(ev, event);
+ case SDL_MOUSEBUTTONDOWN:
+ return handleMouseButtonDown(ev, event);
+ case SDL_MOUSEBUTTONUP:
+ return handleMouseButtonUp(ev, event);
+ case SDL_JOYBUTTONDOWN:
+ return handleJoyButtonDown(ev, event);
+ case SDL_JOYBUTTONUP:
+ return handleJoyButtonUp(ev, event);
+ case SDL_JOYAXISMOTION:
+ return handleJoyAxisMotion(ev, event);
+
+ case SDL_VIDEOEXPOSE:
+ // HACK: Send a fake event, handled by SdlGraphicsManager
+ event.type = (Common::EventType)OSystem_SDL::kSdlEventExpose;
+ return true;
+
+ case SDL_VIDEORESIZE:
+ // HACK: Send a fake event, handled by OpenGLSdlGraphicsManager
+ event.type = (Common::EventType)OSystem_SDL::kSdlEventResize;
+ event.mouse.x = ev.resize.w;
+ event.mouse.y = ev.resize.h;
+ return true;
+
+ case SDL_QUIT:
+ event.type = Common::EVENT_QUIT;
+ return true;
+
+ }
+
+ return false;
+}
+
+
+bool SdlEventSource::handleKeyDown(SDL_Event &ev, Common::Event &event) {
+
+ SDLModToOSystemKeyFlags(SDL_GetModState(), event);
+
+ // Handle scroll lock as a key modifier
+ if (ev.key.keysym.sym == SDLK_SCROLLOCK)
+ _scrollLock = !_scrollLock;
+
+ if (_scrollLock)
+ event.kbd.flags |= Common::KBD_SCRL;
+
+ // Ctrl-m toggles mouse capture
+ if (event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'm') {
+ toggleMouseGrab();
+ return false;
+ }
+
+#if defined(MACOSX)
+ // On Macintosh', Cmd-Q quits
+ if ((ev.key.keysym.mod & KMOD_META) && ev.key.keysym.sym == 'q') {
+ event.type = Common::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.type = Common::EVENT_QUIT;
+ return true;
+ }
+#else
+ // Ctrl-z and Alt-X quit
+ if ((event.kbd.hasFlags(Common::KBD_CTRL) && ev.key.keysym.sym == 'z') || (event.kbd.hasFlags(Common::KBD_ALT) && ev.key.keysym.sym == 'x')) {
+ event.type = Common::EVENT_QUIT;
+ return true;
+ }
+#endif
+
+ if ((ev.key.keysym.mod & KMOD_CTRL) && ev.key.keysym.sym == 'u') {
+ event.type = Common::EVENT_MUTE;
+ return true;
+ }
+
+ if (remapKey(ev, event))
+ return true;
+
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+
+ return true;
+}
+
+bool SdlEventSource::handleKeyUp(SDL_Event &ev, Common::Event &event) {
+ if (remapKey(ev, event))
+ return true;
+
+ event.type = Common::EVENT_KEYUP;
+ event.kbd.keycode = (Common::KeyCode)ev.key.keysym.sym;
+ event.kbd.ascii = mapKey(ev.key.keysym.sym, ev.key.keysym.mod, ev.key.keysym.unicode);
+
+ // Ctrl-Alt-<key> will change the GFX mode
+ SDLModToOSystemKeyFlags(SDL_GetModState(), event);
+
+ // Set the scroll lock sticky flag
+ if (_scrollLock)
+ event.kbd.flags |= Common::KBD_SCRL;
+
+ return true;
+}
+
+bool SdlEventSource::handleMouseMotion(SDL_Event &ev, Common::Event &event) {
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, ev.motion.x, ev.motion.y);
+
+ return true;
+}
+
+bool SdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
+ if (ev.button.button == SDL_BUTTON_LEFT)
+ event.type = Common::EVENT_LBUTTONDOWN;
+ else if (ev.button.button == SDL_BUTTON_RIGHT)
+ event.type = Common::EVENT_RBUTTONDOWN;
+#if defined(SDL_BUTTON_WHEELUP) && defined(SDL_BUTTON_WHEELDOWN)
+ else if (ev.button.button == SDL_BUTTON_WHEELUP)
+ event.type = Common::EVENT_WHEELUP;
+ else if (ev.button.button == SDL_BUTTON_WHEELDOWN)
+ event.type = Common::EVENT_WHEELDOWN;
+#endif
+#if defined(SDL_BUTTON_MIDDLE)
+ else if (ev.button.button == SDL_BUTTON_MIDDLE)
+ event.type = Common::EVENT_MBUTTONDOWN;
+#endif
+ else
+ return false;
+
+ fillMouseEvent(event, ev.button.x, ev.button.y);
+
+ return true;
+}
+
+bool SdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
+ if (ev.button.button == SDL_BUTTON_LEFT)
+ event.type = Common::EVENT_LBUTTONUP;
+ else if (ev.button.button == SDL_BUTTON_RIGHT)
+ event.type = Common::EVENT_RBUTTONUP;
+#if defined(SDL_BUTTON_MIDDLE)
+ else if (ev.button.button == SDL_BUTTON_MIDDLE)
+ event.type = Common::EVENT_MBUTTONUP;
+#endif
+ else
+ return false;
+ fillMouseEvent(event, ev.button.x, ev.button.y);
+
+ return true;
+}
+
+bool SdlEventSource::handleJoyButtonDown(SDL_Event &ev, Common::Event &event) {
+ if (ev.jbutton.button == JOY_BUT_LMOUSE) {
+ event.type = Common::EVENT_LBUTTONDOWN;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
+ event.type = Common::EVENT_RBUTTONDOWN;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else {
+ event.type = Common::EVENT_KEYDOWN;
+ switch (ev.jbutton.button) {
+ case JOY_BUT_ESCAPE:
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ break;
+ case JOY_BUT_PERIOD:
+ event.kbd.keycode = Common::KEYCODE_PERIOD;
+ event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+ break;
+ case JOY_BUT_SPACE:
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ break;
+ case JOY_BUT_F5:
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ break;
+ }
+ }
+ return true;
+}
+
+bool SdlEventSource::handleJoyButtonUp(SDL_Event &ev, Common::Event &event) {
+ if (ev.jbutton.button == JOY_BUT_LMOUSE) {
+ event.type = Common::EVENT_LBUTTONUP;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else if (ev.jbutton.button == JOY_BUT_RMOUSE) {
+ event.type = Common::EVENT_RBUTTONUP;
+ fillMouseEvent(event, _km.x, _km.y);
+ } else {
+ event.type = Common::EVENT_KEYUP;
+ switch (ev.jbutton.button) {
+ case JOY_BUT_ESCAPE:
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ break;
+ case JOY_BUT_PERIOD:
+ event.kbd.keycode = Common::KEYCODE_PERIOD;
+ event.kbd.ascii = mapKey(SDLK_PERIOD, ev.key.keysym.mod, 0);
+ break;
+ case JOY_BUT_SPACE:
+ event.kbd.keycode = Common::KEYCODE_SPACE;
+ event.kbd.ascii = mapKey(SDLK_SPACE, ev.key.keysym.mod, 0);
+ break;
+ case JOY_BUT_F5:
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ break;
+ }
+ }
+ return true;
+}
+
+bool SdlEventSource::handleJoyAxisMotion(SDL_Event &ev, Common::Event &event) {
+ int axis = ev.jaxis.value;
+ if ( axis > JOY_DEADZONE) {
+ axis -= JOY_DEADZONE;
+ event.type = Common::EVENT_MOUSEMOVE;
+ } else if ( axis < -JOY_DEADZONE ) {
+ axis += JOY_DEADZONE;
+ event.type = Common::EVENT_MOUSEMOVE;
+ } else
+ axis = 0;
+
+ if ( ev.jaxis.axis == JOY_XAXIS) {
+#ifdef JOY_ANALOG
+ _km.x_vel = axis / 2000;
+ _km.x_down_count = 0;
+#else
+ if (axis != 0) {
+ _km.x_vel = (axis > 0) ? 1:-1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+#endif
+
+ } else if (ev.jaxis.axis == JOY_YAXIS) {
+#ifndef JOY_INVERT_Y
+ axis = -axis;
+#endif
+#ifdef JOY_ANALOG
+ _km.y_vel = -axis / 2000;
+ _km.y_down_count = 0;
+#else
+ if (axis != 0) {
+ _km.y_vel = (-axis > 0) ? 1: -1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+#endif
+ }
+
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+}
+
+bool SdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
+#ifdef LINUPY
+ // On Yopy map the End button to quit
+ if ((ev.key.keysym.sym == 293)) {
+ event.type = Common::EVENT_QUIT;
+ return true;
+ }
+ // Map menu key to f5 (scumm menu)
+ if (ev.key.keysym.sym == 306) {
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = Common::KEYCODE_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.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = Common::KEYCODE_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.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = Common::KEYCODE_ESCAPE;
+ event.kbd.ascii = mapKey(SDLK_ESCAPE, ev.key.keysym.mod, 0);
+ return true;
+ }
+#endif
+
+#ifdef QTOPIA
+ // Quit on fn+backspace on zaurus
+ if (ev.key.keysym.sym == 127) {
+ event.type = Common::EVENT_QUIT;
+ return true;
+ }
+
+ // Map menu key (f11) to f5 (scumm menu)
+ if (ev.key.keysym.sym == SDLK_F11) {
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = Common::KEYCODE_F5;
+ event.kbd.ascii = mapKey(SDLK_F5, ev.key.keysym.mod, 0);
+ }
+ // Nap center (space) to tab (default action )
+ // I wanted to map the calendar button but the calendar comes up
+ //
+ else if (ev.key.keysym.sym == SDLK_SPACE) {
+ event.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = Common::KEYCODE_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.type = Common::EVENT_KEYDOWN;
+ event.kbd.keycode = Common::KEYCODE_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.type = Common::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
+ return false;
+}
+
+void SdlEventSource::toggleMouseGrab() {
+ if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF)
+ SDL_WM_GrabInput(SDL_GRAB_ON);
+ else
+ SDL_WM_GrabInput(SDL_GRAB_OFF);
+}
+
+void SdlEventSource::resetKeyboadEmulation(int16 x_max, int16 y_max) {
+ _km.x_max = x_max;
+ _km.y_max = y_max;
+ _km.delay_time = 25;
+ _km.last_time = 0;
+}
+
+#endif
diff --git a/backends/events/sdl/sdl-events.h b/backends/events/sdl/sdl-events.h
new file mode 100644
index 0000000000..b060d021fc
--- /dev/null
+++ b/backends/events/sdl/sdl-events.h
@@ -0,0 +1,138 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SDL_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SDL_H
+
+#include "backends/events/default/default-events.h"
+
+#if defined(__SYMBIAN32__)
+#include <esdl\SDL.h>
+#else
+#include <SDL.h>
+#endif
+
+/**
+ * The SDL event source.
+ */
+class SdlEventSource : public Common::EventSource {
+public:
+ SdlEventSource();
+ virtual ~SdlEventSource();
+
+ /**
+ * Gets and processes SDL events.
+ */
+ virtual bool pollEvent(Common::Event &event);
+
+ /**
+ * Resets keyboard emulation after a video screen change
+ */
+ virtual void resetKeyboadEmulation(int16 x_max, int16 y_max);
+
+ /**
+ * Toggles mouse input grab
+ */
+ virtual void toggleMouseGrab();
+
+protected:
+ /** @name Keyboard mouse emulation
+ * Disabled by fingolfin 2004-12-18.
+ * I am keeping the rest of the code in for now, since the joystick
+ * code (or rather, "hack") uses it, too.
+ */
+ //@{
+
+ struct KbdMouse {
+ int16 x, y, x_vel, y_vel, x_max, y_max, x_down_count, y_down_count;
+ uint32 last_time, delay_time, x_down_time, y_down_time;
+ };
+ KbdMouse _km;
+
+ //@}
+
+ /** Scroll lock state - since SDL doesn't track it */
+ bool _scrollLock;
+
+ /** Joystick */
+ SDL_Joystick *_joystick;
+
+ /** Last screen id for checking if it was modified */
+ int _lastScreenID;
+
+ /**
+ * Pre process an event before it is dispatched.
+ */
+ virtual void preprocessEvents(SDL_Event *event) {}
+
+ /**
+ * Dispatchs SDL events for each handler.
+ */
+ virtual bool dispatchSDLEvent(SDL_Event &ev, Common::Event &event);
+
+
+ /** @name Event Handlers
+ * Handlers for specific SDL events, called by SdlEventManager::dispatchSDLEvent().
+ * This way, if a managers inherits fromt this SDL events manager, it can
+ * change the behavior of only a single event, without having to override all
+ * of SdlEventManager::dispatchSDLEvent().
+ */
+ //@{
+
+ virtual bool handleKeyDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleKeyUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleMouseMotion(SDL_Event &ev, Common::Event &event);
+ virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonDown(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyButtonUp(SDL_Event &ev, Common::Event &event);
+ virtual bool handleJoyAxisMotion(SDL_Event &ev, Common::Event &event);
+ virtual void handleKbdMouse();
+
+ //@}
+
+ /**
+ * Assigns the mouse coords to the mouse event
+ */
+ virtual void fillMouseEvent(Common::Event &event, int x, int y);
+
+ /**
+ * Remaps key events. This allows platforms to configure
+ * their custom keys.
+ */
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+
+ /**
+ * Maps the ASCII value of key
+ */
+ virtual int mapKey(SDLKey key, SDLMod mod, Uint16 unicode);
+
+ /**
+ * Configures the key modifiers flags status
+ */
+ virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
+};
+
+#endif
diff --git a/backends/events/symbiansdl/symbiansdl-events.cpp b/backends/events/symbiansdl/symbiansdl-events.cpp
new file mode 100644
index 0000000000..2d144f9ad9
--- /dev/null
+++ b/backends/events/symbiansdl/symbiansdl-events.cpp
@@ -0,0 +1,201 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#ifdef __SYMBIAN32__
+
+#include "backends/events/symbiansdl/symbiansdl-events.h"
+#include "backends/platform/symbian/src/SymbianActions.h"
+#include "gui/message.h"
+#include "common/translation.h"
+
+#include <bautils.h>
+
+SymbianSdlEventManager::zoneDesc SymbianSdlEventManager::_zones[TOTAL_ZONES] = {
+ { 0, 0, 320, 145 },
+ { 0, 145, 150, 55 },
+ { 150, 145, 170, 55 }
+};
+
+SymbianSdlEventManager::SymbianSdlEventManager(Common::EventSource *boss)
+ :
+ _currentZone(0),
+ SdlEventManager(boss) {
+ for (int i = 0; i < TOTAL_ZONES; i++) {
+ _mouseXZone[i] = (_zones[i].x + (_zones[i].width / 2));
+ _mouseYZone[i] = (_zones[i].y + (_zones[i].height / 2));
+ }
+}
+
+bool SymbianSdlEventManager::remapKey(SDL_Event &ev, Common::Event &event) {
+ if (GUI::Actions::Instance()->mappingActive() || ev.key.keysym.sym <= SDLK_UNKNOWN)
+ return false;
+
+ for (TInt loop = 0; loop < GUI::ACTION_LAST; loop++) {
+ if (GUI::Actions::Instance()->getMapping(loop) == (uint)ev.key.keysym.sym &&
+ GUI::Actions::Instance()->isEnabled(loop)) {
+ // Create proper event instead
+ switch (loop) {
+ case GUI::ACTION_UP:
+ if (ev.type == SDL_KEYDOWN) {
+ _km.y_vel = -1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_DOWN:
+ if (ev.type == SDL_KEYDOWN) {
+ _km.y_vel = 1;
+ _km.y_down_count = 1;
+ } else {
+ _km.y_vel = 0;
+ _km.y_down_count = 0;
+ }
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_LEFT:
+ if (ev.type == SDL_KEYDOWN) {
+ _km.x_vel = -1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_RIGHT:
+ if (ev.type == SDL_KEYDOWN) {
+ _km.x_vel = 1;
+ _km.x_down_count = 1;
+ } else {
+ _km.x_vel = 0;
+ _km.x_down_count = 0;
+ }
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_LEFTCLICK:
+ event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_LBUTTONDOWN : Common::EVENT_LBUTTONUP);
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_RIGHTCLICK:
+ event.type = (ev.type == SDL_KEYDOWN ? Common::EVENT_RBUTTONDOWN : Common::EVENT_RBUTTONUP);
+ fillMouseEvent(event, _km.x, _km.y);
+
+ return true;
+
+ case GUI::ACTION_ZONE:
+ if (ev.type == SDL_KEYDOWN) {
+ for (int i = 0; i < TOTAL_ZONES; i++)
+ if (_km.x >= _zones[i].x && _km.y >= _zones[i].y &&
+ _km.x <= _zones[i].x + _zones[i].width && _km.y <= _zones[i].y + _zones[i].height
+ ) {
+ _mouseXZone[i] = _km.x;
+ _mouseYZone[i] = _km.y;
+ break;
+ }
+ _currentZone++;
+ if (_currentZone >= TOTAL_ZONES)
+ _currentZone = 0;
+ event.type = Common::EVENT_MOUSEMOVE;
+ fillMouseEvent(event, _mouseXZone[_currentZone], _mouseYZone[_currentZone]);
+ SDL_WarpMouse(event.mouse.x, event.mouse.y);
+ }
+
+ return true;
+ case GUI::ACTION_MULTI: {
+ GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop);
+ // if key code is pause, then change event to interactive or just fall through
+ if (key.keycode() == SDLK_PAUSE) {
+ event.type = Common::EVENT_PREDICTIVE_DIALOG;
+ return true;
+ }
+ }
+ case GUI::ACTION_SAVE:
+ case GUI::ACTION_SKIP:
+ case GUI::ACTION_SKIP_TEXT:
+ case GUI::ACTION_PAUSE:
+ case GUI::ACTION_SWAPCHAR:
+ case GUI::ACTION_FASTMODE:
+ case GUI::ACTION_DEBUGGER:
+ case GUI::ACTION_MAINMENU:
+ case GUI::ACTION_VKB:
+ case GUI::ACTION_KEYMAPPER:{
+ GUI::Key &key = GUI::Actions::Instance()->getKeyAction(loop);
+ ev.key.keysym.sym = (SDLKey) key.keycode();
+ ev.key.keysym.scancode = 0;
+ ev.key.keysym.mod = (SDLMod) key.flags();
+
+ // Translate from SDL keymod event to Scummvm Key Mod Common::Event.
+ // This codes is also present in GP32 backend and in SDL backend as a static function
+ // Perhaps it should be shared.
+ if (key.flags() != 0) {
+ event.kbd.flags = 0;
+
+ if (ev.key.keysym.mod & KMOD_SHIFT)
+ event.kbd.flags |= Common::KBD_SHIFT;
+
+ if (ev.key.keysym.mod & KMOD_ALT)
+ event.kbd.flags |= Common::KBD_ALT;
+
+ if (ev.key.keysym.mod & KMOD_CTRL)
+ event.kbd.flags |= Common::KBD_CTRL;
+ }
+
+ return false;
+ }
+
+ case GUI::ACTION_QUIT:
+ {
+ GUI::MessageDialog alert(_("Do you want to quit ?"), _("Yes"), _("No"));
+ if (alert.runModal() == GUI::kMessageOK)
+ g_system->quit();
+
+ return true;
+ }
+ }
+ }
+ }
+
+ return false;
+}
+
+#endif
+
diff --git a/backends/events/symbiansdl/symbiansdl-events.h b/backends/events/symbiansdl/symbiansdl-events.h
new file mode 100644
index 0000000000..fa1c066cae
--- /dev/null
+++ b/backends/events/symbiansdl/symbiansdl-events.h
@@ -0,0 +1,59 @@
+/* ScummVM - Graphic Adventure Engine
+ *
+ * ScummVM is the legal property of its developers, whose names
+ * are too numerous to list here. Please refer to the COPYRIGHT
+ * file distributed with this source distribution.
+ *
+ * This program is free software; you can redistribute it and/or
+ * modify it under the terms of the GNU General Public License
+ * as published by the Free Software Foundation; either version 2
+ * of the License, or (at your option) any later version.
+
+ * This program is distributed in the hope that it will be useful,
+ * but WITHOUT ANY WARRANTY; without even the implied warranty of
+ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
+ * GNU General Public License for more details.
+
+ * You should have received a copy of the GNU General Public License
+ * along with this program; if not, write to the Free Software
+ * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
+ *
+ * $URL$
+ * $Id$
+ *
+ */
+
+#if !defined(BACKEND_EVENTS_SYMBIAN_SDL_H) && !defined(DISABLE_DEFAULT_EVENTMANAGER)
+#define BACKEND_EVENTS_SYMBIAN_SDL_H
+
+#include "backends/events/sdl/sdl-events.h"
+
+#define TOTAL_ZONES 3
+
+/**
+ * SDL events manager for Symbian
+ */
+class SymbianSdlEventManager : public SdlEventManager {
+public:
+ SymbianSdlEventManager(Common::EventSource *boss);
+
+protected:
+ // Used to handle joystick navi zones
+ int _mouseXZone[TOTAL_ZONES];
+ int _mouseYZone[TOTAL_ZONES];
+ int _currentZone;
+
+ struct zoneDesc {
+ int x;
+ int y;
+ int width;
+ int height;
+ };
+
+ static zoneDesc _zones[TOTAL_ZONES];
+
+ virtual bool remapKey(SDL_Event &ev, Common::Event &event);
+};
+
+#endif
+