History

rename HFCancelEvent to HFBackEvent, fire from joystick

Stephen Birarda committed 12 years ago

Commit 8a9f2d11 parent 04e7e975 files · +33 −20Browse files

Showing the changes to interface/src/scripting/JoystickScriptingInterface.cpp (1 of 5 files). Show all

Unified · Split

interface/src/scripting/JoystickScriptingInterface.cpp+13−0
@@ -9,6 +9,7 @@ · 8 unmodified lines
99 // See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
1010 //
1111
12+#include <qapplication.h>
1213 #include <QtDebug>
1314 #include <QScriptValue>
1415
@@ -17,6 +18,7 @@ · 2 unmodified lines
1718 #undef main
1819 #endif
1920
21+#include <HFBackEvent.h>
2022 #include <PerfStat.h>
2123
2224 #include "JoystickScriptingInterface.h"
@@ -108,6 +110,17 @@ void JoystickScriptingInterface::update() { · 85 unmodified lines
108110 if (joystick) {
109111 joystick->handleButtonEvent(event.cbutton);
110112 }
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+
111124 } else if (event.type == SDL_CONTROLLERDEVICEADDED) {
112125 SDL_GameController* controller = SDL_GameControllerOpen(event.cdevice.which);
113126