1 /* ScummVM - Graphic Adventure Engine 2 * 3 * ScummVM is the legal property of its developers, whose names 4 * are too numerous to list here. Please refer to the COPYRIGHT 5 * file distributed with this source distribution. 6 * 7 * This program is free software; you can redistribute it and/or 8 * modify it under the terms of the GNU General Public License 9 * as published by the Free Software Foundation; either version 2 10 * of the License, or (at your option) any later version. 11 * 12 * This program is distributed in the hope that it will be useful, 13 * but WITHOUT ANY WARRANTY; without even the implied warranty of 14 * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the 15 * GNU General Public License for more details. 16 * 17 * You should have received a copy of the GNU General Public License 18 * along with this program; if not, write to the Free Software 19 * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA. 20 * 21 */ 22 23 /* 24 * This file is based on WME Lite. 25 * http://dead-code.org/redir.php?target=wmelite 26 * Copyright (c) 2011 Jan Nedoma 27 */ 28 29 #ifndef WINTERMUTE_BASE_KEYBOARD_STATE_H 30 #define WINTERMUTE_BASE_KEYBOARD_STATE_H 31 32 33 #include "engines/wintermute/base/base.h" 34 #include "engines/wintermute/base/base_scriptable.h" 35 #include "common/keyboard.h" 36 #include "common/events.h" 37 38 namespace Wintermute { 39 40 struct keyCodeMapping { 41 Common::KeyCode commonKeycode; 42 uint32 engineKeycode; 43 }; 44 45 class BaseKeyboardState : public BaseScriptable { 46 public: 47 DECLARE_PERSISTENT(BaseKeyboardState, BaseScriptable) 48 BaseKeyboardState(BaseGame *inGame); 49 ~BaseKeyboardState() override; 50 bool readKey(Common::Event *event); 51 52 void handleKeyPress(Common::Event *event); 53 void handleKeyRelease(Common::Event *event); 54 static bool isShiftDown(); 55 static bool isControlDown(); 56 static bool isAltDown(); 57 bool isCurrentPrintable() const; 58 59 // scripting interface 60 ScValue *scGetProperty(const Common::String &name) override; 61 bool scSetProperty(const char *name, ScValue *value) override; 62 bool scCallMethod(ScScript *script, ScStack *stack, ScStack *thisStack, const char *name) override; 63 const char *scToString() override; 64 65 private: 66 void init(); 67 68 bool _currentPrintable; 69 uint32 _currentKeyData; 70 uint32 _currentCharCode; 71 72 bool _currentShift; 73 bool _currentAlt; 74 bool _currentControl; 75 76 uint8 *_keyStates; 77 78 const keyCodeMapping *_mapping; 79 uint32 _mappingSize; 80 }; 81 82 } // End of namespace Wintermute 83 84 #endif 85