From 51ab709da7bb6455764eff5406bd06f650095f1f Mon Sep 17 00:00:00 2001 From: kichikuou Date: Tue, 4 Nov 2025 10:17:30 +0900 Subject: [PATCH] Advance messages by scrolling mouse wheel down Now the 'A' command accepts mouse wheel down events in addition to keyboard and mouse buttons. --- src/sys/nact.cpp | 4 +++- src/sys/nact.h | 1 + src/sys/nact_input.cpp | 13 ++++++++++++- 3 files changed, 16 insertions(+), 2 deletions(-) diff --git a/src/sys/nact.cpp b/src/sys/nact.cpp index e010b4d..fb11295 100644 --- a/src/sys/nact.cpp +++ b/src/sys/nact.cpp @@ -410,12 +410,14 @@ void NACT::cmd_a() ags->draw_push(text_window); } + get_wheel(); // clear wheel input + // キーが押されて離されるまで待機 while (!msgskip->skipping()) { if(terminate) { return; } - if(get_key()) { + if (get_key() || get_wheel() < 0) { break; } sys_sleep(16); diff --git a/src/sys/nact.h b/src/sys/nact.h index d5bf4ef..d73fd0d 100644 --- a/src/sys/nact.h +++ b/src/sys/nact.h @@ -149,6 +149,7 @@ protected: uint8 get_key(); void get_cursor(int* x, int* y); void set_cursor(int x, int y); + int get_wheel(); SDL_GameController *sdl_gamecontroller = NULL; diff --git a/src/sys/nact_input.cpp b/src/sys/nact_input.cpp index cd8c7ee..8c95d7c 100644 --- a/src/sys/nact_input.cpp +++ b/src/sys/nact_input.cpp @@ -21,7 +21,7 @@ enum TouchState { }; extern SDL_Window* g_window; -static int mousex, mousey; +static int mousex, mousey, wheel; static TouchState touch_state = TOUCH_NONE; void NACT::handle_event(SDL_Event e) @@ -47,6 +47,10 @@ void NACT::handle_event(SDL_Event e) mousey = e.motion.y * ags->screen_height / ags->window_height; break; + case SDL_MOUSEWHEEL: + wheel += e.wheel.y * (e.wheel.direction == SDL_MOUSEWHEEL_FLIPPED ? -1 : 1); + break; + case SDL_FINGERDOWN: case SDL_FINGERUP: case SDL_FINGERMOTION: @@ -154,6 +158,13 @@ void NACT::set_cursor(int x, int y) SDL_WarpMouseInWindow(g_window, x, y); } +int NACT::get_wheel() +{ + int val = wheel; + wheel = 0; + return val; +} + void NACT::show_quit_dialog() { const SDL_MessageBoxButtonData buttons[] = {