WEBOS: Enable keymapper, implement FORWARD key and right+middle button clicks
This commit is contained in:
parent
48dbbdcd74
commit
aa79a2634d
8 changed files with 276 additions and 11 deletions
|
@ -30,26 +30,84 @@
|
||||||
|
|
||||||
#include "backends/events/webossdl/webossdl-events.h"
|
#include "backends/events/webossdl/webossdl-events.h"
|
||||||
|
|
||||||
|
static int mouseButton = 0;
|
||||||
|
|
||||||
|
// WebOS devices only have a shift key and a ctrl key. There is also an alt
|
||||||
|
// key (the orange key) but this is already processed by WebOS to change the
|
||||||
|
// mode of the keys so ScummVM must not use this key as a modifier.
|
||||||
|
void WebOSSdlEventSource::SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event) {
|
||||||
|
event.kbd.flags = 0;
|
||||||
|
|
||||||
|
if (mod & KMOD_SHIFT)
|
||||||
|
event.kbd.flags |= Common::KBD_SHIFT;
|
||||||
|
if (mod & KMOD_CTRL)
|
||||||
|
event.kbd.flags |= Common::KBD_CTRL;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Capture Shift and Control to decide the active mouse button
|
||||||
bool WebOSSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
|
bool WebOSSdlEventSource::remapKey(SDL_Event &ev, Common::Event &event) {
|
||||||
|
int sym = ev.key.keysym.sym;
|
||||||
switch (ev.type) {
|
switch (ev.type) {
|
||||||
case SDL_KEYDOWN:{
|
case SDL_KEYDOWN:
|
||||||
if (ev.key.keysym.sym == 231) {
|
if (sym == 304) {
|
||||||
printf("metatap down\n");
|
mouseButton = 1;
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
else if (sym == 305) {
|
||||||
|
mouseButton = 2;
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
case SDL_KEYUP:
|
||||||
case SDL_KEYUP: {
|
if (sym == 304 || sym == 305) {
|
||||||
if (ev.key.keysym.sym == 231) {
|
mouseButton = 0;
|
||||||
printf("metatap up\n");
|
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
}
|
|
||||||
|
|
||||||
// Invoke parent implementation of this method
|
// Invoke parent implementation of this method
|
||||||
return SdlEventSource::remapKey(ev, event);
|
return SdlEventSource::remapKey(ev, event);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool WebOSSdlEventSource::handleMouseButtonDown(SDL_Event &ev, Common::Event &event) {
|
||||||
|
// Simulate right mouse button
|
||||||
|
if (ev.button.button == SDL_BUTTON_LEFT && mouseButton == 1) {
|
||||||
|
event.type = Common::EVENT_RBUTTONDOWN;
|
||||||
|
fillMouseEvent(event, ev.button.x, ev.button.y);
|
||||||
|
printf("rbutton down\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simulate middle mouse button
|
||||||
|
if (ev.button.button == SDL_BUTTON_LEFT && mouseButton == 2) {
|
||||||
|
event.type = Common::EVENT_MBUTTONDOWN;
|
||||||
|
fillMouseEvent(event, ev.button.x, ev.button.y);
|
||||||
|
printf("rbutton down\n");
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoke parent implementation of this method
|
||||||
|
return SdlEventSource::handleMouseButtonDown(ev, event);
|
||||||
|
}
|
||||||
|
|
||||||
|
bool WebOSSdlEventSource::handleMouseButtonUp(SDL_Event &ev, Common::Event &event) {
|
||||||
|
// Simulate right mouse button
|
||||||
|
if (ev.button.button == SDL_BUTTON_LEFT && mouseButton == 1) {
|
||||||
|
event.type = Common::EVENT_RBUTTONUP;
|
||||||
|
fillMouseEvent(event, ev.button.x, ev.button.y);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Simulate right mouse button
|
||||||
|
if (ev.button.button == SDL_BUTTON_LEFT && mouseButton == 2) {
|
||||||
|
event.type = Common::EVENT_MBUTTONUP;
|
||||||
|
fillMouseEvent(event, ev.button.x, ev.button.y);
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
|
||||||
|
// Invoke parent implementation of this method
|
||||||
|
return SdlEventSource::handleMouseButtonUp(ev, event);
|
||||||
|
}
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -33,7 +33,10 @@
|
||||||
*/
|
*/
|
||||||
class WebOSSdlEventSource : public SdlEventSource {
|
class WebOSSdlEventSource : public SdlEventSource {
|
||||||
protected:
|
protected:
|
||||||
|
virtual void SDLModToOSystemKeyFlags(SDLMod mod, Common::Event &event);
|
||||||
virtual bool remapKey(SDL_Event &ev, Common::Event &event);
|
virtual bool remapKey(SDL_Event &ev, Common::Event &event);
|
||||||
|
virtual bool handleMouseButtonDown(SDL_Event &ev, Common::Event &event);
|
||||||
|
virtual bool handleMouseButtonUp(SDL_Event &ev, Common::Event &event);
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
164
backends/platform/webos/hardwarekeys.cpp
Normal file
164
backends/platform/webos/hardwarekeys.cpp
Normal file
|
@ -0,0 +1,164 @@
|
||||||
|
/* 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$
|
||||||
|
*
|
||||||
|
*/
|
||||||
|
|
||||||
|
#include "backends/platform/webos/webos.h"
|
||||||
|
#include "backends/platform/webos/keyboard.h"
|
||||||
|
#include "backends/keymapper/keymapper.h"
|
||||||
|
#include "common/keyboard.h"
|
||||||
|
|
||||||
|
#ifdef ENABLE_KEYMAPPER
|
||||||
|
|
||||||
|
using namespace Common;
|
||||||
|
|
||||||
|
struct Key {
|
||||||
|
const char *hwId;
|
||||||
|
KeyCode keycode;
|
||||||
|
uint16 ascii;
|
||||||
|
const char *desc;
|
||||||
|
KeyType preferredAction;
|
||||||
|
bool shiftable;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Key keys[] = {
|
||||||
|
{"BACKSPACE", KEYCODE_BACKSPACE, ASCII_BACKSPACE, "Backspace", kActionKeyType, false},
|
||||||
|
{"RETURN", KEYCODE_RETURN, ASCII_RETURN, "Return", kActionKeyType, false},
|
||||||
|
{"ESCAPE", KEYCODE_ESCAPE, ASCII_ESCAPE, "Esc", kStartKeyType, false},
|
||||||
|
{"SPACE", KEYCODE_SPACE, ASCII_SPACE, "Space", kActionKeyType, false},
|
||||||
|
{"EXCLAIM", KEYCODE_EXCLAIM, '!', "!", kActionKeyType, false},
|
||||||
|
{"QUOTEDBL", KEYCODE_QUOTEDBL, '"', "\"", kActionKeyType, false},
|
||||||
|
{"HASH", KEYCODE_HASH, '#', "#", kActionKeyType, false},
|
||||||
|
{"DOLLAR", KEYCODE_DOLLAR, '$', "$", kActionKeyType, false},
|
||||||
|
{"AMPERSAND", KEYCODE_AMPERSAND, '&', "&", kActionKeyType, false},
|
||||||
|
{"QUOTE", KEYCODE_QUOTE, '\'', "'", kActionKeyType, false},
|
||||||
|
{"LEFTPAREN", KEYCODE_LEFTPAREN, '(', "(", kActionKeyType, false},
|
||||||
|
{"RIGHTPAREN", KEYCODE_RIGHTPAREN, ')', ")", kActionKeyType, false},
|
||||||
|
{"ASTERISK", KEYCODE_ASTERISK, '*', "*", kActionKeyType, false},
|
||||||
|
{"PLUS", KEYCODE_PLUS, '+', "+", kActionKeyType, false},
|
||||||
|
{"COMMA", KEYCODE_COMMA, ',', ",", kActionKeyType, false},
|
||||||
|
{"MINUS", KEYCODE_MINUS, '-', "-", kActionKeyType, false},
|
||||||
|
{"PERIOD", KEYCODE_PERIOD, '.', ".", kActionKeyType, false},
|
||||||
|
{"SLASH", KEYCODE_SLASH, '/', "/", kActionKeyType, false},
|
||||||
|
{"0", KEYCODE_0, '0', "0", kActionKeyType, false},
|
||||||
|
{"1", KEYCODE_1, '1', "1", kActionKeyType, false},
|
||||||
|
{"2", KEYCODE_2, '2', "2", kActionKeyType, false},
|
||||||
|
{"3", KEYCODE_3, '3', "3", kActionKeyType, false},
|
||||||
|
{"4", KEYCODE_4, '4', "4", kActionKeyType, false},
|
||||||
|
{"5", KEYCODE_5, '5', "5", kActionKeyType, false},
|
||||||
|
{"6", KEYCODE_6, '6', "6", kActionKeyType, false},
|
||||||
|
{"7", KEYCODE_7, '7', "7", kActionKeyType, false},
|
||||||
|
{"8", KEYCODE_8, '8', "8", kActionKeyType, false},
|
||||||
|
{"9", KEYCODE_9, '9', "9", kActionKeyType, false},
|
||||||
|
{"COLON", KEYCODE_COLON, ':', ":", kActionKeyType, false},
|
||||||
|
{"SEMICOLON", KEYCODE_SEMICOLON, ';', ";", kActionKeyType, false},
|
||||||
|
{"EQUALS", KEYCODE_EQUALS, '=', "=", kActionKeyType, false},
|
||||||
|
{"QUESTION", KEYCODE_QUESTION, '?', "?", kActionKeyType, false},
|
||||||
|
{"AT", KEYCODE_AT, '@', "@", kActionKeyType, false},
|
||||||
|
|
||||||
|
{"UNDERSCORE", KEYCODE_UNDERSCORE, '_', "_", kActionKeyType, false},
|
||||||
|
{"a", KEYCODE_a, 'a', "a", kActionKeyType, true},
|
||||||
|
{"b", KEYCODE_b, 'b', "b", kActionKeyType, true},
|
||||||
|
{"c", KEYCODE_c, 'c', "c", kActionKeyType, true},
|
||||||
|
{"d", KEYCODE_d, 'd', "d", kActionKeyType, true},
|
||||||
|
{"e", KEYCODE_e, 'e', "e", kActionKeyType, true},
|
||||||
|
{"f", KEYCODE_f, 'f', "f", kActionKeyType, true},
|
||||||
|
{"g", KEYCODE_g, 'g', "g", kActionKeyType, true},
|
||||||
|
{"h", KEYCODE_h, 'h', "h", kActionKeyType, true},
|
||||||
|
{"i", KEYCODE_i, 'i', "i", kActionKeyType, true},
|
||||||
|
{"j", KEYCODE_j, 'j', "j", kActionKeyType, true},
|
||||||
|
{"k", KEYCODE_k, 'k', "k", kActionKeyType, true},
|
||||||
|
{"l", KEYCODE_l, 'l', "l", kActionKeyType, true},
|
||||||
|
{"m", KEYCODE_m, 'm', "m", kActionKeyType, true},
|
||||||
|
{"n", KEYCODE_n, 'n', "n", kActionKeyType, true},
|
||||||
|
{"o", KEYCODE_o, 'o', "o", kActionKeyType, true},
|
||||||
|
{"p", KEYCODE_p, 'p', "p", kActionKeyType, true},
|
||||||
|
{"q", KEYCODE_q, 'q', "q", kActionKeyType, true},
|
||||||
|
{"r", KEYCODE_r, 'r', "r", kActionKeyType, true},
|
||||||
|
{"s", KEYCODE_s, 's', "s", kActionKeyType, true},
|
||||||
|
{"t", KEYCODE_t, 't', "t", kActionKeyType, true},
|
||||||
|
{"u", KEYCODE_u, 'u', "u", kActionKeyType, true},
|
||||||
|
{"v", KEYCODE_v, 'v', "v", kActionKeyType, true},
|
||||||
|
{"w", KEYCODE_w, 'w', "w", kActionKeyType, true},
|
||||||
|
{"x", KEYCODE_x, 'x', "x", kActionKeyType, true},
|
||||||
|
{"y", KEYCODE_y, 'y', "y", kActionKeyType, true},
|
||||||
|
{"z", KEYCODE_z, 'z', "z", kActionKeyType, true},
|
||||||
|
|
||||||
|
// Miscellaneous function keys
|
||||||
|
{ "FORWARD", (KeyCode) KEYCODE_FORWARD, ASCII_FORWARD, "Forward", kActionKeyType, false },
|
||||||
|
|
||||||
|
{0, KEYCODE_INVALID, 0, 0, kGenericKeyType, false}
|
||||||
|
};
|
||||||
|
|
||||||
|
struct Mod {
|
||||||
|
byte flag;
|
||||||
|
const char *id;
|
||||||
|
const char *desc;
|
||||||
|
bool shiftable;
|
||||||
|
};
|
||||||
|
|
||||||
|
static const Mod modifiers[] = {
|
||||||
|
{ 0, "", "", false },
|
||||||
|
{ KBD_CTRL, "C+", "Ctrl+", false },
|
||||||
|
{ KBD_SHIFT, "", "", true },
|
||||||
|
{ KBD_SHIFT | KBD_CTRL, "S+C+", "Shift+Ctrl+", true },
|
||||||
|
{ 0, 0, 0, false }
|
||||||
|
};
|
||||||
|
#endif
|
||||||
|
|
||||||
|
Common::HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() {
|
||||||
|
#ifdef ENABLE_KEYMAPPER
|
||||||
|
|
||||||
|
HardwareKeySet *keySet = new HardwareKeySet();
|
||||||
|
const Key *key;
|
||||||
|
const Mod *mod;
|
||||||
|
char fullKeyId[50];
|
||||||
|
char fullKeyDesc[100];
|
||||||
|
uint16 ascii;
|
||||||
|
|
||||||
|
for (mod = modifiers; mod->id; mod++) {
|
||||||
|
for (key = keys; key->hwId; key++) {
|
||||||
|
ascii = key->ascii;
|
||||||
|
|
||||||
|
if (mod->shiftable && key->shiftable) {
|
||||||
|
snprintf(fullKeyId, 50, "%s%c", mod->id, toupper(key->hwId[0]));
|
||||||
|
snprintf(fullKeyDesc, 100, "%s%c", mod->desc, toupper(key->desc[0]));
|
||||||
|
ascii = toupper(key->ascii);
|
||||||
|
} else if (mod->shiftable) {
|
||||||
|
snprintf(fullKeyId, 50, "S+%s%s", mod->id, key->hwId);
|
||||||
|
snprintf(fullKeyDesc, 100, "Shift+%s%s", mod->desc, key->desc);
|
||||||
|
} else {
|
||||||
|
snprintf(fullKeyId, 50, "%s%s", mod->id, key->hwId);
|
||||||
|
snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc);
|
||||||
|
}
|
||||||
|
|
||||||
|
keySet->addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc, key->preferredAction ));
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
return keySet;
|
||||||
|
|
||||||
|
#else
|
||||||
|
return 0;
|
||||||
|
#endif
|
||||||
|
}
|
37
backends/platform/webos/keyboard.h
Normal file
37
backends/platform/webos/keyboard.h
Normal file
|
@ -0,0 +1,37 @@
|
||||||
|
/* 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 WEBOS_KEYBOARD_H
|
||||||
|
#define WEBOS_KEYBOARD_H
|
||||||
|
|
||||||
|
enum {
|
||||||
|
KEYCODE_FORWARD = 229
|
||||||
|
};
|
||||||
|
|
||||||
|
enum {
|
||||||
|
ASCII_FORWARD = 229
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif
|
|
@ -32,7 +32,6 @@
|
||||||
#include <unistd.h>
|
#include <unistd.h>
|
||||||
|
|
||||||
int main(int argc, char* argv[]) {
|
int main(int argc, char* argv[]) {
|
||||||
|
|
||||||
g_system = new OSystem_SDL_WebOS();
|
g_system = new OSystem_SDL_WebOS();
|
||||||
assert(g_system);
|
assert(g_system);
|
||||||
|
|
||||||
|
|
|
@ -2,7 +2,8 @@ MODULE := backends/platform/webos
|
||||||
|
|
||||||
MODULE_OBJS := \
|
MODULE_OBJS := \
|
||||||
main.o \
|
main.o \
|
||||||
webos.o
|
webos.o \
|
||||||
|
hardwarekeys.o
|
||||||
|
|
||||||
# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
|
# We don't use rules.mk but rather manually update OBJS and MODULE_DIRS.
|
||||||
MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
|
MODULE_OBJS := $(addprefix $(MODULE)/, $(MODULE_OBJS))
|
||||||
|
|
|
@ -26,6 +26,7 @@
|
||||||
#ifndef PLATFORM_SDL_WEBOS_H
|
#ifndef PLATFORM_SDL_WEBOS_H
|
||||||
#define PLATFORM_SDL_WEBOS_H
|
#define PLATFORM_SDL_WEBOS_H
|
||||||
|
|
||||||
|
#include "common/system.h"
|
||||||
#include "backends/platform/sdl/posix/posix.h"
|
#include "backends/platform/sdl/posix/posix.h"
|
||||||
|
|
||||||
class OSystem_SDL_WebOS : public OSystem_POSIX {
|
class OSystem_SDL_WebOS : public OSystem_POSIX {
|
||||||
|
@ -33,6 +34,7 @@ public:
|
||||||
OSystem_SDL_WebOS();
|
OSystem_SDL_WebOS();
|
||||||
|
|
||||||
virtual void initBackend();
|
virtual void initBackend();
|
||||||
|
virtual Common::HardwareKeySet *getHardwareKeySet();
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif
|
#endif
|
||||||
|
|
3
configure
vendored
3
configure
vendored
|
@ -2068,6 +2068,7 @@ if test -n "$_host"; then
|
||||||
_mt32emu=no
|
_mt32emu=no
|
||||||
_seq_midi=no
|
_seq_midi=no
|
||||||
_vkeybd=yes
|
_vkeybd=yes
|
||||||
|
_keymapper=yes
|
||||||
;;
|
;;
|
||||||
wii)
|
wii)
|
||||||
_endian=big
|
_endian=big
|
||||||
|
@ -3132,7 +3133,7 @@ case $_backend in
|
||||||
DEFINES="$DEFINES -DSDL_BACKEND"
|
DEFINES="$DEFINES -DSDL_BACKEND"
|
||||||
;;
|
;;
|
||||||
webos)
|
webos)
|
||||||
INCLUDES="$INCLUDES -I$WEBOS_PDK/include/SDL"
|
INCLUDES="$INCLUDES -I$WEBOS_PDK/include -I$WEBOS_PDK/include/SDL"
|
||||||
LIBS="$LIBS -lSDL -lpdl"
|
LIBS="$LIBS -lSDL -lpdl"
|
||||||
DEFINES="$DEFINES -DSDL_BACKEND -DWEBOS"
|
DEFINES="$DEFINES -DSDL_BACKEND -DWEBOS"
|
||||||
MODULES="$MODULES backends/platform/sdl"
|
MODULES="$MODULES backends/platform/sdl"
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue