KEYMAPPER: Rename HardwareKey to HardwareInput
This commit is contained in:
parent
b0f961924a
commit
6afac4e01e
21 changed files with 160 additions and 160 deletions
|
@ -29,7 +29,7 @@
|
|||
namespace Common {
|
||||
|
||||
Action::Action(Keymap *boss, const char *i, String des)
|
||||
: _boss(boss), description(des), _hwKey(0) {
|
||||
: _boss(boss), description(des), _hwInput(0) {
|
||||
assert(i);
|
||||
assert(_boss);
|
||||
|
||||
|
@ -38,18 +38,18 @@ Action::Action(Keymap *boss, const char *i, String des)
|
|||
_boss->addAction(this);
|
||||
}
|
||||
|
||||
void Action::mapKey(const HardwareKey *key) {
|
||||
if (_hwKey)
|
||||
void Action::mapInput(const HardwareInput *input) {
|
||||
if (_hwInput)
|
||||
_boss->unregisterMapping(this);
|
||||
|
||||
_hwKey = key;
|
||||
_hwInput = input;
|
||||
|
||||
if (_hwKey)
|
||||
_boss->registerMapping(this, _hwKey);
|
||||
if (_hwInput)
|
||||
_boss->registerMapping(this, _hwInput);
|
||||
}
|
||||
|
||||
const HardwareKey *Action::getMappedKey() const {
|
||||
return _hwKey;
|
||||
const HardwareInput *Action::getMappedInput() const {
|
||||
return _hwInput;
|
||||
}
|
||||
|
||||
} // End of namespace Common
|
||||
|
|
|
@ -34,7 +34,7 @@
|
|||
|
||||
namespace Common {
|
||||
|
||||
struct HardwareKey;
|
||||
struct HardwareInput;
|
||||
class Keymap;
|
||||
|
||||
#define ACTION_ID_SIZE (4)
|
||||
|
@ -55,8 +55,8 @@ struct Action {
|
|||
List<Event> events;
|
||||
|
||||
private:
|
||||
/** Hardware key that is mapped to this Action */
|
||||
const HardwareKey *_hwKey;
|
||||
/** Hardware input that is mapped to this Action */
|
||||
const HardwareInput *_hwInput;
|
||||
Keymap *_boss;
|
||||
|
||||
public:
|
||||
|
@ -97,8 +97,8 @@ public:
|
|||
return _boss;
|
||||
}
|
||||
|
||||
void mapKey(const HardwareKey *key);
|
||||
const HardwareKey *getMappedKey() const;
|
||||
void mapInput(const HardwareInput *input);
|
||||
const HardwareInput *getMappedInput() const;
|
||||
|
||||
};
|
||||
|
||||
|
|
|
@ -32,9 +32,9 @@
|
|||
namespace Common {
|
||||
|
||||
/**
|
||||
* Describes an available hardware key
|
||||
* Describes an available hardware input
|
||||
*/
|
||||
struct HardwareKey {
|
||||
struct HardwareInput {
|
||||
/** unique id used for saving/loading to config */
|
||||
String id;
|
||||
|
||||
|
@ -47,7 +47,7 @@ struct HardwareKey {
|
|||
*/
|
||||
KeyState key;
|
||||
|
||||
HardwareKey(String i, KeyState ky = KeyState(), String desc = "")
|
||||
HardwareInput(String i, KeyState ky = KeyState(), String desc = "")
|
||||
: id(i), key(ky), description(desc) { }
|
||||
};
|
||||
|
||||
|
@ -73,70 +73,70 @@ struct ModifierTableEntry {
|
|||
};
|
||||
|
||||
/**
|
||||
* Simple class to encapsulate a device's set of HardwareKeys.
|
||||
* Each device should instantiate this and call addHardwareKey a number of times
|
||||
* Simple class to encapsulate a device's set of HardwareInputs.
|
||||
* Each device should instantiate this and call addHardwareInput a number of times
|
||||
* in its constructor to define the device's available keys.
|
||||
*/
|
||||
class HardwareKeySet {
|
||||
class HardwareInputSet {
|
||||
public:
|
||||
|
||||
/**
|
||||
* Add hardware keys to the set out of key and modifier tables.
|
||||
* Add hardware input keys to the set out of key and modifier tables.
|
||||
* @param keys table of available keys
|
||||
* @param modifiers table of available modifiers
|
||||
*/
|
||||
HardwareKeySet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) {
|
||||
addHardwareKeys(keys, modifiers);
|
||||
HardwareInputSet(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) {
|
||||
addHardwareInputs(keys, modifiers);
|
||||
}
|
||||
|
||||
HardwareKeySet() { }
|
||||
HardwareInputSet() { }
|
||||
|
||||
virtual ~HardwareKeySet() {
|
||||
List<const HardwareKey *>::const_iterator it;
|
||||
virtual ~HardwareInputSet() {
|
||||
List<const HardwareInput *>::const_iterator it;
|
||||
|
||||
for (it = _keys.begin(); it != _keys.end(); it++)
|
||||
for (it = _inputs.begin(); it != _inputs.end(); it++)
|
||||
delete *it;
|
||||
}
|
||||
|
||||
void addHardwareKey(const HardwareKey *key) {
|
||||
checkForKey(key);
|
||||
_keys.push_back(key);
|
||||
void addHardwareInput(const HardwareInput *input) {
|
||||
checkForInput(input);
|
||||
_inputs.push_back(input);
|
||||
}
|
||||
|
||||
const HardwareKey *findHardwareKey(String id) const {
|
||||
List<const HardwareKey *>::const_iterator it;
|
||||
const HardwareInput *findHardwareInput(String id) const {
|
||||
List<const HardwareInput *>::const_iterator it;
|
||||
|
||||
for (it = _keys.begin(); it != _keys.end(); it++) {
|
||||
for (it = _inputs.begin(); it != _inputs.end(); it++) {
|
||||
if ((*it)->id == id)
|
||||
return (*it);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const HardwareKey *findHardwareKey(const KeyState& keystate) const {
|
||||
List<const HardwareKey *>::const_iterator it;
|
||||
const HardwareInput *findHardwareInput(const KeyState& keystate) const {
|
||||
List<const HardwareInput *>::const_iterator it;
|
||||
|
||||
for (it = _keys.begin(); it != _keys.end(); it++) {
|
||||
for (it = _inputs.begin(); it != _inputs.end(); it++) {
|
||||
if ((*it)->key == keystate)
|
||||
return (*it);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
const List<const HardwareKey *> &getHardwareKeys() const {
|
||||
return _keys;
|
||||
const List<const HardwareInput *> &getHardwareInputs() const {
|
||||
return _inputs;
|
||||
}
|
||||
|
||||
uint size() const {
|
||||
return _keys.size();
|
||||
return _inputs.size();
|
||||
}
|
||||
|
||||
/**
|
||||
* Add hardware keys to the set out of key and modifier tables.
|
||||
* Add hardware inputs to the set out of key and modifier tables.
|
||||
* @param keys table of available keys
|
||||
* @param modifiers table of available modifiers
|
||||
*/
|
||||
void addHardwareKeys(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) {
|
||||
void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]) {
|
||||
const KeyTableEntry *key;
|
||||
const ModifierTableEntry *mod;
|
||||
char fullKeyId[50];
|
||||
|
@ -159,25 +159,25 @@ public:
|
|||
snprintf(fullKeyDesc, 100, "%s%s", mod->desc, key->desc);
|
||||
}
|
||||
|
||||
addHardwareKey(new HardwareKey(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc));
|
||||
addHardwareInput(new HardwareInput(fullKeyId, KeyState(key->keycode, ascii, mod->flag), fullKeyDesc));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
private:
|
||||
|
||||
void checkForKey(const HardwareKey *key) {
|
||||
List<const HardwareKey *>::iterator it;
|
||||
void checkForInput(const HardwareInput *input) {
|
||||
List<const HardwareInput *>::iterator it;
|
||||
|
||||
for (it = _keys.begin(); it != _keys.end(); it++) {
|
||||
if ((*it)->id == key->id)
|
||||
error("Error adding HardwareKey '%s' - id of %s already in use!", key->description.c_str(), key->id.c_str());
|
||||
else if ((*it)->key == key->key)
|
||||
error("Error adding HardwareKey '%s' - key already in use!", key->description.c_str());
|
||||
for (it = _inputs.begin(); it != _inputs.end(); it++) {
|
||||
if ((*it)->id == input->id)
|
||||
error("Error adding HardwareInput '%s' - id of %s already in use!", input->description.c_str(), input->id.c_str());
|
||||
else if ((*it)->key == input->key)
|
||||
error("Error adding HardwareInput '%s' - key already in use!", input->description.c_str());
|
||||
}
|
||||
}
|
||||
|
||||
List<const HardwareKey *> _keys;
|
||||
List<const HardwareInput *> _inputs;
|
||||
};
|
||||
|
||||
} // End of namespace Common
|
|
@ -26,7 +26,7 @@
|
|||
|
||||
#include "common/system.h"
|
||||
|
||||
#include "backends/keymapper/hardware-key.h"
|
||||
#include "backends/keymapper/hardware-input.h"
|
||||
#include "backends/keymapper/keymapper-defaults.h"
|
||||
|
||||
#define KEYMAP_KEY_PREFIX "keymap_"
|
||||
|
@ -37,10 +37,10 @@ Keymap::Keymap(const Keymap& km) : _actions(km._actions), _keymap(), _configDoma
|
|||
List<Action *>::iterator it;
|
||||
|
||||
for (it = _actions.begin(); it != _actions.end(); ++it) {
|
||||
const HardwareKey *hwKey = (*it)->getMappedKey();
|
||||
const HardwareInput *hwInput = (*it)->getMappedInput();
|
||||
|
||||
if (hwKey) {
|
||||
_keymap[hwKey->key] = *it;
|
||||
if (hwInput) {
|
||||
_keymap[hwInput->key] = *it;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -59,24 +59,24 @@ void Keymap::addAction(Action *action) {
|
|||
_actions.push_back(action);
|
||||
}
|
||||
|
||||
void Keymap::registerMapping(Action *action, const HardwareKey *hwKey) {
|
||||
void Keymap::registerMapping(Action *action, const HardwareInput *hwInput) {
|
||||
HashMap<KeyState, Action *>::iterator it;
|
||||
|
||||
it = _keymap.find(hwKey->key);
|
||||
it = _keymap.find(hwInput->key);
|
||||
|
||||
// if key is already mapped to a different action then un-map it
|
||||
if (it != _keymap.end() && action != it->_value) {
|
||||
it->_value->mapKey(0);
|
||||
it->_value->mapInput(0);
|
||||
}
|
||||
|
||||
_keymap[hwKey->key] = action;
|
||||
_keymap[hwInput->key] = action;
|
||||
}
|
||||
|
||||
void Keymap::unregisterMapping(Action *action) {
|
||||
const HardwareKey *hwKey = action->getMappedKey();
|
||||
const HardwareInput *hwInput = action->getMappedInput();
|
||||
|
||||
if (hwKey) {
|
||||
_keymap.erase(hwKey->key);
|
||||
if (hwInput) {
|
||||
_keymap.erase(hwInput->key);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -120,7 +120,7 @@ void Keymap::setConfigDomain(ConfigManager::Domain *dom) {
|
|||
_configDomain = dom;
|
||||
}
|
||||
|
||||
void Keymap::loadMappings(const HardwareKeySet *hwKeys) {
|
||||
void Keymap::loadMappings(const HardwareInputSet *hwKeys) {
|
||||
if (!_configDomain)
|
||||
return;
|
||||
|
||||
|
@ -129,7 +129,7 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) {
|
|||
|
||||
Common::KeymapperDefaultBindings *defaults = g_system->getKeymapperDefaultBindings();
|
||||
|
||||
HashMap<String, const HardwareKey *> mappedKeys;
|
||||
HashMap<String, const HardwareInput *> mappedInputs;
|
||||
List<Action*>::iterator it;
|
||||
String prefix = KEYMAP_KEY_PREFIX + _name + "_";
|
||||
|
||||
|
@ -138,37 +138,37 @@ void Keymap::loadMappings(const HardwareKeySet *hwKeys) {
|
|||
String actionId(ua->id);
|
||||
String confKey = prefix + actionId;
|
||||
|
||||
String hwKeyId = _configDomain->getVal(confKey);
|
||||
String hwInputId = _configDomain->getVal(confKey);
|
||||
|
||||
bool defaulted = false;
|
||||
// fall back to the platform-specific defaults
|
||||
if (hwKeyId.empty() && defaults) {
|
||||
hwKeyId = defaults->getDefaultBinding(_name, actionId);
|
||||
if (!hwKeyId.empty())
|
||||
if (hwInputId.empty() && defaults) {
|
||||
hwInputId = defaults->getDefaultBinding(_name, actionId);
|
||||
if (!hwInputId.empty())
|
||||
defaulted = true;
|
||||
}
|
||||
// there's no mapping
|
||||
if (hwKeyId.empty())
|
||||
if (hwInputId.empty())
|
||||
continue;
|
||||
|
||||
const HardwareKey *hwKey = hwKeys->findHardwareKey(hwKeyId.c_str());
|
||||
const HardwareInput *hwInput = hwKeys->findHardwareInput(hwInputId.c_str());
|
||||
|
||||
if (!hwKey) {
|
||||
warning("HardwareKey with ID '%s' not known", hwKeyId.c_str());
|
||||
if (!hwInput) {
|
||||
warning("HardwareInput with ID '%s' not known", hwInputId.c_str());
|
||||
continue;
|
||||
}
|
||||
|
||||
if (defaulted) {
|
||||
if (mappedKeys.contains(hwKeyId)) {
|
||||
debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the key is in use", confKey.c_str(), hwKeyId.c_str());
|
||||
if (mappedInputs.contains(hwInputId)) {
|
||||
debug(1, "Action [%s] not falling back to hardcoded default value [%s] because the hardware input is in use", confKey.c_str(), hwInputId.c_str());
|
||||
continue;
|
||||
}
|
||||
warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwKeyId.c_str());
|
||||
warning("Action [%s] fell back to hardcoded default value [%s]", confKey.c_str(), hwInputId.c_str());
|
||||
}
|
||||
|
||||
mappedKeys.setVal(hwKeyId, hwKey);
|
||||
mappedInputs.setVal(hwInputId, hwInput);
|
||||
// map the key
|
||||
ua->mapKey(hwKey);
|
||||
ua->mapInput(hwInput);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -187,27 +187,27 @@ void Keymap::saveMappings() {
|
|||
String actId((*it)->id, (*it)->id + actIdLen);
|
||||
String hwId = "";
|
||||
|
||||
if ((*it)->getMappedKey()) {
|
||||
hwId = (*it)->getMappedKey()->id;
|
||||
if ((*it)->getMappedInput()) {
|
||||
hwId = (*it)->getMappedInput()->id;
|
||||
}
|
||||
_configDomain->setVal(prefix + actId, hwId);
|
||||
}
|
||||
}
|
||||
|
||||
bool Keymap::isComplete(const HardwareKeySet *hwKeys) {
|
||||
bool Keymap::isComplete(const HardwareInputSet *hwInputs) {
|
||||
List<Action *>::iterator it;
|
||||
bool allMapped = true;
|
||||
uint numberMapped = 0;
|
||||
|
||||
for (it = _actions.begin(); it != _actions.end(); ++it) {
|
||||
if ((*it)->getMappedKey()) {
|
||||
numberMapped++;
|
||||
if ((*it)->getMappedInput()) {
|
||||
++numberMapped;
|
||||
} else {
|
||||
allMapped = false;
|
||||
}
|
||||
}
|
||||
|
||||
return allMapped || (numberMapped == hwKeys->size());
|
||||
return allMapped || (numberMapped == hwInputs->size());
|
||||
}
|
||||
|
||||
} // End of namespace Common
|
||||
|
|
|
@ -36,8 +36,8 @@
|
|||
|
||||
namespace Common {
|
||||
|
||||
struct HardwareKey;
|
||||
class HardwareKeySet;
|
||||
struct HardwareInput;
|
||||
class HardwareInputSet;
|
||||
|
||||
/**
|
||||
* Hash function for KeyState
|
||||
|
@ -80,9 +80,9 @@ public:
|
|||
|
||||
/**
|
||||
* Load this keymap's mappings from the config manager.
|
||||
* @param hwKeys the set to retrieve hardware key pointers from
|
||||
* @param hwInputs the set to retrieve hardware input pointers from
|
||||
*/
|
||||
void loadMappings(const HardwareKeySet *hwKeys);
|
||||
void loadMappings(const HardwareInputSet *hwInputs);
|
||||
|
||||
/**
|
||||
* Save this keymap's mappings to the config manager
|
||||
|
@ -93,9 +93,9 @@ public:
|
|||
|
||||
/**
|
||||
* Returns true if all UserAction's in Keymap are mapped, or,
|
||||
* all HardwareKey's from the given set have been used up.
|
||||
* all HardwareInputs from the given set have been used up.
|
||||
*/
|
||||
bool isComplete(const HardwareKeySet *hwKeys);
|
||||
bool isComplete(const HardwareInputSet *hwInputs);
|
||||
|
||||
const String& getName() { return _name; }
|
||||
|
||||
|
@ -110,15 +110,15 @@ private:
|
|||
void addAction(Action *action);
|
||||
|
||||
/**
|
||||
* Registers a HardwareKey to the given Action
|
||||
* Registers a HardwareInput to the given Action
|
||||
* @param action Action in this Keymap
|
||||
* @param key pointer to HardwareKey to map
|
||||
* @param key pointer to HardwareInput to map
|
||||
* @see Action::mapKey
|
||||
*/
|
||||
void registerMapping(Action *action, const HardwareKey *key);
|
||||
void registerMapping(Action *action, const HardwareInput *input);
|
||||
|
||||
/**
|
||||
* Unregisters a HardwareKey from the given Action (if one is mapped)
|
||||
* Unregisters a HardwareInput from the given Action (if one is mapped)
|
||||
* @param action Action in this Keymap
|
||||
* @see Action::mapKey
|
||||
*/
|
||||
|
|
|
@ -35,17 +35,17 @@ namespace Common {
|
|||
class KeymapperDefaultBindings : HashMap<String, String> {
|
||||
public:
|
||||
/**
|
||||
* This sets a default hwKey for a given Keymap Action
|
||||
* This sets a default hwInput for a given Keymap Action
|
||||
* @param keymapId String representing Keymap id (Keymap.name)
|
||||
* @param actionId String representing Action id (Action.id)
|
||||
* @param hwKeyId String representing the HardwareKey id (HardwareKey.hwKeyId)
|
||||
* @param hwInputId String representing the HardwareInput id (HardwareInput.id)
|
||||
*/
|
||||
void setDefaultBinding(String keymapId, String actionId, String hwKeyId) { setVal(keymapId + "_" + actionId, hwKeyId); }
|
||||
void setDefaultBinding(String keymapId, String actionId, String hwInputId) { setVal(keymapId + "_" + actionId, hwInputId); }
|
||||
/**
|
||||
* This retrieves the assigned default hwKey for a given Keymap Action
|
||||
* @param keymapId String representing Keymap id (Keymap.name)
|
||||
* @param actionId String representing Action id (Action.id)
|
||||
* @return hwKeyId String representing the HardwareKey id (HardwareKey.hwKeyId)
|
||||
* @return String representing the HardwareInput id (HardwareInput.id)
|
||||
*/
|
||||
String getDefaultBinding(String keymapId, String actionId) { return getVal(keymapId + "_" + actionId); }
|
||||
};
|
||||
|
|
|
@ -54,26 +54,26 @@ Keymap *Keymapper::Domain::getKeymap(const String& name) {
|
|||
}
|
||||
|
||||
Keymapper::Keymapper(EventManager *evtMgr)
|
||||
: _eventMan(evtMgr), _enabled(true), _hardwareKeys(0) {
|
||||
: _eventMan(evtMgr), _enabled(true), _hardwareInputs(0) {
|
||||
ConfigManager::Domain *confDom = ConfMan.getDomain(ConfigManager::kKeymapperDomain);
|
||||
|
||||
_globalDomain.setConfigDomain(confDom);
|
||||
}
|
||||
|
||||
Keymapper::~Keymapper() {
|
||||
delete _hardwareKeys;
|
||||
delete _hardwareInputs;
|
||||
}
|
||||
|
||||
void Keymapper::registerHardwareKeySet(HardwareKeySet *keys) {
|
||||
if (_hardwareKeys)
|
||||
error("Hardware key set already registered");
|
||||
void Keymapper::registerHardwareInputSet(HardwareInputSet *inputs) {
|
||||
if (_hardwareInputs)
|
||||
error("Hardware input set already registered");
|
||||
|
||||
if (!keys) {
|
||||
warning("No hardware keys are supplied");
|
||||
if (!inputs) {
|
||||
warning("No hardware input are supplied");
|
||||
return;
|
||||
}
|
||||
|
||||
_hardwareKeys = keys;
|
||||
_hardwareInputs = inputs;
|
||||
}
|
||||
|
||||
void Keymapper::addGlobalKeymap(Keymap *keymap) {
|
||||
|
@ -95,15 +95,15 @@ void Keymapper::addGameKeymap(Keymap *keymap) {
|
|||
}
|
||||
|
||||
void Keymapper::initKeymap(Domain &domain, Keymap *map) {
|
||||
if (!_hardwareKeys) {
|
||||
warning("No hardware keys were registered yet (%s)", map->getName().c_str());
|
||||
if (!_hardwareInputs) {
|
||||
warning("No hardware inputs were registered yet (%s)", map->getName().c_str());
|
||||
return;
|
||||
}
|
||||
|
||||
map->setConfigDomain(domain.getConfigDomain());
|
||||
map->loadMappings(_hardwareKeys);
|
||||
map->loadMappings(_hardwareInputs);
|
||||
|
||||
if (map->isComplete(_hardwareKeys) == false) {
|
||||
if (map->isComplete(_hardwareInputs) == false) {
|
||||
map->saveMappings();
|
||||
ConfMan.flushToDisk();
|
||||
}
|
||||
|
@ -291,8 +291,8 @@ List<Event> Keymapper::executeAction(const Action *action, bool keyDown) {
|
|||
return mappedEvents;
|
||||
}
|
||||
|
||||
const HardwareKey *Keymapper::findHardwareKey(const KeyState& key) {
|
||||
return (_hardwareKeys) ? _hardwareKeys->findHardwareKey(key) : 0;
|
||||
const HardwareInput *Keymapper::findHardwareInput(const KeyState& key) {
|
||||
return (_hardwareInputs) ? _hardwareInputs->findHardwareInput(key) : 0;
|
||||
}
|
||||
|
||||
} // End of namespace Common
|
||||
|
|
|
@ -31,7 +31,7 @@
|
|||
#include "common/list.h"
|
||||
#include "common/hashmap.h"
|
||||
#include "common/stack.h"
|
||||
#include "backends/keymapper/hardware-key.h"
|
||||
#include "backends/keymapper/hardware-input.h"
|
||||
#include "backends/keymapper/keymap.h"
|
||||
|
||||
namespace Common {
|
||||
|
@ -81,17 +81,17 @@ public:
|
|||
virtual List<Event> mapEvent(const Event &ev, EventSource *source);
|
||||
|
||||
/**
|
||||
* Registers a HardwareKeySet with the Keymapper
|
||||
* Registers a HardwareInputSet with the Keymapper
|
||||
* @note should only be called once (during backend initialisation)
|
||||
*/
|
||||
void registerHardwareKeySet(HardwareKeySet *keys);
|
||||
void registerHardwareInputSet(HardwareInputSet *inputs);
|
||||
|
||||
/**
|
||||
* Get a list of all registered HardwareKeys
|
||||
* Get a list of all registered HardwareInputs
|
||||
*/
|
||||
const List<const HardwareKey *> &getHardwareKeys() const {
|
||||
assert(_hardwareKeys);
|
||||
return _hardwareKeys->getHardwareKeys();
|
||||
const List<const HardwareInput *> &getHardwareInputs() const {
|
||||
assert(_hardwareInputs);
|
||||
return _hardwareInputs->getHardwareInputs();
|
||||
}
|
||||
|
||||
/**
|
||||
|
@ -168,9 +168,9 @@ public:
|
|||
void setEnabled(bool enabled) { _enabled = enabled; }
|
||||
|
||||
/**
|
||||
* Return a HardwareKey pointer for the given key state
|
||||
* Return a HardwareInput pointer for the given key state
|
||||
*/
|
||||
const HardwareKey *findHardwareKey(const KeyState& key);
|
||||
const HardwareInput *findHardwareInput(const KeyState& key);
|
||||
|
||||
Domain& getGlobalDomain() { return _globalDomain; }
|
||||
Domain& getGameDomain() { return _gameDomain; }
|
||||
|
@ -183,7 +183,7 @@ private:
|
|||
Domain _globalDomain;
|
||||
Domain _gameDomain;
|
||||
|
||||
HardwareKeySet *_hardwareKeys;
|
||||
HardwareInputSet *_hardwareInputs;
|
||||
|
||||
void pushKeymap(Keymap *newMap, bool transparent, bool global);
|
||||
|
||||
|
|
|
@ -244,7 +244,7 @@ void RemapDialog::clearMapping(uint i) {
|
|||
|
||||
debug(3, "clear the mapping %u", i);
|
||||
_activeRemapAction = _currentActions[_topAction + i].action;
|
||||
_activeRemapAction->mapKey(0);
|
||||
_activeRemapAction->mapInput(0);
|
||||
_activeRemapAction->getParent()->saveMappings();
|
||||
_changes = true;
|
||||
|
||||
|
@ -286,12 +286,12 @@ void RemapDialog::handleKeyDown(Common::KeyState state) {
|
|||
|
||||
void RemapDialog::handleKeyUp(Common::KeyState state) {
|
||||
if (_activeRemapAction) {
|
||||
const HardwareKey *hwkey = _keymapper->findHardwareKey(state);
|
||||
const HardwareInput *hwInput = _keymapper->findHardwareInput(state);
|
||||
|
||||
debug(4, "RemapDialog::handleKeyUp Key: %d, %d (%c), %x", state.keycode, state.ascii, (state.ascii ? state.ascii : ' '), state.flags);
|
||||
|
||||
if (hwkey) {
|
||||
_activeRemapAction->mapKey(hwkey);
|
||||
if (hwInput) {
|
||||
_activeRemapAction->mapInput(hwInput);
|
||||
_activeRemapAction->getParent()->saveMappings();
|
||||
_changes = true;
|
||||
stopRemapping();
|
||||
|
@ -325,7 +325,7 @@ void RemapDialog::loadKeymap() {
|
|||
// - all of the topmost keymap action
|
||||
// - all mapped actions that are reachable
|
||||
|
||||
List<const HardwareKey *> freeKeys(_keymapper->getHardwareKeys());
|
||||
List<const HardwareInput *> freeInputs(_keymapper->getHardwareInputs());
|
||||
|
||||
int topIndex = activeKeymaps.size() - 1;
|
||||
|
||||
|
@ -344,8 +344,8 @@ void RemapDialog::loadKeymap() {
|
|||
|
||||
_currentActions.push_back(info);
|
||||
|
||||
if (act->getMappedKey())
|
||||
freeKeys.remove(act->getMappedKey());
|
||||
if (act->getMappedInput())
|
||||
freeInputs.remove(act->getMappedInput());
|
||||
}
|
||||
|
||||
// loop through remaining finding mappings for unmapped keys
|
||||
|
@ -353,21 +353,21 @@ void RemapDialog::loadKeymap() {
|
|||
for (int i = topIndex - 1; i >= 0; --i) {
|
||||
Keymapper::MapRecord mr = activeKeymaps[i];
|
||||
debug(3, "RemapDialog::loadKeymap keymap: %s", mr.keymap->getName().c_str());
|
||||
List<const HardwareKey *>::iterator keyIt = freeKeys.begin();
|
||||
List<const HardwareInput *>::iterator inputIt = freeInputs.begin();
|
||||
while (inputIt != freeInputs.end()) {
|
||||
|
||||
while (keyIt != freeKeys.end()) {
|
||||
Action *act = mr.keymap->getMappedAction((*keyIt)->key);
|
||||
Action *act = mr.keymap->getMappedAction((*inputIt)->key);
|
||||
|
||||
if (act) {
|
||||
ActionInfo info = {act, true, act->description + " (" + mr.keymap->getName() + ")"};
|
||||
_currentActions.push_back(info);
|
||||
freeKeys.erase(keyIt++);
|
||||
freeInputs.erase(inputIt);
|
||||
} else {
|
||||
++keyIt;
|
||||
++inputIt;
|
||||
}
|
||||
}
|
||||
|
||||
if (mr.transparent == false || freeKeys.empty())
|
||||
if (mr.transparent == false || freeInputs.empty())
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
@ -420,10 +420,10 @@ void RemapDialog::refreshKeymap() {
|
|||
widg.actionText->setLabel(info.description);
|
||||
widg.actionText->setEnabled(!info.inherited);
|
||||
|
||||
const HardwareKey *mappedKey = info.action->getMappedKey();
|
||||
const HardwareInput *mappedInput = info.action->getMappedInput();
|
||||
|
||||
if (mappedKey)
|
||||
widg.keyButton->setLabel(mappedKey->description);
|
||||
if (mappedInput)
|
||||
widg.keyButton->setLabel(mappedInput->description);
|
||||
else
|
||||
widg.keyButton->setLabel("-");
|
||||
|
||||
|
|
|
@ -224,12 +224,12 @@ void OSystem_Android::setupKeymapper() {
|
|||
|
||||
Keymapper *mapper = getEventManager()->getKeymapper();
|
||||
|
||||
HardwareKeySet *keySet = new HardwareKeySet();
|
||||
HardwareInputSet *inputSet = new HardwareInputSet();
|
||||
|
||||
keySet->addHardwareKey(
|
||||
new HardwareKey("n", KeyState(KEYCODE_n), "n (vk)"));
|
||||
keySet->addHardwareInput(
|
||||
new HardwareInput("n", KeyState(KEYCODE_n), "n (vk)"));
|
||||
|
||||
mapper->registerHardwareKeySet(keySet);
|
||||
mapper->registerHardwareInputSet(inputSet);
|
||||
|
||||
Keymap *globalMap = new Keymap(kGlobalKeymapName);
|
||||
Action *act;
|
||||
|
|
|
@ -106,7 +106,7 @@ static const Mod modifiers[] = {
|
|||
{ 0, 0, 0, false }
|
||||
};
|
||||
|
||||
Common::HardwareKeySet *OSystem_LINUXMOTO::getHardwareKeySet() {
|
||||
return OSystem_SDL::getHardwareKeySet();
|
||||
Common::HardwareInputSet *OSystem_LINUXMOTO::getHardwareInputSet() {
|
||||
return OSystem_SDL::getHardwareInputSet();
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -31,7 +31,7 @@ public:
|
|||
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
// FIXME: This just calls parent methods, is it needed?
|
||||
virtual Common::HardwareKeySet *getHardwareKeySet();
|
||||
virtual Common::HardwareInputSet *getHardwareInputSet();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -28,7 +28,7 @@
|
|||
|
||||
#include "common/keyboard.h"
|
||||
|
||||
#include "backends/keymapper/hardware-key.h"
|
||||
#include "backends/keymapper/hardware-input.h"
|
||||
|
||||
namespace Common {
|
||||
|
||||
|
|
|
@ -182,8 +182,8 @@ void OSystem_SDL_Maemo::setupIcon() {
|
|||
}
|
||||
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
Common::HardwareKeySet *OSystem_SDL_Maemo::getHardwareKeySet() {
|
||||
return new Common::HardwareKeySet(Common::maemoKeys, Common::maemoModifiers);
|
||||
Common::HardwareInputSet *OSystem_SDL_Maemo::getHardwareInputSet() {
|
||||
return new Common::HardwareInputSet(Common::maemoKeys, Common::maemoModifiers);
|
||||
}
|
||||
|
||||
Common::Keymap *OSystem_SDL_Maemo::getGlobalKeymap() {
|
||||
|
|
|
@ -42,7 +42,7 @@ public:
|
|||
virtual void setWindowCaption(const char *caption);
|
||||
virtual void setupIcon();
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
virtual Common::HardwareKeySet *getHardwareKeySet();
|
||||
virtual Common::HardwareInputSet *getHardwareInputSet();
|
||||
virtual Common::Keymap *getGlobalKeymap();
|
||||
virtual Common::KeymapperDefaultBindings *getKeymapperDefaultBindings() { return _keymapperDefaultBindings; }
|
||||
#endif
|
||||
|
|
|
@ -175,7 +175,7 @@ static const ModifierTableEntry sdlModifiers[] = {
|
|||
{ 0, 0, 0, false }
|
||||
};
|
||||
|
||||
Common::HardwareKeySet *OSystem_SDL::getHardwareKeySet() {
|
||||
return new HardwareKeySet(sdlKeys, sdlModifiers);
|
||||
Common::HardwareInputSet *OSystem_SDL::getHardwareInputSet() {
|
||||
return new HardwareInputSet(sdlKeys, sdlModifiers);
|
||||
}
|
||||
#endif
|
||||
|
|
|
@ -59,7 +59,7 @@ public:
|
|||
virtual void engineDone();
|
||||
#endif
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
virtual Common::HardwareKeySet *getHardwareKeySet();
|
||||
virtual Common::HardwareInputSet *getHardwareInputSet();
|
||||
#endif
|
||||
virtual void quit();
|
||||
virtual void fatalError();
|
||||
|
|
|
@ -52,16 +52,16 @@ void OSystem_SDL_WebOS::initBackend() {
|
|||
* @return The hardware key set with added webOS specific keys.
|
||||
*/
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
HardwareKeySet *OSystem_SDL_WebOS::getHardwareKeySet() {
|
||||
HardwareInputSet *OSystem_SDL_WebOS::getHardwareInputSet() {
|
||||
// Get the original SDL hardware key set
|
||||
HardwareKeySet *keySet = OSystem_SDL::getHardwareKeySet();
|
||||
HardwareInputSet *inputSet = OSystem_SDL::getHardwareInputSet();
|
||||
|
||||
// Add WebOS specific keys
|
||||
keySet->addHardwareKey(new HardwareKey("FORWARD",
|
||||
keySet->addHardwareInput(new HardwareInput("FORWARD",
|
||||
KeyState((KeyCode) 229, 229, 0), "Forward"));
|
||||
|
||||
// Return the modified hardware key set
|
||||
return keySet;
|
||||
return inputSet;
|
||||
}
|
||||
#endif
|
||||
|
||||
|
|
|
@ -32,7 +32,7 @@ public:
|
|||
|
||||
virtual void initBackend();
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
virtual Common::HardwareKeySet *getHardwareKeySet();
|
||||
virtual Common::HardwareInputSet *getHardwareInputSet();
|
||||
#endif
|
||||
};
|
||||
|
||||
|
|
|
@ -264,10 +264,10 @@ static void setupKeymapper(OSystem &system) {
|
|||
|
||||
Keymapper *mapper = system.getEventManager()->getKeymapper();
|
||||
|
||||
HardwareKeySet *keySet = system.getHardwareKeySet();
|
||||
HardwareInputSet *inputSet = system.getHardwareInputSet();
|
||||
|
||||
// Query backend for hardware keys and register them
|
||||
mapper->registerHardwareKeySet(keySet);
|
||||
mapper->registerHardwareInputSet(inputSet);
|
||||
|
||||
// Now create the global keymap
|
||||
Keymap *primaryGlobalKeymap = new Keymap(kGlobalKeymapName);
|
||||
|
|
|
@ -52,7 +52,7 @@ class TimerManager;
|
|||
class SeekableReadStream;
|
||||
class WriteStream;
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
class HardwareKeySet;
|
||||
class HardwareInputSet;
|
||||
class Keymap;
|
||||
class KeymapperDefaultBindings;
|
||||
#endif
|
||||
|
@ -938,15 +938,15 @@ public:
|
|||
|
||||
#ifdef ENABLE_KEYMAPPER
|
||||
/**
|
||||
* Register hardware keys with keymapper
|
||||
* Register hardware inputs with keymapper
|
||||
* IMPORTANT NOTE: This is part of the WIP Keymapper. If you plan to use
|
||||
* this, please talk to tsoliman and/or LordHoto.
|
||||
*
|
||||
* @return HardwareKeySet with all keys and recommended mappings
|
||||
* @return HardwareInputSet with all keys and recommended mappings
|
||||
*
|
||||
* See keymapper documentation for further reference.
|
||||
*/
|
||||
virtual Common::HardwareKeySet *getHardwareKeySet() { return 0; }
|
||||
virtual Common::HardwareInputSet *getHardwareInputSet() { return 0; }
|
||||
|
||||
/**
|
||||
* Return a platform-specific global keymap
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue