Made "middle button to untrap" configurable

It's now an option in the Misc panel, like in WinUAE. Defaults to enabled, like before.
This commit is contained in:
Dimitris Panokostas 2020-06-28 23:24:31 +02:00
parent 389ee9bd03
commit 7b6c194287
4 changed files with 26 additions and 9 deletions

View file

@ -1571,7 +1571,7 @@ int handle_msgpump()
break;
case SDL_FINGERDOWN:
setmousebuttonstate(0, 0, 0);
setmousebuttonstate(0, 0, 1);
break;
case SDL_MOUSEBUTTONDOWN:
@ -1599,8 +1599,10 @@ int handle_msgpump()
setmousebuttonstate(0, 1, 0);
if (event.button.button == SDL_BUTTON_MIDDLE)
{
setmousebuttonstate(0, 2, 0);
toggle_mouse_grab();
if (currprefs.input_mouse_untrap)
toggle_mouse_grab();
else
setmousebuttonstate(0, 2, 0);
}
}
break;

View file

@ -850,6 +850,11 @@ int check_prefs_changed_gfx()
currprefs.chipset_refreshrate = changed_prefs.chipset_refreshrate;
changed = 1;
}
if (currprefs.input_mouse_untrap != changed_prefs.input_mouse_untrap)
{
currprefs.input_mouse_untrap = changed_prefs.input_mouse_untrap;
changed = 1;
}
currprefs.filesys_limit = changed_prefs.filesys_limit;
currprefs.harddrive_read_only = changed_prefs.harddrive_read_only;

View file

@ -280,12 +280,13 @@ static NavigationMap navMap[] =
// active move left move right move up move down
{"StatusLine", "Miscellaneous", "RetroArchQuit", "cboScrolllock", "ShowGUI"},
{"ShowGUI", "Miscellaneous", "RetroArchMenu", "StatusLine", "BSDSocket"},
{"ShowGUI", "Miscellaneous", "RetroArchMenu", "StatusLine", "chkMouseUntrap"},
{"chkMouseUntrap", "Miscellaneous", "RetroArchReset", "ShowGUI", "BSDSocket"},
{"RetroArchQuit", "StatusLine", "Miscellaneous", "KeyForQuit", "RetroArchMenu"},
{"RetroArchMenu", "ShowGUI", "Miscellaneous", "RetroArchQuit", "RetroArchReset"},
{"RetroArchReset", "ShowGUI", "Miscellaneous", "RetroArchMenu", "BSDSocket"},
{"RetroArchReset", "chkMouseUntrap", "Miscellaneous", "RetroArchMenu", "BSDSocket"},
{"BSDSocket", "Miscellaneous", "Miscellaneous", "ShowGUI", "MasterWP"},
{"BSDSocket", "Miscellaneous", "Miscellaneous", "chkMouseUntrap", "MasterWP"},
{"MasterWP", "Miscellaneous", "Miscellaneous", "BSDSocket", "cboNumlock"},
{"cboNumlock", "Miscellaneous", "cboScrolllock", "MasterWP", "OpenGUI"},
{"cboScrolllock", "cboNumlock", "Miscellaneous", "MasterWP", "KeyForQuit"},

View file

@ -1,9 +1,8 @@
#include <string.h>
#include <cstring>
#include <guisan.hpp>
#include <SDL_ttf.h>
#include <guisan/sdl.hpp>
#include <guisan/sdl/sdltruetypefont.hpp>
#include "SelectorEntry.hpp"
#include "sysdeps.h"
@ -17,7 +16,7 @@ static gcn::CheckBox* chkRetroArchReset;
static gcn::CheckBox* chkStatusLine;
static gcn::CheckBox* chkShowGUI;
static gcn::CheckBox* chkMouseUntrap;
static gcn::CheckBox* chkBSDSocket;
static gcn::CheckBox* chkMasterWP;
@ -79,6 +78,9 @@ public:
else if (actionEvent.getSource() == chkShowGUI)
changed_prefs.start_gui = chkShowGUI->isSelected();
else if (actionEvent.getSource() == chkMouseUntrap)
changed_prefs.input_mouse_untrap = chkMouseUntrap->isSelected();
else if (actionEvent.getSource() == chkRetroArchQuit)
{
changed_prefs.use_retroarch_quit = chkRetroArchQuit->isSelected();
@ -173,6 +175,10 @@ void InitPanelMisc(const struct _ConfigCategory& category)
chkShowGUI->setId("ShowGUI");
chkShowGUI->addActionListener(miscActionListener);
chkMouseUntrap = new gcn::CheckBox("Untrap = middle button");
chkMouseUntrap->setId("chkMouseUntrap");
chkMouseUntrap->addActionListener(miscActionListener);
chkRetroArchQuit = new gcn::CheckBox("Use RetroArch Quit Button");
chkRetroArchQuit->setId("RetroArchQuit");
chkRetroArchQuit->addActionListener(miscActionListener);
@ -266,6 +272,7 @@ void InitPanelMisc(const struct _ConfigCategory& category)
posY += chkStatusLine->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(chkShowGUI, DISTANCE_BORDER, posY);
posY += chkShowGUI->getHeight() + DISTANCE_NEXT_Y;
category.panel->add(chkMouseUntrap, DISTANCE_BORDER, posY);
posY = DISTANCE_BORDER;
auto posX = 300;
@ -317,6 +324,7 @@ void ExitPanelMisc()
{
delete chkStatusLine;
delete chkShowGUI;
delete chkMouseUntrap;
delete chkRetroArchQuit;
delete chkRetroArchMenu;
@ -354,6 +362,7 @@ void RefreshPanelMisc()
{
chkStatusLine->setSelected(changed_prefs.leds_on_screen);
chkShowGUI->setSelected(changed_prefs.start_gui);
chkMouseUntrap->setSelected(changed_prefs.input_mouse_untrap);
chkRetroArchQuit->setSelected(changed_prefs.use_retroarch_quit);
chkRetroArchMenu->setSelected(changed_prefs.use_retroarch_menu);