|
|
1.1 root 1: /* 1.1.1.5 ! root 2: Hatari - shortcut.c ! 3: ! 4: This file is distributed under the GNU Public License, version 2 or at ! 5: your option any later version. Read the file gpl.txt for details. 1.1 root 6: 7: Shortcut keys 8: */ 1.1.1.5 ! root 9: char ShortCut_rcsid[] = "Hatari $Id: shortcut.c,v 1.18 2004/06/24 14:52:57 thothy Exp $"; 1.1 root 10: 1.1.1.2 root 11: #include <SDL.h> 12: 1.1 root 13: #include "main.h" 14: #include "dialog.h" 15: #include "audio.h" 16: #include "joy.h" 1.1.1.5 ! root 17: #include "m68000.h" 1.1 root 18: #include "memAlloc.h" 19: #include "memorySnapShot.h" 20: #include "reset.h" 21: #include "screen.h" 22: #include "screenSnapShot.h" 23: #include "shortcut.h" 24: #include "sound.h" 1.1.1.2 root 25: 26: 1.1 root 27: SHORTCUT_KEY ShortCutKey; 28: 1.1.1.4 root 29: 1.1.1.2 root 30: /*-----------------------------------------------------------------------*/ 1.1 root 31: /* 32: Shortcut to toggle full-screen 33: */ 1.1.1.5 ! root 34: static void ShortCut_FullScreen(void) 1.1 root 35: { 1.1.1.4 root 36: if(!bInFullScreen) 37: { 38: Screen_EnterFullScreen(); 39: } 40: else 41: { 42: Screen_ReturnFromFullScreen(); 1.1 root 43: } 44: } 45: 1.1.1.4 root 46: 47: /*-----------------------------------------------------------------------*/ 1.1 root 48: /* 49: Shortcut to toggle mouse mode 50: */ 1.1.1.5 ! root 51: static void ShortCut_MouseMode(void) 1.1 root 52: { 1.1.1.4 root 53: bGrabMouse = !bGrabMouse; /* Toggle flag */ 1.1 root 54: 1.1.1.4 root 55: /* If we are in windowed mode, toggle the mouse cursor mode now: */ 56: if(!bInFullScreen) 57: { 58: if(bGrabMouse) 59: { 60: SDL_WM_GrabInput(SDL_GRAB_ON); 1.1 root 61: } 62: else 1.1.1.4 root 63: { 64: SDL_WM_GrabInput(SDL_GRAB_OFF); 65: } 1.1 root 66: } 67: } 68: 1.1.1.4 root 69: 1.1.1.5 ! root 70: /*-----------------------------------------------------------------------*/ 1.1 root 71: /* 72: Shortcut to toggle YM/WAV sound recording 73: */ 1.1.1.5 ! root 74: static void ShortCut_RecordSound(void) 1.1 root 75: { 1.1.1.5 ! root 76: /* Is working? */ ! 77: if (bSoundWorking) ! 78: { ! 79: /* Are we currently recording? If so stop */ ! 80: if (Sound_AreWeRecording()) ! 81: { ! 82: /* Stop, and save */ ! 83: Sound_EndRecording(); 1.1 root 84: } 1.1.1.5 ! root 85: else ! 86: { ! 87: /* Begin recording */ ! 88: Sound_BeginRecording(ConfigureParams.Sound.szYMCaptureFileName); 1.1 root 89: } 90: } 91: } 92: 1.1.1.5 ! root 93: ! 94: /*-----------------------------------------------------------------------*/ 1.1 root 95: /* 96: Shortcut to toggle screen animation recording 97: */ 1.1.1.5 ! root 98: static void ShortCut_RecordAnimation(void) 1.1 root 99: { 1.1.1.5 ! root 100: /* Are we currently recording? If so stop */ ! 101: if (ScreenSnapShot_AreWeRecording()) ! 102: { ! 103: /* Stop */ ! 104: ScreenSnapShot_EndRecording(); ! 105: } ! 106: else ! 107: { ! 108: /* Start animation */ ! 109: ScreenSnapShot_BeginRecording(ConfigureParams.Screen.bCaptureChange, ConfigureParams.Screen.nFramesPerSecond); 1.1 root 110: } 111: } 112: 1.1.1.4 root 113: 114: /*-----------------------------------------------------------------------*/ 1.1 root 115: /* 116: Shortcut to toggle joystick cursor emulation 117: */ 1.1.1.5 ! root 118: static void ShortCut_JoystickCursorEmulation(void) 1.1 root 119: { 1.1.1.4 root 120: /* Toggle it on/off */ 1.1 root 121: Joy_ToggleCursorEmulation(); 122: } 123: 1.1.1.4 root 124: 1.1.1.5 ! root 125: /*-----------------------------------------------------------------------*/ 1.1 root 126: /* 127: Shortcut to sound on/off 128: */ 1.1.1.5 ! root 129: static void ShortCut_SoundOnOff(void) 1.1 root 130: { 1.1.1.5 ! root 131: /* Toggle sound on/off */ 1.1 root 132: ConfigureParams.Sound.bEnableSound ^= TRUE; 1.1.1.5 ! root 133: /* And start/stop if need to */ ! 134: if (!ConfigureParams.Sound.bEnableSound) ! 135: { 1.1 root 136: if (Sound_AreWeRecording()) 1.1.1.5 ! root 137: Sound_EndRecording(); ! 138: Audio_UnInit(); 1.1 root 139: } 140: else 1.1.1.5 ! root 141: { ! 142: Audio_Init(); ! 143: } 1.1 root 144: } 145: 1.1.1.5 ! root 146: ! 147: /*-----------------------------------------------------------------------*/ 1.1 root 148: /* 149: Shortcut to maximum speed 150: */ 1.1.1.5 ! root 151: static void ShortCut_MaximumSpeed(void) 1.1 root 152: { 1.1.1.5 ! root 153: /* If already on max speed, switch back to normal */ ! 154: if (ConfigureParams.System.nMinMaxSpeed == MINMAXSPEED_MAX) ! 155: { ! 156: /* Restore */ ! 157: ConfigureParams.System.nMinMaxSpeed = MINMAXSPEED_MIN; ! 158: ! 159: /* Reset the sound emulation variables: */ ! 160: Sound_Reset(); 1.1 root 161: } 1.1.1.5 ! root 162: else ! 163: { ! 164: /* Set maximum speed */ ! 165: ConfigureParams.System.nMinMaxSpeed = MINMAXSPEED_MAX; 1.1 root 166: } 167: } 168: 1.1.1.5 ! root 169: ! 170: /*-----------------------------------------------------------------------*/ 1.1 root 171: /* 172: Shortcut to 'Boss' key, ie minmize Window and switch to another application 173: */ 1.1.1.5 ! root 174: static void ShortCut_BossKey(void) 1.1 root 175: { 1.1.1.5 ! root 176: /* If we are in full-screen, then return to a window */ 1.1 root 177: Screen_ReturnFromFullScreen(); 1.1.1.5 ! root 178: ! 179: if(bGrabMouse) ! 180: { ! 181: SDL_WM_GrabInput(SDL_GRAB_OFF); ! 182: bGrabMouse = FALSE; ! 183: } ! 184: ! 185: /* Minimize Window and give up processing to next one! */ ! 186: SDL_WM_IconifyWindow(); 1.1 root 187: } 188: 1.1.1.4 root 189: 190: /*-----------------------------------------------------------------------*/ 1.1 root 191: /* 192: Shortcut to 'Cold' reset 193: */ 1.1.1.5 ! root 194: static void ShortCut_ColdReset(void) 1.1 root 195: { 1.1.1.2 root 196: Reset_Cold(); /* Reset emulator with 'cold' (clear all) */ 1.1 root 197: } 198: 1.1.1.4 root 199: 200: /*-----------------------------------------------------------------------*/ 1.1 root 201: /* 202: Shortcut to 'Warm' reset 203: */ 1.1.1.5 ! root 204: static void ShortCut_WarmReset(void) 1.1 root 205: { 1.1.1.2 root 206: Reset_Warm(); /* Emulator 'warm' reset */ 1.1 root 207: } 1.1.1.5 ! root 208: ! 209: ! 210: /*-----------------------------------------------------------------------*/ ! 211: /* ! 212: Clear shortkey structure ! 213: */ ! 214: static void ShortCut_ClearKeys(void) ! 215: { ! 216: /* Clear short-cut key structure */ ! 217: Memory_Clear(&ShortCutKey,sizeof(SHORTCUT_KEY)); ! 218: } ! 219: ! 220: ! 221: /*-----------------------------------------------------------------------*/ ! 222: /* ! 223: Check to see if pressed any shortcut keys, and call handling function ! 224: */ ! 225: void ShortCut_CheckKeys(void) ! 226: { ! 227: /* Check for supported keys: */ ! 228: switch(ShortCutKey.Key) ! 229: { ! 230: case SDLK_F11: /* Switch between fullscreen/windowed mode */ ! 231: ShortCut_FullScreen(); ! 232: break; ! 233: case SDLK_F12: /* Show options dialog */ ! 234: Dialog_DoProperty(); ! 235: break; ! 236: case SDLK_a: /* Record animation */ ! 237: ShortCut_RecordAnimation(); ! 238: break; ! 239: case SDLK_c: /* Cold reset */ ! 240: ShortCut_ColdReset(); ! 241: break; ! 242: case SDLK_g: /* Grab screenshot */ ! 243: ScreenSnapShot_SaveScreen(); ! 244: break; ! 245: case SDLK_i: /* Boss key */ ! 246: ShortCut_BossKey (); ! 247: break; ! 248: case SDLK_j: /* Toggle cursor-joystick emulation */ ! 249: ShortCut_JoystickCursorEmulation(); ! 250: break; ! 251: case SDLK_m: /* Toggle mouse mode */ ! 252: ShortCut_MouseMode(); ! 253: break; ! 254: case SDLK_r: /* Warm reset */ ! 255: ShortCut_WarmReset(); ! 256: break; ! 257: case SDLK_s: /* Enable/disable sound */ ! 258: ShortCut_SoundOnOff(); ! 259: break; ! 260: case SDLK_q: /* Quit program */ ! 261: bQuitProgram = TRUE; ! 262: set_special(SPCFLAG_BRK); ! 263: break; ! 264: case SDLK_x: /* Toggle Min/Max speed */ ! 265: ShortCut_MaximumSpeed(); ! 266: break; ! 267: case SDLK_y: /* Toggle sound recording */ ! 268: ShortCut_RecordSound(); ! 269: break; ! 270: } ! 271: ! 272: /* And clear */ ! 273: ShortCut_ClearKeys(); ! 274: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.