|
|
1.1 ! root 1: /* ! 2: Hatari ! 3: ! 4: Shortcut keys ! 5: */ ! 6: ! 7: #include <SDL.h> ! 8: ! 9: #include "main.h" ! 10: #include "audio.h" ! 11: #include "screen.h" ! 12: #include "shortcut.h" ! 13: #include "hostcall.h" ! 14: #include "../m68000.h" ! 15: ! 16: ! 17: /* List of possible short-cuts(MUST match SHORTCUT_xxxx) */ ! 18: char *pszShortCutTextStrings[NUM_SHORTCUTS+1] = { ! 19: "(not assigned)", ! 20: "Full Screen", ! 21: "Mouse Mode", ! 22: NULL /*term*/ ! 23: }; ! 24: ! 25: char *pszShortCutF11TextString[] = { ! 26: "Full Screen", ! 27: NULL /*term*/ ! 28: }; ! 29: ! 30: char *pszShortCutF12TextString[] = { ! 31: "Mouse Mode", ! 32: NULL /*term*/ ! 33: }; ! 34: ! 35: ShortCutFunction_t pShortCutFunctions[NUM_SHORTCUTS] = { ! 36: NULL, ! 37: ShortCut_FullScreen, ! 38: ShortCut_MouseMode, ! 39: }; ! 40: ! 41: SHORTCUT_KEY ShortCutKey; ! 42: ! 43: /*-----------------------------------------------------------------------*/ ! 44: /* ! 45: Clear shortkey structure ! 46: */ ! 47: void ShortCut_ClearKeys(void) ! 48: { ! 49: /* Clear short-cut key structure */ ! 50: memset (&ShortCutKey,0, sizeof(SHORTCUT_KEY)); ! 51: } ! 52: ! 53: /*-----------------------------------------------------------------------*/ ! 54: /* ! 55: Check to see if pressed any shortcut keys, and call handling function ! 56: */ ! 57: void ShortCut_CheckKeys(void) ! 58: { ! 59: /* Check for supported keys: */ ! 60: switch(ShortCutKey.Key) { ! 61: case SDLK_F11: /* Switch between fullscreen/windowed mode */ ! 62: ShortCut_FullScreen(); ! 63: break; ! 64: case SDLK_m: /* Toggle mouse mode */ ! 65: ShortCut_MouseMode(); ! 66: break; ! 67: case SDLK_q: /* Quit program */ ! 68: SDL_Quit (); ! 69: exit (0); ! 70: bQuitProgram = TRUE; ! 71: break; ! 72: case SDLK_d: ! 73: Call_DumpDebug (); ! 74: break; ! 75: case SDLK_e: ! 76: Screen_ToggleRenderer (); ! 77: break; ! 78: } ! 79: ! 80: /* And clear */ ! 81: ShortCut_ClearKeys(); ! 82: } ! 83: ! 84: ! 85: /*-----------------------------------------------------------------------*/ ! 86: /* ! 87: Shortcut to toggle full-screen ! 88: */ ! 89: void ShortCut_FullScreen(void) ! 90: { ! 91: Screen_ToggleFullScreen (); ! 92: } ! 93: ! 94: ! 95: /*-----------------------------------------------------------------------*/ ! 96: /* ! 97: Shortcut to toggle mouse mode ! 98: */ ! 99: void ShortCut_MouseMode(void) ! 100: { ! 101: bGrabMouse = !bGrabMouse; /* Toggle flag */ ! 102: ! 103: if(!bInFullScreen) ! 104: { ! 105: if(bGrabMouse) ! 106: { ! 107: SDL_WM_GrabInput(SDL_GRAB_ON); ! 108: } ! 109: else ! 110: { ! 111: SDL_WM_GrabInput(SDL_GRAB_OFF); ! 112: } ! 113: } ! 114: } ! 115: ! 116:
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.