Showing the changes to interface/src/scripting/JoystickScriptingInterface.cpp (1 of 2 files). Show all
Unified · Split
| @@ -18,9 +18,12 @@ · 17 unmodified lines | ||
| 18 | 18 | #undef main |
| 19 | 19 | #endif |
| 20 | 20 | |
| 21 | +#include <HFActionEvent.h> | |
| 21 | 22 | #include <HFBackEvent.h> |
| 22 | 23 | #include <PerfStat.h> |
| 23 | 24 | |
| 25 | +#include "Application.h" | |
| 26 | + | |
| 24 | 27 | #include "JoystickScriptingInterface.h" |
| 25 | 28 | |
| 26 | 29 | #ifdef HAVE_SDL2 |
| @@ -112,13 +115,24 @@ void JoystickScriptingInterface::update() { · 85 unmodified lines | ||
| 112 | 115 | } |
| 113 | 116 | |
| 114 | 117 | if (event.cbutton.button == SDL_CONTROLLER_BUTTON_BACK) { |
| 115 | − // this will either start or stop a cancel event | |
| 118 | + // this will either start or stop a global back event | |
| 116 | 119 | QEvent::Type backType = (event.type == SDL_CONTROLLERBUTTONDOWN) |
| 117 | 120 | ? HFBackEvent::startType() |
| 118 | 121 | : HFBackEvent::endType(); |
| 119 | 122 | HFBackEvent backEvent(backType); |
| 120 | 123 | |
| 121 | 124 | qApp->sendEvent(qApp, &backEvent); |
| 125 | + } else if (event.cbutton.button == SDL_CONTROLLER_BUTTON_A) { | |
| 126 | + // this will either start or stop a global action event | |
| 127 | + QEvent::Type actionType = (event.type == SDL_CONTROLLERBUTTONDOWN) | |
| 128 | + ? HFActionEvent::startType() | |
| 129 | + : HFActionEvent::endType(); | |
| 130 | + | |
| 131 | + // global action events fire in the center of the screen | |
| 132 | + QPointF centerPoint = Application::getInstance()->getViewportCenter(); | |
| 133 | + HFActionEvent actionEvent(actionType, centerPoint); | |
| 134 | + | |
| 135 | + qApp->sendEvent(qApp, &actionEvent); | |
| 122 | 136 | } |
| 123 | 137 | |
| 124 | 138 | } else if (event.type == SDL_CONTROLLERDEVICEADDED) { |