add a new meta event, HFCancelEvent

This commit is contained in:
Stephen Birarda 2014-10-27 15:37:31 -07:00
parent 8556b8b95d
commit 7b5115c35f
5 changed files with 70 additions and 5 deletions

View file

@ -10,10 +10,13 @@
//
#include <HandData.h>
#include <HFCancelEvent.h>
#include "Application.h"
#include "devices/MotionTracker.h"
#include "devices/SixenseManager.h"
#include "ControllerScriptingInterface.h"
#include "devices/MotionTracker.h"
ControllerScriptingInterface::ControllerScriptingInterface() :
_mouseCaptured(false),
@ -25,9 +28,13 @@ ControllerScriptingInterface::ControllerScriptingInterface() :
void ControllerScriptingInterface::handleMetaEvent(HFMetaEvent* event) {
if (event->type() == HFActionEvent::startType()) {
emitActionStartEvent(static_cast<HFActionEvent*>(event));
emit actionStartEvent(static_cast<HFActionEvent&>(*event));
} else if (event->type() == HFActionEvent::endType()) {
emitActionEndEvent(static_cast<HFActionEvent*>(event));
emit actionEndEvent(static_cast<HFActionEvent&>(*event));
} else if (event->type() == HFCancelEvent::startType()) {
emit cancelStartEvent();
} else if (event->type() == HFCancelEvent::endType()) {
emit cancelEndEvent();
}
}

View file

@ -58,8 +58,6 @@ public:
void emitKeyReleaseEvent(QKeyEvent* event) { emit keyReleaseEvent(KeyEvent(*event)); }
void handleMetaEvent(HFMetaEvent* event);
void emitActionStartEvent(HFActionEvent* event) { emit actionStartEvent(*event); }
void emitActionEndEvent(HFActionEvent* event) { emit actionEndEvent(*event); }
void emitMouseMoveEvent(QMouseEvent* event, unsigned int deviceID = 0) { emit mouseMoveEvent(MouseEvent(*event, deviceID)); }
void emitMousePressEvent(QMouseEvent* event, unsigned int deviceID = 0) { emit mousePressEvent(MouseEvent(*event, deviceID)); }

View file

@ -96,6 +96,9 @@ signals:
void actionStartEvent(const HFActionEvent& event);
void actionEndEvent(const HFActionEvent& event);
void cancelStartEvent();
void cancelEndEvent();
void mouseMoveEvent(const MouseEvent& event, unsigned int deviceID = 0);
void mousePressEvent(const MouseEvent& event, unsigned int deviceID = 0);

View file

@ -0,0 +1,28 @@
//
// HFCancelEvent.cpp
// script-engine/src
//
// Created by Stephen Birarda on 2014-10-27.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#include "HFCancelEvent.h"
HFCancelEvent::HFCancelEvent(QEvent::Type type) :
HFMetaEvent(type)
{
}
QEvent::Type HFCancelEvent::startType() {
static QEvent::Type startType = HFMetaEvent::newEventType();
return startType;
}
QEvent::Type HFCancelEvent::endType() {
static QEvent::Type endType = HFMetaEvent::newEventType();
return endType;
}

View file

@ -0,0 +1,29 @@
//
// HFCancelEvent.h
// script-engine/src
//
// Created by Stephen Birarda on 2014-10-27.
// Copyright 2014 High Fidelity, Inc.
//
// Distributed under the Apache License, Version 2.0.
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
//
#ifndef hifi_HFCancelEvent_h
#define hifi_HFCancelEvent_h
#include <qevent.h>
#include <qscriptengine.h>
#include "HFMetaEvent.h"
class HFCancelEvent : public HFMetaEvent {
public:
HFCancelEvent() {};
HFCancelEvent(QEvent::Type type);
static QEvent::Type startType();
static QEvent::Type endType();
};
#endif // hifi_HFCancelEvent_h