mirror of
https://github.com/izzy2lost/WeeU.git
synced 2026-07-06 00:19:59 -07:00
Added support for motion
This commit is contained in:
@@ -967,3 +967,9 @@ void InputManager::update_thread()
|
||||
std::this_thread::yield();
|
||||
}
|
||||
}
|
||||
|
||||
MotionSample InputManager::get_device_motion_sample() const
|
||||
{
|
||||
std::shared_lock lock(m_device_motion.m_mutex);
|
||||
return m_device_motion.m_motion_sample;
|
||||
}
|
||||
@@ -98,6 +98,14 @@ public:
|
||||
std::optional<glm::ivec2> get_right_down_mouse_info(bool* is_pad);
|
||||
|
||||
std::atomic<float> m_mouse_wheel;
|
||||
struct DeviceMotion
|
||||
{
|
||||
mutable std::shared_mutex m_mutex;
|
||||
MotionSample m_motion_sample;
|
||||
bool m_device_motion_enabled;
|
||||
} m_device_motion{};
|
||||
|
||||
MotionSample get_device_motion_sample() const;
|
||||
|
||||
private:
|
||||
void update_thread();
|
||||
|
||||
@@ -1,5 +1,6 @@
|
||||
#include "input/emulated/VPADController.h"
|
||||
#include "input/api/Controller.h"
|
||||
#include <mutex>
|
||||
#if HAS_SDL
|
||||
#include "input/api/SDL/SDLController.h"
|
||||
#endif // HAS_SDL
|
||||
@@ -237,10 +238,11 @@ void VPADController::update_touch(VPADStatus_t& status)
|
||||
|
||||
void VPADController::update_motion(VPADStatus_t& status)
|
||||
{
|
||||
if (has_motion())
|
||||
auto& input_manager = InputManager::instance();
|
||||
bool has_device_motion = input_manager.m_device_motion.m_device_motion_enabled;
|
||||
if (has_motion() || has_device_motion)
|
||||
{
|
||||
auto motionSample = get_motion_data();
|
||||
|
||||
MotionSample motionSample = has_device_motion ? input_manager.get_device_motion_sample() : get_motion_data();
|
||||
glm::vec3 acc;
|
||||
motionSample.getVPADAccelerometer(&acc[0]);
|
||||
//const auto& acc = motionSample.getVPADAccelerometer();
|
||||
@@ -281,7 +283,6 @@ void VPADController::update_motion(VPADStatus_t& status)
|
||||
}
|
||||
|
||||
bool pad_view;
|
||||
auto& input_manager = InputManager::instance();
|
||||
if (const auto right_mouse = input_manager.get_right_down_mouse_info(&pad_view))
|
||||
{
|
||||
const Vector2<float> mousePos(right_mouse->x, right_mouse->y);
|
||||
|
||||
Reference in New Issue
Block a user