History

have controller A button fire action at center of screen

Stephen Birarda committed 12 years ago

Commit 8e6b6d51 parent 8a9f2d12 files · +17 −1Browse files

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

Unified · Split

interface/src/scripting/JoystickScriptingInterface.cpp+15−1
@@ -18,9 +18,12 @@ · 17 unmodified lines
18#undef main18#undef main
19#endif19#endif
20 20
21#include <HFActionEvent.h>
21#include <HFBackEvent.h>22#include <HFBackEvent.h>
22#include <PerfStat.h>23#include <PerfStat.h>
23 24
25#include "Application.h"
26
24#include "JoystickScriptingInterface.h"27#include "JoystickScriptingInterface.h"
25 28
26#ifdef HAVE_SDL229#ifdef HAVE_SDL2
@@ -112,13 +115,24 @@ void JoystickScriptingInterface::update() { · 85 unmodified lines
112 }115 }
113 116
114 if (event.cbutton.button == SDL_CONTROLLER_BUTTON_BACK) {117 if (event.cbutton.button == SDL_CONTROLLER_BUTTON_BACK) {
115 // this will either start or stop a cancel event118 // this will either start or stop a global back event
116 QEvent::Type backType = (event.type == SDL_CONTROLLERBUTTONDOWN)119 QEvent::Type backType = (event.type == SDL_CONTROLLERBUTTONDOWN)
117 ? HFBackEvent::startType()120 ? HFBackEvent::startType()
118 : HFBackEvent::endType();121 : HFBackEvent::endType();
119 HFBackEvent backEvent(backType);122 HFBackEvent backEvent(backType);
120 123
121 qApp->sendEvent(qApp, &backEvent);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 } else if (event.type == SDL_CONTROLLERDEVICEADDED) {138 } else if (event.type == SDL_CONTROLLERDEVICEADDED) {