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

keymap.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_KEYMAP_H
00024 #define COMMON_KEYMAP_H
00025 
00026 #include "common/scummsys.h"
00027 
00028 #ifdef ENABLE_KEYMAPPER
00029 
00030 #include "common/config-manager.h"
00031 #include "common/func.h"
00032 #include "common/hashmap.h"
00033 #include "common/keyboard.h"
00034 #include "common/list.h"
00035 #include "backends/keymapper/action.h"
00036 #include "backends/keymapper/hardware-input.h"
00037 
00038 namespace Common {
00039 
00043 template<> struct Hash<KeyState>
00044     : public UnaryFunction<KeyState, uint> {
00045 
00046     uint operator()(const KeyState &val) const {
00047         return (uint)val.keycode | ((uint)val.flags << 24);
00048     }
00049 };
00050 
00051 class Keymap {
00052 public:
00053     Keymap(const String& name) : _name(name) {}
00054     Keymap(const Keymap& km);
00055     ~Keymap();
00056 
00057 public:
00063     Action *getAction(const char *id);
00064 
00068     List<Action *>& getActions() { return _actions; }
00069 
00075     Action *getMappedAction(const KeyState& ks) const;
00076 
00082     Action *getMappedAction(const HardwareInputCode code) const;
00083 
00084     void setConfigDomain(ConfigManager::Domain *dom);
00085 
00090     void loadMappings(const HardwareInputSet *hwInputs);
00091 
00097     void saveMappings();
00098 
00103     bool isComplete(const HardwareInputSet *hwInputs);
00104 
00105     const String& getName() { return _name; }
00106 
00107 private:
00108     friend struct Action;
00109 
00115     void addAction(Action *action);
00116 
00123     void registerMapping(Action *action, const HardwareInput *input);
00124 
00130     void unregisterMapping(Action *action);
00131 
00132     Action *findAction(const char *id);
00133     const Action *findAction(const char *id) const;
00134 
00135     String _name;
00136     List<Action *> _actions;
00137     HashMap<KeyState, Action *> _keymap;
00138     HashMap<HardwareInputCode, Action *> _nonkeymap;
00139     ConfigManager::Domain *_configDomain;
00140 
00141 };
00142 
00143 
00144 } // End of namespace Common
00145 
00146 #endif // #ifdef ENABLE_KEYMAPPER
00147 
00148 #endif // #ifndef COMMON_KEYMAP_H


Generated on Sat Mar 16 2019 05:01:40 for ResidualVM by doxygen 1.7.1
curved edge   curved edge