Showing the changes to interface/src/scripting/JoystickScriptingInterface.cpp (1 of 5 files). Show all
Unified · Split
| @@ -9,6 +9,7 @@ · 8 unmodified lines | ||
| 9 | 9 | // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html |
| 10 | 10 | // |
| 11 | 11 | |
| 12 | +#include <qapplication.h> | |
| 12 | 13 | #include <QtDebug> |
| 13 | 14 | #include <QScriptValue> |
| 14 | 15 | |
| @@ -17,6 +18,7 @@ · 2 unmodified lines | ||
| 17 | 18 | #undef main |
| 18 | 19 | #endif |
| 19 | 20 | |
| 21 | +#include <HFBackEvent.h> | |
| 20 | 22 | #include <PerfStat.h> |
| 21 | 23 | |
| 22 | 24 | #include "JoystickScriptingInterface.h" |
| @@ -108,6 +110,17 @@ void JoystickScriptingInterface::update() { · 85 unmodified lines | ||
| 108 | 110 | if (joystick) { |
| 109 | 111 | joystick->handleButtonEvent(event.cbutton); |
| 110 | 112 | } |
| 113 | + | |
| 114 | + if (event.cbutton.button == SDL_CONTROLLER_BUTTON_BACK) { | |
| 115 | + // this will either start or stop a cancel event | |
| 116 | + QEvent::Type backType = (event.type == SDL_CONTROLLERBUTTONDOWN) | |
| 117 | + ? HFBackEvent::startType() | |
| 118 | + : HFBackEvent::endType(); | |
| 119 | + HFBackEvent backEvent(backType); | |
| 120 | + | |
| 121 | + qApp->sendEvent(qApp, &backEvent); | |
| 122 | + } | |
| 123 | + | |
| 111 | 124 | } else if (event.type == SDL_CONTROLLERDEVICEADDED) { |
| 112 | 125 | SDL_GameController* controller = SDL_GameControllerOpen(event.cdevice.which); |
| 113 | 126 | |