mirror of https://github.com/qt/qt3d.git
Renamed to QKeyboardHandler
Also: - rename property controller to sourceDevice - remove protected ctor - move keyEvent() to the dpointer class Change-Id: I0badbc4d0ef0bcc202866f8cbdbaea8d107374fa Task-Id: QTBUG-51439 Reviewed-by: Sean Harmer <sean.harmer@kdab.com>
This commit is contained in:
parent
c3ed77c7af
commit
2b90bd2976
|
|
@ -74,7 +74,7 @@ Entity {
|
|||
}
|
||||
}
|
||||
|
||||
KeyboardInput { id: input }
|
||||
KeyboardHandler { id: input }
|
||||
|
||||
components: [material, sphereMesh, transform, input]
|
||||
}
|
||||
|
|
|
|||
|
|
@ -89,14 +89,14 @@ Entity {
|
|||
color: "red"
|
||||
input.onTabPressed: sphere2.input.focus = true
|
||||
input.focus: true
|
||||
input.controller: keyboardController
|
||||
input.sourceDevice: keyboardController
|
||||
}
|
||||
|
||||
SphereEntity {
|
||||
id: sphere2
|
||||
color: "green"
|
||||
input.onTabPressed: sphere3.input.focus = true
|
||||
input.controller: keyboardController
|
||||
input.sourceDevice: keyboardController
|
||||
}
|
||||
|
||||
SphereEntity {
|
||||
|
|
@ -104,6 +104,6 @@ Entity {
|
|||
position: Qt.vector3d(5, 0, 0)
|
||||
color: "blue"
|
||||
input.onTabPressed: sphere1.input.focus = true
|
||||
input.controller: keyboardController
|
||||
input.sourceDevice: keyboardController
|
||||
}
|
||||
}
|
||||
|
|
|
|||
|
|
@ -69,14 +69,14 @@ Entity {
|
|||
|
||||
KeyboardController {id: keyboardController}
|
||||
|
||||
KeyboardInput {
|
||||
id: keyboardInput
|
||||
KeyboardHandler {
|
||||
id: keyboardHandler
|
||||
controller: keyboardController
|
||||
focus: true
|
||||
onTabPressed: root.detailCamera = !root.detailCamera;
|
||||
}
|
||||
|
||||
components: [external_forward_renderer, keyboardInput]
|
||||
components: [external_forward_renderer, keyboardHandler]
|
||||
|
||||
FirstPersonCameraController { camera: mainView.camera }
|
||||
|
||||
|
|
|
|||
|
|
@ -58,7 +58,7 @@ Entity {
|
|||
|
||||
KeyboardController { id: keyboard1 }
|
||||
|
||||
KeyboardInput {
|
||||
KeyboardHandler {
|
||||
id: input
|
||||
controller: keyboard1
|
||||
focus: true
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "assignkeyboardfocusjob_p.h"
|
||||
#include "keyboardcontroller_p.h"
|
||||
#include "keyboardinput_p.h"
|
||||
#include "keyboardhandler_p.h"
|
||||
#include "inputhandler_p.h"
|
||||
#include "inputmanagers_p.h"
|
||||
|
||||
|
|
@ -63,8 +63,8 @@ void AssignKeyboardFocusJob::setInputHandler(InputHandler *handler)
|
|||
void AssignKeyboardFocusJob::run()
|
||||
{
|
||||
KeyboardController *controller = m_inputHandler->keyboardControllerManager()->lookupResource(m_keyboardController);
|
||||
Q_FOREACH (const HKeyboardInput handle, controller->keyboardInputsHandles()) {
|
||||
KeyboardInput *input = m_inputHandler->keyboardInputManager()->data(handle);
|
||||
Q_FOREACH (const HKeyboardHandler handle, controller->keyboardInputsHandles()) {
|
||||
KeyboardHandler *input = m_inputHandler->keyboardInputManager()->data(handle);
|
||||
if (input) {
|
||||
bool hasFocus = input->peerUuid() == controller->lastKeyboardInputRequester();
|
||||
input->setFocus(hasFocus);
|
||||
|
|
|
|||
|
|
@ -1,6 +1,6 @@
|
|||
HEADERS += \
|
||||
$$PWD/keyboardcontroller_p.h \
|
||||
$$PWD/keyboardinput_p.h \
|
||||
$$PWD/keyboardhandler_p.h \
|
||||
$$PWD/inputhandler_p.h \
|
||||
$$PWD/inputmanagers_p.h \
|
||||
$$PWD/handle_types_p.h \
|
||||
|
|
@ -31,7 +31,7 @@ HEADERS += \
|
|||
|
||||
SOURCES += \
|
||||
$$PWD/keyboardcontroller.cpp \
|
||||
$$PWD/keyboardinput.cpp \
|
||||
$$PWD/keyboardhandler.cpp \
|
||||
$$PWD/inputhandler.cpp \
|
||||
$$PWD/keyboardeventfilter.cpp \
|
||||
$$PWD/assignkeyboardfocusjob.cpp \
|
||||
|
|
|
|||
|
|
@ -59,7 +59,7 @@ namespace Qt3DInput {
|
|||
namespace Input {
|
||||
|
||||
class KeyboardController;
|
||||
class KeyboardInput;
|
||||
class KeyboardHandler;
|
||||
class MouseController;
|
||||
class MouseHandler;
|
||||
class Axis;
|
||||
|
|
@ -74,7 +74,7 @@ class LogicalDevice;
|
|||
class GenericDeviceBackendNode;
|
||||
|
||||
typedef Qt3DCore::QHandle<KeyboardController, 8> HKeyboardController;
|
||||
typedef Qt3DCore::QHandle<KeyboardInput, 16> HKeyboardInput;
|
||||
typedef Qt3DCore::QHandle<KeyboardHandler, 16> HKeyboardHandler;
|
||||
typedef Qt3DCore::QHandle<MouseController, 8> HMouseController;
|
||||
typedef Qt3DCore::QHandle<MouseHandler, 16> HMouseHandler;
|
||||
typedef Qt3DCore::QHandle<Axis, 16> HAxis;
|
||||
|
|
|
|||
|
|
@ -54,7 +54,7 @@
|
|||
#include <QtGlobal>
|
||||
#include <Qt3DInput/private/handle_types_p.h>
|
||||
#include <Qt3DInput/private/keyboardcontroller_p.h>
|
||||
#include <Qt3DInput/private/keyboardinput_p.h>
|
||||
#include <Qt3DInput/private/keyboardhandler_p.h>
|
||||
#include <Qt3DInput/private/mousecontroller_p.h>
|
||||
#include <Qt3DInput/private/mousehandler_p.h>
|
||||
#include <Qt3DCore/private/qresourcemanager_p.h>
|
||||
|
|
@ -74,7 +74,7 @@ namespace Qt3DInput {
|
|||
namespace Input {
|
||||
|
||||
class KeyboardInputManager : public Qt3DCore::QResourceManager<
|
||||
KeyboardInput,
|
||||
KeyboardHandler,
|
||||
Qt3DCore::QNodeId,
|
||||
16,
|
||||
Qt3DCore::ArrayAllocatingPolicy>
|
||||
|
|
|
|||
|
|
@ -90,7 +90,7 @@ public:
|
|||
inline Qt3DCore::QNodeId currentFocusItem() const { return m_currentFocusItem; }
|
||||
inline Qt3DCore::QNodeId lastKeyboardInputRequester() const { return m_lastRequester; }
|
||||
inline QVector<Qt3DCore::QNodeId> keyboardInputs() const { return m_keyboardInputs; }
|
||||
inline QVector<HKeyboardInput> keyboardInputsHandles() const { return m_keyboardInputHandles; }
|
||||
inline QVector<HKeyboardHandler> keyboardInputsHandles() const { return m_keyboardInputHandles; }
|
||||
|
||||
protected:
|
||||
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &) Q_DECL_OVERRIDE;
|
||||
|
|
@ -100,7 +100,7 @@ private:
|
|||
|
||||
InputHandler *m_inputHandler;
|
||||
QVector<Qt3DCore::QNodeId> m_keyboardInputs;
|
||||
QVector<HKeyboardInput> m_keyboardInputHandles;
|
||||
QVector<HKeyboardHandler> m_keyboardInputHandles;
|
||||
Qt3DCore::QNodeId m_lastRequester;
|
||||
Qt3DCore::QNodeId m_currentFocusItem;
|
||||
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "keyboardinput_p.h"
|
||||
#include "qkeyboardinput.h"
|
||||
#include "keyboardhandler_p.h"
|
||||
#include "qkeyboardhandler.h"
|
||||
#include "qkeyboardcontroller.h"
|
||||
#include "inputhandler_p.h"
|
||||
#include "inputmanagers_p.h"
|
||||
|
|
@ -53,37 +53,37 @@ using namespace Qt3DCore;
|
|||
namespace Qt3DInput {
|
||||
namespace Input {
|
||||
|
||||
KeyboardInput::KeyboardInput()
|
||||
KeyboardHandler::KeyboardHandler()
|
||||
: QBackendNode(QBackendNode::ReadWrite)
|
||||
, m_inputHandler(Q_NULLPTR)
|
||||
, m_focus(false)
|
||||
{
|
||||
}
|
||||
|
||||
void KeyboardInput::updateFromPeer(Qt3DCore::QNode *peer)
|
||||
void KeyboardHandler::updateFromPeer(Qt3DCore::QNode *peer)
|
||||
{
|
||||
QKeyboardInput *input = static_cast<QKeyboardInput *>(peer);
|
||||
if (input->controller() != Q_NULLPTR)
|
||||
setController(input->controller()->id());
|
||||
QKeyboardHandler *input = static_cast<QKeyboardHandler *>(peer);
|
||||
if (input->sourceDevice() != Q_NULLPTR)
|
||||
setController(input->sourceDevice()->id());
|
||||
m_focus = false;
|
||||
m_enabled = input->isEnabled();
|
||||
if (input->focus())
|
||||
requestFocus();
|
||||
}
|
||||
|
||||
Qt3DCore::QNodeId KeyboardInput::keyboardController() const
|
||||
Qt3DCore::QNodeId KeyboardHandler::keyboardController() const
|
||||
{
|
||||
return m_keyboardController;
|
||||
}
|
||||
|
||||
void KeyboardInput::setInputHandler(InputHandler *handler)
|
||||
void KeyboardHandler::setInputHandler(InputHandler *handler)
|
||||
{
|
||||
m_inputHandler = handler;
|
||||
}
|
||||
|
||||
// Called by the KeyboadController when the focus for the KeyboardInput has changed
|
||||
// Called by the KeyboadController when the focus for the KeyboardHandler has changed
|
||||
// Sends a change notification so that the frontend can update itself
|
||||
void KeyboardInput::setFocus(bool focus)
|
||||
void KeyboardHandler::setFocus(bool focus)
|
||||
{
|
||||
if (focus != m_focus) {
|
||||
m_focus = focus;
|
||||
|
|
@ -95,7 +95,7 @@ void KeyboardInput::setFocus(bool focus)
|
|||
}
|
||||
}
|
||||
|
||||
void KeyboardInput::keyEvent(const QKeyEventPtr &event)
|
||||
void KeyboardHandler::keyEvent(const QKeyEventPtr &event)
|
||||
{
|
||||
QBackendScenePropertyChangePtr e(new QBackendScenePropertyChange(NodeUpdated, peerUuid()));
|
||||
e->setTargetNode(peerUuid());
|
||||
|
|
@ -104,7 +104,7 @@ void KeyboardInput::keyEvent(const QKeyEventPtr &event)
|
|||
notifyObservers(e);
|
||||
}
|
||||
|
||||
void KeyboardInput::sceneChangeEvent(const QSceneChangePtr &e)
|
||||
void KeyboardHandler::sceneChangeEvent(const QSceneChangePtr &e)
|
||||
{
|
||||
bool focusRequest = false;
|
||||
if (e->type() == NodeUpdated) {
|
||||
|
|
@ -125,14 +125,14 @@ void KeyboardInput::sceneChangeEvent(const QSceneChangePtr &e)
|
|||
requestFocus();
|
||||
}
|
||||
|
||||
void KeyboardInput::requestFocus()
|
||||
void KeyboardHandler::requestFocus()
|
||||
{
|
||||
KeyboardController *controller = m_inputHandler->keyboardControllerManager()->lookupResource(m_keyboardController);
|
||||
if (controller && m_enabled)
|
||||
controller->requestFocusForInput(peerUuid());
|
||||
}
|
||||
|
||||
void KeyboardInput::setController(QNodeId controller)
|
||||
void KeyboardHandler::setController(QNodeId controller)
|
||||
{
|
||||
if (!m_keyboardController.isNull()) {
|
||||
KeyboardController *controller = m_inputHandler->keyboardControllerManager()->lookupResource(m_keyboardController);
|
||||
|
|
@ -147,25 +147,25 @@ void KeyboardInput::setController(QNodeId controller)
|
|||
}
|
||||
}
|
||||
|
||||
KeyboardInputFunctor::KeyboardInputFunctor(InputHandler *handler)
|
||||
KeyboardHandlerFunctor::KeyboardHandlerFunctor(InputHandler *handler)
|
||||
: m_handler(handler)
|
||||
{
|
||||
}
|
||||
|
||||
QBackendNode *KeyboardInputFunctor::create(QNode *frontend) const
|
||||
QBackendNode *KeyboardHandlerFunctor::create(QNode *frontend) const
|
||||
{
|
||||
KeyboardInput *input = m_handler->keyboardInputManager()->getOrCreateResource(frontend->id());
|
||||
KeyboardHandler *input = m_handler->keyboardInputManager()->getOrCreateResource(frontend->id());
|
||||
input->setInputHandler(m_handler);
|
||||
input->setPeer(frontend);
|
||||
return input;
|
||||
}
|
||||
|
||||
QBackendNode *KeyboardInputFunctor::get(QNodeId id) const
|
||||
QBackendNode *KeyboardHandlerFunctor::get(QNodeId id) const
|
||||
{
|
||||
return m_handler->keyboardInputManager()->lookupResource(id);
|
||||
}
|
||||
|
||||
void KeyboardInputFunctor::destroy(QNodeId id) const
|
||||
void KeyboardHandlerFunctor::destroy(QNodeId id) const
|
||||
{
|
||||
m_handler->keyboardInputManager()->releaseResource(id);
|
||||
}
|
||||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DINPUT_INPUT_KEYBOARDINPUT_P_H
|
||||
#define QT3DINPUT_INPUT_KEYBOARDINPUT_P_H
|
||||
#ifndef QT3DINPUT_INPUT_KEYBOARDHANDLER_P_H
|
||||
#define QT3DINPUT_INPUT_KEYBOARDHANDLER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
|
|
@ -63,10 +63,10 @@ namespace Input {
|
|||
|
||||
class InputHandler;
|
||||
|
||||
class KeyboardInput : public Qt3DCore::QBackendNode
|
||||
class KeyboardHandler : public Qt3DCore::QBackendNode
|
||||
{
|
||||
public:
|
||||
KeyboardInput();
|
||||
KeyboardHandler();
|
||||
void updateFromPeer(Qt3DCore::QNode *peer) Q_DECL_OVERRIDE;
|
||||
Qt3DCore::QNodeId keyboardController() const;
|
||||
void setInputHandler(InputHandler *handler);
|
||||
|
|
@ -87,10 +87,10 @@ private:
|
|||
bool m_enabled;
|
||||
};
|
||||
|
||||
class KeyboardInputFunctor : public Qt3DCore::QBackendNodeMapper
|
||||
class KeyboardHandlerFunctor : public Qt3DCore::QBackendNodeMapper
|
||||
{
|
||||
public:
|
||||
explicit KeyboardInputFunctor(InputHandler *handler);
|
||||
explicit KeyboardHandlerFunctor(InputHandler *handler);
|
||||
|
||||
Qt3DCore::QBackendNode *create(Qt3DCore::QNode *frontend) const Q_DECL_OVERRIDE;
|
||||
Qt3DCore::QBackendNode *get(Qt3DCore::QNodeId id) const Q_DECL_OVERRIDE;
|
||||
|
|
@ -105,4 +105,4 @@ private:
|
|||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT3DINPUT_INPUT_KEYBOARDINPUT_P_H
|
||||
#endif // QT3DINPUT_INPUT_KEYBOARDHANDLER_P_H
|
||||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "keyeventdispatcherjob_p.h"
|
||||
#include "inputhandler_p.h"
|
||||
#include "keyboardinput_p.h"
|
||||
#include "keyboardhandler_p.h"
|
||||
#include "inputmanagers_p.h"
|
||||
|
||||
QT_BEGIN_NAMESPACE
|
||||
|
|
@ -50,7 +50,7 @@ namespace Input {
|
|||
KeyEventDispatcherJob::KeyEventDispatcherJob(Qt3DCore::QNodeId input, const QList<QT_PREPEND_NAMESPACE(QKeyEvent)> &events)
|
||||
: QAspectJob()
|
||||
, m_inputHandler(Q_NULLPTR)
|
||||
, m_keyboardInput(input)
|
||||
, m_keyboardHandler(input)
|
||||
, m_events(events)
|
||||
{
|
||||
}
|
||||
|
|
@ -62,7 +62,7 @@ void KeyEventDispatcherJob::setInputHandler(InputHandler *handler)
|
|||
|
||||
void KeyEventDispatcherJob::run()
|
||||
{
|
||||
KeyboardInput *input = m_inputHandler->keyboardInputManager()->lookupResource(m_keyboardInput);
|
||||
KeyboardHandler *input = m_inputHandler->keyboardInputManager()->lookupResource(m_keyboardHandler);
|
||||
if (input)
|
||||
Q_FOREACH (const QT_PREPEND_NAMESPACE(QKeyEvent) &e, m_events) {
|
||||
// Send events to frontend
|
||||
|
|
|
|||
|
|
@ -71,7 +71,7 @@ public:
|
|||
|
||||
private:
|
||||
InputHandler *m_inputHandler;
|
||||
const Qt3DCore::QNodeId m_keyboardInput;
|
||||
const Qt3DCore::QNodeId m_keyboardHandler;
|
||||
const QList<QT_PREPEND_NAMESPACE(QKeyEvent)> m_events;
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -2,8 +2,8 @@ HEADERS += \
|
|||
$$PWD/qinputaspect.h \
|
||||
$$PWD/qkeyboardcontroller.h \
|
||||
$$PWD/qkeyboardcontroller_p.h \
|
||||
$$PWD/qkeyboardinput.h \
|
||||
$$PWD/qkeyboardinput_p.h \
|
||||
$$PWD/qkeyboardhandler.h \
|
||||
$$PWD/qkeyboardhandler_p.h \
|
||||
$$PWD/qinputaspect_p.h \
|
||||
$$PWD/qkeyevent.h \
|
||||
$$PWD/qmousecontroller.h \
|
||||
|
|
@ -35,7 +35,7 @@ HEADERS += \
|
|||
SOURCES += \
|
||||
$$PWD/qinputaspect.cpp \
|
||||
$$PWD/qkeyboardcontroller.cpp \
|
||||
$$PWD/qkeyboardinput.cpp \
|
||||
$$PWD/qkeyboardhandler.cpp \
|
||||
$$PWD/qkeyevent.cpp \
|
||||
$$PWD/qmousehandler.cpp \
|
||||
$$PWD/qmousecontroller.cpp \
|
||||
|
|
|
|||
|
|
@ -41,11 +41,11 @@
|
|||
#include "qinputaspect_p.h"
|
||||
#include "inputhandler_p.h"
|
||||
#include "keyboardcontroller_p.h"
|
||||
#include "keyboardinput_p.h"
|
||||
#include "keyboardhandler_p.h"
|
||||
#include "mousecontroller_p.h"
|
||||
#include "mousehandler_p.h"
|
||||
#include <Qt3DInput/qkeyboardcontroller.h>
|
||||
#include <Qt3DInput/qkeyboardinput.h>
|
||||
#include <Qt3DInput/qkeyboardhandler.h>
|
||||
#include <Qt3DInput/qmousecontroller.h>
|
||||
#include <Qt3DInput/qmousehandler.h>
|
||||
#include <Qt3DInput/qinputdeviceintegration.h>
|
||||
|
|
@ -111,7 +111,7 @@ QInputAspect::QInputAspect(QObject *parent)
|
|||
: QAbstractAspect(*new QInputAspectPrivate, parent)
|
||||
{
|
||||
registerBackendType<QKeyboardController>(QBackendNodeMapperPtr(new Input::KeyboardControllerFunctor(this, d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QKeyboardInput>(QBackendNodeMapperPtr(new Input::KeyboardInputFunctor(d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QKeyboardHandler>(QBackendNodeMapperPtr(new Input::KeyboardHandlerFunctor(d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QMouseController>(QBackendNodeMapperPtr(new Input::MouseControllerFunctor(this, d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QMouseHandler>(QBackendNodeMapperPtr(new Input::MouseHandlerFunctor(d_func()->m_inputHandler.data())));
|
||||
registerBackendType<QAxis>(QBackendNodeMapperPtr(new Input::InputNodeFunctor<Input::Axis, Input::AxisManager>(d_func()->m_inputHandler->axisManager())));
|
||||
|
|
|
|||
|
|
@ -39,7 +39,7 @@
|
|||
|
||||
#include "qkeyboardcontroller.h"
|
||||
#include "qkeyboardcontroller_p.h"
|
||||
#include "qkeyboardinput.h"
|
||||
#include "qkeyboardhandler.h"
|
||||
#include <Qt3DCore/private/qscene_p.h>
|
||||
#include <Qt3DCore/qbackendscenepropertychange.h>
|
||||
|
||||
|
|
@ -226,10 +226,10 @@ QKeyboardController::~QKeyboardController()
|
|||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty KeyboardInput Qt3D.Input::KeyboardController::activeInput
|
||||
\qmlproperty KeyboardHandler Qt3D.Input::KeyboardController::activeInput
|
||||
\readonly
|
||||
*/
|
||||
QKeyboardInput *QKeyboardController::activeInput() const
|
||||
QKeyboardHandler *QKeyboardController::activeInput() const
|
||||
{
|
||||
Q_D(const QKeyboardController);
|
||||
return d->m_activeInput;
|
||||
|
|
@ -281,11 +281,11 @@ void QKeyboardController::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &chan
|
|||
QBackendScenePropertyChangePtr e = qSharedPointerCast<QBackendScenePropertyChange>(change);
|
||||
if (e->type() == NodeUpdated && e->propertyName() == QByteArrayLiteral("activeInput")) {
|
||||
QNodeId activeInputId = e->value().value<QNodeId>();
|
||||
setActiveInput(qobject_cast<QKeyboardInput *>(d->scene()->lookupNode(activeInputId)));
|
||||
setActiveInput(qobject_cast<QKeyboardHandler *>(d->scene()->lookupNode(activeInputId)));
|
||||
}
|
||||
}
|
||||
|
||||
void QKeyboardController::setActiveInput(QKeyboardInput *activeInput)
|
||||
void QKeyboardController::setActiveInput(QKeyboardHandler *activeInput)
|
||||
{
|
||||
Q_D(QKeyboardController);
|
||||
if (d->m_activeInput != activeInput) {
|
||||
|
|
|
|||
|
|
@ -48,18 +48,18 @@ QT_BEGIN_NAMESPACE
|
|||
namespace Qt3DInput {
|
||||
|
||||
class QKeyboardControllerPrivate;
|
||||
class QKeyboardInput;
|
||||
class QKeyboardHandler;
|
||||
|
||||
class QT3DINPUTSHARED_EXPORT QKeyboardController : public Qt3DInput::QAbstractPhysicalDevice
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Qt3DInput::QKeyboardInput *activeInput READ activeInput NOTIFY activeInputChanged)
|
||||
Q_PROPERTY(Qt3DInput::QKeyboardHandler *activeInput READ activeInput NOTIFY activeInputChanged)
|
||||
|
||||
public:
|
||||
explicit QKeyboardController(QNode *parent = 0);
|
||||
~QKeyboardController();
|
||||
|
||||
QKeyboardInput *activeInput() const;
|
||||
QKeyboardHandler *activeInput() const;
|
||||
|
||||
int axisCount() const Q_DECL_FINAL;
|
||||
int buttonCount() const Q_DECL_FINAL;
|
||||
|
|
@ -73,12 +73,12 @@ protected:
|
|||
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
|
||||
|
||||
Q_SIGNALS:
|
||||
void activeInputChanged(QKeyboardInput *activeInput);
|
||||
void activeInputChanged(QKeyboardHandler *activeInput);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QKeyboardController)
|
||||
QT3D_CLONEABLE(QKeyboardController)
|
||||
void setActiveInput(QKeyboardInput *activeInput);
|
||||
void setActiveInput(QKeyboardHandler *activeInput);
|
||||
};
|
||||
|
||||
} // namespace Qt3DInput
|
||||
|
|
|
|||
|
|
@ -60,7 +60,7 @@ QT_BEGIN_NAMESPACE
|
|||
namespace Qt3DInput {
|
||||
|
||||
class QKeyboardController;
|
||||
class QKeyboardInput;
|
||||
class QKeyboardHandler;
|
||||
|
||||
class QKeyboardControllerPrivate : public Qt3DInput::QAbstractPhysicalDevicePrivate
|
||||
{
|
||||
|
|
@ -68,7 +68,7 @@ public:
|
|||
QKeyboardControllerPrivate();
|
||||
|
||||
Q_DECLARE_PUBLIC(QKeyboardController)
|
||||
QKeyboardInput *m_activeInput;
|
||||
QKeyboardHandler *m_activeInput;
|
||||
QHash<QString, int> m_keyMap;
|
||||
QStringList m_keyNames;
|
||||
};
|
||||
|
|
|
|||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#include "qkeyboardinput.h"
|
||||
#include "qkeyboardinput_p.h"
|
||||
#include "qkeyboardhandler.h"
|
||||
#include "qkeyboardhandler_p.h"
|
||||
#include "qkeyboardcontroller.h"
|
||||
#include <Qt3DCore/qbackendscenepropertychange.h>
|
||||
|
||||
|
|
@ -48,57 +48,7 @@ using namespace Qt3DCore;
|
|||
|
||||
namespace Qt3DInput {
|
||||
|
||||
QKeyboardInputPrivate::QKeyboardInputPrivate()
|
||||
: QComponentPrivate()
|
||||
, m_controller(Q_NULLPTR)
|
||||
, m_focus(false)
|
||||
{
|
||||
m_shareable = false;
|
||||
}
|
||||
|
||||
/*!
|
||||
\class Qt3DInput::QKeyboardInput
|
||||
\inmodule Qt3DInput
|
||||
\since 5.5
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmltype KeyboardInput
|
||||
\inqmlmodule Qt3D.Input
|
||||
\instantiates Qt3DInput::QKeyboardInput
|
||||
\inherits Component3D
|
||||
\since 5.5
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a new QKeyboardInput instance with parent \a parent.
|
||||
*/
|
||||
QKeyboardInput::QKeyboardInput(QNode *parent)
|
||||
: QComponent(*new QKeyboardInputPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QKeyboardInput::~QKeyboardInput()
|
||||
{
|
||||
QNode::cleanup();
|
||||
}
|
||||
|
||||
/*! \internal */
|
||||
QKeyboardInput::QKeyboardInput(QKeyboardInputPrivate &dd, QNode *parent)
|
||||
: QComponent(dd, parent)
|
||||
{
|
||||
}
|
||||
|
||||
void QKeyboardInput::copy(const QNode *ref)
|
||||
{
|
||||
QComponent::copy(ref);
|
||||
const QKeyboardInput *input = static_cast<const QKeyboardInput *>(ref);
|
||||
|
||||
// TO DO: We may want to store the controller id and only send a clone when we are the parent
|
||||
// of the controller
|
||||
if (input->d_func()->m_controller != Q_NULLPTR && input->d_func()->m_controller->parent() == ref)
|
||||
setController(qobject_cast<QKeyboardController *>(QNode::clone(input->d_func()->m_controller)));
|
||||
}
|
||||
namespace {
|
||||
|
||||
// SigMap and the sigMap table are taken from QQ2 QQuickKeysAttached
|
||||
struct SigMap {
|
||||
|
|
@ -153,25 +103,21 @@ const QByteArray keyToSignal(int key)
|
|||
return keySignal;
|
||||
}
|
||||
|
||||
void QKeyboardInput::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
|
||||
} // anonymous
|
||||
|
||||
QKeyboardHandlerPrivate::QKeyboardHandlerPrivate()
|
||||
: QComponentPrivate()
|
||||
, m_sourceDevice(Q_NULLPTR)
|
||||
, m_focus(false)
|
||||
{
|
||||
QBackendScenePropertyChangePtr e = qSharedPointerCast<QBackendScenePropertyChange>(change);
|
||||
if (e->type() == NodeUpdated) {
|
||||
if (e->propertyName() == QByteArrayLiteral("focus")) {
|
||||
bool block = blockNotifications(true);
|
||||
setFocus(e->value().toBool());
|
||||
blockNotifications(block);
|
||||
} else if (e->propertyName() == QByteArrayLiteral("event")) {
|
||||
QKeyEventPtr ev = e->value().value<QKeyEventPtr>();
|
||||
keyEvent(ev.data());
|
||||
}
|
||||
}
|
||||
m_shareable = false;
|
||||
}
|
||||
|
||||
void QKeyboardInput::keyEvent(QKeyEvent *event)
|
||||
void QKeyboardHandlerPrivate::keyEvent(QKeyEvent *event)
|
||||
{
|
||||
Q_Q(QKeyboardHandler);
|
||||
if (event->type() == QEvent::KeyPress) {
|
||||
emit pressed(event);
|
||||
emit q->pressed(event);
|
||||
|
||||
QByteArray keySignal = keyToSignal(event->key());
|
||||
if (!keySignal.isEmpty()) {
|
||||
|
|
@ -180,54 +126,109 @@ void QKeyboardInput::keyEvent(QKeyEvent *event)
|
|||
// could be an improvement
|
||||
// That's what QQ2 does but since it accesses QML private classes to do so, that may not be
|
||||
// applicable in our case
|
||||
int idx = QKeyboardInput::staticMetaObject.indexOfSignal(keySignal);
|
||||
metaObject()->method(idx).invoke(this, Qt::DirectConnection, Q_ARG(QKeyEvent *, event));
|
||||
int idx = QKeyboardHandler::staticMetaObject.indexOfSignal(keySignal);
|
||||
q->metaObject()->method(idx).invoke(q, Qt::DirectConnection, Q_ARG(QKeyEvent *, event));
|
||||
}
|
||||
} else if (event->type() == QEvent::KeyRelease) {
|
||||
emit released(event);
|
||||
emit q->released(event);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
/*!
|
||||
\class Qt3DInput::QKeyboardHandler
|
||||
\inmodule Qt3DInput
|
||||
\since 5.5
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmltype KeyboardHandler
|
||||
\inqmlmodule Qt3D.Input
|
||||
\instantiates Qt3DInput::QKeyboardHandler
|
||||
\inherits Component3D
|
||||
\since 5.5
|
||||
*/
|
||||
|
||||
/*!
|
||||
Constructs a new QKeyboardHandler instance with parent \a parent.
|
||||
*/
|
||||
QKeyboardHandler::QKeyboardHandler(QNode *parent)
|
||||
: QComponent(*new QKeyboardHandlerPrivate, parent)
|
||||
{
|
||||
}
|
||||
|
||||
QKeyboardHandler::~QKeyboardHandler()
|
||||
{
|
||||
QNode::cleanup();
|
||||
}
|
||||
|
||||
void QKeyboardHandler::copy(const QNode *ref)
|
||||
{
|
||||
QComponent::copy(ref);
|
||||
const QKeyboardHandler *input = static_cast<const QKeyboardHandler *>(ref);
|
||||
|
||||
// TO DO: We may want to store the controller id and only send a clone when we are the parent
|
||||
// of the controller
|
||||
if (input->d_func()->m_sourceDevice != Q_NULLPTR && input->d_func()->m_sourceDevice->parent() == ref)
|
||||
setSourceDevice(qobject_cast<QKeyboardController *>(QNode::clone(input->d_func()->m_sourceDevice)));
|
||||
}
|
||||
|
||||
void QKeyboardHandler::sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change)
|
||||
{
|
||||
Q_D(QKeyboardHandler);
|
||||
QBackendScenePropertyChangePtr e = qSharedPointerCast<QBackendScenePropertyChange>(change);
|
||||
if (e->type() == NodeUpdated) {
|
||||
if (e->propertyName() == QByteArrayLiteral("focus")) {
|
||||
bool block = blockNotifications(true);
|
||||
setFocus(e->value().toBool());
|
||||
blockNotifications(block);
|
||||
} else if (e->propertyName() == QByteArrayLiteral("event")) {
|
||||
QKeyEventPtr ev = e->value().value<QKeyEventPtr>();
|
||||
d->keyEvent(ev.data());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty KeyboardController Qt3D.Input::KeyboardInput::controller
|
||||
\qmlproperty KeyboardController Qt3D.Input::KeyboardHandler::controller
|
||||
*/
|
||||
|
||||
/*!
|
||||
Sets the keyboard controller to \a controller. Without a valid controller,
|
||||
the QKeyboardInput won't receive any event.
|
||||
the QKeyboardHandler won't receive any event.
|
||||
*/
|
||||
void QKeyboardInput::setController(QKeyboardController *controller)
|
||||
void QKeyboardHandler::setSourceDevice(QKeyboardController *sourceDevice)
|
||||
{
|
||||
Q_D(QKeyboardInput);
|
||||
if (d->m_controller != controller) {
|
||||
Q_D(QKeyboardHandler);
|
||||
if (d->m_sourceDevice != sourceDevice) {
|
||||
|
||||
if (controller && !controller->parent())
|
||||
controller->setParent(this);
|
||||
if (sourceDevice && !sourceDevice->parent())
|
||||
sourceDevice->setParent(this);
|
||||
|
||||
d->m_controller = controller;
|
||||
emit controllerChanged(controller);
|
||||
d->m_sourceDevice = sourceDevice;
|
||||
emit sourceDeviceChanged(sourceDevice);
|
||||
}
|
||||
}
|
||||
|
||||
/*!
|
||||
Returns the current keyboard controller.
|
||||
*/
|
||||
QKeyboardController *QKeyboardInput::controller() const
|
||||
QKeyboardController *QKeyboardHandler::sourceDevice() const
|
||||
{
|
||||
Q_D(const QKeyboardInput);
|
||||
return d->m_controller;
|
||||
Q_D(const QKeyboardHandler);
|
||||
return d->m_sourceDevice;
|
||||
}
|
||||
|
||||
/*!
|
||||
\qmlproperty bool Qt3D.Input::KeyboardInput::focus
|
||||
\qmlproperty bool Qt3D.Input::KeyboardHandler::focus
|
||||
*/
|
||||
|
||||
/*!
|
||||
Returns the current focus.
|
||||
*/
|
||||
bool QKeyboardInput::focus() const
|
||||
bool QKeyboardHandler::focus() const
|
||||
{
|
||||
Q_D(const QKeyboardInput);
|
||||
Q_D(const QKeyboardHandler);
|
||||
return d->m_focus;
|
||||
}
|
||||
|
||||
|
|
@ -235,9 +236,9 @@ bool QKeyboardInput::focus() const
|
|||
Sets the focus to \a focus. If focus is not currently set to \c true,
|
||||
this component will receive keyboard focus.
|
||||
*/
|
||||
void QKeyboardInput::setFocus(bool focus)
|
||||
void QKeyboardHandler::setFocus(bool focus)
|
||||
{
|
||||
Q_D(QKeyboardInput);
|
||||
Q_D(QKeyboardHandler);
|
||||
if (d->m_focus != focus) {
|
||||
d->m_focus = focus;
|
||||
emit focusChanged(focus);
|
||||
|
|
@ -245,167 +246,167 @@ void QKeyboardInput::setFocus(bool focus)
|
|||
}
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit0Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit0Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit1Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit1Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit2Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit2Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit3Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit3Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit4Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit4Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit5Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit5Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit6Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit6Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit7Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit7Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit8Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit8Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::digit9Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::digit9Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::leftPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::leftPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::rightPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::rightPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::upPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::upPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::downPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::downPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::tabPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::tabPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::backtabPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::backtabPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::asteriskPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::asteriskPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::numberSignPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::numberSignPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::backtabPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::backtabPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::escapePressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::escapePressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::returnPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::returnPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::enterPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::enterPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::deletePressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::deletePressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::spacePressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::spacePressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::backPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::backPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::cancelPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::cancelPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::selectPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::selectPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::yesPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::yesPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::noPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::noPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::context1Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::context1Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::context2Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::context2Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::context3Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::context3Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::context4Pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::context4Pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::callPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::callPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::hangupPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::hangupPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::flipPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::flipPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::menuPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::menuPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::volumeUpPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::volumeUpPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::volumeDownPressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::volumeDownPressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::pressed(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::pressed(KeyEvent event)
|
||||
*/
|
||||
|
||||
/*!
|
||||
\qmlsignal Qt3D.Input::KeyboardInput::released(KeyEvent event)
|
||||
\qmlsignal Qt3D.Input::KeyboardHandler::released(KeyEvent event)
|
||||
*/
|
||||
|
||||
} // namespace Qt3DInput
|
||||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DINPUT_INPUT_QKEYBOARDINPUT_H
|
||||
#define QT3DINPUT_INPUT_QKEYBOARDINPUT_H
|
||||
#ifndef QT3DINPUT_INPUT_QKEYBOARDHANDLER_H
|
||||
#define QT3DINPUT_INPUT_QKEYBOARDHANDLER_H
|
||||
|
||||
#include <Qt3DInput/qt3dinput_global.h>
|
||||
#include <Qt3DInput/qkeyevent.h>
|
||||
|
|
@ -49,26 +49,26 @@ QT_BEGIN_NAMESPACE
|
|||
namespace Qt3DInput {
|
||||
|
||||
class QKeyboardController;
|
||||
class QKeyboardInputPrivate;
|
||||
class QKeyboardHandlerPrivate;
|
||||
|
||||
class QT3DINPUTSHARED_EXPORT QKeyboardInput : public Qt3DCore::QComponent
|
||||
class QT3DINPUTSHARED_EXPORT QKeyboardHandler : public Qt3DCore::QComponent
|
||||
{
|
||||
Q_OBJECT
|
||||
Q_PROPERTY(Qt3DInput::QKeyboardController *controller READ controller WRITE setController NOTIFY controllerChanged)
|
||||
Q_PROPERTY(Qt3DInput::QKeyboardController *sourceDevice READ sourceDevice WRITE setSourceDevice NOTIFY sourceDeviceChanged)
|
||||
Q_PROPERTY(bool focus READ focus WRITE setFocus NOTIFY focusChanged)
|
||||
public:
|
||||
explicit QKeyboardInput(QNode *parent = 0);
|
||||
~QKeyboardInput();
|
||||
explicit QKeyboardHandler(QNode *parent = 0);
|
||||
~QKeyboardHandler();
|
||||
|
||||
QKeyboardController *controller() const;
|
||||
QKeyboardController *sourceDevice() const;
|
||||
bool focus() const;
|
||||
|
||||
public Q_SLOTS:
|
||||
void setController(QKeyboardController *controller);
|
||||
void setSourceDevice(QKeyboardController *sourceDevice);
|
||||
void setFocus(bool focus);
|
||||
|
||||
Q_SIGNALS:
|
||||
void controllerChanged(QKeyboardController *controller);
|
||||
void sourceDeviceChanged(QKeyboardController *sourceDevice);
|
||||
void focusChanged(bool focus);
|
||||
|
||||
void digit0Pressed(Qt3DInput::QKeyEvent *event);
|
||||
|
|
@ -116,18 +116,16 @@ Q_SIGNALS:
|
|||
void released(Qt3DInput::QKeyEvent *event);
|
||||
|
||||
protected:
|
||||
QKeyboardInput(QKeyboardInputPrivate &dd, QNode *parent = 0);
|
||||
void copy(const Qt3DCore::QNode *ref) Q_DECL_OVERRIDE;
|
||||
void sceneChangeEvent(const Qt3DCore::QSceneChangePtr &change) Q_DECL_OVERRIDE;
|
||||
void keyEvent(QKeyEvent *event);
|
||||
|
||||
private:
|
||||
Q_DECLARE_PRIVATE(QKeyboardInput)
|
||||
QT3D_CLONEABLE(QKeyboardInput)
|
||||
Q_DECLARE_PRIVATE(QKeyboardHandler)
|
||||
QT3D_CLONEABLE(QKeyboardHandler)
|
||||
};
|
||||
|
||||
} // namespace Qt3DInput
|
||||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT3DINPUT_INPUT_QKEYBOARDINPUT_H
|
||||
#endif // QT3DINPUT_INPUT_QKEYBOARDHANDLER_H
|
||||
|
|
@ -37,8 +37,8 @@
|
|||
**
|
||||
****************************************************************************/
|
||||
|
||||
#ifndef QT3DINPUT_INPUT_QKEYBOARDINPUT_P_H
|
||||
#define QT3DINPUT_INPUT_QKEYBOARDINPUT_P_H
|
||||
#ifndef QT3DINPUT_INPUT_QKEYBOARDHANDLER_P_H
|
||||
#define QT3DINPUT_INPUT_QKEYBOARDHANDLER_P_H
|
||||
|
||||
//
|
||||
// W A R N I N G
|
||||
|
|
@ -57,16 +57,18 @@ QT_BEGIN_NAMESPACE
|
|||
|
||||
namespace Qt3DInput {
|
||||
|
||||
class QKeyboardInput;
|
||||
class QKeyboardHandler;
|
||||
class QKeyboardController;
|
||||
|
||||
class QKeyboardInputPrivate : public Qt3DCore::QComponentPrivate
|
||||
class QKeyboardHandlerPrivate : public Qt3DCore::QComponentPrivate
|
||||
{
|
||||
public:
|
||||
QKeyboardInputPrivate();
|
||||
QKeyboardHandlerPrivate();
|
||||
|
||||
Q_DECLARE_PUBLIC(QKeyboardInput)
|
||||
QKeyboardController *m_controller;
|
||||
void keyEvent(QKeyEvent *event);
|
||||
|
||||
Q_DECLARE_PUBLIC(QKeyboardHandler)
|
||||
QKeyboardController *m_sourceDevice;
|
||||
bool m_focus;
|
||||
};
|
||||
|
||||
|
|
@ -74,4 +76,4 @@ public:
|
|||
|
||||
QT_END_NAMESPACE
|
||||
|
||||
#endif // QT3DINPUT_INPUT_QKEYBOARDINPUT_P_H
|
||||
#endif // QT3DINPUT_INPUT_QKEYBOARDHANDLER_P_H
|
||||
|
|
@ -58,7 +58,7 @@ namespace Qt3DInput {
|
|||
\since 5.5
|
||||
|
||||
The KeyEvent QML type cannot be directly created. Objects of this type
|
||||
are used as signal parameters in KeyboardInput.
|
||||
are used as signal parameters in KeyboardHandler.
|
||||
*/
|
||||
|
||||
QKeyEvent::QKeyEvent(QEvent::Type type, int key, Qt::KeyboardModifiers modifiers, const QString &text, bool autorep, ushort count)
|
||||
|
|
|
|||
|
|
@ -40,7 +40,7 @@
|
|||
#include <QtQml>
|
||||
#include <Qt3DInput/qgenericinputdevice.h>
|
||||
#include <Qt3DInput/qkeyboardcontroller.h>
|
||||
#include <Qt3DInput/qkeyboardinput.h>
|
||||
#include <Qt3DInput/qkeyboardhandler.h>
|
||||
#include <Qt3DInput/qkeyevent.h>
|
||||
#include <Qt3DInput/qmousecontroller.h>
|
||||
#include <Qt3DInput/qmousehandler.h>
|
||||
|
|
@ -74,7 +74,7 @@ void Qt3DQuick3DInputPlugin::registerTypes(const char *uri)
|
|||
{
|
||||
qmlRegisterUncreatableType<Qt3DInput::QKeyEvent>(uri, 2, 0, "KeyEvent", QStringLiteral("Events cannot be created"));
|
||||
qmlRegisterType<Qt3DInput::QKeyboardController>(uri, 2, 0, "KeyboardController");
|
||||
qmlRegisterType<Qt3DInput::QKeyboardInput>(uri, 2, 0, "KeyboardInput");
|
||||
qmlRegisterType<Qt3DInput::QKeyboardHandler>(uri, 2, 0, "KeyboardHandler");
|
||||
qmlRegisterType<Qt3DInput::QInputSettings>(uri, 2, 0, "InputSettings");
|
||||
|
||||
qmlRegisterUncreatableType<Qt3DInput::QMouseEvent>(uri, 2, 0, "MouseEvent", QStringLiteral("Events cannot be created"));
|
||||
|
|
|
|||
Loading…
Reference in New Issue