add Controler.Actions

This commit is contained in:
Brad Hefta-Gaub 2015-10-09 21:23:19 -07:00
parent f55b6115d6
commit 63f3156a61
3 changed files with 17 additions and 1 deletions

View file

@ -17,6 +17,10 @@ Object.keys(Controller.Hardware).forEach(function (deviceName) {
});
});
Object.keys(Controller.Actions).forEach(function (actionName) {
print(actionName + ":" + Controller.Actions[actionName]);
});
// Resets every device to its default key bindings:
Controller.resetAllDeviceBindings();

View file

@ -390,8 +390,9 @@ QString ControllerScriptingInterface::sanatizeName(const QString& name) {
}
void ControllerScriptingInterface::wireUpControllers(ScriptEngine* engine) {
auto devices = DependencyManager::get<UserInputMapper>()->getDevices();
// Controller.Hardware.*
auto devices = DependencyManager::get<UserInputMapper>()->getDevices();
for(const auto& deviceMapping : devices) {
auto device = deviceMapping.second.get();
auto deviceName = sanatizeName(device->getName());
@ -403,6 +404,15 @@ void ControllerScriptingInterface::wireUpControllers(ScriptEngine* engine) {
engine->registerValue(deviceInputName, input.getID());
}
}
// Controller.Actions.*
auto actionNames = DependencyManager::get<UserInputMapper>()->getActionNames();
int actionNumber = 0;
for (const auto& actionName : actionNames) {
QString safeActionName { "Controller.Actions." + sanatizeName(actionName) };
engine->registerValue(safeActionName, actionNumber);
actionNumber++;
}
}
AbstractInputController* ControllerScriptingInterface::createInputController(const QString& deviceName, const QString& tracker) {

View file

@ -319,4 +319,6 @@ void UserInputMapper::createActionNames() {
_actionNames[SHIFT] = "SHIFT";
_actionNames[ACTION1] = "ACTION1";
_actionNames[ACTION2] = "ACTION2";
_actionNames[CONTEXT_MENU] = "CONTEXT_MENU";
_actionNames[TOGGLE_MUTE] = "TOGGLE_MUTE";
}