mirror of
https://github.com/OpenSpace/OpenSpace.git
synced 2026-01-06 03:29:44 -06:00
Feature/internal touchhandling (#1038)
* Removal of dead code and compiler warnings
* Added basic internal touch
This commit only adds the description-shell of the touch implementation
* Added callbacks and first WIP of internal touch
Makes use of the TouchInput/TouchInputs class in the TouchModule.
Internally we cache the TouchInputs as an input deque and utilizes it
for motion-vectors.
This commit has bugs and issues, which will be worked upon.
* Happy new year!
Bumped year on branch-local files
* Improvements to internal touch
Almost reached feature-parity with tuio-handled touch events
- Added most of the touch-logic to touchinteraction
- Added helper functions to new TouchInput/TouchInputs classes
* Naming changes to touch interface
* Translate TUIO to TouchInput
This commit translates TUIO messages to an internal TouchInput structure
while still trying to keep feature parity.
Removed TUIO-dependencies from many files.
Changed behavior on tuioear to lock-swap its content.
* Minor cleanup and fixes
- Should fix touch roll
- Simplified some functions
* Build fix
* Use internal touch in webgui
- Added consume-logic to touch callbacks
- Constrained touch-input to either webgui or 3D application as mouse is
- This fixes some flaws with previous implementation,
such as ghost inputs
- Initialize touchmodule through init-functions rather than constructor
* Cleanup of comments
* Simplified touch classes
Added timestamp through constructor meaning no more sprinkled timestamps
Renamed TouchInputs to TouchInputHolder for clarity
Added helper functions to the Holder to see if it holds an input
Remade addInput as tryAddInput which return true on successful insertion
+ other cleanup
* Code style cleanup and tweaks
Removed avoidable zero-comparison for code clarity
Cleanup of code style
* Added comments to DirectInputSolver
Clarifying the use of the DirectInputSolver.
* Changes for coding style
Change SGCT version to make it checkout-able
* Clarify magic bitmask
* const -> constexpr const for magic bitmasks
Co-authored-by: Alexander Bock <mail@alexanderbock.eu>
This commit is contained in:
committed by
GitHub
parent
a1a4e56b5b
commit
4e75b161db
@@ -27,6 +27,7 @@
|
||||
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
#include <openspace/util/touch.h>
|
||||
#include <functional>
|
||||
#include <vector>
|
||||
|
||||
@@ -53,6 +54,10 @@ std::vector<std::function<bool(MouseButton, MouseAction, KeyModifier)>>& gMouseB
|
||||
std::vector<std::function<void(double, double)>>& gMousePosition();
|
||||
std::vector<std::function<bool(double, double)>>& gMouseScrollWheel();
|
||||
|
||||
std::vector<std::function<bool(TouchInput)>>& gTouchDetected();
|
||||
std::vector<std::function<bool(TouchInput)>>& gTouchUpdated();
|
||||
std::vector<std::function<void(TouchInput)>>& gTouchExit();
|
||||
|
||||
} // namespace detail
|
||||
|
||||
namespace callback {
|
||||
@@ -76,7 +81,12 @@ static std::vector<std::function<void(double, double)>>& mousePosition =
|
||||
detail::gMousePosition();
|
||||
static std::vector<std::function<bool(double, double)>>& mouseScrollWheel =
|
||||
detail::gMouseScrollWheel();
|
||||
|
||||
static std::vector<std::function<bool(TouchInput)>>& touchDetected =
|
||||
detail::gTouchDetected();
|
||||
static std::vector<std::function<bool(TouchInput)>>& touchUpdated =
|
||||
detail::gTouchUpdated();
|
||||
static std::vector<std::function<void(TouchInput)>>& touchExit =
|
||||
detail::gTouchExit();
|
||||
|
||||
/**
|
||||
* If the framerate becomes slow, Chromium Embedded Framework (used in Web Browser Module)
|
||||
|
||||
@@ -28,6 +28,7 @@
|
||||
#include <openspace/properties/stringproperty.h>
|
||||
#include <openspace/util/keys.h>
|
||||
#include <openspace/util/mouse.h>
|
||||
#include <openspace/util/touch.h>
|
||||
#include <openspace/util/versionchecker.h>
|
||||
#include <ghoul/glm.h>
|
||||
#include <memory>
|
||||
@@ -80,7 +81,9 @@ public:
|
||||
void mouseButtonCallback(MouseButton button, MouseAction action, KeyModifier mods);
|
||||
void mousePositionCallback(double x, double y);
|
||||
void mouseScrollWheelCallback(double posX, double posY);
|
||||
void externalControlCallback(const char* receivedChars, int size, int clientId);
|
||||
void touchDetectionCallback(TouchInput input);
|
||||
void touchUpdateCallback(TouchInput input);
|
||||
void touchExitCallback(TouchInput input);
|
||||
std::vector<char> encode();
|
||||
void decode(std::vector<char> data);
|
||||
|
||||
@@ -105,7 +108,6 @@ private:
|
||||
void loadFonts();
|
||||
|
||||
void runGlobalCustomizationScripts();
|
||||
void configureLogging();
|
||||
|
||||
std::unique_ptr<Scene> _scene;
|
||||
std::unique_ptr<AssetManager> _assetManager;
|
||||
|
||||
@@ -99,7 +99,6 @@ public:
|
||||
// Right now this function returns the actual combined matrix which makes some
|
||||
// of the old calls to the function wrong..
|
||||
const glm::dmat4& combinedViewMatrix() const;
|
||||
const glm::dmat4& combinedViewMatrixNoScale() const;
|
||||
|
||||
void invalidateCache();
|
||||
|
||||
|
||||
88
include/openspace/util/touch.h
Normal file
88
include/openspace/util/touch.h
Normal file
@@ -0,0 +1,88 @@
|
||||
/*****************************************************************************************
|
||||
* *
|
||||
* OpenSpace *
|
||||
* *
|
||||
* Copyright (c) 2014-2020 *
|
||||
* *
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a copy of this *
|
||||
* software and associated documentation files (the "Software"), to deal in the Software *
|
||||
* without restriction, including without limitation the rights to use, copy, modify, *
|
||||
* merge, publish, distribute, sublicense, and/or sell copies of the Software, and to *
|
||||
* permit persons to whom the Software is furnished to do so, subject to the following *
|
||||
* conditions: *
|
||||
* *
|
||||
* The above copyright notice and this permission notice shall be included in all copies *
|
||||
* or substantial portions of the Software. *
|
||||
* *
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, *
|
||||
* INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A *
|
||||
* PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT *
|
||||
* HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF *
|
||||
* CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE *
|
||||
* OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. *
|
||||
****************************************************************************************/
|
||||
|
||||
#ifndef __OPENSPACE_CORE___TOUCH___H__
|
||||
#define __OPENSPACE_CORE___TOUCH___H__
|
||||
|
||||
#include <glm/detail/type_vec2.hpp>
|
||||
|
||||
#include <cstdint>
|
||||
#include <deque>
|
||||
|
||||
namespace openspace {
|
||||
|
||||
struct TouchInput {
|
||||
TouchInput(size_t touchDeviceId, size_t fingerId, float x, float y, double timestamp);
|
||||
glm::vec2 screenCoordinates(glm::vec2 resolution) const;
|
||||
glm::vec2 currentWindowCoordinates() const;
|
||||
bool isMoving() const;
|
||||
float distanceToPos(float otherX, float otherY) const;
|
||||
float angleToPos(float otherX, float otherY) const;
|
||||
|
||||
size_t touchDeviceId;
|
||||
size_t fingerId;
|
||||
float x;
|
||||
float y;
|
||||
float dx = 0.f; // movement in x direction since last touch input
|
||||
float dy = 0.f; // movement in y direction since last touch input
|
||||
double timestamp; // timestamp in seconds from global touch initialization
|
||||
};
|
||||
|
||||
class TouchInputHolder {
|
||||
public:
|
||||
TouchInputHolder(TouchInput input);
|
||||
|
||||
// tryAddInput:
|
||||
// Succeeds upon a different input than last.
|
||||
// Fails upon a too similar input as last.
|
||||
bool tryAddInput(TouchInput input);
|
||||
void clearInputs();
|
||||
|
||||
bool holdsInput(const TouchInput &input) const;
|
||||
|
||||
size_t touchDeviceId() const;
|
||||
size_t fingerId() const;
|
||||
|
||||
float speedX() const;
|
||||
float speedY() const;
|
||||
|
||||
bool isMoving() const;
|
||||
float gestureDistance() const;
|
||||
double gestureTime() const;
|
||||
|
||||
size_t numInputs() const;
|
||||
const TouchInput& latestInput() const;
|
||||
const std::deque<TouchInput>& peekInputs() const;
|
||||
|
||||
private:
|
||||
//A deque of recorded inputs. Adding newer points to the front of the queue
|
||||
std::deque<TouchInput> _inputs;
|
||||
|
||||
size_t _touchDeviceId;
|
||||
size_t _fingerId;
|
||||
};
|
||||
|
||||
} // namespace openspace
|
||||
|
||||
#endif // __OPENSPACE_CORE___TOUCH___H__
|
||||
Reference in New Issue
Block a user