2008-07-30 13:47:54 +00:00
|
|
|
/* 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.
|
|
|
|
*
|
|
|
|
* $URL$
|
|
|
|
* $Id$
|
|
|
|
*
|
|
|
|
*/
|
|
|
|
|
2008-07-19 00:57:37 +00:00
|
|
|
#ifndef COMMON_KEYMAPPER
|
|
|
|
#define COMMON_KEYMAPPER
|
|
|
|
|
2008-07-24 10:00:56 +00:00
|
|
|
#include "common/events.h"
|
2008-07-21 00:11:25 +00:00
|
|
|
#include "common/list.h"
|
2008-07-19 00:57:37 +00:00
|
|
|
|
2008-07-24 10:00:56 +00:00
|
|
|
|
2008-07-19 00:57:37 +00:00
|
|
|
namespace Common {
|
|
|
|
|
2008-07-24 10:00:56 +00:00
|
|
|
struct HardwareKey;
|
|
|
|
class HardwareKeySet;
|
2008-07-21 00:11:25 +00:00
|
|
|
class KeymapManager;
|
2008-07-24 10:00:56 +00:00
|
|
|
class Keymap;
|
2008-07-21 00:11:25 +00:00
|
|
|
|
2008-07-19 00:57:37 +00:00
|
|
|
class Keymapper {
|
|
|
|
public:
|
|
|
|
|
2008-07-21 00:11:25 +00:00
|
|
|
Keymapper(EventManager *eventMan);
|
2008-07-19 00:57:37 +00:00
|
|
|
|
2008-07-23 08:45:12 +00:00
|
|
|
/**
|
|
|
|
* Registers a HardwareKeySet with the Keymapper
|
|
|
|
* @note should only be called once (during backend initialisation)
|
|
|
|
*/
|
2008-07-21 00:11:25 +00:00
|
|
|
void registerHardwareKeySet(HardwareKeySet *keys);
|
2008-07-21 15:55:25 +00:00
|
|
|
|
2008-07-23 08:45:12 +00:00
|
|
|
/**
|
|
|
|
* Add a keymap to the global domain.
|
|
|
|
* If a saved key setup exists for it in the ini file it will be used.
|
|
|
|
* Else, the key setup will be automatically mapped.
|
|
|
|
*/
|
2008-07-21 15:55:25 +00:00
|
|
|
void addGlobalKeyMap(const String& name, Keymap *keymap);
|
|
|
|
|
2008-07-23 08:45:12 +00:00
|
|
|
/**
|
|
|
|
* Add a keymap to the game domain.
|
|
|
|
* @see addGlobalKeyMap
|
|
|
|
* @note initGame() should be called before any game keymaps are added.
|
|
|
|
*/
|
2008-07-21 15:55:25 +00:00
|
|
|
void addGameKeyMap(const String& name, Keymap *keymap);
|
|
|
|
|
2008-07-23 08:45:12 +00:00
|
|
|
/**
|
|
|
|
* Initialise the keymapper for a new game
|
|
|
|
*/
|
2008-07-21 15:55:25 +00:00
|
|
|
void initGame();
|
|
|
|
|
2008-07-23 08:45:12 +00:00
|
|
|
/**
|
|
|
|
* Cleanup the keymapper after a game has ended
|
|
|
|
*/
|
|
|
|
void cleanupGame();
|
|
|
|
|
|
|
|
/**
|
|
|
|
* Switch the active keymap.
|
|
|
|
* @param name name of the new keymap
|
|
|
|
* @return true if successful
|
|
|
|
*/
|
2008-07-21 15:55:25 +00:00
|
|
|
bool switchKeymap(const String& name);
|
2008-07-19 00:57:37 +00:00
|
|
|
|
2008-07-23 08:45:12 +00:00
|
|
|
/**
|
|
|
|
* @brief Map a key press event.
|
2008-08-01 16:44:49 +00:00
|
|
|
* If the active keymap contains a Action mapped to the given key, then
|
|
|
|
* the Action's events are pushed into the EventManager's event queue.
|
2008-07-23 08:45:12 +00:00
|
|
|
* @param key key that was pressed
|
|
|
|
* @param isKeyDown true for key down, false for key up
|
|
|
|
* @return true if key was mapped
|
|
|
|
*/
|
|
|
|
bool mapKey(const KeyState& key, bool isKeyDown);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Map a key down event.
|
|
|
|
* @see mapKey
|
|
|
|
*/
|
|
|
|
bool mapKeyDown(const KeyState& key);
|
|
|
|
|
|
|
|
/**
|
|
|
|
* @brief Map a key up event.
|
|
|
|
* @see mapKey
|
|
|
|
*/
|
|
|
|
bool mapKeyUp(const KeyState& key);
|
|
|
|
|
2008-07-19 00:57:37 +00:00
|
|
|
private:
|
|
|
|
|
2008-07-21 00:11:25 +00:00
|
|
|
typedef List<HardwareKey*>::iterator Iterator;
|
|
|
|
|
|
|
|
EventManager *_eventMan;
|
|
|
|
KeymapManager *_keymapMan;
|
|
|
|
|
2008-07-21 15:55:25 +00:00
|
|
|
String _gameId;
|
|
|
|
|
2008-07-21 00:11:25 +00:00
|
|
|
Keymap *_currentMap;
|
2008-07-19 00:57:37 +00:00
|
|
|
|
|
|
|
};
|
|
|
|
|
2008-07-19 19:12:49 +00:00
|
|
|
} // end of namespace Common
|
|
|
|
|
2008-07-30 13:47:54 +00:00
|
|
|
#endif
|