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

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 "screen.h"
                     14: #include "shortcut.h"
1.1.1.2 ! root       15: #include "hostcall.h"
        !            16: #include "../m68000.h"
1.1       root       17: 
                     18: 
                     19: /* List of possible short-cuts(MUST match SHORTCUT_xxxx) */
                     20: char *pszShortCutTextStrings[NUM_SHORTCUTS+1] = {
                     21:   "(not assigned)",
                     22:   "Full Screen",
                     23:   "Mouse Mode",
                     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: };
                     42: 
                     43: SHORTCUT_KEY ShortCutKey;
                     44: 
                     45: /*-----------------------------------------------------------------------*/
                     46: /*
                     47:   Clear shortkey structure
                     48: */
                     49: void ShortCut_ClearKeys(void)
                     50: {
                     51:   /* Clear short-cut key structure */
                     52:   Memory_Clear(&ShortCutKey,sizeof(SHORTCUT_KEY));
                     53: }
                     54: 
                     55: /*-----------------------------------------------------------------------*/
                     56: /*
                     57:   Check to see if pressed any shortcut keys, and call handling function
                     58: */
                     59: void ShortCut_CheckKeys(void)
                     60: {
                     61:   /* Check for supported keys: */
                     62:   switch(ShortCutKey.Key) {
                     63:      case SDLK_F12:                  /* Show options dialog */
                     64:        Dialog_DoProperty();
                     65:        break;
                     66:      case SDLK_F11:                  /* Switch between fullscreen/windowed mode */
                     67:        ShortCut_FullScreen();
                     68:        break;
                     69:      case SDLK_m:                    /* Toggle mouse mode */
                     70:        ShortCut_MouseMode();
                     71:        break;
                     72:      case SDLK_q:                    /* Quit program */
1.1.1.2 ! root       73:        SDL_Quit ();
        !            74:        exit (0);
1.1       root       75:        bQuitProgram = TRUE;
                     76:        break;
1.1.1.2 ! root       77:      case SDLK_d:
        !            78:        Call_DumpDebug ();
        !            79:        break;
1.1       root       80:   }
                     81: 
                     82:     /* And clear */
                     83:     ShortCut_ClearKeys();
                     84: }
                     85: 
                     86: 
                     87: /*-----------------------------------------------------------------------*/
                     88: /*
                     89:   Shortcut to toggle full-screen
                     90: */
                     91: void ShortCut_FullScreen(void)
                     92: {
                     93:   if(!bInFullScreen)
                     94:   {
                     95:     Screen_EnterFullScreen();
                     96:   }
                     97:   else
                     98:   {
                     99:     Screen_ReturnFromFullScreen();
                    100:   }
                    101: }
                    102: 
                    103: 
                    104: /*-----------------------------------------------------------------------*/
                    105: /*
                    106:   Shortcut to toggle mouse mode
                    107: */
                    108: void ShortCut_MouseMode(void)
                    109: {
                    110:   bGrabMouse = !bGrabMouse;        /* Toggle flag */
                    111: 
                    112:   /* If we are in windowed mode, toggle the mouse cursor mode now: */
                    113:   if(!bInFullScreen)
                    114:   {
                    115:     if(bGrabMouse)
                    116:     {
                    117:       SDL_WM_GrabInput(SDL_GRAB_ON);
                    118:     }
                    119:     else
                    120:     {
                    121:       SDL_WM_GrabInput(SDL_GRAB_OFF);
                    122:     }
                    123:   }
                    124: }
                    125: 
                    126: 

unix.superglobalmegacorp.com

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