From 9e990680dc3378093cb888628f251ea759433de8 Mon Sep 17 00:00:00 2001 From: meowtech Date: Tue, 26 May 2026 10:46:32 +0000 Subject: [PATCH] now using float for wheel --- binding-mri/input-binding.cpp | 10 +++++----- scripts/Window_Settings.rb | 12 ++++++------ src/eventthread.cpp | 4 ++-- src/eventthread.h | 2 +- src/input.cpp | 6 +++--- src/input.h | 4 ++-- 6 files changed, 19 insertions(+), 19 deletions(-) diff --git a/binding-mri/input-binding.cpp b/binding-mri/input-binding.cpp index ead73fc..f0f9507 100644 --- a/binding-mri/input-binding.cpp +++ b/binding-mri/input-binding.cpp @@ -96,12 +96,12 @@ RB_METHOD(inputMouseY){ // wheel :3 RB_METHOD(inputWheelX) { RB_UNUSED_PARAM; - return rb_fix_new(shState->input().wheelX()); + return rb_float_new(shState->input().wheelX()); } RB_METHOD(inputWheelY) { RB_UNUSED_PARAM; - return rb_fix_new(shState->input().wheelY()); + return rb_float_new(shState->input().wheelY()); } RB_METHOD(inputWheelFlipped) { @@ -165,9 +165,9 @@ void inputBindingInit(){ _rb_define_module_function(module, "mouse_y", inputMouseY); // wheel support :P - _rb_define_module_function(module, "mouse_wheel_x", inputWheelX); - _rb_define_module_function(module, "mouse_wheel_y", inputWheelY); - _rb_define_module_function(module, "mouse_wheel_flipped", inputWheelFlipped); + _rb_define_module_function(module, "wheel_x", inputWheelX); + _rb_define_module_function(module, "wheel_y", inputWheelY); + _rb_define_module_function(module, "wheel_flipped", inputWheelFlipped); _rb_define_module_function(module, "quit?", inputQuit); diff --git a/scripts/Window_Settings.rb b/scripts/Window_Settings.rb index a95e382..b715914 100644 --- a/scripts/Window_Settings.rb +++ b/scripts/Window_Settings.rb @@ -281,6 +281,10 @@ class Window_Settings def update + if @visible + @version.bitmap.clear + @version.bitmap.draw_text(0, 0, @version.bitmap.width, @version.bitmap.height, Input.wheel_y.to_s) + end @version.opacity = 128 @@ -350,12 +354,8 @@ class Window_Settings end end - if Input.mouse_wheel_y > 0 - @index = (@index - 1) % @data.size - $game_system.se_play($data_system.cursor_se) - end - if Input.mouse_wheel_y < 0 - @index = (@index + 1) % @data.size + if Input.wheel_y != 0 + @index = (@index - Input.wheel_y.round) % @data.size $game_system.se_play($data_system.cursor_se) end diff --git a/src/eventthread.cpp b/src/eventthread.cpp index becc5f1..d57e1a8 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -434,8 +434,8 @@ void EventThread::process(RGSSThreadData &rtData){ case SDL_EVENT_MOUSE_WHEEL: { mouseState.wheelFlipped = event.wheel.direction == SDL_MOUSEWHEEL_FLIPPED; - mouseState.wheelX += event.wheel.integer_x; - mouseState.wheelY += event.wheel.integer_y; + mouseState.wheelX += event.wheel.x; + mouseState.wheelY += event.wheel.y; } break; diff --git a/src/eventthread.h b/src/eventthread.h index 62be527..8ab897f 100644 --- a/src/eventthread.h +++ b/src/eventthread.h @@ -66,7 +66,7 @@ public: // mouse wheel support for sunshine bool wheelFlipped; - int wheelX, wheelY; + float wheelX, wheelY; }; struct FingerState{ diff --git a/src/input.cpp b/src/input.cpp index b506770..ff597b5 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -280,7 +280,7 @@ static const Input::ButtonCode otherDirs[4][3] = { // storing wheel as buffer cause yes. struct MouseFrameState { - int wheelX, wheelY; + float wheelX, wheelY; bool wheelFlipped; }; @@ -704,8 +704,8 @@ int Input::mouseY(){ } // wheel support :3 -int Input::wheelX() { return p->mouseWheelState.wheelX; } -int Input::wheelY() { return p->mouseWheelState.wheelY; } +float Input::wheelX() { return p->mouseWheelState.wheelX; } +float Input::wheelY() { return p->mouseWheelState.wheelY; } bool Input::wheelFlipped() { return p->mouseWheelState.wheelFlipped; } bool Input::hasQuit(){ diff --git a/src/input.h b/src/input.h index 78fadc0..c2984ef 100644 --- a/src/input.h +++ b/src/input.h @@ -63,8 +63,8 @@ public: int mouseY(); // more non-standard extensions - int wheelX(); - int wheelY(); + float wheelX(); + float wheelY(); bool wheelFlipped(); bool hasQuit();