Annotation of hatari/src/gui-sdl/dlgKeyboard.c, revision 1.1.1.3

1.1       root        1: /*
                      2:   Hatari - dlgKeyboard.c
                      3: 
                      4:   This file is distributed under the GNU Public License, version 2 or at
                      5:   your option any later version. Read the file gpl.txt for details.
                      6: */
1.1.1.3 ! root        7: const char DlgKeyboard_rcsid[] = "Hatari $Id: dlgKeyboard.c,v 1.7 2006/02/08 22:46:10 eerot Exp $";
1.1       root        8: 
                      9: #include <unistd.h>
                     10: 
                     11: #include "main.h"
                     12: #include "configuration.h"
                     13: #include "dialog.h"
                     14: #include "sdlgui.h"
                     15: #include "file.h"
                     16: #include "screen.h"
                     17: 
                     18: 
                     19: #define DLGKEY_SYMBOLIC  3
                     20: #define DLGKEY_SCANCODE  4
                     21: #define DLGKEY_FROMFILE  5
                     22: #define DLGKEY_MAPNAME   7
                     23: #define DLGKEY_MAPBROWSE 8
                     24: #define DLGKEY_EXIT      9
                     25: 
                     26: 
                     27: /* The keyboard dialog: */
                     28: static SGOBJ keyboarddlg[] =
                     29: {
                     30:   { SGBOX, 0, 0, 0,0, 40,12, NULL },
                     31:   { SGTEXT, 0, 0, 13,1, 14,1, "Keyboard setup" },
                     32:   { SGTEXT, 0, 0, 2,3, 17,1, "Keyboard mapping:" },
                     33:   { SGRADIOBUT, 0, 0, 3,5, 10,1, "Symbolic" },
                     34:   { SGRADIOBUT, 0, 0, 15,5, 10,1, "Scancode" },
                     35:   { SGRADIOBUT, 0, 0, 27,5, 11,1, "From file" },
                     36:   { SGTEXT, 0, 0, 2,7, 13,1, "Mapping file:" },
                     37:   { SGTEXT, 0, 0, 2,8, 36,1, NULL },
                     38:   { SGBUTTON, 0, 0, 32,7, 6,1, "Browse" },
                     39:   { SGBUTTON, 0, 0, 10,10, 20,1, "Back to main menu" },
                     40:   { -1, 0, 0, 0,0, 0,0, NULL }
                     41: };
                     42: 
                     43: 
                     44: /*-----------------------------------------------------------------------*/
                     45: /*
                     46:   Show and process the "Keyboard" dialog.
                     47: */
                     48: void Dialog_KeyboardDlg(void)
                     49: {
                     50:   int i, but;
                     51:   char dlgmapfile[40];
                     52:   char *tmpname;
                     53: 
1.1.1.2   root       54:   tmpname = malloc(FILENAME_MAX);
                     55:   if (!tmpname)
                     56:   {
                     57:     perror("Dialog_KeyboardDlg");
                     58:     return;
                     59:   }
1.1       root       60: 
                     61:   SDLGui_CenterDlg(keyboarddlg);
                     62: 
                     63:   /* Set up dialog from actual values: */
                     64:   for(i = DLGKEY_SYMBOLIC; i <= DLGKEY_FROMFILE; i++)
                     65:   {
                     66:     keyboarddlg[i].state &= ~SG_SELECTED;
                     67:   }
                     68:   keyboarddlg[DLGKEY_SYMBOLIC+DialogParams.Keyboard.nKeymapType].state |= SG_SELECTED;
                     69: 
                     70:   File_ShrinkName(dlgmapfile, DialogParams.Keyboard.szMappingFileName, keyboarddlg[DLGKEY_MAPNAME].w);
                     71:   keyboarddlg[DLGKEY_MAPNAME].txt = dlgmapfile;
                     72: 
                     73:   /* Show the dialog: */
                     74:   do
                     75:   {
1.1.1.2   root       76:     but = SDLGui_DoDialog(keyboarddlg, NULL);
1.1       root       77: 
                     78:     if(but == DLGKEY_MAPBROWSE)
                     79:     {
                     80:       strcpy(tmpname, DialogParams.Keyboard.szMappingFileName);
                     81:       if(!tmpname[0])
                     82:       {
                     83:         getcwd(tmpname, FILENAME_MAX);
                     84:         File_AddSlashToEndFileName(tmpname);
                     85:       }
                     86:       if( SDLGui_FileSelect(tmpname, NULL, FALSE) )
                     87:       {
                     88:         strcpy(DialogParams.Keyboard.szMappingFileName, tmpname);
                     89:         if( !File_DoesFileNameEndWithSlash(tmpname) && File_Exists(tmpname) )
                     90:           File_ShrinkName(dlgmapfile, tmpname, keyboarddlg[DLGKEY_MAPNAME].w);
                     91:         else
                     92:           dlgmapfile[0] = 0;
                     93:       }
                     94:     }
                     95: 
                     96:   }
1.1.1.2   root       97:   while (but != DLGKEY_EXIT && but != SDLGUI_QUIT && !bQuitProgram);
1.1       root       98: 
                     99:   /* Read values from dialog: */
                    100:   if(keyboarddlg[DLGKEY_SYMBOLIC].state & SG_SELECTED)
                    101:     DialogParams.Keyboard.nKeymapType = KEYMAP_SYMBOLIC;
                    102:   else if(keyboarddlg[DLGKEY_SCANCODE].state & SG_SELECTED)
                    103:     DialogParams.Keyboard.nKeymapType = KEYMAP_SCANCODE;
                    104:   else
                    105:     DialogParams.Keyboard.nKeymapType = KEYMAP_LOADED;
                    106: 
1.1.1.2   root      107:   free(tmpname);
1.1       root      108: }

unix.superglobalmegacorp.com

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