|
|
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: {
81: ShortCutFunction_t pShortCutFunction;
82: int PressedKey=SHORT_CUT_NONE;
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.2 root 98: if( !bInFullScreen )
99: Screen_EnterFullScreen();
100: else
101: Screen_ReturnFromFullScreen();
102: break;
1.1.1.3 ! root 103: case SDLK_q: /* Quit program */
! 104: bQuitProgram = TRUE;
! 105: break;
1.1.1.2 root 106: case SDLK_g: /* Grab screenshot */
107: ScreenSnapShot_SaveScreen();
108: break;
109: case SDLK_r: /* Warm reset */
110: ShortCut_WarmReset();
111: break;
112: case SDLK_c: /* Cold reset */
113: ShortCut_ColdReset();
114: break;
115: }
116:
117: /* Winston originally supported remapable shortcuts... perhaps we will do so, too, one day... */
118: /*
1.1 root 119: // Did press key?
120: if (PressedKey!=SHORT_CUT_NONE) {
121: // Find which short-cut to do, eg do have Ctrl or Shift held down?
122: if (ShortCutKey.bCtrlPressed)
123: pShortCutFunction = pShortCutFunctions[ ConfigureParams.Keyboard.ShortCuts[PressedKey][SHORT_CUT_CTRL] ];
124: else if (ShortCutKey.bShiftPressed) {
125: pShortCutFunction = pShortCutFunctions[ ConfigureParams.Keyboard.ShortCuts[PressedKey][SHORT_CUT_SHIFT] ];
126: // If we don't have a SHIFT short-cut assigned, set to normal key(to allow for SHIFT+F11 to bring up Floppy A)
127: if (pShortCutFunction==NULL)
128: pShortCutFunction = pShortCutFunctions[ ConfigureParams.Keyboard.ShortCuts[PressedKey][SHORT_CUT_KEY] ];
129: }
130: else
131: pShortCutFunction = pShortCutFunctions[ ConfigureParams.Keyboard.ShortCuts[PressedKey][SHORT_CUT_KEY] ];
132:
133: // And call short-cut, if have one
134: if (pShortCutFunction)
135: pShortCutFunction();
136: */
1.1.1.2 root 137: /* And clear */
138: ShortCut_ClearKeys();
139: /*}*/
140:
1.1 root 141: }
142:
1.1.1.2 root 143: /*-----------------------------------------------------------------------*/
1.1 root 144: /*
145: Shortcut to toggle full-screen
146: */
147: void ShortCut_FullScreen(void)
148: {
149: /* FIXME */
150: /*
151: // Is working?
152: if (bDirectDrawWorking) {
153: // Toggle full screen
154: if (bInFullScreen) {
155: // Did hold down SHIFT? Bring up insert floppy dialog
156: if (ShortCutKey.bShiftPressed) {
157: // Flip to Windows full-screen GDI surface(or back to Windows if fails)
158: DSurface_FlipToGDI();
159:
160: // Open dialog(ignore SHIFT key)
161: PostMessage(hWnd,WM_COMMAND,ID_FLOPPYA_INSERTDISC,0);
162:
163: // Back if sent user to Windows
164: if (!bFullScreenHold) {
165: // Return back to full-screen
166: Screen_EnterFullScreen();
167: }
168: }
169: else
170: Screen_ReturnFromFullScreen();
171: }
172: else {
173: // Did hold down SHIFT? Bring up insert floppy dialog
174: if (ShortCutKey.bShiftPressed) {
175: // Back to Windows mouse
176: View_ToggleWindowsMouse(MOUSE_WINDOWS);
177: // Open dialog(ignore SHIFT key)
178: ToolBar_Activate_FloppyA(TRUE);
179: }
180: else {
181: // Just pressed F11, so go to full-screen
182: Screen_EnterFullScreen();
183: }
184: }
185: }
186: */
187: }
188:
189: //-----------------------------------------------------------------------
190: /*
191: Shortcut to toggle mouse mode
192: */
193: void ShortCut_MouseMode(void)
194: {
195: /* FIXME */
196: /*
197: if (bInFullScreen) {
198: // Were we in our full-screen menu/Windows mouse mode?
199: if (bFullScreenHold && bWindowsMouseMode) {
200: SetMenu(hWnd,NULL);
201: bFullScreenHold = FALSE; // Release screen hold
202:
203: View_ToggleWindowsMouse(MOUSE_ST);
204:
205: return;
206: }
207: else {
208: // Flip to Windows full-screen GDI surface(or back to Windows if fails)
209: if (DSurface_FlipToGDI()) {
210: // Did hold down SHIFT? Bring up insert floppy dialog
211: if (ShortCutKey.bShiftPressed) {
212: // Open dialog(ignore SHIFT key)
213: PostMessage(hWnd,WM_COMMAND,ID_FLOPPYB_INSERTDISC_NORESET,0);
214: }
215: }
216: }
217:
218: // Do need to return to Windows to handle F12? Ie, low resolution, or GDI flip failed?
219: if (!bFullScreenHold) {
220: Screen_ReturnFromFullScreen();
221:
222: // Did hold down SHIFT? Bring up insert floppy dialog
223: if (ShortCutKey.bShiftPressed) {
224: // Back to Windows mouse
225: View_ToggleWindowsMouse(MOUSE_WINDOWS);
226: // Open dialog(ignore SHIFT key)
227: ToolBar_Activate_FloppyB(TRUE);
228: // Return back to full-screen
229: Screen_EnterFullScreen();
230: }
231: else {
232: View_ToggleWindowsMouse(MOUSE_TOGGLE);
233: }
234: }
235: }
236: else {
237: // Did hold down SHIFT? Bring up insert floppy dialog
238: if (ShortCutKey.bShiftPressed) {
239: // Back to Windows mouse
240: View_ToggleWindowsMouse(MOUSE_WINDOWS);
241: // Open dialog(ignore SHIFT key)
242: ToolBar_Activate_FloppyB(TRUE);
243: }
244: else
245: View_ToggleWindowsMouse(MOUSE_TOGGLE);
246: }
247: */
248: }
249:
250: //-----------------------------------------------------------------------
251: /*
252: Shortcut to toggle YM/WAV sound recording
253: */
254: void ShortCut_RecordSound(void)
255: {
256: /* FIXME */
257: /*
258: // Is working?
1.1.1.2 root 259: if (bSoundWorking) {
1.1 root 260: // Are we currently recording? If so stop
261: if (Sound_AreWeRecording()) {
262: // Stop, and save
263: Sound_EndRecording(NULL);
264: }
265: else {
266: // Being recording
267: Sound_BeginRecording(NULL,ConfigureParams.Sound.szYMCaptureFileName);
268: }
269: }
270: */
271: }
272:
273: //-----------------------------------------------------------------------
274: /*
275: Shortcut to toggle screen animation recording
276: */
277: void ShortCut_RecordAnimation(void)
278: {
279: /* FIXME */
280: /*
281: // Are we in a Window?
282: if (!bInFullScreen) {
283: // Are we currently recording? If so stop
284: if (ScreenSnapShot_AreWeRecording()) {
285: // Stop
286: ScreenSnapShot_EndRecording(NULL);
287: }
288: else {
289: // Start animation
290: ScreenSnapShot_BeginRecording(NULL,ConfigureParams.Screen.bCaptureChange,ConfigureParams.Screen.nFramesPerSecond);
291: }
292: }
293: */
294: }
295:
296: //-----------------------------------------------------------------------
297: /*
298: Shortcut to toggle joystick cursor emulation
299: */
300: void ShortCut_JoystickCursorEmulation(void)
301: {
302: // Toggle it on/off
303: Joy_ToggleCursorEmulation();
304: }
305:
306: //-----------------------------------------------------------------------
307: /*
308: Shortcut to sound on/off
309: */
310: void ShortCut_SoundOnOff(void)
311: {
312: /* FIXME */
313: /*
314: // Toggle sound on/off
315: ConfigureParams.Sound.bEnableSound ^= TRUE;
316: // And start/stop if need to
317: if (!ConfigureParams.Sound.bEnableSound) {
318: if (Sound_AreWeRecording())
319: Sound_EndRecording(NULL);
320: DAudio_StopBuffer();
321: }
322: else
323: DAudio_ResetBuffer();
324: */
325: }
326:
327: //-----------------------------------------------------------------------
328: /*
329: Shortcut to maximum speed
330: */
331: void ShortCut_MaximumSpeed(void)
332: {
333: /* FIXME */
334: /*
335: // If already on max speed, restore
336: if (ConfigureParams.Configure.nMinMaxSpeed==MINMAXSPEED_MAX) {
337: // Restore
338: ConfigureParams.Configure.nMinMaxSpeed = ConfigureParams.Configure.nPrevMinMaxSpeed;
339: }
340: else {
341: // Set maximum speed
342: ConfigureParams.Configure.nPrevMinMaxSpeed = ConfigureParams.Configure.nMinMaxSpeed;
343: ConfigureParams.Configure.nMinMaxSpeed = MINMAXSPEED_MAX;
344: }
345:
346: // Set new timer thread
347: Main_SetSpeedThreadTimer(ConfigureParams.Configure.nMinMaxSpeed);
348: */
349: }
350:
351: //-----------------------------------------------------------------------
352: /*
353: Shortcut to 'Boss' key, ie minmize Window and switch to another application
354: */
355: void ShortCut_BossKey(void)
356: {
357: /* FIXME */
358: /*
359: // If we are in full-screen, then return to a Window
360: Screen_ReturnFromFullScreen();
361: // Restore a few things
362: View_ToggleWindowsMouse(MOUSE_ST); // Put mouse into ST mode
363: View_LimitCursorToScreen(); // Free mouse from Window constraints
364: // Minimize Window and give up processing to next one!
365: ShowWindow(hWnd,SW_MINIMIZE);
366: */
367: }
368:
369: //-----------------------------------------------------------------------
370: /*
371: Shortcut to 'Cold' reset
372: */
373: void ShortCut_ColdReset(void)
374: {
1.1.1.2 root 375: Reset_Cold(); /* Reset emulator with 'cold' (clear all) */
1.1 root 376: }
377:
378: //-----------------------------------------------------------------------
379: /*
380: Shortcut to 'Warm' reset
381: */
382: void ShortCut_WarmReset(void)
383: {
1.1.1.2 root 384: Reset_Warm(); /* Emulator 'warm' reset */
1.1 root 385: }
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.