From b19e31c83ff9fb31aa2cd397f0a22a9ae3a58cc0 Mon Sep 17 00:00:00 2001 From: BearOso Date: Sat, 12 Oct 2024 17:05:26 -0500 Subject: [PATCH] Gtk: Get Superscope working. --- gtk/src/gtk_config.cpp | 10 ++++++++-- gtk/src/gtk_control.cpp | 20 ++++++++++++++++++++ 2 files changed, 28 insertions(+), 2 deletions(-) diff --git a/gtk/src/gtk_config.cpp b/gtk/src/gtk_config.cpp index cd3bfd40..df19a45b 100644 --- a/gtk/src/gtk_config.cpp +++ b/gtk/src/gtk_config.cpp @@ -721,9 +721,15 @@ void Snes9xConfig::rebind_keys() cmd = S9xGetPortCommandT("{Mouse1 L,Superscope Fire,Justifier1 Trigger}"); S9xMapButton(BINDING_MOUSE_BUTTON0, cmd, false); - cmd = S9xGetPortCommandT("{Justifier1 AimOffscreen Trigger,Superscope AimOffscreen}"); + cmd = S9xGetPortCommandT("Superscope ToggleTurbo"); S9xMapButton(BINDING_MOUSE_BUTTON1, cmd, false); - cmd = S9xGetPortCommandT("{Mouse1 R,Superscope Cursor,Justifier1 Start}"); + cmd = S9xGetPortCommandT("{Mouse1 R,Superscope Pause,Justifier1 Start}"); S9xMapButton(BINDING_MOUSE_BUTTON2, cmd, false); + + cmd = S9xGetPortCommandT("Superscope Cursor"); + S9xMapButton(BINDING_MOUSE_BUTTON0 + 7, cmd, false); + + cmd = S9xGetPortCommandT("{Superscope AimOffscreen,Justifier1 AimOffscreen}"); + S9xMapButton(BINDING_MOUSE_BUTTON0 + 8, cmd, false); } diff --git a/gtk/src/gtk_control.cpp b/gtk/src/gtk_control.cpp index 2f24b318..35695093 100644 --- a/gtk/src/gtk_control.cpp +++ b/gtk/src/gtk_control.cpp @@ -139,8 +139,28 @@ bool S9xPollAxis(uint32 id, int16 *value) return true; } +static bool using_superscope() +{ + for (int i = 0; i < 2; i++) + { + enum controllers ctl; + int8_t id1, id2, id3, id4; + S9xGetController(i, &ctl, &id1, &id2, &id3, &id4); + if (ctl == CTL_SUPERSCOPE) + return true; + } + + return false; +} + bool S9xPollPointer(uint32 id, int16 *x, int16 *y) { + if (using_superscope()) + { + top_level->snes_mouse_x = std::clamp(top_level->snes_mouse_x, 0.0, 256.0); + top_level->snes_mouse_y = std::clamp(top_level->snes_mouse_y, 0.0, 239.0); + } + *x = top_level->snes_mouse_x; *y = top_level->snes_mouse_y;