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