[Scummvm-git-logs] scummvm master -> c2e424e08b07f720b8c1de03d42c71865a52611c
grisenti
noreply at scummvm.org
Sun Apr 9 07:41:29 UTC 2023
This automated email contains information about 1 new commit which have been
pushed to the 'scummvm' repo located at https://github.com/scummvm/scummvm .
Summary:
c2e424e08b HPL1: remove indirection for keyboard class
Commit: c2e424e08b07f720b8c1de03d42c71865a52611c
https://github.com/scummvm/scummvm/commit/c2e424e08b07f720b8c1de03d42c71865a52611c
Author: grisenti (emanuele at grisenti.net)
Date: 2023-04-09T09:40:53+02:00
Commit Message:
HPL1: remove indirection for keyboard class
Changed paths:
R engines/hpl1/engine/impl/KeyboardSDL.cpp
R engines/hpl1/engine/impl/KeyboardSDL.h
engines/hpl1/engine/game/low_level_game_setup.cpp
engines/hpl1/engine/input/Keyboard.cpp
engines/hpl1/engine/input/Keyboard.h
engines/hpl1/engine/input/LowLevelInput.cpp
engines/hpl1/engine/input/LowLevelInput.h
engines/hpl1/module.mk
diff --git a/engines/hpl1/engine/game/low_level_game_setup.cpp b/engines/hpl1/engine/game/low_level_game_setup.cpp
index 44ca38504ba..68ad73f053d 100644
--- a/engines/hpl1/engine/game/low_level_game_setup.cpp
+++ b/engines/hpl1/engine/game/low_level_game_setup.cpp
@@ -20,7 +20,6 @@
*/
#include "hpl1/engine/game/low_level_game_setup.h"
-#include "hpl1/engine/impl/KeyboardSDL.h"
#include "hpl1/engine/impl/LowLevelGraphicsSDL.h"
#include "hpl1/engine/impl/LowLevelPhysicsNewton.h"
#include "hpl1/engine/impl/LowLevelSoundOpenAL.h"
diff --git a/engines/hpl1/engine/impl/KeyboardSDL.cpp b/engines/hpl1/engine/impl/KeyboardSDL.cpp
deleted file mode 100644
index 7ec909ba3a6..00000000000
--- a/engines/hpl1/engine/impl/KeyboardSDL.cpp
+++ /dev/null
@@ -1,388 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * Copyright (C) 2006-2010 - Frictional Games
- *
- * This file is part of HPL1 Engine.
- */
-
-#include "common/keyboard.h"
-#include "common/system.h"
-#include "hpl1/engine/impl/KeyboardSDL.h"
-#include "hpl1/engine/input/LowLevelInput.h"
-
-namespace hpl {
-
-//-----------------------------------------------------------------------
-
-cKeyboardSDL::cKeyboardSDL(LowLevelInput *apLowLevelInputSDL) : iKeyboard("SDL Portable Keyboard") {
- _lowLevelSystem = apLowLevelInputSDL;
-
- _downKeys.set_size(eKey_LastEnum);
- _downKeys.clear();
-}
-
-//-----------------------------------------------------------------------
-
-static eKey convertKey(int alKey) {
- switch (alKey) {
- case Common::KEYCODE_BACKSPACE:
- return eKey_BACKSPACE;
- case Common::KEYCODE_TAB:
- return eKey_TAB;
- case Common::KEYCODE_CLEAR:
- return eKey_CLEAR;
- case Common::KEYCODE_RETURN:
- return eKey_RETURN;
- case Common::KEYCODE_PAUSE:
- return eKey_PAUSE;
- case Common::KEYCODE_ESCAPE:
- return eKey_ESCAPE;
- case Common::KEYCODE_SPACE:
- return eKey_SPACE;
- case Common::KEYCODE_EXCLAIM:
- return eKey_EXCLAIM;
- case Common::KEYCODE_QUOTEDBL:
- return eKey_QUOTEDBL;
- case Common::KEYCODE_HASH:
- return eKey_HASH;
- case Common::KEYCODE_DOLLAR:
- return eKey_DOLLAR;
- case Common::KEYCODE_AMPERSAND:
- return eKey_AMPERSAND;
- case Common::KEYCODE_QUOTE:
- return eKey_QUOTE;
- case Common::KEYCODE_LEFTPAREN:
- return eKey_LEFTPAREN;
- case Common::KEYCODE_RIGHTPAREN:
- return eKey_RIGHTPAREN;
- case Common::KEYCODE_ASTERISK:
- return eKey_ASTERISK;
- case Common::KEYCODE_PLUS:
- return eKey_PLUS;
- case Common::KEYCODE_COMMA:
- return eKey_COMMA;
- case Common::KEYCODE_MINUS:
- return eKey_MINUS;
- case Common::KEYCODE_PERIOD:
- return eKey_PERIOD;
- case Common::KEYCODE_SLASH:
- return eKey_SLASH;
- case Common::KEYCODE_0:
- return eKey_0;
- case Common::KEYCODE_1:
- return eKey_1;
- case Common::KEYCODE_2:
- return eKey_2;
- case Common::KEYCODE_3:
- return eKey_3;
- case Common::KEYCODE_4:
- return eKey_4;
- case Common::KEYCODE_5:
- return eKey_5;
- case Common::KEYCODE_6:
- return eKey_6;
- case Common::KEYCODE_7:
- return eKey_7;
- case Common::KEYCODE_8:
- return eKey_8;
- case Common::KEYCODE_9:
- return eKey_9;
- case Common::KEYCODE_COLON:
- return eKey_COLON;
- case Common::KEYCODE_SEMICOLON:
- return eKey_SEMICOLON;
- case Common::KEYCODE_LESS:
- return eKey_LESS;
- case Common::KEYCODE_EQUALS:
- return eKey_EQUALS;
- case Common::KEYCODE_GREATER:
- return eKey_GREATER;
- case Common::KEYCODE_QUESTION:
- return eKey_QUESTION;
- case Common::KEYCODE_AT:
- return eKey_AT;
- case Common::KEYCODE_LEFTBRACKET:
- return eKey_LEFTBRACKET;
- case Common::KEYCODE_BACKSLASH:
- return eKey_BACKSLASH;
- case Common::KEYCODE_RIGHTBRACKET:
- return eKey_RIGHTBRACKET;
- case Common::KEYCODE_CARET:
- return eKey_CARET;
- case Common::KEYCODE_UNDERSCORE:
- return eKey_UNDERSCORE;
- case Common::KEYCODE_BACKQUOTE:
- return eKey_BACKQUOTE;
- case Common::KEYCODE_a:
- return eKey_a;
- case Common::KEYCODE_b:
- return eKey_b;
- case Common::KEYCODE_c:
- return eKey_c;
- case Common::KEYCODE_d:
- return eKey_d;
- case Common::KEYCODE_e:
- return eKey_e;
- case Common::KEYCODE_f:
- return eKey_f;
- case Common::KEYCODE_g:
- return eKey_g;
- case Common::KEYCODE_h:
- return eKey_h;
- case Common::KEYCODE_i:
- return eKey_i;
- case Common::KEYCODE_j:
- return eKey_j;
- case Common::KEYCODE_k:
- return eKey_k;
- case Common::KEYCODE_l:
- return eKey_l;
- case Common::KEYCODE_m:
- return eKey_m;
- case Common::KEYCODE_n:
- return eKey_n;
- case Common::KEYCODE_o:
- return eKey_o;
- case Common::KEYCODE_p:
- return eKey_p;
- case Common::KEYCODE_q:
- return eKey_q;
- case Common::KEYCODE_r:
- return eKey_r;
- case Common::KEYCODE_s:
- return eKey_s;
- case Common::KEYCODE_t:
- return eKey_t;
- case Common::KEYCODE_u:
- return eKey_u;
- case Common::KEYCODE_v:
- return eKey_v;
- case Common::KEYCODE_w:
- return eKey_w;
- case Common::KEYCODE_x:
- return eKey_x;
- case Common::KEYCODE_y:
- return eKey_y;
- case Common::KEYCODE_z:
- return eKey_z;
- case Common::KEYCODE_DELETE:
- return eKey_DELETE;
- case Common::KEYCODE_KP0:
- return eKey_KP0;
- case Common::KEYCODE_KP1:
- return eKey_KP1;
- case Common::KEYCODE_KP2:
- return eKey_KP2;
- case Common::KEYCODE_KP3:
- return eKey_KP3;
- case Common::KEYCODE_KP4:
- return eKey_KP4;
- case Common::KEYCODE_KP5:
- return eKey_KP5;
- case Common::KEYCODE_KP6:
- return eKey_KP6;
- case Common::KEYCODE_KP7:
- return eKey_KP7;
- case Common::KEYCODE_KP8:
- return eKey_KP8;
- case Common::KEYCODE_KP9:
- return eKey_KP9;
- case Common::KEYCODE_KP_PERIOD:
- return eKey_KP_PERIOD;
- case Common::KEYCODE_KP_DIVIDE:
- return eKey_KP_DIVIDE;
- case Common::KEYCODE_KP_MULTIPLY:
- return eKey_KP_MULTIPLY;
- case Common::KEYCODE_KP_MINUS:
- return eKey_KP_MINUS;
- case Common::KEYCODE_KP_PLUS:
- return eKey_KP_PLUS;
- case Common::KEYCODE_KP_ENTER:
- return eKey_KP_ENTER;
- case Common::KEYCODE_KP_EQUALS:
- return eKey_KP_EQUALS;
- case Common::KEYCODE_UP:
- return eKey_UP;
- case Common::KEYCODE_DOWN:
- return eKey_DOWN;
- case Common::KEYCODE_RIGHT:
- return eKey_RIGHT;
- case Common::KEYCODE_LEFT:
- return eKey_LEFT;
- case Common::KEYCODE_INSERT:
- return eKey_INSERT;
- case Common::KEYCODE_HOME:
- return eKey_HOME;
- case Common::KEYCODE_END:
- return eKey_END;
- case Common::KEYCODE_PAGEUP:
- return eKey_PAGEUP;
- case Common::KEYCODE_PAGEDOWN:
- return eKey_PAGEDOWN;
- case Common::KEYCODE_F1:
- return eKey_F1;
- case Common::KEYCODE_F2:
- return eKey_F2;
- case Common::KEYCODE_F3:
- return eKey_F3;
- case Common::KEYCODE_F4:
- return eKey_F4;
- case Common::KEYCODE_F5:
- return eKey_F5;
- case Common::KEYCODE_F6:
- return eKey_F6;
- case Common::KEYCODE_F7:
- return eKey_F7;
- case Common::KEYCODE_F8:
- return eKey_F8;
- case Common::KEYCODE_F9:
- return eKey_F9;
- case Common::KEYCODE_F10:
- return eKey_F10;
- case Common::KEYCODE_F11:
- return eKey_F11;
- case Common::KEYCODE_F12:
- return eKey_F12;
- case Common::KEYCODE_F13:
- return eKey_F13;
- case Common::KEYCODE_F14:
- return eKey_F14;
- case Common::KEYCODE_F15:
- return eKey_F15;
- case Common::KEYCODE_NUMLOCK:
- return eKey_NUMLOCK;
- case Common::KEYCODE_CAPSLOCK:
- return eKey_CAPSLOCK;
- case Common::KEYCODE_SCROLLOCK:
- return eKey_SCROLLOCK;
- case Common::KEYCODE_RSHIFT:
- return eKey_RSHIFT;
- case Common::KEYCODE_LSHIFT:
- return eKey_LSHIFT;
- case Common::KEYCODE_RCTRL:
- return eKey_RCTRL;
- case Common::KEYCODE_LCTRL:
- return eKey_LCTRL;
- case Common::KEYCODE_RALT:
- return eKey_RALT;
- case Common::KEYCODE_LALT:
- return eKey_LALT;
- case Common::KEYCODE_RMETA:
- return eKey_RMETA;
- case Common::KEYCODE_LMETA:
- return eKey_LMETA;
- case Common::KEYCODE_LSUPER:
- return eKey_LSUPER;
- case Common::KEYCODE_RSUPER:
- return eKey_RSUPER;
- case Common::KEYCODE_MODE:
- return eKey_MODE;
- case Common::KEYCODE_HELP:
- return eKey_HELP;
- case Common::KEYCODE_PRINT:
- return eKey_PRINT;
- case Common::KEYCODE_SYSREQ:
- return eKey_SYSREQ;
- case Common::KEYCODE_BREAK:
- return eKey_BREAK;
- case Common::KEYCODE_MENU:
- return eKey_MENU;
- case Common::KEYCODE_POWER:
- return eKey_POWER;
- case Common::KEYCODE_EURO:
- return eKey_EURO;
- }
- return eKey_NONE;
-}
-
-static eKeyModifier convertModifiers(const int mods) {
- eKeyModifier out = eKeyModifier_NONE;
- if (mods & Common::KBD_CTRL)
- out |= eKeyModifier_CTRL;
- if (mods & Common::KBD_SHIFT)
- out |= eKeyModifier_SHIFT;
- if (mods & Common::KBD_ALT)
- out |= eKeyModifier_ALT;
- if (mods & Common::KBD_META)
- out |= eKeyModifier_META;
- return out;
-}
-
-void cKeyboardSDL::processEvent(const Common::Event &ev) {
- if (ev.type != Common::EVENT_KEYDOWN && ev.type != Common::EVENT_KEYUP)
- return;
-
- eKey key = convertKey(ev.kbd.keycode);
- if (ev.type == Common::EVENT_KEYDOWN) {
- _downKeys.set(key);
- _modifiers = convertModifiers(ev.kbd.flags);
- _pressedKeys.push(cKeyPress(key, ev.kbd.ascii, _modifiers));
- } else
- _downKeys.unset(key);
-}
-
-void cKeyboardSDL::Update() {
- _pressedKeys.clear();
- for (const Common::Event &ev : _lowLevelSystem->_events)
- processEvent(ev);
-}
-
-//-----------------------------------------------------------------------
-
-bool cKeyboardSDL::KeyIsDown(eKey key) {
- return _downKeys.get(key);
-}
-
-//-----------------------------------------------------------------------
-
-cKeyPress cKeyboardSDL::GetKey() {
- return _pressedKeys.pop();
-}
-
-//-----------------------------------------------------------------------
-
-bool cKeyboardSDL::KeyIsPressed() {
- return _pressedKeys.empty() == false;
-}
-
-//-----------------------------------------------------------------------
-
-eKeyModifier cKeyboardSDL::GetModifier() {
- return _modifiers;
-}
-
-//-----------------------------------------------------------------------
-
-tString cKeyboardSDL::KeyToString(eKey) {
- return "None";
-}
-
-//-----------------------------------------------------------------------
-
-eKey cKeyboardSDL::StringToKey(tString) {
- return eKey_NONE;
-}
-
-//-----------------------------------------------------------------------
-
-} // namespace hpl
diff --git a/engines/hpl1/engine/impl/KeyboardSDL.h b/engines/hpl1/engine/impl/KeyboardSDL.h
deleted file mode 100644
index a4d20d7344a..00000000000
--- a/engines/hpl1/engine/impl/KeyboardSDL.h
+++ /dev/null
@@ -1,74 +0,0 @@
-/* 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 3 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, see <http://www.gnu.org/licenses/>.
- *
- */
-
-/*
- * Copyright (C) 2006-2010 - Frictional Games
- *
- * This file is part of HPL1 Engine.
- */
-
-#ifndef HPL_KEYBOARD_SDL_H
-#define HPL_KEYBOARD_SDL_H
-
-#include "common/bitarray.h"
-#include "common/queue.h"
-#include "hpl1/engine/input/Keyboard.h"
-#include "hpl1/engine/system/SystemTypes.h"
-
-namespace Common {
-
-struct Event;
-
-}
-
-namespace hpl {
-
-#define MAX_KEY_PRESSES (20)
-
-class LowLevelInput;
-
-class cKeyboardSDL : public iKeyboard {
-public:
- cKeyboardSDL(LowLevelInput *apLowLevelInputSDL);
-
- void Update();
-
- // Keyboard specific
- bool KeyIsDown(eKey aKey);
- cKeyPress GetKey();
- bool KeyIsPressed();
- eKeyModifier GetModifier();
- tString KeyToString(eKey);
- eKey StringToKey(tString);
-
-private:
- void processEvent(const Common::Event &ev);
- eKey AsciiToKey(int alChar);
-
- eKeyModifier _modifiers;
- Common::BitArray _downKeys;
- Common::Queue<cKeyPress> _pressedKeys;
- LowLevelInput *_lowLevelSystem;
-};
-
-} // namespace hpl
-
-#endif // HPL_KEYBOARD_SDL_H
diff --git a/engines/hpl1/engine/input/Keyboard.cpp b/engines/hpl1/engine/input/Keyboard.cpp
index ea9e37751ab..69b268d89cc 100644
--- a/engines/hpl1/engine/input/Keyboard.cpp
+++ b/engines/hpl1/engine/input/Keyboard.cpp
@@ -25,17 +25,363 @@
* This file is part of HPL1 Engine.
*/
+#include "common/events.h"
#include "hpl1/engine/input/Keyboard.h"
+#include "hpl1/engine/input/LowLevelInput.h"
namespace hpl {
-//////////////////////////////////////////////////////////////////////////
-// CONSTRUCTORS
-//////////////////////////////////////////////////////////////////////////
//-----------------------------------------------------------------------
-iKeyboard::iKeyboard(tString asName) : iInputDevice(asName, eInputDeviceType_Keyboard) {
+iKeyboard::iKeyboard(LowLevelInput *lowLevelInput) : iInputDevice("Keyboard", eInputDeviceType_Keyboard) {
+ _lowLevelSystem = lowLevelInput;
+
+ _downKeys.set_size(eKey_LastEnum);
+ _downKeys.clear();
}
//-----------------------------------------------------------------------
+
+static eKey convertKey(int alKey) {
+ switch (alKey) {
+ case Common::KEYCODE_BACKSPACE:
+ return eKey_BACKSPACE;
+ case Common::KEYCODE_TAB:
+ return eKey_TAB;
+ case Common::KEYCODE_CLEAR:
+ return eKey_CLEAR;
+ case Common::KEYCODE_RETURN:
+ return eKey_RETURN;
+ case Common::KEYCODE_PAUSE:
+ return eKey_PAUSE;
+ case Common::KEYCODE_ESCAPE:
+ return eKey_ESCAPE;
+ case Common::KEYCODE_SPACE:
+ return eKey_SPACE;
+ case Common::KEYCODE_EXCLAIM:
+ return eKey_EXCLAIM;
+ case Common::KEYCODE_QUOTEDBL:
+ return eKey_QUOTEDBL;
+ case Common::KEYCODE_HASH:
+ return eKey_HASH;
+ case Common::KEYCODE_DOLLAR:
+ return eKey_DOLLAR;
+ case Common::KEYCODE_AMPERSAND:
+ return eKey_AMPERSAND;
+ case Common::KEYCODE_QUOTE:
+ return eKey_QUOTE;
+ case Common::KEYCODE_LEFTPAREN:
+ return eKey_LEFTPAREN;
+ case Common::KEYCODE_RIGHTPAREN:
+ return eKey_RIGHTPAREN;
+ case Common::KEYCODE_ASTERISK:
+ return eKey_ASTERISK;
+ case Common::KEYCODE_PLUS:
+ return eKey_PLUS;
+ case Common::KEYCODE_COMMA:
+ return eKey_COMMA;
+ case Common::KEYCODE_MINUS:
+ return eKey_MINUS;
+ case Common::KEYCODE_PERIOD:
+ return eKey_PERIOD;
+ case Common::KEYCODE_SLASH:
+ return eKey_SLASH;
+ case Common::KEYCODE_0:
+ return eKey_0;
+ case Common::KEYCODE_1:
+ return eKey_1;
+ case Common::KEYCODE_2:
+ return eKey_2;
+ case Common::KEYCODE_3:
+ return eKey_3;
+ case Common::KEYCODE_4:
+ return eKey_4;
+ case Common::KEYCODE_5:
+ return eKey_5;
+ case Common::KEYCODE_6:
+ return eKey_6;
+ case Common::KEYCODE_7:
+ return eKey_7;
+ case Common::KEYCODE_8:
+ return eKey_8;
+ case Common::KEYCODE_9:
+ return eKey_9;
+ case Common::KEYCODE_COLON:
+ return eKey_COLON;
+ case Common::KEYCODE_SEMICOLON:
+ return eKey_SEMICOLON;
+ case Common::KEYCODE_LESS:
+ return eKey_LESS;
+ case Common::KEYCODE_EQUALS:
+ return eKey_EQUALS;
+ case Common::KEYCODE_GREATER:
+ return eKey_GREATER;
+ case Common::KEYCODE_QUESTION:
+ return eKey_QUESTION;
+ case Common::KEYCODE_AT:
+ return eKey_AT;
+ case Common::KEYCODE_LEFTBRACKET:
+ return eKey_LEFTBRACKET;
+ case Common::KEYCODE_BACKSLASH:
+ return eKey_BACKSLASH;
+ case Common::KEYCODE_RIGHTBRACKET:
+ return eKey_RIGHTBRACKET;
+ case Common::KEYCODE_CARET:
+ return eKey_CARET;
+ case Common::KEYCODE_UNDERSCORE:
+ return eKey_UNDERSCORE;
+ case Common::KEYCODE_BACKQUOTE:
+ return eKey_BACKQUOTE;
+ case Common::KEYCODE_a:
+ return eKey_a;
+ case Common::KEYCODE_b:
+ return eKey_b;
+ case Common::KEYCODE_c:
+ return eKey_c;
+ case Common::KEYCODE_d:
+ return eKey_d;
+ case Common::KEYCODE_e:
+ return eKey_e;
+ case Common::KEYCODE_f:
+ return eKey_f;
+ case Common::KEYCODE_g:
+ return eKey_g;
+ case Common::KEYCODE_h:
+ return eKey_h;
+ case Common::KEYCODE_i:
+ return eKey_i;
+ case Common::KEYCODE_j:
+ return eKey_j;
+ case Common::KEYCODE_k:
+ return eKey_k;
+ case Common::KEYCODE_l:
+ return eKey_l;
+ case Common::KEYCODE_m:
+ return eKey_m;
+ case Common::KEYCODE_n:
+ return eKey_n;
+ case Common::KEYCODE_o:
+ return eKey_o;
+ case Common::KEYCODE_p:
+ return eKey_p;
+ case Common::KEYCODE_q:
+ return eKey_q;
+ case Common::KEYCODE_r:
+ return eKey_r;
+ case Common::KEYCODE_s:
+ return eKey_s;
+ case Common::KEYCODE_t:
+ return eKey_t;
+ case Common::KEYCODE_u:
+ return eKey_u;
+ case Common::KEYCODE_v:
+ return eKey_v;
+ case Common::KEYCODE_w:
+ return eKey_w;
+ case Common::KEYCODE_x:
+ return eKey_x;
+ case Common::KEYCODE_y:
+ return eKey_y;
+ case Common::KEYCODE_z:
+ return eKey_z;
+ case Common::KEYCODE_DELETE:
+ return eKey_DELETE;
+ case Common::KEYCODE_KP0:
+ return eKey_KP0;
+ case Common::KEYCODE_KP1:
+ return eKey_KP1;
+ case Common::KEYCODE_KP2:
+ return eKey_KP2;
+ case Common::KEYCODE_KP3:
+ return eKey_KP3;
+ case Common::KEYCODE_KP4:
+ return eKey_KP4;
+ case Common::KEYCODE_KP5:
+ return eKey_KP5;
+ case Common::KEYCODE_KP6:
+ return eKey_KP6;
+ case Common::KEYCODE_KP7:
+ return eKey_KP7;
+ case Common::KEYCODE_KP8:
+ return eKey_KP8;
+ case Common::KEYCODE_KP9:
+ return eKey_KP9;
+ case Common::KEYCODE_KP_PERIOD:
+ return eKey_KP_PERIOD;
+ case Common::KEYCODE_KP_DIVIDE:
+ return eKey_KP_DIVIDE;
+ case Common::KEYCODE_KP_MULTIPLY:
+ return eKey_KP_MULTIPLY;
+ case Common::KEYCODE_KP_MINUS:
+ return eKey_KP_MINUS;
+ case Common::KEYCODE_KP_PLUS:
+ return eKey_KP_PLUS;
+ case Common::KEYCODE_KP_ENTER:
+ return eKey_KP_ENTER;
+ case Common::KEYCODE_KP_EQUALS:
+ return eKey_KP_EQUALS;
+ case Common::KEYCODE_UP:
+ return eKey_UP;
+ case Common::KEYCODE_DOWN:
+ return eKey_DOWN;
+ case Common::KEYCODE_RIGHT:
+ return eKey_RIGHT;
+ case Common::KEYCODE_LEFT:
+ return eKey_LEFT;
+ case Common::KEYCODE_INSERT:
+ return eKey_INSERT;
+ case Common::KEYCODE_HOME:
+ return eKey_HOME;
+ case Common::KEYCODE_END:
+ return eKey_END;
+ case Common::KEYCODE_PAGEUP:
+ return eKey_PAGEUP;
+ case Common::KEYCODE_PAGEDOWN:
+ return eKey_PAGEDOWN;
+ case Common::KEYCODE_F1:
+ return eKey_F1;
+ case Common::KEYCODE_F2:
+ return eKey_F2;
+ case Common::KEYCODE_F3:
+ return eKey_F3;
+ case Common::KEYCODE_F4:
+ return eKey_F4;
+ case Common::KEYCODE_F5:
+ return eKey_F5;
+ case Common::KEYCODE_F6:
+ return eKey_F6;
+ case Common::KEYCODE_F7:
+ return eKey_F7;
+ case Common::KEYCODE_F8:
+ return eKey_F8;
+ case Common::KEYCODE_F9:
+ return eKey_F9;
+ case Common::KEYCODE_F10:
+ return eKey_F10;
+ case Common::KEYCODE_F11:
+ return eKey_F11;
+ case Common::KEYCODE_F12:
+ return eKey_F12;
+ case Common::KEYCODE_F13:
+ return eKey_F13;
+ case Common::KEYCODE_F14:
+ return eKey_F14;
+ case Common::KEYCODE_F15:
+ return eKey_F15;
+ case Common::KEYCODE_NUMLOCK:
+ return eKey_NUMLOCK;
+ case Common::KEYCODE_CAPSLOCK:
+ return eKey_CAPSLOCK;
+ case Common::KEYCODE_SCROLLOCK:
+ return eKey_SCROLLOCK;
+ case Common::KEYCODE_RSHIFT:
+ return eKey_RSHIFT;
+ case Common::KEYCODE_LSHIFT:
+ return eKey_LSHIFT;
+ case Common::KEYCODE_RCTRL:
+ return eKey_RCTRL;
+ case Common::KEYCODE_LCTRL:
+ return eKey_LCTRL;
+ case Common::KEYCODE_RALT:
+ return eKey_RALT;
+ case Common::KEYCODE_LALT:
+ return eKey_LALT;
+ case Common::KEYCODE_RMETA:
+ return eKey_RMETA;
+ case Common::KEYCODE_LMETA:
+ return eKey_LMETA;
+ case Common::KEYCODE_LSUPER:
+ return eKey_LSUPER;
+ case Common::KEYCODE_RSUPER:
+ return eKey_RSUPER;
+ case Common::KEYCODE_MODE:
+ return eKey_MODE;
+ case Common::KEYCODE_HELP:
+ return eKey_HELP;
+ case Common::KEYCODE_PRINT:
+ return eKey_PRINT;
+ case Common::KEYCODE_SYSREQ:
+ return eKey_SYSREQ;
+ case Common::KEYCODE_BREAK:
+ return eKey_BREAK;
+ case Common::KEYCODE_MENU:
+ return eKey_MENU;
+ case Common::KEYCODE_POWER:
+ return eKey_POWER;
+ case Common::KEYCODE_EURO:
+ return eKey_EURO;
+ }
+ return eKey_NONE;
+}
+
+static eKeyModifier convertModifiers(const int mods) {
+ eKeyModifier out = eKeyModifier_NONE;
+ if (mods & Common::KBD_CTRL)
+ out |= eKeyModifier_CTRL;
+ if (mods & Common::KBD_SHIFT)
+ out |= eKeyModifier_SHIFT;
+ if (mods & Common::KBD_ALT)
+ out |= eKeyModifier_ALT;
+ if (mods & Common::KBD_META)
+ out |= eKeyModifier_META;
+ return out;
+}
+
+void iKeyboard::processEvent(const Common::Event &ev) {
+ if (ev.type != Common::EVENT_KEYDOWN && ev.type != Common::EVENT_KEYUP)
+ return;
+
+ eKey key = convertKey(ev.kbd.keycode);
+ if (ev.type == Common::EVENT_KEYDOWN) {
+ _downKeys.set(key);
+ _modifiers = convertModifiers(ev.kbd.flags);
+ _pressedKeys.push(cKeyPress(key, ev.kbd.ascii, _modifiers));
+ } else
+ _downKeys.unset(key);
+}
+
+void iKeyboard::Update() {
+ _pressedKeys.clear();
+ for (const Common::Event &ev : _lowLevelSystem->_events)
+ processEvent(ev);
+}
+
+//-----------------------------------------------------------------------
+
+bool iKeyboard::KeyIsDown(eKey key) {
+ return _downKeys.get(key);
+}
+
+//-----------------------------------------------------------------------
+
+cKeyPress iKeyboard::GetKey() {
+ return _pressedKeys.pop();
+}
+
+//-----------------------------------------------------------------------
+
+bool iKeyboard::KeyIsPressed() {
+ return _pressedKeys.empty() == false;
+}
+
+//-----------------------------------------------------------------------
+
+eKeyModifier iKeyboard::GetModifier() {
+ return _modifiers;
+}
+
+//-----------------------------------------------------------------------
+
+tString iKeyboard::KeyToString(eKey) {
+ return "None";
+}
+
+//-----------------------------------------------------------------------
+
+eKey iKeyboard::StringToKey(tString) {
+ return eKey_NONE;
+}
+
+//-----------------------------------------------------------------------
+
} // namespace hpl
diff --git a/engines/hpl1/engine/input/Keyboard.h b/engines/hpl1/engine/input/Keyboard.h
index d6f175e8658..bba8117b120 100644
--- a/engines/hpl1/engine/input/Keyboard.h
+++ b/engines/hpl1/engine/input/Keyboard.h
@@ -28,50 +28,67 @@
#ifndef HPL_KEYBOARD_H
#define HPL_KEYBOARD_H
+#include "common/bitarray.h"
+#include "common/keyboard.h"
+#include "common/queue.h"
#include "hpl1/engine/input/InputDevice.h"
#include "hpl1/engine/input/InputTypes.h"
+namespace Common {
+struct Event;
+}
+
namespace hpl {
-//------------------------------
+class LowLevelInput;
class iKeyboard : public iInputDevice {
public:
- iKeyboard(tString asName);
- virtual ~iKeyboard() {}
+ iKeyboard(LowLevelInput *);
/**
*
* \param aKey The key to check
* \return true if pressed else false
*/
- virtual bool KeyIsDown(eKey aKey) = 0;
+ bool KeyIsDown(eKey aKey);
/**
* Can be checked many times to see all key presses
* \return key that is currently pressed. eKey_NONE is no key.
*/
- virtual cKeyPress GetKey() = 0;
+ cKeyPress GetKey();
/**
*
* \return If ANY key is pressed
*/
- virtual bool KeyIsPressed() = 0;
+ bool KeyIsPressed();
/**
* \return The current modifiers.
*/
- virtual eKeyModifier GetModifier() = 0;
+ eKeyModifier GetModifier();
/**
* \todo Implement!
* \param eKey The key to change to string.
* \return The name of the key as a string.
*/
- virtual tString KeyToString(eKey) = 0;
+ tString KeyToString(eKey);
/**
* \todo Implement!
* \param tString NAme of the key
* \return enum of the key.
*/
- virtual eKey StringToKey(tString) = 0;
+ eKey StringToKey(tString);
+
+ void Update();
+
+private:
+ void processEvent(const Common::Event &ev);
+ eKey AsciiToKey(int alChar);
+
+ eKeyModifier _modifiers;
+ Common::BitArray _downKeys;
+ Common::Queue<cKeyPress> _pressedKeys;
+ LowLevelInput *_lowLevelSystem;
};
} // namespace hpl
diff --git a/engines/hpl1/engine/input/LowLevelInput.cpp b/engines/hpl1/engine/input/LowLevelInput.cpp
index 959a8678120..21d24738da7 100644
--- a/engines/hpl1/engine/input/LowLevelInput.cpp
+++ b/engines/hpl1/engine/input/LowLevelInput.cpp
@@ -27,8 +27,8 @@
#include "common/events.h"
#include "common/system.h"
-#include "hpl1/engine/impl/KeyboardSDL.h"
#include "hpl1/engine/impl/MouseSDL.h"
+#include "hpl1/engine/input/Keyboard.h"
#include "hpl1/engine/input/LowLevelInput.h"
#include "hpl1/engine/system/low_level_system.h"
@@ -71,7 +71,7 @@ iMouse *LowLevelInput::CreateMouse() {
//-----------------------------------------------------------------------
iKeyboard *LowLevelInput::CreateKeyboard() {
- return hplNew(cKeyboardSDL, (this));
+ return hplNew(iKeyboard, (this));
}
//-----------------------------------------------------------------------
diff --git a/engines/hpl1/engine/input/LowLevelInput.h b/engines/hpl1/engine/input/LowLevelInput.h
index 12c4ef3f115..e1c2704f0e7 100644
--- a/engines/hpl1/engine/input/LowLevelInput.h
+++ b/engines/hpl1/engine/input/LowLevelInput.h
@@ -38,7 +38,7 @@ class iKeyboard;
class iLowLevelGraphics;
class LowLevelInput {
- friend class cKeyboardSDL;
+ friend class iKeyboard;
friend class cMouseSDL;
public:
diff --git a/engines/hpl1/module.mk b/engines/hpl1/module.mk
index a288ab53f74..d249e1eb83a 100644
--- a/engines/hpl1/module.mk
+++ b/engines/hpl1/module.mk
@@ -93,7 +93,6 @@ MODULE_OBJS := \
engine/impl/CGProgram.o \
engine/impl/CharacterBodyNewton.o \
engine/impl/CollideShapeNewton.o \
- engine/impl/KeyboardSDL.o \
engine/impl/LowLevelGraphicsSDL.o \
engine/impl/LowLevelPhysicsNewton.o \
engine/impl/LowLevelSoundOpenAL.o \
More information about the Scummvm-git-logs
mailing list