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