From 9e9b89071f9a07e2784bf52ef976d6560bf56e67 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Wed, 12 Nov 2014 14:43:04 +0600 Subject: ZVISION: Implement function for convertion of scummvm KeyCode to win vkKey --- engines/zvision/utility/win_keys.cpp | 129 +++++++++++++++++++++++++++++++++++ engines/zvision/utility/win_keys.h | 32 +++++++++ 2 files changed, 161 insertions(+) create mode 100644 engines/zvision/utility/win_keys.cpp create mode 100644 engines/zvision/utility/win_keys.h (limited to 'engines/zvision/utility') diff --git a/engines/zvision/utility/win_keys.cpp b/engines/zvision/utility/win_keys.cpp new file mode 100644 index 0000000000..3441fb8bf0 --- /dev/null +++ b/engines/zvision/utility/win_keys.cpp @@ -0,0 +1,129 @@ +/* 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. + * + */ + +#include "common/keyboard.h" + +namespace ZVision { + +uint8 VKkey(Common::KeyCode scumm_key) { + if (scumm_key >= Common::KEYCODE_a && scumm_key <= Common::KEYCODE_z) + return 0x41 + scumm_key - Common::KEYCODE_a; + if (scumm_key >= Common::KEYCODE_0 && scumm_key <= Common::KEYCODE_9) + return 0x30 + scumm_key - Common::KEYCODE_0; + if (scumm_key >= Common::KEYCODE_F1 && scumm_key <= Common::KEYCODE_F15) + return 0x70 + scumm_key - Common::KEYCODE_F1; + if (scumm_key >= Common::KEYCODE_KP0 && scumm_key <= Common::KEYCODE_KP9) + return 0x60 + scumm_key - Common::KEYCODE_KP0; + + switch (scumm_key) { + case Common::KEYCODE_BACKSPACE: + return 0x8; + case Common::KEYCODE_TAB: + return 0x9; + case Common::KEYCODE_CLEAR: + return 0xC; + case Common::KEYCODE_RETURN: + return 0xD; + case Common::KEYCODE_CAPSLOCK: + return 0x14; + case Common::KEYCODE_ESCAPE: + return 0x1B; + case Common::KEYCODE_SPACE: + return 0x20; + case Common::KEYCODE_PAGEUP: + return 0x21; + case Common::KEYCODE_PAGEDOWN: + return 0x22; + case Common::KEYCODE_END: + return 0x23; + case Common::KEYCODE_HOME: + return 0x24; + case Common::KEYCODE_LEFT: + return 0x25; + case Common::KEYCODE_UP: + return 0x26; + case Common::KEYCODE_RIGHT: + return 0x27; + case Common::KEYCODE_DOWN: + return 0x28; + case Common::KEYCODE_PRINT: + return 0x2A; + case Common::KEYCODE_INSERT: + return 0x2D; + case Common::KEYCODE_DELETE: + return 0x2E; + case Common::KEYCODE_HELP: + return 0x2F; + case Common::KEYCODE_KP_MULTIPLY: + return 0x6A; + case Common::KEYCODE_KP_PLUS: + return 0x6B; + case Common::KEYCODE_KP_MINUS: + return 0x6D; + case Common::KEYCODE_KP_PERIOD: + return 0x6E; + case Common::KEYCODE_KP_DIVIDE: + return 0x6F; + case Common::KEYCODE_NUMLOCK: + return 0x90; + case Common::KEYCODE_SCROLLOCK: + return 0x91; + case Common::KEYCODE_LSHIFT: + return 0xA0; + case Common::KEYCODE_RSHIFT: + return 0xA1; + case Common::KEYCODE_LCTRL: + return 0xA2; + case Common::KEYCODE_RCTRL: + return 0xA3; + case Common::KEYCODE_MENU: + return 0xA5; + case Common::KEYCODE_LEFTBRACKET: + return 0xDB; + case Common::KEYCODE_RIGHTBRACKET: + return 0xDD; + case Common::KEYCODE_SEMICOLON: + return 0xBA; + case Common::KEYCODE_BACKSLASH: + return 0xDC; + case Common::KEYCODE_QUOTE: + return 0xDE; + case Common::KEYCODE_SLASH: + return 0xBF; + case Common::KEYCODE_TILDE: + return 0xC0; + case Common::KEYCODE_COMMA: + return 0xBC; + case Common::KEYCODE_PERIOD: + return 0xBE; + case Common::KEYCODE_MINUS: + return 0xBD; + case Common::KEYCODE_PLUS: + return 0xBB; + default: + return 0; + } + + return 0; +} + +} diff --git a/engines/zvision/utility/win_keys.h b/engines/zvision/utility/win_keys.h new file mode 100644 index 0000000000..a79a03a07b --- /dev/null +++ b/engines/zvision/utility/win_keys.h @@ -0,0 +1,32 @@ +/* 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. + * + */ + +#ifndef ZVISION_WINKEY_H +#define ZVISION_WINKEY_H + +#include "common/keyboard.h" + +namespace ZVision { +uint8 VKkey(Common::KeyCode scumm_key); +} // End of namespace ZVision + +#endif -- cgit v1.2.3 From 5b352da304931bafcfcddbe08461488335c7ad57 Mon Sep 17 00:00:00 2001 From: Marisa-Chan Date: Thu, 20 Nov 2014 14:48:24 +0600 Subject: ZVISION: More CamelCase and a bit of comments cleanup --- engines/zvision/utility/win_keys.cpp | 20 ++++++++++---------- engines/zvision/utility/win_keys.h | 6 +++--- 2 files changed, 13 insertions(+), 13 deletions(-) (limited to 'engines/zvision/utility') diff --git a/engines/zvision/utility/win_keys.cpp b/engines/zvision/utility/win_keys.cpp index 3441fb8bf0..86ed7c596f 100644 --- a/engines/zvision/utility/win_keys.cpp +++ b/engines/zvision/utility/win_keys.cpp @@ -24,17 +24,17 @@ namespace ZVision { -uint8 VKkey(Common::KeyCode scumm_key) { - if (scumm_key >= Common::KEYCODE_a && scumm_key <= Common::KEYCODE_z) - return 0x41 + scumm_key - Common::KEYCODE_a; - if (scumm_key >= Common::KEYCODE_0 && scumm_key <= Common::KEYCODE_9) - return 0x30 + scumm_key - Common::KEYCODE_0; - if (scumm_key >= Common::KEYCODE_F1 && scumm_key <= Common::KEYCODE_F15) - return 0x70 + scumm_key - Common::KEYCODE_F1; - if (scumm_key >= Common::KEYCODE_KP0 && scumm_key <= Common::KEYCODE_KP9) - return 0x60 + scumm_key - Common::KEYCODE_KP0; +uint8 VKkey(Common::KeyCode scummKeyCode) { + if (scummKeyCode >= Common::KEYCODE_a && scummKeyCode <= Common::KEYCODE_z) + return 0x41 + scummKeyCode - Common::KEYCODE_a; + if (scummKeyCode >= Common::KEYCODE_0 && scummKeyCode <= Common::KEYCODE_9) + return 0x30 + scummKeyCode - Common::KEYCODE_0; + if (scummKeyCode >= Common::KEYCODE_F1 && scummKeyCode <= Common::KEYCODE_F15) + return 0x70 + scummKeyCode - Common::KEYCODE_F1; + if (scummKeyCode >= Common::KEYCODE_KP0 && scummKeyCode <= Common::KEYCODE_KP9) + return 0x60 + scummKeyCode - Common::KEYCODE_KP0; - switch (scumm_key) { + switch (scummKeyCode) { case Common::KEYCODE_BACKSPACE: return 0x8; case Common::KEYCODE_TAB: diff --git a/engines/zvision/utility/win_keys.h b/engines/zvision/utility/win_keys.h index a79a03a07b..53d76c4d5f 100644 --- a/engines/zvision/utility/win_keys.h +++ b/engines/zvision/utility/win_keys.h @@ -20,13 +20,13 @@ * */ -#ifndef ZVISION_WINKEY_H -#define ZVISION_WINKEY_H +#ifndef ZVISION_WIN_KEYS_H +#define ZVISION_WIN_KEYS_H #include "common/keyboard.h" namespace ZVision { -uint8 VKkey(Common::KeyCode scumm_key); +uint8 VKkey(Common::KeyCode scummKeyCode); } // End of namespace ZVision #endif -- cgit v1.2.3