Gtk: Get Superscope working.

This commit is contained in:
BearOso 2024-10-12 17:05:26 -05:00
parent 8028d3b6ca
commit b19e31c83f
2 changed files with 28 additions and 2 deletions

View File

@ -721,9 +721,15 @@ void Snes9xConfig::rebind_keys()
cmd = S9xGetPortCommandT("{Mouse1 L,Superscope Fire,Justifier1 Trigger}"); cmd = S9xGetPortCommandT("{Mouse1 L,Superscope Fire,Justifier1 Trigger}");
S9xMapButton(BINDING_MOUSE_BUTTON0, cmd, false); S9xMapButton(BINDING_MOUSE_BUTTON0, cmd, false);
cmd = S9xGetPortCommandT("{Justifier1 AimOffscreen Trigger,Superscope AimOffscreen}"); cmd = S9xGetPortCommandT("Superscope ToggleTurbo");
S9xMapButton(BINDING_MOUSE_BUTTON1, cmd, false); 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); 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);
} }

View File

@ -139,8 +139,28 @@ bool S9xPollAxis(uint32 id, int16 *value)
return true; 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) 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; *x = top_level->snes_mouse_x;
*y = top_level->snes_mouse_y; *y = top_level->snes_mouse_y;