mirror of
https://github.com/overte-org/overte.git
synced 2025-04-21 17:03:58 +02:00
have controller A button fire action at center of screen
This commit is contained in:
parent
8a9f2d172a
commit
8e6b6d5294
2 changed files with 17 additions and 1 deletions
|
@ -283,6 +283,8 @@ public:
|
|||
PointShader& getPointShader() { return _pointShader; }
|
||||
FileLogger* getLogger() { return _logger; }
|
||||
|
||||
QPointF getViewportCenter() const
|
||||
{ return QPointF(_glWidget->getDeviceWidth() / 2.0f, _glWidget->getDeviceHeight() / 2.0f); }
|
||||
glm::vec2 getViewportDimensions() const { return glm::vec2(_glWidget->getDeviceWidth(), _glWidget->getDeviceHeight()); }
|
||||
NodeToJurisdictionMap& getVoxelServerJurisdictions() { return _voxelServerJurisdictions; }
|
||||
NodeToJurisdictionMap& getEntityServerJurisdictions() { return _entityServerJurisdictions; }
|
||||
|
|
|
@ -18,9 +18,12 @@
|
|||
#undef main
|
||||
#endif
|
||||
|
||||
#include <HFActionEvent.h>
|
||||
#include <HFBackEvent.h>
|
||||
#include <PerfStat.h>
|
||||
|
||||
#include "Application.h"
|
||||
|
||||
#include "JoystickScriptingInterface.h"
|
||||
|
||||
#ifdef HAVE_SDL2
|
||||
|
@ -112,13 +115,24 @@ void JoystickScriptingInterface::update() {
|
|||
}
|
||||
|
||||
if (event.cbutton.button == SDL_CONTROLLER_BUTTON_BACK) {
|
||||
// this will either start or stop a cancel event
|
||||
// this will either start or stop a global back event
|
||||
QEvent::Type backType = (event.type == SDL_CONTROLLERBUTTONDOWN)
|
||||
? HFBackEvent::startType()
|
||||
: HFBackEvent::endType();
|
||||
HFBackEvent backEvent(backType);
|
||||
|
||||
qApp->sendEvent(qApp, &backEvent);
|
||||
} else if (event.cbutton.button == SDL_CONTROLLER_BUTTON_A) {
|
||||
// this will either start or stop a global action event
|
||||
QEvent::Type actionType = (event.type == SDL_CONTROLLERBUTTONDOWN)
|
||||
? HFActionEvent::startType()
|
||||
: HFActionEvent::endType();
|
||||
|
||||
// global action events fire in the center of the screen
|
||||
QPointF centerPoint = Application::getInstance()->getViewportCenter();
|
||||
HFActionEvent actionEvent(actionType, centerPoint);
|
||||
|
||||
qApp->sendEvent(qApp, &actionEvent);
|
||||
}
|
||||
|
||||
} else if (event.type == SDL_CONTROLLERDEVICEADDED) {
|
||||
|
|
Loading…
Reference in a new issue