From f4653d40cf08cc51298c4ba07dc4bc3dfddea91b Mon Sep 17 00:00:00 2001 From: kalaposfos13 <153381648+kalaposfos13@users.noreply.github.com> Date: Thu, 19 Jun 2025 21:53:29 +0200 Subject: [PATCH] Basic gyro emulation working for two out of the three dimensions --- src/input/input_mouse.cpp | 8 +++++++- 1 file changed, 7 insertions(+), 1 deletion(-) diff --git a/src/input/input_mouse.cpp b/src/input/input_mouse.cpp index aef1df0ba..64733252e 100644 --- a/src/input/input_mouse.cpp +++ b/src/input/input_mouse.cpp @@ -73,8 +73,14 @@ void EmulateJoystick(GameController* controller, u32 interval) { } } +constexpr float constant_down_accel[3] = {0.0f, 10.0f, 0.0f}; void EmulateGyro(GameController* controller, u32 interval) { - LOG_INFO(Input, "todo gyro"); + // LOG_INFO(Input, "todo gyro"); + float d_x = 0, d_y = 0; + SDL_GetRelativeMouseState(&d_x, &d_y); + controller->Acceleration(1, constant_down_accel); + float gyro_from_mouse[3] = {-d_y / 100, -d_x / 100, 0.0f}; + controller->Gyro(1, gyro_from_mouse); } Uint32 MousePolling(void* param, Uint32 id, Uint32 interval) {