mirror of
https://github.com/overte-org/overte.git
synced 2025-08-09 21:12:53 +02:00
hacking on controller events
This commit is contained in:
parent
64afd17d14
commit
5addc35cd8
3 changed files with 61 additions and 0 deletions
|
@ -681,6 +681,9 @@ void Application::controlledBroadcastToNodes(unsigned char* broadcastData, size_
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::keyPressEvent(QKeyEvent* event) {
|
void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
|
|
||||||
|
_controllerScriptingInterface.emitKeyPressEvent(event); // send events to any registered scripts
|
||||||
|
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
if (_chatEntryOn) {
|
if (_chatEntryOn) {
|
||||||
if (_chatEntry.keyPressEvent(event)) {
|
if (_chatEntry.keyPressEvent(event)) {
|
||||||
|
@ -1092,6 +1095,9 @@ void Application::keyPressEvent(QKeyEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::keyReleaseEvent(QKeyEvent* event) {
|
void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
|
|
||||||
|
_controllerScriptingInterface.emitKeyReleaseEvent(event); // send events to any registered scripts
|
||||||
|
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
if (_chatEntryOn) {
|
if (_chatEntryOn) {
|
||||||
_myAvatar.setKeyState(NO_KEY_DOWN);
|
_myAvatar.setKeyState(NO_KEY_DOWN);
|
||||||
|
@ -1154,6 +1160,8 @@ void Application::keyReleaseEvent(QKeyEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::mouseMoveEvent(QMouseEvent* event) {
|
void Application::mouseMoveEvent(QMouseEvent* event) {
|
||||||
|
_controllerScriptingInterface.emitMouseMoveEvent(event); // send events to any registered scripts
|
||||||
|
|
||||||
_lastMouseMove = usecTimestampNow();
|
_lastMouseMove = usecTimestampNow();
|
||||||
if (_mouseHidden) {
|
if (_mouseHidden) {
|
||||||
getGLWidget()->setCursor(Qt::ArrowCursor);
|
getGLWidget()->setCursor(Qt::ArrowCursor);
|
||||||
|
@ -1200,6 +1208,7 @@ const float HOVER_VOXEL_FREQUENCY = 7040.f;
|
||||||
const float HOVER_VOXEL_DECAY = 0.999f;
|
const float HOVER_VOXEL_DECAY = 0.999f;
|
||||||
|
|
||||||
void Application::mousePressEvent(QMouseEvent* event) {
|
void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
|
_controllerScriptingInterface.emitMousePressEvent(event); // send events to any registered scripts
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
_mouseX = event->x();
|
_mouseX = event->x();
|
||||||
|
@ -1267,6 +1276,7 @@ void Application::mousePressEvent(QMouseEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::mouseReleaseEvent(QMouseEvent* event) {
|
void Application::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
|
_controllerScriptingInterface.emitMouseReleaseEvent(event); // send events to any registered scripts
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
if (event->button() == Qt::LeftButton) {
|
if (event->button() == Qt::LeftButton) {
|
||||||
_mouseX = event->x();
|
_mouseX = event->x();
|
||||||
|
@ -1283,6 +1293,7 @@ void Application::mouseReleaseEvent(QMouseEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::touchUpdateEvent(QTouchEvent* event) {
|
void Application::touchUpdateEvent(QTouchEvent* event) {
|
||||||
|
_controllerScriptingInterface.emitTouchUpdateEvent(event); // send events to any registered scripts
|
||||||
bool validTouch = false;
|
bool validTouch = false;
|
||||||
if (activeWindow() == _window) {
|
if (activeWindow() == _window) {
|
||||||
const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
|
const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
|
||||||
|
@ -1307,12 +1318,15 @@ void Application::touchUpdateEvent(QTouchEvent* event) {
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::touchBeginEvent(QTouchEvent* event) {
|
void Application::touchBeginEvent(QTouchEvent* event) {
|
||||||
|
_controllerScriptingInterface.emitTouchBeginEvent(event); // send events to any registered scripts
|
||||||
|
|
||||||
touchUpdateEvent(event);
|
touchUpdateEvent(event);
|
||||||
_lastTouchAvgX = _touchAvgX;
|
_lastTouchAvgX = _touchAvgX;
|
||||||
_lastTouchAvgY = _touchAvgY;
|
_lastTouchAvgY = _touchAvgY;
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::touchEndEvent(QTouchEvent* event) {
|
void Application::touchEndEvent(QTouchEvent* event) {
|
||||||
|
_controllerScriptingInterface.emitTouchEndEvent(event); // send events to any registered scripts
|
||||||
_touchDragStartedAvgX = _touchAvgX;
|
_touchDragStartedAvgX = _touchAvgX;
|
||||||
_touchDragStartedAvgY = _touchAvgY;
|
_touchDragStartedAvgY = _touchAvgY;
|
||||||
_isTouchPressed = false;
|
_isTouchPressed = false;
|
||||||
|
@ -1320,6 +1334,9 @@ void Application::touchEndEvent(QTouchEvent* event) {
|
||||||
|
|
||||||
const bool USE_MOUSEWHEEL = false;
|
const bool USE_MOUSEWHEEL = false;
|
||||||
void Application::wheelEvent(QWheelEvent* event) {
|
void Application::wheelEvent(QWheelEvent* event) {
|
||||||
|
|
||||||
|
_controllerScriptingInterface.emitWheelEvent(event); // send events to any registered scripts
|
||||||
|
|
||||||
// Wheel Events disabled for now because they are also activated by touch look pitch up/down.
|
// Wheel Events disabled for now because they are also activated by touch look pitch up/down.
|
||||||
if (USE_MOUSEWHEEL && (activeWindow() == _window)) {
|
if (USE_MOUSEWHEEL && (activeWindow() == _window)) {
|
||||||
if (!Menu::getInstance()->isVoxelModeActionChecked()) {
|
if (!Menu::getInstance()->isVoxelModeActionChecked()) {
|
||||||
|
|
|
@ -18,6 +18,25 @@ class PalmData;
|
||||||
class ControllerScriptingInterface : public AbstractControllerScriptingInterface {
|
class ControllerScriptingInterface : public AbstractControllerScriptingInterface {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
|
||||||
|
public:
|
||||||
|
void emitKeyPressEvent(QKeyEvent* x) {
|
||||||
|
KeyEvent event(x);
|
||||||
|
emit keyPressEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
void emitKeyReleaseEvent(QKeyEvent* event) { emit keyReleaseEvent(*event); }
|
||||||
|
|
||||||
|
void emitMouseMoveEvent(QMouseEvent* event) { emit mouseMoveEvent(*event); }
|
||||||
|
void emitMousePressEvent(QMouseEvent* event) { emit mousePressEvent(*event); }
|
||||||
|
void emitMouseReleaseEvent(QMouseEvent* event) { emit mouseReleaseEvent(*event); }
|
||||||
|
|
||||||
|
void emitTouchBeginEvent(QTouchEvent* event) { emit touchBeginEvent(event); }
|
||||||
|
void emitTouchEndEvent(QTouchEvent* event) { emit touchEndEvent(event); }
|
||||||
|
void emitTouchUpdateEvent(QTouchEvent* event) { emit touchUpdateEvent(event); }
|
||||||
|
void emitWheelEvent(QWheelEvent* event) { emit wheelEvent(event); }
|
||||||
|
**/
|
||||||
|
|
||||||
public slots:
|
public slots:
|
||||||
virtual bool isPrimaryButtonPressed() const;
|
virtual bool isPrimaryButtonPressed() const;
|
||||||
virtual glm::vec2 getPrimaryJoystickPosition() const;
|
virtual glm::vec2 getPrimaryJoystickPosition() const;
|
||||||
|
@ -36,6 +55,12 @@ public slots:
|
||||||
virtual glm::vec3 getSpatialControlVelocity(int controlIndex) const;
|
virtual glm::vec3 getSpatialControlVelocity(int controlIndex) const;
|
||||||
virtual glm::vec3 getSpatialControlNormal(int controlIndex) const;
|
virtual glm::vec3 getSpatialControlNormal(int controlIndex) const;
|
||||||
|
|
||||||
|
// The following signals are defined by AbstractControllerScriptingInterface
|
||||||
|
//
|
||||||
|
// signals:
|
||||||
|
// void keyPressEvent();
|
||||||
|
// void keyPressEvent();
|
||||||
|
|
||||||
private:
|
private:
|
||||||
const PalmData* getPrimaryPalm() const;
|
const PalmData* getPrimaryPalm() const;
|
||||||
const PalmData* getPalm(int palmIndex) const;
|
const PalmData* getPalm(int palmIndex) const;
|
||||||
|
|
|
@ -10,8 +10,12 @@
|
||||||
#define __hifi__AbstractControllerScriptingInterface__
|
#define __hifi__AbstractControllerScriptingInterface__
|
||||||
|
|
||||||
#include <QtCore/QObject>
|
#include <QtCore/QObject>
|
||||||
|
|
||||||
#include <glm/glm.hpp>
|
#include <glm/glm.hpp>
|
||||||
|
|
||||||
|
#include "EventTypes.h"
|
||||||
|
|
||||||
|
|
||||||
/// handles scripting of input controller commands from JS
|
/// handles scripting of input controller commands from JS
|
||||||
class AbstractControllerScriptingInterface : public QObject {
|
class AbstractControllerScriptingInterface : public QObject {
|
||||||
Q_OBJECT
|
Q_OBJECT
|
||||||
|
@ -33,6 +37,21 @@ public slots:
|
||||||
virtual glm::vec3 getSpatialControlPosition(int controlIndex) const = 0;
|
virtual glm::vec3 getSpatialControlPosition(int controlIndex) const = 0;
|
||||||
virtual glm::vec3 getSpatialControlVelocity(int controlIndex) const = 0;
|
virtual glm::vec3 getSpatialControlVelocity(int controlIndex) const = 0;
|
||||||
virtual glm::vec3 getSpatialControlNormal(int controlIndex) const = 0;
|
virtual glm::vec3 getSpatialControlNormal(int controlIndex) const = 0;
|
||||||
|
|
||||||
|
signals:
|
||||||
|
void keyPressEvent(const KeyEvent& event);
|
||||||
|
void keyReleaseEvent(const KeyEvent& event);
|
||||||
|
|
||||||
|
void mouseMoveEvent(const MouseEvent& event);
|
||||||
|
void mousePressEvent(const MouseEvent& event);
|
||||||
|
void mouseReleaseEvent(const MouseEvent& event);
|
||||||
|
|
||||||
|
void touchBeginEvent(const TouchEvent& event);
|
||||||
|
void touchEndEvent(const TouchEvent& event);
|
||||||
|
void touchUpdateEvent(const TouchEvent& event);
|
||||||
|
|
||||||
|
void wheelEvent(const WheelEvent& event);
|
||||||
|
|
||||||
};
|
};
|
||||||
|
|
||||||
#endif /* defined(__hifi__AbstractControllerScriptingInterface__) */
|
#endif /* defined(__hifi__AbstractControllerScriptingInterface__) */
|
||||||
|
|
Loading…
Reference in a new issue