Annotation of hatari/src/shortcut.c, revision 1.1.1.2

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

unix.superglobalmegacorp.com

This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.