mirror of
https://github.com/Armored-Dragon/overte.git
synced 2025-03-11 16:13:16 +01:00
Merge remote-tracking branch 'gcalero/android_virtual_touchpad' into android_new
This commit is contained in:
commit
d3c4b0ef45
19 changed files with 621 additions and 4 deletions
15
interface/resources/controllers/touchscreenvirtualpad.json
Normal file
15
interface/resources/controllers/touchscreenvirtualpad.json
Normal file
|
@ -0,0 +1,15 @@
|
||||||
|
{
|
||||||
|
"name": "TouchscreenVirtualPad to Actions",
|
||||||
|
"channels": [
|
||||||
|
{ "from": "TouchscreenVirtualPad.LY", "when": "Application.CameraFirstPerson", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateZ" },
|
||||||
|
{ "from": "TouchscreenVirtualPad.LX", "when": "Application.CameraFirstPerson", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.TranslateX" },
|
||||||
|
|
||||||
|
|
||||||
|
{ "from": "TouchscreenVirtualPad.RX", "when": "Application.CameraFirstPerson", "filters": { "type": "deadZone", "min": 0.05 }, "to": "Actions.Yaw" },
|
||||||
|
|
||||||
|
{ "from": "TouchscreenVirtualPad.RY",
|
||||||
|
"when": "Application.CameraFirstPerson",
|
||||||
|
"to": "Actions.Pitch"
|
||||||
|
}
|
||||||
|
]
|
||||||
|
}
|
BIN
interface/resources/images/analog_stick.png
Normal file
BIN
interface/resources/images/analog_stick.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2.6 KiB |
BIN
interface/resources/images/analog_stick_base.png
Normal file
BIN
interface/resources/images/analog_stick_base.png
Normal file
Binary file not shown.
After Width: | Height: | Size: 2 KiB |
|
@ -69,6 +69,7 @@
|
||||||
#include <AudioInjectorManager.h>
|
#include <AudioInjectorManager.h>
|
||||||
#include <AvatarBookmarks.h>
|
#include <AvatarBookmarks.h>
|
||||||
#include <CursorManager.h>
|
#include <CursorManager.h>
|
||||||
|
#include <VirtualPadManager.h>
|
||||||
#include <DebugDraw.h>
|
#include <DebugDraw.h>
|
||||||
#include <DeferredLightingEffect.h>
|
#include <DeferredLightingEffect.h>
|
||||||
#include <EntityScriptClient.h>
|
#include <EntityScriptClient.h>
|
||||||
|
@ -669,6 +670,7 @@ bool setupEssentials(int& argc, char** argv, bool runningMarkerExisted) {
|
||||||
DependencyManager::set<PointerScriptingInterface>();
|
DependencyManager::set<PointerScriptingInterface>();
|
||||||
DependencyManager::set<PickScriptingInterface>();
|
DependencyManager::set<PickScriptingInterface>();
|
||||||
DependencyManager::set<Cursor::Manager>();
|
DependencyManager::set<Cursor::Manager>();
|
||||||
|
DependencyManager::set<VirtualPad::Manager>();
|
||||||
DependencyManager::set<AccountManager>(std::bind(&Application::getUserAgent, qApp));
|
DependencyManager::set<AccountManager>(std::bind(&Application::getUserAgent, qApp));
|
||||||
DependencyManager::set<StatTracker>();
|
DependencyManager::set<StatTracker>();
|
||||||
DependencyManager::set<ScriptEngines>(ScriptEngine::CLIENT_SCRIPT);
|
DependencyManager::set<ScriptEngines>(ScriptEngine::CLIENT_SCRIPT);
|
||||||
|
@ -1422,12 +1424,15 @@ Application::Application(int& argc, char** argv, QElapsedTimer& startupTimer, bo
|
||||||
return DependencyManager::get<OffscreenUi>()->navigationFocused() ? 1 : 0;
|
return DependencyManager::get<OffscreenUi>()->navigationFocused() ? 1 : 0;
|
||||||
});
|
});
|
||||||
|
|
||||||
// Setup the _keyboardMouseDevice, _touchscreenDevice and the user input mapper with the default bindings
|
// Setup the _keyboardMouseDevice, _touchscreenDevice, _touchscreenVirtualPadDevice and the user input mapper with the default bindings
|
||||||
userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());
|
userInputMapper->registerDevice(_keyboardMouseDevice->getInputDevice());
|
||||||
// if the _touchscreenDevice is not supported it will not be registered
|
// if the _touchscreenDevice is not supported it will not be registered
|
||||||
if (_touchscreenDevice) {
|
if (_touchscreenDevice) {
|
||||||
userInputMapper->registerDevice(_touchscreenDevice->getInputDevice());
|
userInputMapper->registerDevice(_touchscreenDevice->getInputDevice());
|
||||||
}
|
}
|
||||||
|
if (_touchscreenVirtualPadDevice) {
|
||||||
|
userInputMapper->registerDevice(_touchscreenVirtualPadDevice->getInputDevice());
|
||||||
|
}
|
||||||
|
|
||||||
// force the model the look at the correct directory (weird order of operations issue)
|
// force the model the look at the correct directory (weird order of operations issue)
|
||||||
scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation());
|
scriptEngines->setScriptsLocation(scriptEngines->getScriptsLocation());
|
||||||
|
@ -2491,6 +2496,9 @@ void Application::initializeUi() {
|
||||||
if (TouchscreenDevice::NAME == inputPlugin->getName()) {
|
if (TouchscreenDevice::NAME == inputPlugin->getName()) {
|
||||||
_touchscreenDevice = std::dynamic_pointer_cast<TouchscreenDevice>(inputPlugin);
|
_touchscreenDevice = std::dynamic_pointer_cast<TouchscreenDevice>(inputPlugin);
|
||||||
}
|
}
|
||||||
|
if (TouchscreenVirtualPadDevice::NAME == inputPlugin->getName()) {
|
||||||
|
_touchscreenVirtualPadDevice = std::dynamic_pointer_cast<TouchscreenVirtualPadDevice>(inputPlugin);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
_window->setMenuBar(new Menu());
|
_window->setMenuBar(new Menu());
|
||||||
|
|
||||||
|
@ -3579,6 +3587,9 @@ void Application::touchUpdateEvent(QTouchEvent* event) {
|
||||||
if (_touchscreenDevice && _touchscreenDevice->isActive()) {
|
if (_touchscreenDevice && _touchscreenDevice->isActive()) {
|
||||||
_touchscreenDevice->touchUpdateEvent(event);
|
_touchscreenDevice->touchUpdateEvent(event);
|
||||||
}
|
}
|
||||||
|
if (_touchscreenVirtualPadDevice && _touchscreenVirtualPadDevice->isActive()) {
|
||||||
|
_touchscreenVirtualPadDevice->touchUpdateEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::touchBeginEvent(QTouchEvent* event) {
|
void Application::touchBeginEvent(QTouchEvent* event) {
|
||||||
|
@ -3600,6 +3611,9 @@ void Application::touchBeginEvent(QTouchEvent* event) {
|
||||||
if (_touchscreenDevice && _touchscreenDevice->isActive()) {
|
if (_touchscreenDevice && _touchscreenDevice->isActive()) {
|
||||||
_touchscreenDevice->touchBeginEvent(event);
|
_touchscreenDevice->touchBeginEvent(event);
|
||||||
}
|
}
|
||||||
|
if (_touchscreenVirtualPadDevice && _touchscreenVirtualPadDevice->isActive()) {
|
||||||
|
_touchscreenVirtualPadDevice->touchBeginEvent(event);
|
||||||
|
}
|
||||||
|
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3620,7 +3634,9 @@ void Application::touchEndEvent(QTouchEvent* event) {
|
||||||
if (_touchscreenDevice && _touchscreenDevice->isActive()) {
|
if (_touchscreenDevice && _touchscreenDevice->isActive()) {
|
||||||
_touchscreenDevice->touchEndEvent(event);
|
_touchscreenDevice->touchEndEvent(event);
|
||||||
}
|
}
|
||||||
|
if (_touchscreenVirtualPadDevice && _touchscreenVirtualPadDevice->isActive()) {
|
||||||
|
_touchscreenVirtualPadDevice->touchEndEvent(event);
|
||||||
|
}
|
||||||
// put any application specific touch behavior below here..
|
// put any application specific touch behavior below here..
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -3628,6 +3644,9 @@ void Application::touchGestureEvent(QGestureEvent* event) {
|
||||||
if (_touchscreenDevice && _touchscreenDevice->isActive()) {
|
if (_touchscreenDevice && _touchscreenDevice->isActive()) {
|
||||||
_touchscreenDevice->touchGestureEvent(event);
|
_touchscreenDevice->touchGestureEvent(event);
|
||||||
}
|
}
|
||||||
|
if (_touchscreenVirtualPadDevice && _touchscreenVirtualPadDevice->isActive()) {
|
||||||
|
_touchscreenVirtualPadDevice->touchGestureEvent(event);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
void Application::wheelEvent(QWheelEvent* event) const {
|
void Application::wheelEvent(QWheelEvent* event) const {
|
||||||
|
|
|
@ -33,6 +33,7 @@
|
||||||
#include <FileScriptingInterface.h>
|
#include <FileScriptingInterface.h>
|
||||||
#include <input-plugins/KeyboardMouseDevice.h>
|
#include <input-plugins/KeyboardMouseDevice.h>
|
||||||
#include <input-plugins/TouchscreenDevice.h>
|
#include <input-plugins/TouchscreenDevice.h>
|
||||||
|
#include <input-plugins/TouchscreenVirtualPadDevice.h>
|
||||||
#include <OctreeQuery.h>
|
#include <OctreeQuery.h>
|
||||||
#include <PhysicalEntitySimulation.h>
|
#include <PhysicalEntitySimulation.h>
|
||||||
#include <PhysicsEngine.h>
|
#include <PhysicsEngine.h>
|
||||||
|
@ -545,6 +546,7 @@ private:
|
||||||
std::shared_ptr<controller::StateController> _applicationStateDevice; // Default ApplicationDevice reflecting the state of different properties of the session
|
std::shared_ptr<controller::StateController> _applicationStateDevice; // Default ApplicationDevice reflecting the state of different properties of the session
|
||||||
std::shared_ptr<KeyboardMouseDevice> _keyboardMouseDevice; // Default input device, the good old keyboard mouse and maybe touchpad
|
std::shared_ptr<KeyboardMouseDevice> _keyboardMouseDevice; // Default input device, the good old keyboard mouse and maybe touchpad
|
||||||
std::shared_ptr<TouchscreenDevice> _touchscreenDevice; // the good old touchscreen
|
std::shared_ptr<TouchscreenDevice> _touchscreenDevice; // the good old touchscreen
|
||||||
|
std::shared_ptr<TouchscreenVirtualPadDevice> _touchscreenVirtualPadDevice;
|
||||||
SimpleMovingAverage _avatarSimsPerSecond {10};
|
SimpleMovingAverage _avatarSimsPerSecond {10};
|
||||||
int _avatarSimsPerSecondReport {0};
|
int _avatarSimsPerSecondReport {0};
|
||||||
quint64 _lastAvatarSimsPerSecondUpdate {0};
|
quint64 _lastAvatarSimsPerSecondUpdate {0};
|
||||||
|
|
|
@ -16,6 +16,7 @@
|
||||||
#include <plugins/PluginManager.h>
|
#include <plugins/PluginManager.h>
|
||||||
|
|
||||||
#include "Application.h"
|
#include "Application.h"
|
||||||
|
#include "VirtualPadManager.h"
|
||||||
|
|
||||||
bool ControllerScriptingInterface::isKeyCaptured(QKeyEvent* event) const {
|
bool ControllerScriptingInterface::isKeyCaptured(QKeyEvent* event) const {
|
||||||
return isKeyCaptured(KeyEvent(*event));
|
return isKeyCaptured(KeyEvent(*event));
|
||||||
|
@ -83,6 +84,11 @@ QVariant ControllerScriptingInterface::getRecommendedHUDRect() const {
|
||||||
return qRectToVariant(rect);
|
return qRectToVariant(rect);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void ControllerScriptingInterface::setVPadEnabled(const bool enable) {
|
||||||
|
auto& virtualPadManager = VirtualPad::Manager::instance();
|
||||||
|
virtualPadManager.enable(enable);
|
||||||
|
}
|
||||||
|
|
||||||
void ControllerScriptingInterface::emitKeyPressEvent(QKeyEvent* event) { emit keyPressEvent(KeyEvent(*event)); }
|
void ControllerScriptingInterface::emitKeyPressEvent(QKeyEvent* event) { emit keyPressEvent(KeyEvent(*event)); }
|
||||||
void ControllerScriptingInterface::emitKeyReleaseEvent(QKeyEvent* event) { emit keyReleaseEvent(KeyEvent(*event)); }
|
void ControllerScriptingInterface::emitKeyReleaseEvent(QKeyEvent* event) { emit keyReleaseEvent(KeyEvent(*event)); }
|
||||||
|
|
||||||
|
|
|
@ -65,6 +65,8 @@ public slots:
|
||||||
virtual glm::vec2 getViewportDimensions() const;
|
virtual glm::vec2 getViewportDimensions() const;
|
||||||
virtual QVariant getRecommendedHUDRect() const;
|
virtual QVariant getRecommendedHUDRect() const;
|
||||||
|
|
||||||
|
virtual void setVPadEnabled(bool enable);
|
||||||
|
|
||||||
signals:
|
signals:
|
||||||
void keyPressEvent(const KeyEvent& event);
|
void keyPressEvent(const KeyEvent& event);
|
||||||
void keyReleaseEvent(const KeyEvent& event);
|
void keyReleaseEvent(const KeyEvent& event);
|
||||||
|
|
|
@ -6,6 +6,8 @@
|
||||||
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
// See the accompanying file LICENSE or http://www.apache.org/licenses/LICENSE-2.0.html
|
||||||
//
|
//
|
||||||
#include "Basic2DWindowOpenGLDisplayPlugin.h"
|
#include "Basic2DWindowOpenGLDisplayPlugin.h"
|
||||||
|
#include "CompositorHelper.h"
|
||||||
|
#include "VirtualPadManager.h"
|
||||||
|
|
||||||
#include <mutex>
|
#include <mutex>
|
||||||
|
|
||||||
|
@ -14,11 +16,60 @@
|
||||||
#include <QtWidgets/QAction>
|
#include <QtWidgets/QAction>
|
||||||
|
|
||||||
#include <ui-plugins/PluginContainer.h>
|
#include <ui-plugins/PluginContainer.h>
|
||||||
|
#include <PathUtils.h>
|
||||||
|
|
||||||
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("Desktop");
|
const QString Basic2DWindowOpenGLDisplayPlugin::NAME("Desktop");
|
||||||
|
|
||||||
static const QString FULLSCREEN = "Fullscreen";
|
static const QString FULLSCREEN = "Fullscreen";
|
||||||
|
|
||||||
|
void Basic2DWindowOpenGLDisplayPlugin::customizeContext() {
|
||||||
|
auto iconPath = PathUtils::resourcesPath() + "images/analog_stick.png";
|
||||||
|
auto image = QImage(iconPath);
|
||||||
|
if (image.format() != QImage::Format_ARGB32) {
|
||||||
|
image = image.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
}
|
||||||
|
if ((image.width() > 0) && (image.height() > 0)) {
|
||||||
|
|
||||||
|
_virtualPadStickTexture = gpu::Texture::createStrict(
|
||||||
|
gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA),
|
||||||
|
image.width(), image.height(),
|
||||||
|
gpu::Texture::MAX_NUM_MIPS,
|
||||||
|
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR));
|
||||||
|
_virtualPadStickTexture->setSource("virtualPad stick");
|
||||||
|
auto usage = gpu::Texture::Usage::Builder().withColor().withAlpha();
|
||||||
|
_virtualPadStickTexture->setUsage(usage.build());
|
||||||
|
_virtualPadStickTexture->setStoredMipFormat(gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA));
|
||||||
|
_virtualPadStickTexture->assignStoredMip(0, image.byteCount(), image.constBits());
|
||||||
|
_virtualPadStickTexture->setAutoGenerateMips(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
iconPath = PathUtils::resourcesPath() + "images/analog_stick_base.png";
|
||||||
|
image = QImage(iconPath);
|
||||||
|
if (image.format() != QImage::Format_ARGB32) {
|
||||||
|
image = image.convertToFormat(QImage::Format_ARGB32);
|
||||||
|
}
|
||||||
|
if ((image.width() > 0) && (image.height() > 0)) {
|
||||||
|
_virtualPadStickBaseTexture = gpu::Texture::createStrict(
|
||||||
|
gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA),
|
||||||
|
image.width(), image.height(),
|
||||||
|
gpu::Texture::MAX_NUM_MIPS,
|
||||||
|
gpu::Sampler(gpu::Sampler::FILTER_MIN_MAG_MIP_LINEAR));
|
||||||
|
_virtualPadStickBaseTexture->setSource("virtualPad base");
|
||||||
|
auto usage = gpu::Texture::Usage::Builder().withColor().withAlpha();
|
||||||
|
_virtualPadStickBaseTexture->setUsage(usage.build());
|
||||||
|
_virtualPadStickBaseTexture->setStoredMipFormat(gpu::Element(gpu::VEC4, gpu::NUINT8, gpu::RGBA));
|
||||||
|
_virtualPadStickBaseTexture->assignStoredMip(0, image.byteCount(), image.constBits());
|
||||||
|
_virtualPadStickBaseTexture->setAutoGenerateMips(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
|
Parent::customizeContext();
|
||||||
|
}
|
||||||
|
|
||||||
|
void Basic2DWindowOpenGLDisplayPlugin::uncustomizeContext() {
|
||||||
|
Parent::uncustomizeContext();
|
||||||
|
}
|
||||||
|
|
||||||
bool Basic2DWindowOpenGLDisplayPlugin::internalActivate() {
|
bool Basic2DWindowOpenGLDisplayPlugin::internalActivate() {
|
||||||
_framerateActions.clear();
|
_framerateActions.clear();
|
||||||
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, MENU_PATH(), FULLSCREEN,
|
_container->addMenuItem(PluginType::DISPLAY_PLUGIN, MENU_PATH(), FULLSCREEN,
|
||||||
|
@ -33,6 +84,37 @@ bool Basic2DWindowOpenGLDisplayPlugin::internalActivate() {
|
||||||
return Parent::internalActivate();
|
return Parent::internalActivate();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
void Basic2DWindowOpenGLDisplayPlugin::compositeExtra() {
|
||||||
|
auto& virtualPadManager = VirtualPad::Manager::instance();
|
||||||
|
if(virtualPadManager.getLeftVirtualPad()->isBeingTouched()) {
|
||||||
|
// render stick base
|
||||||
|
auto stickBaseTransform = DependencyManager::get<CompositorHelper>()->getPoint2DTransform(virtualPadManager.getLeftVirtualPad()->getFirstTouch());
|
||||||
|
render([&](gpu::Batch& batch) {
|
||||||
|
batch.enableStereo(false);
|
||||||
|
batch.setProjectionTransform(mat4());
|
||||||
|
batch.setPipeline(_cursorPipeline);
|
||||||
|
batch.setResourceTexture(0, _virtualPadStickBaseTexture);
|
||||||
|
batch.resetViewTransform();
|
||||||
|
batch.setModelTransform(stickBaseTransform);
|
||||||
|
batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize()));
|
||||||
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
});
|
||||||
|
// render stick head
|
||||||
|
auto stickTransform = DependencyManager::get<CompositorHelper>()->getPoint2DTransform(virtualPadManager.getLeftVirtualPad()->getCurrentTouch());
|
||||||
|
render([&](gpu::Batch& batch) {
|
||||||
|
batch.enableStereo(false);
|
||||||
|
batch.setProjectionTransform(mat4());
|
||||||
|
batch.setPipeline(_cursorPipeline);
|
||||||
|
batch.setResourceTexture(0, _virtualPadStickTexture);
|
||||||
|
batch.resetViewTransform();
|
||||||
|
batch.setModelTransform(stickTransform);
|
||||||
|
batch.setViewportTransform(ivec4(uvec2(0), getRecommendedRenderSize()));
|
||||||
|
batch.draw(gpu::TRIANGLE_STRIP, 4);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
Parent::compositeExtra();
|
||||||
|
}
|
||||||
|
|
||||||
static const uint32_t MIN_THROTTLE_CHECK_FRAMES = 60;
|
static const uint32_t MIN_THROTTLE_CHECK_FRAMES = 60;
|
||||||
|
|
||||||
bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
|
bool Basic2DWindowOpenGLDisplayPlugin::isThrottled() const {
|
||||||
|
|
|
@ -22,10 +22,15 @@ public:
|
||||||
|
|
||||||
virtual float getTargetFrameRate() const override { return _framerateTarget ? (float) _framerateTarget : TARGET_FRAMERATE_Basic2DWindowOpenGL; }
|
virtual float getTargetFrameRate() const override { return _framerateTarget ? (float) _framerateTarget : TARGET_FRAMERATE_Basic2DWindowOpenGL; }
|
||||||
|
|
||||||
|
virtual void customizeContext() override;
|
||||||
|
virtual void uncustomizeContext() override;
|
||||||
|
|
||||||
virtual bool internalActivate() override;
|
virtual bool internalActivate() override;
|
||||||
|
|
||||||
virtual bool isThrottled() const override;
|
virtual bool isThrottled() const override;
|
||||||
|
|
||||||
|
virtual void compositeExtra() override;
|
||||||
|
|
||||||
protected:
|
protected:
|
||||||
mutable bool _isThrottled = false;
|
mutable bool _isThrottled = false;
|
||||||
|
|
||||||
|
@ -36,4 +41,7 @@ private:
|
||||||
QAction* _vsyncAction { nullptr };
|
QAction* _vsyncAction { nullptr };
|
||||||
uint32_t _framerateTarget { 0 };
|
uint32_t _framerateTarget { 0 };
|
||||||
int _fullscreenTarget{ -1 };
|
int _fullscreenTarget{ -1 };
|
||||||
|
|
||||||
|
gpu::TexturePointer _virtualPadStickTexture;
|
||||||
|
gpu::TexturePointer _virtualPadStickBaseTexture;
|
||||||
};
|
};
|
||||||
|
|
|
@ -458,6 +458,22 @@ glm::mat4 CompositorHelper::getReticleTransform(const glm::mat4& eyePose, const
|
||||||
return result;
|
return result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
glm::mat4 CompositorHelper::getPoint2DTransform(const glm::vec2& point) const {
|
||||||
|
glm::mat4 result;
|
||||||
|
static const float PIXEL_SIZE = 512.0f;
|
||||||
|
const auto canvasSize = vec2(toGlm(_renderingWidget->size()));;
|
||||||
|
QPoint qPoint(point.x,point.y);
|
||||||
|
vec2 position = toGlm(_renderingWidget->mapFromGlobal(qPoint));
|
||||||
|
position /= canvasSize;
|
||||||
|
position *= 2.0;
|
||||||
|
position -= 1.0;
|
||||||
|
position.y *= -1.0f;
|
||||||
|
|
||||||
|
vec2 size = PIXEL_SIZE / canvasSize;
|
||||||
|
result = glm::scale(glm::translate(glm::mat4(), vec3(position, 0.0f)), vec3(size, 1.0f));
|
||||||
|
return result;
|
||||||
|
}
|
||||||
|
|
||||||
|
|
||||||
QVariant ReticleInterface::getPosition() const {
|
QVariant ReticleInterface::getPosition() const {
|
||||||
return vec2toVariant(_compositor->getReticlePosition());
|
return vec2toVariant(_compositor->getReticlePosition());
|
||||||
|
|
|
@ -92,6 +92,7 @@ public:
|
||||||
glm::vec2 getReticleMaximumPosition() const;
|
glm::vec2 getReticleMaximumPosition() const;
|
||||||
|
|
||||||
glm::mat4 getReticleTransform(const glm::mat4& eyePose = glm::mat4(), const glm::vec3& headPosition = glm::vec3()) const;
|
glm::mat4 getReticleTransform(const glm::mat4& eyePose = glm::mat4(), const glm::vec3& headPosition = glm::vec3()) const;
|
||||||
|
glm::mat4 getPoint2DTransform(const glm::vec2& point = glm::vec2()) const;
|
||||||
|
|
||||||
ReticleInterface* getReticleInterface() { return _reticleInterface; }
|
ReticleInterface* getReticleInterface() { return _reticleInterface; }
|
||||||
|
|
||||||
|
|
|
@ -1,5 +1,5 @@
|
||||||
set(TARGET_NAME input-plugins)
|
set(TARGET_NAME input-plugins)
|
||||||
setup_hifi_library()
|
setup_hifi_library()
|
||||||
link_hifi_libraries(shared plugins ui-plugins controllers)
|
link_hifi_libraries(shared plugins ui-plugins controllers ui)
|
||||||
|
|
||||||
GroupSources("src/input-plugins")
|
GroupSources("src/input-plugins")
|
||||||
|
|
|
@ -14,12 +14,16 @@
|
||||||
|
|
||||||
#include "KeyboardMouseDevice.h"
|
#include "KeyboardMouseDevice.h"
|
||||||
#include "TouchscreenDevice.h"
|
#include "TouchscreenDevice.h"
|
||||||
|
#include "TouchscreenVirtualPadDevice.h"
|
||||||
|
|
||||||
// TODO migrate to a DLL model where plugins are discovered and loaded at runtime by the PluginManager class
|
// TODO migrate to a DLL model where plugins are discovered and loaded at runtime by the PluginManager class
|
||||||
InputPluginList getInputPlugins() {
|
InputPluginList getInputPlugins() {
|
||||||
InputPlugin* PLUGIN_POOL[] = {
|
InputPlugin* PLUGIN_POOL[] = {
|
||||||
new KeyboardMouseDevice(),
|
new KeyboardMouseDevice(),
|
||||||
new TouchscreenDevice(),
|
new TouchscreenDevice(),
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
new TouchscreenVirtualPadDevice(),
|
||||||
|
#endif
|
||||||
nullptr
|
nullptr
|
||||||
};
|
};
|
||||||
|
|
||||||
|
|
|
@ -0,0 +1,247 @@
|
||||||
|
//
|
||||||
|
// TouchscreenVirtualPadDevice.cpp
|
||||||
|
// input-plugins/src/input-plugins
|
||||||
|
//
|
||||||
|
// Created by Triplelexx on 01/31/16.
|
||||||
|
// Copyright 2016 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 "TouchscreenVirtualPadDevice.h"
|
||||||
|
#include "KeyboardMouseDevice.h"
|
||||||
|
|
||||||
|
#include <QtGui/QTouchEvent>
|
||||||
|
#include <QGestureEvent>
|
||||||
|
#include <QGuiApplication>
|
||||||
|
#include <QWindow>
|
||||||
|
#include <QScreen>
|
||||||
|
|
||||||
|
#include <controllers/UserInputMapper.h>
|
||||||
|
#include <PathUtils.h>
|
||||||
|
#include <NumericalConstants.h>
|
||||||
|
#include "VirtualPadManager.h"
|
||||||
|
|
||||||
|
const char* TouchscreenVirtualPadDevice::NAME = "TouchscreenVirtualPad";
|
||||||
|
|
||||||
|
bool TouchscreenVirtualPadDevice::isSupported() const {
|
||||||
|
for (auto touchDevice : QTouchDevice::devices()) {
|
||||||
|
if (touchDevice->type() == QTouchDevice::TouchScreen) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
#if defined(Q_OS_ANDROID)
|
||||||
|
// last chance, assume that if this is android, a touchscreen is indeed supported
|
||||||
|
return true;
|
||||||
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
float clip(float n, float lower, float upper) {
|
||||||
|
return std::max(lower, std::min(n, upper));
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
|
auto userInputMapper = DependencyManager::get<controller::UserInputMapper>();
|
||||||
|
userInputMapper->withLock([&, this]() {
|
||||||
|
_inputDevice->update(deltaTime, inputCalibrationData);
|
||||||
|
});
|
||||||
|
|
||||||
|
auto& virtualPadManager = VirtualPad::Manager::instance();
|
||||||
|
if (_validTouchLeft) {
|
||||||
|
float leftDistanceScaleX, leftDistanceScaleY;
|
||||||
|
leftDistanceScaleX = (_currentTouchLeftPoint.x - _firstTouchLeftPoint.x) / _screenDPIScale.x;
|
||||||
|
leftDistanceScaleY = (_currentTouchLeftPoint.y - _firstTouchLeftPoint.y) / _screenDPIScale.y;
|
||||||
|
|
||||||
|
leftDistanceScaleX = clip(leftDistanceScaleX, -STICK_RADIUS_INCHES, STICK_RADIUS_INCHES);
|
||||||
|
leftDistanceScaleY = clip(leftDistanceScaleY, -STICK_RADIUS_INCHES, STICK_RADIUS_INCHES);
|
||||||
|
|
||||||
|
// NOW BETWEEN -1 1
|
||||||
|
leftDistanceScaleX /= STICK_RADIUS_INCHES;
|
||||||
|
leftDistanceScaleY /= STICK_RADIUS_INCHES;
|
||||||
|
|
||||||
|
_inputDevice->_axisStateMap[controller::LX] = leftDistanceScaleX;
|
||||||
|
_inputDevice->_axisStateMap[controller::LY] = leftDistanceScaleY;
|
||||||
|
|
||||||
|
/* Shared variables for stick rendering (clipped to the stick radius)*/
|
||||||
|
// Prevent this for being done when not in first person view
|
||||||
|
virtualPadManager.getLeftVirtualPad()->setBeingTouched(true);
|
||||||
|
virtualPadManager.getLeftVirtualPad()->setFirstTouch(_firstTouchLeftPoint);
|
||||||
|
virtualPadManager.getLeftVirtualPad()->setCurrentTouch(
|
||||||
|
glm::vec2(clip(_currentTouchLeftPoint.x, -STICK_RADIUS_INCHES * _screenDPIScale.x + _firstTouchLeftPoint.x, STICK_RADIUS_INCHES * _screenDPIScale.x + _firstTouchLeftPoint.x),
|
||||||
|
clip(_currentTouchLeftPoint.y, -STICK_RADIUS_INCHES * _screenDPIScale.y + _firstTouchLeftPoint.y, STICK_RADIUS_INCHES * _screenDPIScale.y + _firstTouchLeftPoint.y))
|
||||||
|
);
|
||||||
|
} else {
|
||||||
|
virtualPadManager.getLeftVirtualPad()->setBeingTouched(false);
|
||||||
|
}
|
||||||
|
|
||||||
|
if (_validTouchRight) {
|
||||||
|
float rightDistanceScaleX, rightDistanceScaleY;
|
||||||
|
rightDistanceScaleX = (_currentTouchRightPoint.x - _firstTouchRightPoint.x) / _screenDPIScale.x;
|
||||||
|
rightDistanceScaleY = (_currentTouchRightPoint.y - _firstTouchRightPoint.y) / _screenDPIScale.y;
|
||||||
|
|
||||||
|
rightDistanceScaleX = clip(rightDistanceScaleX, -STICK_RADIUS_INCHES, STICK_RADIUS_INCHES);
|
||||||
|
rightDistanceScaleY = clip(rightDistanceScaleY, -STICK_RADIUS_INCHES, STICK_RADIUS_INCHES);
|
||||||
|
|
||||||
|
// NOW BETWEEN -1 1
|
||||||
|
rightDistanceScaleX /= STICK_RADIUS_INCHES;
|
||||||
|
rightDistanceScaleY /= STICK_RADIUS_INCHES;
|
||||||
|
|
||||||
|
_inputDevice->_axisStateMap[controller::RX] = rightDistanceScaleX;
|
||||||
|
_inputDevice->_axisStateMap[controller::RY] = rightDistanceScaleY;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::InputDevice::update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) {
|
||||||
|
_axisStateMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::InputDevice::focusOutEvent() {
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::debugPoints(const QTouchEvent* event, QString who) {
|
||||||
|
// convert the touch points into an average
|
||||||
|
const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
|
||||||
|
QVector<glm::vec2> points;
|
||||||
|
int touchPoints = tPoints.count();
|
||||||
|
for (int i = 0; i < touchPoints; ++i) {
|
||||||
|
glm::vec2 thisPoint(tPoints[i].pos().x(), tPoints[i].pos().y());
|
||||||
|
points << thisPoint;
|
||||||
|
}
|
||||||
|
QScreen* eventScreen = event->window()->screen();
|
||||||
|
int midScreenX = eventScreen->size().width()/2;
|
||||||
|
int lefties = 0;
|
||||||
|
int righties = 0;
|
||||||
|
vec2 currentPoint;
|
||||||
|
for (int i = 0; i < points.length(); i++) {
|
||||||
|
currentPoint = points.at(i);
|
||||||
|
if (currentPoint.x < midScreenX) {
|
||||||
|
lefties++;
|
||||||
|
} else {
|
||||||
|
righties++;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchBeginEvent(const QTouchEvent* event) {
|
||||||
|
// touch begin here is a big begin -> begins both pads? maybe it does nothing
|
||||||
|
debugPoints(event, " BEGIN ++++++++++++++++");
|
||||||
|
KeyboardMouseDevice::enableTouch(false);
|
||||||
|
QScreen* eventScreen = event->window()->screen();
|
||||||
|
_screenWidthCenter = eventScreen->size().width() / 2;
|
||||||
|
if (_screenDPI != eventScreen->physicalDotsPerInch()) {
|
||||||
|
_screenDPIScale.x = (float)eventScreen->physicalDotsPerInchX();
|
||||||
|
_screenDPIScale.y = (float)eventScreen->physicalDotsPerInchY();
|
||||||
|
_screenDPI = eventScreen->physicalDotsPerInch();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchEndEvent(const QTouchEvent* event) {
|
||||||
|
// touch end here is a big reset -> resets both pads
|
||||||
|
_touchPointCount = 0;
|
||||||
|
KeyboardMouseDevice::enableTouch(true);
|
||||||
|
debugPoints(event, " END ----------------");
|
||||||
|
touchLeftEnd();
|
||||||
|
touchRightEnd();
|
||||||
|
_inputDevice->_axisStateMap.clear();
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchUpdateEvent(const QTouchEvent* event) {
|
||||||
|
_touchPointCount = event->touchPoints().count();
|
||||||
|
|
||||||
|
const QList<QTouchEvent::TouchPoint>& tPoints = event->touchPoints();
|
||||||
|
bool leftTouchFound = false;
|
||||||
|
bool rightTouchFound = false;
|
||||||
|
for (int i = 0; i < _touchPointCount; ++i) {
|
||||||
|
glm::vec2 thisPoint(tPoints[i].pos().x(), tPoints[i].pos().y());
|
||||||
|
if (thisPoint.x < _screenWidthCenter) {
|
||||||
|
if (!leftTouchFound) {
|
||||||
|
leftTouchFound = true;
|
||||||
|
if (!_validTouchLeft) {
|
||||||
|
touchLeftBegin(thisPoint);
|
||||||
|
} else {
|
||||||
|
touchLeftUpdate(thisPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
if (!rightTouchFound) {
|
||||||
|
rightTouchFound = true;
|
||||||
|
if (!_validTouchRight) {
|
||||||
|
touchRightBegin(thisPoint);
|
||||||
|
} else {
|
||||||
|
touchRightUpdate(thisPoint);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
if (!leftTouchFound) {
|
||||||
|
touchLeftEnd();
|
||||||
|
}
|
||||||
|
if (!rightTouchFound) {
|
||||||
|
touchRightEnd();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchLeftBegin(glm::vec2 touchPoint) {
|
||||||
|
auto& virtualPadManager = VirtualPad::Manager::instance();
|
||||||
|
if (virtualPadManager.isEnabled()) {
|
||||||
|
_firstTouchLeftPoint = touchPoint;
|
||||||
|
_validTouchLeft = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchLeftUpdate(glm::vec2 touchPoint) {
|
||||||
|
_currentTouchLeftPoint = touchPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchLeftEnd() {
|
||||||
|
if (_validTouchLeft) { // do stuff once
|
||||||
|
_validTouchLeft = false;
|
||||||
|
_inputDevice->_axisStateMap[controller::LX] = 0;
|
||||||
|
_inputDevice->_axisStateMap[controller::LY] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchRightBegin(glm::vec2 touchPoint) {
|
||||||
|
auto& virtualPadManager = VirtualPad::Manager::instance();
|
||||||
|
if (virtualPadManager.isEnabled()) {
|
||||||
|
_firstTouchRightPoint = touchPoint;
|
||||||
|
_validTouchRight = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchRightUpdate(glm::vec2 touchPoint) {
|
||||||
|
_currentTouchRightPoint = touchPoint;
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchRightEnd() {
|
||||||
|
if (_validTouchRight) { // do stuff once
|
||||||
|
_validTouchRight = false;
|
||||||
|
_inputDevice->_axisStateMap[controller::RX] = 0;
|
||||||
|
_inputDevice->_axisStateMap[controller::RY] = 0;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
void TouchscreenVirtualPadDevice::touchGestureEvent(const QGestureEvent* event) {
|
||||||
|
if (QGesture* gesture = event->gesture(Qt::PinchGesture)) {
|
||||||
|
QPinchGesture* pinch = static_cast<QPinchGesture*>(gesture);
|
||||||
|
_pinchScale = pinch->totalScaleFactor();
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
controller::Input::NamedVector TouchscreenVirtualPadDevice::InputDevice::getAvailableInputs() const {
|
||||||
|
using namespace controller;
|
||||||
|
QVector<Input::NamedPair> availableInputs{
|
||||||
|
makePair(LX, "LX"),
|
||||||
|
makePair(LY, "LY"),
|
||||||
|
makePair(RX, "RX"),
|
||||||
|
makePair(RY, "RY")
|
||||||
|
};
|
||||||
|
return availableInputs;
|
||||||
|
}
|
||||||
|
|
||||||
|
QString TouchscreenVirtualPadDevice::InputDevice::getDefaultMappingConfig() const {
|
||||||
|
static const QString MAPPING_JSON = PathUtils::resourcesPath() + "/controllers/touchscreenvirtualpad.json";
|
||||||
|
return MAPPING_JSON;
|
||||||
|
}
|
|
@ -0,0 +1,89 @@
|
||||||
|
//
|
||||||
|
// TouchscreenVirtualPadDevice.h
|
||||||
|
// input-plugins/src/input-plugins
|
||||||
|
//
|
||||||
|
// Created by Triplelexx on 1/31/16.
|
||||||
|
// Copyright 2016 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_TouchscreenVirtualPadDevice_h
|
||||||
|
#define hifi_TouchscreenVirtualPadDevice_h
|
||||||
|
|
||||||
|
#include <controllers/InputDevice.h>
|
||||||
|
#include "InputPlugin.h"
|
||||||
|
#include <QtGui/qtouchdevice.h>
|
||||||
|
|
||||||
|
class QTouchEvent;
|
||||||
|
class QGestureEvent;
|
||||||
|
|
||||||
|
const float STICK_RADIUS_INCHES = .3f;
|
||||||
|
|
||||||
|
class TouchscreenVirtualPadDevice : public InputPlugin {
|
||||||
|
Q_OBJECT
|
||||||
|
public:
|
||||||
|
|
||||||
|
// Plugin functions
|
||||||
|
virtual bool isSupported() const override;
|
||||||
|
virtual const QString getName() const override { return NAME; }
|
||||||
|
|
||||||
|
bool isHandController() const override { return false; }
|
||||||
|
|
||||||
|
virtual void pluginFocusOutEvent() override { _inputDevice->focusOutEvent(); }
|
||||||
|
virtual void pluginUpdate(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;
|
||||||
|
|
||||||
|
void touchBeginEvent(const QTouchEvent* event);
|
||||||
|
void touchEndEvent(const QTouchEvent* event);
|
||||||
|
void touchUpdateEvent(const QTouchEvent* event);
|
||||||
|
void touchGestureEvent(const QGestureEvent* event);
|
||||||
|
|
||||||
|
static const char* NAME;
|
||||||
|
|
||||||
|
protected:
|
||||||
|
|
||||||
|
class InputDevice : public controller::InputDevice {
|
||||||
|
public:
|
||||||
|
InputDevice() : controller::InputDevice("TouchscreenVirtualPad") {}
|
||||||
|
private:
|
||||||
|
// Device functions
|
||||||
|
virtual controller::Input::NamedVector getAvailableInputs() const override;
|
||||||
|
virtual QString getDefaultMappingConfig() const override;
|
||||||
|
virtual void update(float deltaTime, const controller::InputCalibrationData& inputCalibrationData) override;
|
||||||
|
virtual void focusOutEvent() override;
|
||||||
|
|
||||||
|
friend class TouchscreenVirtualPadDevice;
|
||||||
|
};
|
||||||
|
|
||||||
|
public:
|
||||||
|
const std::shared_ptr<InputDevice>& getInputDevice() const { return _inputDevice; }
|
||||||
|
|
||||||
|
protected:
|
||||||
|
qreal _lastPinchScale;
|
||||||
|
qreal _pinchScale;
|
||||||
|
qreal _screenDPI;
|
||||||
|
glm::vec2 _screenDPIScale;
|
||||||
|
bool _validTouchLeft;
|
||||||
|
glm::vec2 _firstTouchLeftPoint;
|
||||||
|
glm::vec2 _currentTouchLeftPoint;
|
||||||
|
bool _validTouchRight;
|
||||||
|
glm::vec2 _firstTouchRightPoint;
|
||||||
|
glm::vec2 _currentTouchRightPoint;
|
||||||
|
int _touchPointCount;
|
||||||
|
int _screenWidthCenter;
|
||||||
|
std::shared_ptr<InputDevice> _inputDevice { std::make_shared<InputDevice>() };
|
||||||
|
|
||||||
|
void touchLeftBegin(glm::vec2 touchPoint);
|
||||||
|
void touchLeftUpdate(glm::vec2 touchPoint);
|
||||||
|
void touchLeftEnd();
|
||||||
|
void touchRightBegin(glm::vec2 touchPoint);
|
||||||
|
void touchRightUpdate(glm::vec2 touchPoint);
|
||||||
|
void touchRightEnd();
|
||||||
|
// just for debug
|
||||||
|
private:
|
||||||
|
void debugPoints(const QTouchEvent* event, QString who);
|
||||||
|
|
||||||
|
};
|
||||||
|
|
||||||
|
#endif // hifi_TouchscreenVirtualPadDevice_h
|
58
libraries/ui/src/VirtualPadManager.cpp
Normal file
58
libraries/ui/src/VirtualPadManager.cpp
Normal file
|
@ -0,0 +1,58 @@
|
||||||
|
//
|
||||||
|
// Created by Gabriel Calero & Cristian Duarte on 01/16/2018
|
||||||
|
// Copyright 2018 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 "VirtualPadManager.h"
|
||||||
|
|
||||||
|
namespace VirtualPad {
|
||||||
|
|
||||||
|
bool Instance::isBeingTouched() {
|
||||||
|
return _isBeingTouched;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::setBeingTouched(bool touched) {
|
||||||
|
_isBeingTouched = touched;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::setFirstTouch(glm::vec2 point) {
|
||||||
|
_firstTouch = point;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec2 Instance::getFirstTouch() {
|
||||||
|
return _firstTouch;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Instance::setCurrentTouch(glm::vec2 point) {
|
||||||
|
_currentTouch = point;
|
||||||
|
}
|
||||||
|
|
||||||
|
glm::vec2 Instance::getCurrentTouch() {
|
||||||
|
return _currentTouch;
|
||||||
|
}
|
||||||
|
|
||||||
|
Manager::Manager() {
|
||||||
|
|
||||||
|
}
|
||||||
|
|
||||||
|
Manager& Manager::instance() {
|
||||||
|
static QSharedPointer<Manager> instance = DependencyManager::get<VirtualPad::Manager>();
|
||||||
|
return *instance;
|
||||||
|
}
|
||||||
|
|
||||||
|
void Manager::enable(bool enable) {
|
||||||
|
_enabled = enable;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool Manager::isEnabled() {
|
||||||
|
return _enabled;
|
||||||
|
}
|
||||||
|
|
||||||
|
Instance* Manager::getLeftVirtualPad() {
|
||||||
|
return &_leftVPadInstance;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
46
libraries/ui/src/VirtualPadManager.h
Normal file
46
libraries/ui/src/VirtualPadManager.h
Normal file
|
@ -0,0 +1,46 @@
|
||||||
|
//
|
||||||
|
// Created by Gabriel Calero & Cristian Duarte on 01/16/2018
|
||||||
|
// Copyright 2018 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
|
||||||
|
//
|
||||||
|
|
||||||
|
#pragma once
|
||||||
|
#include <stdint.h>
|
||||||
|
#include <DependencyManager.h>
|
||||||
|
|
||||||
|
#include <GLMHelpers.h>
|
||||||
|
|
||||||
|
namespace VirtualPad {
|
||||||
|
class Instance {
|
||||||
|
public:
|
||||||
|
virtual bool isBeingTouched();
|
||||||
|
virtual void setBeingTouched(bool touched);
|
||||||
|
virtual void setFirstTouch(glm::vec2 point);
|
||||||
|
virtual glm::vec2 getFirstTouch();
|
||||||
|
virtual void setCurrentTouch(glm::vec2 point);
|
||||||
|
virtual glm::vec2 getCurrentTouch();
|
||||||
|
private:
|
||||||
|
bool _isBeingTouched;
|
||||||
|
glm::vec2 _firstTouch;
|
||||||
|
glm::vec2 _currentTouch;
|
||||||
|
};
|
||||||
|
|
||||||
|
class Manager : public QObject, public Dependency {
|
||||||
|
SINGLETON_DEPENDENCY
|
||||||
|
|
||||||
|
Manager();
|
||||||
|
Manager(const Manager& other) = delete;
|
||||||
|
public:
|
||||||
|
static Manager& instance();
|
||||||
|
Instance* getLeftVirtualPad();
|
||||||
|
bool isEnabled();
|
||||||
|
void enable(bool enable);
|
||||||
|
private:
|
||||||
|
Instance _leftVPadInstance;
|
||||||
|
bool _enabled;
|
||||||
|
};
|
||||||
|
}
|
||||||
|
|
||||||
|
|
|
@ -12,7 +12,8 @@
|
||||||
//
|
//
|
||||||
|
|
||||||
var DEFAULT_SCRIPTS_COMBINED = [
|
var DEFAULT_SCRIPTS_COMBINED = [
|
||||||
"system/progress.js"/*,
|
"system/progress.js",
|
||||||
|
"system/touchscreenvirtualpad.js"/*,
|
||||||
"system/away.js",
|
"system/away.js",
|
||||||
"system/controllers/controllerDisplayManager.js",
|
"system/controllers/controllerDisplayManager.js",
|
||||||
"system/controllers/handControllerGrabAndroid.js",
|
"system/controllers/handControllerGrabAndroid.js",
|
||||||
|
|
21
scripts/system/touchscreenvirtualpad.js
Normal file
21
scripts/system/touchscreenvirtualpad.js
Normal file
|
@ -0,0 +1,21 @@
|
||||||
|
"use strict";
|
||||||
|
//
|
||||||
|
// android.js
|
||||||
|
// scripts/system/
|
||||||
|
//
|
||||||
|
// Created by Gabriel Calero & Cristian Duarte on Jan 16, 2018
|
||||||
|
// Copyright 2018 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
|
||||||
|
//
|
||||||
|
|
||||||
|
(function() { // BEGIN LOCAL_SCOPE
|
||||||
|
|
||||||
|
function init() {
|
||||||
|
Controller.setVPadEnabled(true);
|
||||||
|
}
|
||||||
|
|
||||||
|
init();
|
||||||
|
|
||||||
|
}()); // END LOCAL_SCOPE
|
Loading…
Reference in a new issue