Annotation of frontvm/hardware/shortcut.c, revision 1.1.1.1

1.1       root        1: /*
                      2:   Hatari
                      3: 
                      4:   Shortcut keys
                      5: */
                      6: 
                      7: #include <SDL.h>
                      8: 
                      9: #include "main.h"
                     10: #include "dialog.h"
                     11: #include "audio.h"
                     12: #include "memAlloc.h"
                     13: #include "reset.h"
                     14: #include "screen.h"
                     15: #include "shortcut.h"
                     16: 
                     17: 
                     18: /* List of possible short-cuts(MUST match SHORTCUT_xxxx) */
                     19: char *pszShortCutTextStrings[NUM_SHORTCUTS+1] = {
                     20:   "(not assigned)",
                     21:   "Full Screen",
                     22:   "Mouse Mode",
                     23:   "Reset",
                     24:   NULL  /*term*/
                     25: };
                     26: 
                     27: char *pszShortCutF11TextString[] = {
                     28:   "Full Screen",
                     29:   NULL  /*term*/
                     30: };
                     31: 
                     32: char *pszShortCutF12TextString[] = {
                     33:   "Mouse Mode",
                     34:   NULL  /*term*/
                     35: };
                     36: 
                     37: ShortCutFunction_t pShortCutFunctions[NUM_SHORTCUTS] = {
                     38:   NULL,
                     39:   ShortCut_FullScreen,
                     40:   ShortCut_MouseMode,
                     41:   ShortCut_ColdReset,
                     42: };
                     43: 
                     44: SHORTCUT_KEY ShortCutKey;
                     45: 
                     46: /*-----------------------------------------------------------------------*/
                     47: /*
                     48:   Clear shortkey structure
                     49: */
                     50: void ShortCut_ClearKeys(void)
                     51: {
                     52:   /* Clear short-cut key structure */
                     53:   Memory_Clear(&ShortCutKey,sizeof(SHORTCUT_KEY));
                     54: }
                     55: 
                     56: /*-----------------------------------------------------------------------*/
                     57: /*
                     58:   Check to see if pressed any shortcut keys, and call handling function
                     59: */
                     60: void ShortCut_CheckKeys(void)
                     61: {
                     62:   /* Check for supported keys: */
                     63:   switch(ShortCutKey.Key) {
                     64:      case SDLK_F12:                  /* Show options dialog */
                     65:        Dialog_DoProperty();
                     66:        break;
                     67:      case SDLK_F11:                  /* Switch between fullscreen/windowed mode */
                     68:        ShortCut_FullScreen();
                     69:        break;
                     70:      case SDLK_m:                    /* Toggle mouse mode */
                     71:        ShortCut_MouseMode();
                     72:        break;
                     73:      case SDLK_r:                    /* Cold reset */
                     74:        ShortCut_ColdReset();
                     75:        break;
                     76:      case SDLK_q:                    /* Quit program */
                     77:        bQuitProgram = TRUE;
                     78:        break;
                     79:   }
                     80: 
                     81:     /* And clear */
                     82:     ShortCut_ClearKeys();
                     83: }
                     84: 
                     85: 
                     86: /*-----------------------------------------------------------------------*/
                     87: /*
                     88:   Shortcut to toggle full-screen
                     89: */
                     90: void ShortCut_FullScreen(void)
                     91: {
                     92:   if(!bInFullScreen)
                     93:   {
                     94:     Screen_EnterFullScreen();
                     95:   }
                     96:   else
                     97:   {
                     98:     Screen_ReturnFromFullScreen();
                     99:   }
                    100: }
                    101: 
                    102: 
                    103: /*-----------------------------------------------------------------------*/
                    104: /*
                    105:   Shortcut to toggle mouse mode
                    106: */
                    107: void ShortCut_MouseMode(void)
                    108: {
                    109:   bGrabMouse = !bGrabMouse;        /* Toggle flag */
                    110: 
                    111:   /* If we are in windowed mode, toggle the mouse cursor mode now: */
                    112:   if(!bInFullScreen)
                    113:   {
                    114:     if(bGrabMouse)
                    115:     {
                    116:       SDL_WM_GrabInput(SDL_GRAB_ON);
                    117:     }
                    118:     else
                    119:     {
                    120:       SDL_WM_GrabInput(SDL_GRAB_OFF);
                    121:     }
                    122:   }
                    123: }
                    124: 
                    125: 
                    126: /*-----------------------------------------------------------------------*/
                    127: /*
                    128:   Shortcut to 'Cold' reset
                    129: */
                    130: void ShortCut_ColdReset(void)
                    131: {
                    132:   Reset_VM();                 /* Reset emulator with 'cold' (clear all) */
                    133: }
                    134: 

unix.superglobalmegacorp.com

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