Add capture mouse option, patch #860831

Uses Ctrl m to toggle, since that is closest to original games.
Disabled by default.

svn-id: r11680
This commit is contained in:
Travis Howell 2003-12-16 09:58:21 +00:00
parent 83e9c59327
commit 6f6675ed8b
2 changed files with 16 additions and 2 deletions

View File

@ -635,6 +635,12 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
return true; return true;
} }
#else #else
// Ctrl-b toggles mouse capture
if (b == KBD_CTRL && ev.key.keysym.sym == 'm') {
property(PROP_TOGGLE_MOUSE_GRAB, NULL);
break;
}
// Ctrl-z and Alt-X quit // Ctrl-z and Alt-X quit
if ((b == KBD_CTRL && ev.key.keysym.sym == 'z') || (b == KBD_ALT && ev.key.keysym.sym == 'x')) { if ((b == KBD_CTRL && ev.key.keysym.sym == 'z') || (b == KBD_ALT && ev.key.keysym.sym == 'x')) {
event->event_code = EVENT_QUIT; event->event_code = EVENT_QUIT;
@ -642,7 +648,7 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
} }
#endif #endif
// Ctr-Alt-<key> will change the GFX mode // Ctrl-Alt-<key> will change the GFX mode
if ((b & (KBD_CTRL|KBD_ALT)) == (KBD_CTRL|KBD_ALT)) { if ((b & (KBD_CTRL|KBD_ALT)) == (KBD_CTRL|KBD_ALT)) {
static const int gfxModes[][4] = { static const int gfxModes[][4] = {
{ GFX_NORMAL, GFX_DOUBLESIZE, GFX_TRIPLESIZE, -1 }, { GFX_NORMAL, GFX_DOUBLESIZE, GFX_TRIPLESIZE, -1 },
@ -676,7 +682,7 @@ bool OSystem_SDL_Common::poll_event(Event *event) {
Property prop; Property prop;
int factor = _scaleFactor - 1; int factor = _scaleFactor - 1;
// Ctr-Alt-a toggles aspect ratio correction // Ctrl-Alt-a toggles aspect ratio correction
if (ev.key.keysym.sym == 'a') { if (ev.key.keysym.sym == 'a') {
property(PROP_TOGGLE_ASPECT_RATIO, NULL); property(PROP_TOGGLE_ASPECT_RATIO, NULL);
break; break;
@ -1020,6 +1026,13 @@ uint32 OSystem_SDL_Common::property(int param, Property *value) {
case PROP_GET_SAMPLE_RATE: case PROP_GET_SAMPLE_RATE:
return SAMPLES_PER_SEC; return SAMPLES_PER_SEC;
case PROP_TOGGLE_MOUSE_GRAB:
if (SDL_WM_GrabInput(SDL_GRAB_QUERY) == SDL_GRAB_OFF)
SDL_WM_GrabInput(SDL_GRAB_ON);
else
SDL_WM_GrabInput(SDL_GRAB_OFF);
break;
} }
return 0; return 0;

View File

@ -98,6 +98,7 @@ public:
PROP_GET_FMOPL_ENV_BITS, PROP_GET_FMOPL_ENV_BITS,
PROP_GET_FMOPL_EG_ENT, PROP_GET_FMOPL_EG_ENT,
PROP_TOGGLE_ASPECT_RATIO, PROP_TOGGLE_ASPECT_RATIO,
PROP_TOGGLE_MOUSE_GRAB,
PROP_WANT_RECT_OPTIM PROP_WANT_RECT_OPTIM
}; };
union Property { union Property {