diff --git a/binding-mri/input-binding.cpp b/binding-mri/input-binding.cpp index a2838e8..ead73fc 100644 --- a/binding-mri/input-binding.cpp +++ b/binding-mri/input-binding.cpp @@ -93,6 +93,22 @@ RB_METHOD(inputMouseY){ return rb_fix_new(shState->input().mouseY()); } +// wheel :3 +RB_METHOD(inputWheelX) { + RB_UNUSED_PARAM; + return rb_fix_new(shState->input().wheelX()); +} + +RB_METHOD(inputWheelY) { + RB_UNUSED_PARAM; + return rb_fix_new(shState->input().wheelY()); +} + +RB_METHOD(inputWheelFlipped) { + RB_UNUSED_PARAM; + return rb_bool_new(shState->input().wheelFlipped()); +} + RB_METHOD(inputQuit){ RB_UNUSED_PARAM; return rb_bool_new(shState->input().hasQuit()); @@ -148,6 +164,11 @@ void inputBindingInit(){ _rb_define_module_function(module, "mouse_x", inputMouseX); _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, "quit?", inputQuit); if (rgssVer >= 3){ diff --git a/make-oneshot-linux.sh b/make-oneshot-linux.sh old mode 100644 new mode 100755 index 93af95c..d8f2b78 --- a/make-oneshot-linux.sh +++ b/make-oneshot-linux.sh @@ -17,7 +17,7 @@ color_reset="\033[0m" # Reset Colors echo -e "${white}Compiling ${bold}SyngleChance v${linux_version} ${white}engine for Linux...${color_reset}\n" -cmake . -B build/ +cmake -DZLIB_LIBRARY=/usr/lib/libz.so . -B build/ cd build make -j${nproc} cd .. @@ -62,7 +62,6 @@ yes | cp build/oneshot build/bandle/Sunshine cp installer/installer.sh build/bandle/ cp -r ../SunshineAssets/* build/bandle/Sunshine -cp assets/oneshot.png build/bandle/Sunshine cd build zip -r OneshotSunshine.zip bandle/* diff --git a/scripts/Window_Settings.rb b/scripts/Window_Settings.rb index 9eb78a2..a95e382 100644 --- a/scripts/Window_Settings.rb +++ b/scripts/Window_Settings.rb @@ -350,6 +350,15 @@ 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 + $game_system.se_play($data_system.cursor_se) + end + if Input.trigger?(Input::UP) @index = (@index - 1) % @data.size $game_system.se_play($data_system.cursor_se) diff --git a/src/eventthread.cpp b/src/eventthread.cpp index 0fc1577..becc5f1 100644 --- a/src/eventthread.cpp +++ b/src/eventthread.cpp @@ -430,6 +430,15 @@ void EventThread::process(RGSSThreadData &rtData){ updateCursorState(cursorInWindow, gameScreen); break; + // more mouse support for sunshine :3c + 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; + } + break; + case SDL_EVENT_FINGER_DOWN : i = event.tfinger.fingerID; touchState.fingers[i].down = true; diff --git a/src/eventthread.h b/src/eventthread.h index 5e1bf97..62be527 100644 --- a/src/eventthread.h +++ b/src/eventthread.h @@ -63,6 +63,10 @@ public: int x, y; bool inWindow; bool buttons[32]; + + // mouse wheel support for sunshine + bool wheelFlipped; + int wheelX, wheelY; }; struct FingerState{ diff --git a/src/input.cpp b/src/input.cpp index cc72273..b506770 100644 --- a/src/input.cpp +++ b/src/input.cpp @@ -278,6 +278,12 @@ static const Input::ButtonCode otherDirs[4][3] = { { Input::Left, Input::Right, Input::Up } /* Up */ }; +// storing wheel as buffer cause yes. +struct MouseFrameState { + int wheelX, wheelY; + bool wheelFlipped; +}; + struct InputPrivate { std::vector kbStatBindings; std::vector kbBindings; @@ -310,6 +316,7 @@ struct InputPrivate { int active; } dir8Data; + MouseFrameState mouseWheelState; InputPrivate(const RGSSThreadData &rtData){ initStaticKbBindings(); @@ -335,6 +342,8 @@ struct InputPrivate { dir8Data.active = 0; triedExit = false; + + mouseWheelState = { 0, 0 }; } inline ButtonState &getStateCheck(int code){ @@ -615,6 +624,17 @@ void Input::update(){ p->swapBuffers(); p->clearBuffer(); + // updating mouse wheel state + { + p->mouseWheelState.wheelFlipped = EventThread::mouseState.wheelFlipped; + p->mouseWheelState.wheelX = EventThread::mouseState.wheelX; + p->mouseWheelState.wheelY = EventThread::mouseState.wheelY; + + EventThread::mouseState.wheelFlipped = false; + EventThread::mouseState.wheelX = 0; + EventThread::mouseState.wheelY = 0; + } + ButtonCode repeatCand = None; /* Poll all bindings */ @@ -683,6 +703,11 @@ int Input::mouseY(){ return (EventThread::mouseState.y - rtData.screenOffset.y) * rtData.sizeResoRatio.y; } +// wheel support :3 +int Input::wheelX() { return p->mouseWheelState.wheelX; } +int Input::wheelY() { return p->mouseWheelState.wheelY; } +bool Input::wheelFlipped() { return p->mouseWheelState.wheelFlipped; } + bool Input::hasQuit(){ return p->triedExit; } diff --git a/src/input.h b/src/input.h index 8b454dc..78fadc0 100644 --- a/src/input.h +++ b/src/input.h @@ -62,6 +62,11 @@ public: int mouseX(); int mouseY(); + // more non-standard extensions + int wheelX(); + int wheelY(); + bool wheelFlipped(); + bool hasQuit(); private: