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