Add an option to trap mouse within window/display area.

This commit is contained in:
LunaMoo committed 2017-04-27 16:29:08 +02:00
1 parent a9d9063680
commit 26006e9d80
4 files changed
+11

No files matched your search

+1
View File
@@ -697,6 +697,7 @@ static ConfigSetting controlSettings[] = {
ConfigSetting("UseMouse", &g_Config.bMouseControl, false, true, true),
ConfigSetting("MapMouse", &g_Config.bMapMouse, false, true, true),
ConfigSetting("ConfineMap", &g_Config.bMouseConfine, false, true, true),
ConfigSetting("MouseSensitivity", &g_Config.fMouseSensitivity, 0.1, true, true),
ConfigSetting("MouseSmoothing", &g_Config.fMouseSmoothing, 0.9, true, true),
+1
View File
@@ -395,6 +395,7 @@ public:
bool bMouseControl;
bool bMapMouse; // Workaround for mapping screen:|
bool bMouseConfine; // Trap inside the window.
float fMouseSensitivity;
float fMouseSmoothing;
+1
View File
@@ -583,6 +583,7 @@ void GameSettingsScreen::CreateViews() {
settingInfo_->Show(co->T("MouseControl Tip", "You can now map mouse in control mapping screen by pressing the 'M' icon."), e.v);
return UI::EVENT_CONTINUE;
});
controlsSettings->Add(new CheckBox(&g_Config.bMouseConfine, co->T("Confine Mouse", "Trap mouse within window/display area")));
controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMouseSensitivity, 0.01f, 1.0f, co->T("Mouse sensitivity"), 0.01f, screenManager(), "x"));
controlsSettings->Add(new PopupSliderChoiceFloat(&g_Config.fMouseSmoothing, 0.0f, 0.95f, co->T("Mouse smoothing"), 0.05f, screenManager(), "x"));
#endif
+8
View File
@@ -233,12 +233,20 @@ namespace MainWindow
while (cursorCounter >= 0) {
cursorCounter = ShowCursor(FALSE);
}
if (g_Config.bMouseConfine) {
RECT rc;
GetClientRect(hwndDisplay, &rc);
ClientToScreen(hwndDisplay, reinterpret_cast<POINT*>(&rc.left));
ClientToScreen(hwndDisplay, reinterpret_cast<POINT*>(&rc.right));
ClipCursor(&rc);
}
} else {
hideCursor = !autoHide;
if (cursorCounter < 0) {
cursorCounter = ShowCursor(TRUE);
SetCursor(LoadCursor(NULL, IDC_ARROW));
}
ClipCursor(NULL);
}
}