wheel support :3 (settings will be rewriten soon)

This commit is contained in:
meowtech 2026-05-26 10:31:36 +00:00
parent b2043bce59
commit 30ba0b2ae0
7 changed files with 74 additions and 2 deletions

View File

@ -93,6 +93,22 @@ RB_METHOD(inputMouseY){
return rb_fix_new(shState->input().mouseY()); 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_METHOD(inputQuit){
RB_UNUSED_PARAM; RB_UNUSED_PARAM;
return rb_bool_new(shState->input().hasQuit()); 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_x", inputMouseX);
_rb_define_module_function(module, "mouse_y", inputMouseY); _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); _rb_define_module_function(module, "quit?", inputQuit);
if (rgssVer >= 3){ if (rgssVer >= 3){

3
make-oneshot-linux.sh Normal file → Executable file
View File

@ -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" 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 cd build
make -j${nproc} make -j${nproc}
cd .. cd ..
@ -62,7 +62,6 @@ yes | cp build/oneshot build/bandle/Sunshine
cp installer/installer.sh build/bandle/ cp installer/installer.sh build/bandle/
cp -r ../SunshineAssets/* build/bandle/Sunshine cp -r ../SunshineAssets/* build/bandle/Sunshine
cp assets/oneshot.png build/bandle/Sunshine
cd build cd build
zip -r OneshotSunshine.zip bandle/* zip -r OneshotSunshine.zip bandle/*

View File

@ -350,6 +350,15 @@ class Window_Settings
end end
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) if Input.trigger?(Input::UP)
@index = (@index - 1) % @data.size @index = (@index - 1) % @data.size
$game_system.se_play($data_system.cursor_se) $game_system.se_play($data_system.cursor_se)

View File

@ -430,6 +430,15 @@ void EventThread::process(RGSSThreadData &rtData){
updateCursorState(cursorInWindow, gameScreen); updateCursorState(cursorInWindow, gameScreen);
break; 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 : case SDL_EVENT_FINGER_DOWN :
i = event.tfinger.fingerID; i = event.tfinger.fingerID;
touchState.fingers[i].down = true; touchState.fingers[i].down = true;

View File

@ -63,6 +63,10 @@ public:
int x, y; int x, y;
bool inWindow; bool inWindow;
bool buttons[32]; bool buttons[32];
// mouse wheel support for sunshine
bool wheelFlipped;
int wheelX, wheelY;
}; };
struct FingerState{ struct FingerState{

View File

@ -278,6 +278,12 @@ static const Input::ButtonCode otherDirs[4][3] = {
{ Input::Left, Input::Right, Input::Up } /* Up */ { Input::Left, Input::Right, Input::Up } /* Up */
}; };
// storing wheel as buffer cause yes.
struct MouseFrameState {
int wheelX, wheelY;
bool wheelFlipped;
};
struct InputPrivate { struct InputPrivate {
std::vector<KbBinding> kbStatBindings; std::vector<KbBinding> kbStatBindings;
std::vector<KbBinding> kbBindings; std::vector<KbBinding> kbBindings;
@ -310,6 +316,7 @@ struct InputPrivate {
int active; int active;
} dir8Data; } dir8Data;
MouseFrameState mouseWheelState;
InputPrivate(const RGSSThreadData &rtData){ InputPrivate(const RGSSThreadData &rtData){
initStaticKbBindings(); initStaticKbBindings();
@ -335,6 +342,8 @@ struct InputPrivate {
dir8Data.active = 0; dir8Data.active = 0;
triedExit = false; triedExit = false;
mouseWheelState = { 0, 0 };
} }
inline ButtonState &getStateCheck(int code){ inline ButtonState &getStateCheck(int code){
@ -615,6 +624,17 @@ void Input::update(){
p->swapBuffers(); p->swapBuffers();
p->clearBuffer(); 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; ButtonCode repeatCand = None;
/* Poll all bindings */ /* Poll all bindings */
@ -683,6 +703,11 @@ int Input::mouseY(){
return (EventThread::mouseState.y - rtData.screenOffset.y) * rtData.sizeResoRatio.y; 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(){ bool Input::hasQuit(){
return p->triedExit; return p->triedExit;
} }

View File

@ -62,6 +62,11 @@ public:
int mouseX(); int mouseX();
int mouseY(); int mouseY();
// more non-standard extensions
int wheelX();
int wheelY();
bool wheelFlipped();
bool hasQuit(); bool hasQuit();
private: private: