Follow-up on previous commit: Generalized the "Command" key support, it compiles on all platforms and somebody may want to plug a Mac keyboard in a PC :)

Added a "command" symbol in the fonts, so shortcuts that use this key can be displayed.
Fixed: In Keyboard settings, some very weird keys (Thinkpad "volume up") were displayed with a wrong number.


git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@806 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
Yves Rizoud 2009-05-14 18:42:03 +00:00
parent 2feab9d52c
commit 4a39819c86
4 changed files with 14 additions and 16 deletions

View File

@ -1,5 +1,7 @@
/* Grafx2 - The Ultimate 256-color bitmap paint program /* Grafx2 - The Ultimate 256-color bitmap paint program
Copyright 2009 Franck Charlet
Copyright 2009 Yves Rizoud
Copyright 2007 Adrien Destugues Copyright 2007 Adrien Destugues
Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud) Copyright 1996-2001 Sunset Design (Guillaume Dorme & Karl Maritaud)
@ -103,21 +105,14 @@ GFX2_GLOBAL dword Key_ANSI;
#undef MOD_ALT #undef MOD_ALT
#endif #endif
#if defined(__macosx__)
#ifdef MOD_META
#undef MOD_META
#endif
#endif
/// Key modifier for SHIFT key. Used as mask in ::Key, for example. /// Key modifier for SHIFT key. Used as mask in ::Key, for example.
#define MOD_SHIFT 0x1000 #define MOD_SHIFT 0x1000
/// Key modifier for CONTROL key. Used as mask in ::Key, for example. /// Key modifier for CONTROL key. Used as mask in ::Key, for example.
#define MOD_CTRL 0x2000 #define MOD_CTRL 0x2000
/// Key modifier for ALT key. Used as mask in ::Key, for example. /// Key modifier for ALT key. Used as mask in ::Key, for example.
#define MOD_ALT 0x4000 #define MOD_ALT 0x4000
#if defined(__macosx__) /// Key modifier for META key. Used as mask in ::Key, for example.
#define MOD_META 0x8000 #define MOD_META 0x8000
#endif
/// Boolean set to true when the OS/window manager requests the application to close. ie: [X] button /// Boolean set to true when the OS/window manager requests the application to close. ie: [X] button
GFX2_GLOBAL byte Quit_is_required; GFX2_GLOBAL byte Quit_is_required;

View File

@ -356,22 +356,22 @@ int Handle_key_release(SDL_KeyboardEvent event)
case SDLK_LSHIFT: case SDLK_LSHIFT:
modifier=MOD_SHIFT; modifier=MOD_SHIFT;
break; break;
case SDLK_RCTRL: case SDLK_RCTRL:
case SDLK_LCTRL: case SDLK_LCTRL:
modifier=MOD_CTRL; modifier=MOD_CTRL;
break; break;
case SDLK_RALT: case SDLK_RALT:
case SDLK_LALT: case SDLK_LALT:
case SDLK_MODE: case SDLK_MODE:
modifier=MOD_ALT; modifier=MOD_ALT;
break; break;
#if defined(__macosx__)
case SDLK_RMETA: case SDLK_RMETA:
case SDLK_LMETA: case SDLK_LMETA:
modifier=MOD_META; modifier=MOD_META;
break; break;
#endif
default: default:
modifier=0; modifier=0;

View File

@ -318,11 +318,8 @@ word Key_modifiers(SDLMod mod)
modifiers|=MOD_SHIFT; modifiers|=MOD_SHIFT;
if (mod & (KMOD_ALT|KMOD_MODE)) if (mod & (KMOD_ALT|KMOD_MODE))
modifiers|=MOD_ALT; modifiers|=MOD_ALT;
#if defined(__macosx__)
if (mod & (KMOD_META)) if (mod & (KMOD_META))
modifiers|=MOD_META; modifiers|=MOD_META;
#endif
return modifiers; return modifiers;
} }
@ -457,6 +454,12 @@ const char * Key_name(word Key)
strcat(buffer, "Alt+"); strcat(buffer, "Alt+");
if (Key & MOD_SHIFT) if (Key & MOD_SHIFT)
strcat(buffer, "Shift+"); strcat(buffer, "Shift+");
if (Key & MOD_META)
strcat(buffer, "\201");
// Note: Apple's "command" character is not present in the ANSI table, so we
// recycled an ANSI value that doesn't have any displayable character
// associated.
Key=Key & ~(MOD_CTRL|MOD_ALT|MOD_SHIFT); Key=Key & ~(MOD_CTRL|MOD_ALT|MOD_SHIFT);
@ -495,12 +498,12 @@ const char * Key_name(word Key)
return buffer; return buffer;
} }
if (Key & 0x8000) if (Key & 0x800)
{ {
sprintf(buffer+strlen(buffer), "[%d]", Key & 0xFFF); sprintf(buffer+strlen(buffer), "[%d]", Key & 0x7FF);
return buffer; return buffer;
} }
Key = Key & 0xFFF; Key = Key & 0x7FF;
// Touches ASCII // Touches ASCII
if (Key>=' ' && Key < 127) if (Key>=' ' && Key < 127)
{ {

Binary file not shown.

Before

Width:  |  Height:  |  Size: 21 KiB

After

Width:  |  Height:  |  Size: 21 KiB