KEYMAPPER: Add non-key inputs to HardwareInput

This commit is contained in:
Tarek Soliman 2012-02-24 13:55:48 -06:00
parent 101ec2b885
commit 4ee1a3acea
6 changed files with 97 additions and 28 deletions

View file

@ -34,6 +34,15 @@
namespace Common {
typedef uint32 HardwareInputCode;
enum HardwareInputType {
/** Input that sends single events */
kHardwareInputTypeGeneric,
/** Input that usually send -up and -down events */
kHardwareInputTypeKeyboard
};
/**
* Describes an available hardware input
*/
@ -44,14 +53,33 @@ struct HardwareInput {
/** Human readable description */
String description;
const HardwareInputType type;
/**
* The KeyState that is generated by the back-end
* when this hardware key is pressed.
*/
* A platform specific unique identifier for an input event
* generated when this input is triggered.
* This is only relevant when type == kHardwareInputTypeGeneric
*/
HardwareInputCode inputCode;
/**
* The KeyState that is generated by the back-end
* when this hardware key is pressed.
* This is only relevant when type == kHardwareInputTypeKeyboard
*/
KeyState key;
HardwareInput(String i, KeyState ky = KeyState(), String desc = "")
: id(i), key(ky), description(desc) { }
HardwareInput(String i, HardwareInputCode ic = 0, String desc = "")
: id(i), inputCode(ic), description(desc), type(kHardwareInputTypeGeneric) { }
HardwareInput(String i, KeyState ky, String desc = "")
: id(i), key(ky), description(desc), type(kHardwareInputTypeKeyboard) { }
};
struct HardwareInputTableEntry {
const char *hwId;
HardwareInputCode code;
const char *desc;
};
/**
@ -97,12 +125,20 @@ public:
const HardwareInput *findHardwareInput(String id) const;
const HardwareInput *findHardwareInput(const HardwareInputCode code) const;
const HardwareInput *findHardwareInput(const KeyState& keystate) const;
const List<const HardwareInput *> &getHardwareInputs() const { return _inputs; }
uint size() const { return _inputs.size(); }
/**
* Add hardware inputs to the set out of a table.
* @param inputs table of available inputs
*/
void addHardwareInputs(const HardwareInputTableEntry inputs[]);
/**
* Add hardware inputs to the set out of key and modifier tables.
* @param keys table of available keys
@ -110,13 +146,6 @@ public:
*/
void addHardwareInputs(const KeyTableEntry keys[], const ModifierTableEntry modifiers[]);
/**
* Add hardware inputs to the set out of a key table.
* The default modifiers are applied to the key entries
* @param keys table of available keys
*/
void addHardwareInputs(const KeyTableEntry keys[]);
void removeHardwareInput(const HardwareInput *input);
private: