|
|
1.1 root 1: /*
2: Hatari
3:
4: Shortcut keys
5: */
6:
1.1.1.2 root 7: #include <SDL.h>
8:
1.1 root 9: #include "main.h"
10: #include "dialog.h"
11: #include "audio.h"
12: #include "joy.h"
13: #include "memAlloc.h"
14: #include "memorySnapShot.h"
15: #include "reset.h"
16: #include "screen.h"
17: #include "screenSnapShot.h"
18: #include "shortcut.h"
19: #include "sound.h"
1.1.1.2 root 20:
21:
22:
23: /* List of possible short-cuts(MUST match SHORTCUT_xxxx) */
1.1 root 24: char *pszShortCutTextStrings[NUM_SHORTCUTS+1] = {
25: "(not assigned)",
26: "Full Screen",
27: "Mouse Mode",
28: "Record YM/WAV",
29: "Record Animation",
30: "Joystick Emulation",
31: "Sound On/Off",
32: "Maximum Speed",
33: "'Cold' Reset",
34: "'Warm' Reset",
35: "'Boss' Key",
1.1.1.3 root 36: NULL /*term*/
1.1 root 37: };
38:
39: char *pszShortCutF11TextString[] = {
40: "Full Screen",
1.1.1.3 root 41: NULL /*term*/
1.1 root 42: };
43:
44: char *pszShortCutF12TextString[] = {
45: "Mouse Mode",
1.1.1.3 root 46: NULL /*term*/
1.1 root 47: };
48:
49: ShortCutFunction_t pShortCutFunctions[NUM_SHORTCUTS] = {
50: NULL,
51: ShortCut_FullScreen,
52: ShortCut_MouseMode,
53: ShortCut_RecordSound,
54: ShortCut_RecordAnimation,
55: ShortCut_JoystickCursorEmulation,
56: ShortCut_SoundOnOff,
57: ShortCut_MaximumSpeed,
58: ShortCut_ColdReset,
59: ShortCut_WarmReset,
60: ShortCut_BossKey
61: };
62:
63: SHORTCUT_KEY ShortCutKey;
64:
1.1.1.2 root 65: /*-----------------------------------------------------------------------*/
1.1 root 66: /*
67: Clear shortkey structure
68: */
69: void ShortCut_ClearKeys(void)
70: {
1.1.1.2 root 71: /* Clear short-cut key structure */
1.1 root 72: Memory_Clear(&ShortCutKey,sizeof(SHORTCUT_KEY));
73: }
74:
1.1.1.2 root 75: /*-----------------------------------------------------------------------*/
1.1 root 76: /*
1.1.1.2 root 77: Check to see if pressed any shortcut keys, and call handling function
1.1 root 78: */
79: void ShortCut_CheckKeys(void)
80: {
1.1.1.4 ! root 81: /*ShortCutFunction_t pShortCutFunction;
! 82: int PressedKey=SHORT_CUT_NONE;*/
1.1 root 83:
1.1.1.2 root 84: /* Check for F11 or F12 */
85: /*
86: if (ShortCutKey.Key==SDLK_F11)
1.1 root 87: PressedKey = SHORT_CUT_F11;
1.1.1.2 root 88: else if (ShortCutKey.Key==SDLK_F12)
1.1 root 89: PressedKey = SHORT_CUT_F12;
1.1.1.2 root 90: */
1.1 root 91:
1.1.1.2 root 92: /* Check for supported keys: */
93: switch(ShortCutKey.Key) {
1.1.1.3 root 94: case SDLK_F12: /* Show options dialog */
95: Dialog_DoProperty();
1.1.1.2 root 96: break;
1.1.1.3 root 97: case SDLK_F11: /* Switch between fullscreen/windowed mode */
1.1.1.4 ! root 98: ShortCut_FullScreen();
1.1.1.3 root 99: break;
1.1.1.2 root 100: case SDLK_g: /* Grab screenshot */
101: ScreenSnapShot_SaveScreen();
102: break;
1.1.1.4 ! root 103: case SDLK_j: /* Toggle cursor-joystick emulation */
! 104: ShortCut_JoystickCursorEmulation();
! 105: break;
! 106: case SDLK_m: /* Toggle mouse mode */
! 107: ShortCut_MouseMode();
! 108: break;
1.1.1.2 root 109: case SDLK_r: /* Warm reset */
110: ShortCut_WarmReset();
111: break;
112: case SDLK_c: /* Cold reset */
113: ShortCut_ColdReset();
114: break;
1.1.1.4 ! root 115: case SDLK_q: /* Quit program */
! 116: bQuitProgram = TRUE;
! 117: break;
1.1.1.2 root 118: }
119:
120: /* Winston originally supported remapable shortcuts... perhaps we will do so, too, one day... */
121: /*
1.1 root 122: // Did press key?
123: if (PressedKey!=SHORT_CUT_NONE) {
124: // Find which short-cut to do, eg do have Ctrl or Shift held down?
125: if (ShortCutKey.bCtrlPressed)
126: pShortCutFunction = pShortCutFunctions[ ConfigureParams.Keyboard.ShortCuts[PressedKey][SHORT_CUT_CTRL] ];
127: else if (ShortCutKey.bShiftPressed) {
128: pShortCutFunction = pShortCutFunctions[ ConfigureParams.Keyboard.ShortCuts[PressedKey][SHORT_CUT_SHIFT] ];
129: // If we don't have a SHIFT short-cut assigned, set to normal key(to allow for SHIFT+F11 to bring up Floppy A)
130: if (pShortCutFunction==NULL)
131: pShortCutFunction = pShortCutFunctions[ ConfigureParams.Keyboard.ShortCuts[PressedKey][SHORT_CUT_KEY] ];
132: }
133: else
134: pShortCutFunction = pShortCutFunctions[ ConfigureParams.Keyboard.ShortCuts[PressedKey][SHORT_CUT_KEY] ];
135:
136: // And call short-cut, if have one
137: if (pShortCutFunction)
138: pShortCutFunction();
139: */
1.1.1.2 root 140: /* And clear */
141: ShortCut_ClearKeys();
142: /*}*/
143:
1.1 root 144: }
145:
1.1.1.4 ! root 146:
1.1.1.2 root 147: /*-----------------------------------------------------------------------*/
1.1 root 148: /*
149: Shortcut to toggle full-screen
150: */
151: void ShortCut_FullScreen(void)
152: {
1.1.1.4 ! root 153: if(!bInFullScreen)
! 154: {
! 155: Screen_EnterFullScreen();
! 156: }
! 157: else
! 158: {
! 159: Screen_ReturnFromFullScreen();
1.1 root 160: }
161: }
162:
1.1.1.4 ! root 163:
! 164: /*-----------------------------------------------------------------------*/
1.1 root 165: /*
166: Shortcut to toggle mouse mode
167: */
168: void ShortCut_MouseMode(void)
169: {
1.1.1.4 ! root 170: bGrabMouse = !bGrabMouse; /* Toggle flag */
1.1 root 171:
1.1.1.4 ! root 172: /* If we are in windowed mode, toggle the mouse cursor mode now: */
! 173: if(!bInFullScreen)
! 174: {
! 175: if(bGrabMouse)
! 176: {
! 177: SDL_WM_GrabInput(SDL_GRAB_ON);
1.1 root 178: }
179: else
1.1.1.4 ! root 180: {
! 181: SDL_WM_GrabInput(SDL_GRAB_OFF);
! 182: }
1.1 root 183: }
184: }
185:
1.1.1.4 ! root 186:
1.1 root 187: //-----------------------------------------------------------------------
188: /*
189: Shortcut to toggle YM/WAV sound recording
190: */
191: void ShortCut_RecordSound(void)
192: {
193: /* FIXME */
194: /*
195: // Is working?
1.1.1.2 root 196: if (bSoundWorking) {
1.1 root 197: // Are we currently recording? If so stop
198: if (Sound_AreWeRecording()) {
199: // Stop, and save
200: Sound_EndRecording(NULL);
201: }
202: else {
203: // Being recording
204: Sound_BeginRecording(NULL,ConfigureParams.Sound.szYMCaptureFileName);
205: }
206: }
207: */
208: }
209:
210: //-----------------------------------------------------------------------
211: /*
212: Shortcut to toggle screen animation recording
213: */
214: void ShortCut_RecordAnimation(void)
215: {
216: /* FIXME */
217: /*
218: // Are we in a Window?
219: if (!bInFullScreen) {
220: // Are we currently recording? If so stop
221: if (ScreenSnapShot_AreWeRecording()) {
222: // Stop
223: ScreenSnapShot_EndRecording(NULL);
224: }
225: else {
226: // Start animation
227: ScreenSnapShot_BeginRecording(NULL,ConfigureParams.Screen.bCaptureChange,ConfigureParams.Screen.nFramesPerSecond);
228: }
229: }
230: */
231: }
232:
1.1.1.4 ! root 233:
! 234: /*-----------------------------------------------------------------------*/
1.1 root 235: /*
236: Shortcut to toggle joystick cursor emulation
237: */
238: void ShortCut_JoystickCursorEmulation(void)
239: {
1.1.1.4 ! root 240: /* Toggle it on/off */
1.1 root 241: Joy_ToggleCursorEmulation();
242: }
243:
1.1.1.4 ! root 244:
1.1 root 245: //-----------------------------------------------------------------------
246: /*
247: Shortcut to sound on/off
248: */
249: void ShortCut_SoundOnOff(void)
250: {
251: /* FIXME */
252: /*
253: // Toggle sound on/off
254: ConfigureParams.Sound.bEnableSound ^= TRUE;
255: // And start/stop if need to
256: if (!ConfigureParams.Sound.bEnableSound) {
257: if (Sound_AreWeRecording())
258: Sound_EndRecording(NULL);
259: DAudio_StopBuffer();
260: }
261: else
262: DAudio_ResetBuffer();
263: */
264: }
265:
266: //-----------------------------------------------------------------------
267: /*
268: Shortcut to maximum speed
269: */
270: void ShortCut_MaximumSpeed(void)
271: {
272: /* FIXME */
273: /*
274: // If already on max speed, restore
275: if (ConfigureParams.Configure.nMinMaxSpeed==MINMAXSPEED_MAX) {
276: // Restore
277: ConfigureParams.Configure.nMinMaxSpeed = ConfigureParams.Configure.nPrevMinMaxSpeed;
278: }
279: else {
280: // Set maximum speed
281: ConfigureParams.Configure.nPrevMinMaxSpeed = ConfigureParams.Configure.nMinMaxSpeed;
282: ConfigureParams.Configure.nMinMaxSpeed = MINMAXSPEED_MAX;
283: }
284:
285: // Set new timer thread
286: Main_SetSpeedThreadTimer(ConfigureParams.Configure.nMinMaxSpeed);
287: */
288: }
289:
290: //-----------------------------------------------------------------------
291: /*
292: Shortcut to 'Boss' key, ie minmize Window and switch to another application
293: */
294: void ShortCut_BossKey(void)
295: {
296: /* FIXME */
297: /*
298: // If we are in full-screen, then return to a Window
299: Screen_ReturnFromFullScreen();
300: // Restore a few things
301: View_ToggleWindowsMouse(MOUSE_ST); // Put mouse into ST mode
302: View_LimitCursorToScreen(); // Free mouse from Window constraints
303: // Minimize Window and give up processing to next one!
304: ShowWindow(hWnd,SW_MINIMIZE);
305: */
306: }
307:
1.1.1.4 ! root 308:
! 309: /*-----------------------------------------------------------------------*/
1.1 root 310: /*
311: Shortcut to 'Cold' reset
312: */
313: void ShortCut_ColdReset(void)
314: {
1.1.1.2 root 315: Reset_Cold(); /* Reset emulator with 'cold' (clear all) */
1.1 root 316: }
317:
1.1.1.4 ! root 318:
! 319: /*-----------------------------------------------------------------------*/
1.1 root 320: /*
321: Shortcut to 'Warm' reset
322: */
323: void ShortCut_WarmReset(void)
324: {
1.1.1.2 root 325: Reset_Warm(); /* Emulator 'warm' reset */
1.1 root 326: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.