ResidualVM logo ResidualVM website - Forums - Contact us BuildBot - Doxygen - Wiki curved edge

hardware-input.h

Go to the documentation of this file.
00001 /* ScummVM - Graphic Adventure Engine
00002  *
00003  * ScummVM is the legal property of its developers, whose names
00004  * are too numerous to list here. Please refer to the COPYRIGHT
00005  * file distributed with this source distribution.
00006  *
00007  * This program is free software; you can redistribute it and/or
00008  * modify it under the terms of the GNU General Public License
00009  * as published by the Free Software Foundation; either version 2
00010  * of the License, or (at your option) any later version.
00011  *
00012  * This program is distributed in the hope that it will be useful,
00013  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00014  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00015  * GNU General Public License for more details.
00016  *
00017  * You should have received a copy of the GNU General Public License
00018  * along with this program; if not, write to the Free Software
00019  * Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA.
00020  *
00021  */
00022 
00023 #ifndef COMMON_HARDWARE_KEY_H
00024 #define COMMON_HARDWARE_KEY_H
00025 
00026 #include "common/scummsys.h"
00027 
00028 #ifdef ENABLE_KEYMAPPER
00029 
00030 #include "common/keyboard.h"
00031 #include "common/list.h"
00032 #include "common/str.h"
00033 #include "common/textconsole.h"
00034 
00035 namespace Common {
00036 
00037 typedef uint32 HardwareInputCode;
00038 
00039 enum HardwareInputType {
00041     kHardwareInputTypeGeneric,
00043     kHardwareInputTypeKeyboard
00044 };
00045 
00049 struct HardwareInput {
00051     String id;
00052 
00054     String description;
00055 
00056     const HardwareInputType type;
00057 
00063     HardwareInputCode inputCode;
00064 
00070     KeyState key;
00071 
00072     HardwareInput(String i, HardwareInputCode ic = 0, String desc = "")
00073         : id(i), inputCode(ic), description(desc), type(kHardwareInputTypeGeneric) { }
00074 
00075     HardwareInput(String i, KeyState ky, String desc = "")
00076         : id(i), key(ky), description(desc), type(kHardwareInputTypeKeyboard) { }
00077 };
00078 
00079 struct HardwareInputTableEntry {
00080     const char *hwId;
00081     HardwareInputCode code;
00082     const char *desc;
00083 };
00084 
00088 struct KeyTableEntry {
00089     const char *hwId;
00090     KeyCode keycode;
00091     uint16 ascii;
00092     const char *desc;
00093     bool shiftable;
00094 };
00095 
00099 struct ModifierTableEntry {
00100     byte flag;
00101     const char *id;
00102     const char *desc;
00103     bool shiftable;
00104 };
00105 
00111 class HardwareInputSet {
00112 public:
00113 
00120     HardwareInputSet(bool useDefault = false, const KeyTableEntry keys[] = 0, const ModifierTableEntry modifiers[] = 0);
00121 
00122     virtual ~HardwareInputSet();
00123 
00124     void addHardwareInput(const HardwareInput *input);
00125 
00126     const HardwareInput *findHardwareInput(String id) const;
00127 
00128     const HardwareInput *findHardwareInput(const HardwareInputCode code) const;
00129 
00130     const HardwareInput *findHardwareInput(const KeyState& keystate) const;
00131 
00132     const List<const HardwareInput *> &getHardwareInputs() const { return _inputs; }
00133 
00134     uint size() const { return _inputs.size(); }
00135 
00140     void addHardwareInputs(const HardwareInputTableEntry inputs[]);
00141 
00147     void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]);
00148 
00149     void removeHardwareInput(const HardwareInput *input);
00150 
00151 private:
00152 
00153     List<const HardwareInput *> _inputs;
00154 };
00155 
00156 } // End of namespace Common
00157 
00158 #endif // #ifdef ENABLE_KEYMAPPER
00159 
00160 #endif // #ifndef COMMON_HARDWARE_KEY_H


Generated on Sat Feb 16 2019 05:00:54 for ResidualVM by doxygen 1.7.1
curved edge   curved edge