gfxcfg now uses SDL keysyms for input, you can test it to check how SDL understands keys on your platform. The utility still doesn't load gfx2.cfg, and still saves is badly.
Fixed more hardcoded scancodes (shade menu). git-svn-id: svn://pulkomandy.tk/GrafX2/trunk@171 416bcca6-2ee7-4201-b75f-2eb2f807beb1
This commit is contained in:
237
clavier.c
237
clavier.c
@@ -1,3 +1,4 @@
|
||||
#include <string.h>
|
||||
#include "global.h"
|
||||
|
||||
// Table de correspondance des scancode de clavier IBM PC AT vers
|
||||
@@ -284,3 +285,239 @@ word Touche_pour_scancode(word scancode)
|
||||
else
|
||||
return Scancode_to_Sym[scancode & 0xFF][0];
|
||||
}
|
||||
|
||||
word Conversion_Touche(SDL_keysym Sym)
|
||||
{
|
||||
word Retour = 0;
|
||||
// On ignore shift, alt et control isolés.
|
||||
if (Sym.sym == SDLK_RSHIFT || Sym.sym == SDLK_LSHIFT ||
|
||||
Sym.sym == SDLK_RCTRL || Sym.sym == SDLK_LCTRL ||
|
||||
Sym.sym == SDLK_RALT || Sym.sym == SDLK_LALT ||
|
||||
Sym.sym == SDLK_MODE) // AltGr
|
||||
return 0;
|
||||
|
||||
// Les touches qui n'ont qu'une valeur unicode (très rares)
|
||||
// seront codées sur 11 bits, le 12e bit est mis à 1 (0x0800)
|
||||
if (Sym.sym > 0)
|
||||
Retour = Sym.sym;
|
||||
else if (Sym.unicode > 0)
|
||||
Retour = (Sym.unicode & 0x07FF) | 0x0800;
|
||||
|
||||
if (Sym.mod & (KMOD_LSHIFT | KMOD_RSHIFT))
|
||||
Retour |= 0x1000;
|
||||
if (Sym.mod & (KMOD_LCTRL | KMOD_RCTRL))
|
||||
Retour |= 0x2000;
|
||||
if (Sym.mod & (KMOD_LALT | KMOD_RALT | KMOD_MODE))
|
||||
Retour |= 0x4000;
|
||||
return Retour;
|
||||
}
|
||||
|
||||
const char * Nom_touche(word Touche)
|
||||
{
|
||||
typedef struct
|
||||
{
|
||||
word Sym;
|
||||
char *Nom_touche;
|
||||
} S_Libelle_touche;
|
||||
S_Libelle_touche Table_touches[] =
|
||||
{
|
||||
{ SDLK_BACKSPACE , "Backspace" },
|
||||
{ SDLK_TAB , "Tab" },
|
||||
{ SDLK_CLEAR , "Clear" },
|
||||
{ SDLK_RETURN , "Return" },
|
||||
{ SDLK_PAUSE , "Pause" },
|
||||
{ SDLK_ESCAPE , "Esc" },
|
||||
{ SDLK_DELETE , "Del" },
|
||||
{ SDLK_KP0 , "KP 0" },
|
||||
{ SDLK_KP1 , "KP 1" },
|
||||
{ SDLK_KP2 , "KP 2" },
|
||||
{ SDLK_KP3 , "KP 3" },
|
||||
{ SDLK_KP4 , "KP 4" },
|
||||
{ SDLK_KP5 , "KP 5" },
|
||||
{ SDLK_KP6 , "KP 6" },
|
||||
{ SDLK_KP7 , "KP 7" },
|
||||
{ SDLK_KP8 , "KP 8" },
|
||||
{ SDLK_KP9 , "KP 9" },
|
||||
{ SDLK_KP_PERIOD , "KP ." },
|
||||
{ SDLK_KP_DIVIDE , "KP /" },
|
||||
{ SDLK_KP_MULTIPLY, "KP *" },
|
||||
{ SDLK_KP_MINUS , "KP -" },
|
||||
{ SDLK_KP_PLUS , "KP Plus" },
|
||||
{ SDLK_KP_ENTER , "KP Enter" },
|
||||
{ SDLK_KP_EQUALS , "KP =" },
|
||||
{ SDLK_UP , "Up" },
|
||||
{ SDLK_DOWN , "Down" },
|
||||
{ SDLK_RIGHT , "Right" },
|
||||
{ SDLK_LEFT , "Left" },
|
||||
{ SDLK_INSERT , "Ins" },
|
||||
{ SDLK_HOME , "Home" },
|
||||
{ SDLK_END , "End" },
|
||||
{ SDLK_PAGEUP , "PgUp" },
|
||||
{ SDLK_PAGEDOWN , "PgDn" },
|
||||
{ SDLK_F1 , "F1" },
|
||||
{ SDLK_F2 , "F2" },
|
||||
{ SDLK_F3 , "F3" },
|
||||
{ SDLK_F4 , "F4" },
|
||||
{ SDLK_F5 , "F5" },
|
||||
{ SDLK_F6 , "F6" },
|
||||
{ SDLK_F7 , "F7" },
|
||||
{ SDLK_F8 , "F8" },
|
||||
{ SDLK_F9 , "F9" },
|
||||
{ SDLK_F10 , "F10" },
|
||||
{ SDLK_F11 , "F11" },
|
||||
{ SDLK_F12 , "F12" },
|
||||
{ SDLK_F13 , "F13" },
|
||||
{ SDLK_F14 , "F14" },
|
||||
{ SDLK_F15 , "F15" },
|
||||
{ SDLK_NUMLOCK , "NumLock" },
|
||||
{ SDLK_CAPSLOCK , "CapsLck" },
|
||||
{ SDLK_SCROLLOCK , "ScrlLock" },
|
||||
{ SDLK_RSHIFT , "RShift" },
|
||||
{ SDLK_LSHIFT , "LShift" },
|
||||
{ SDLK_RCTRL , "RCtrol" },
|
||||
{ SDLK_LCTRL , "LCtrl" },
|
||||
{ SDLK_RALT , "RAlt" },
|
||||
{ SDLK_LALT , "LAlt" },
|
||||
{ SDLK_RMETA , "RMeta" },
|
||||
{ SDLK_LMETA , "LMeta" },
|
||||
{ SDLK_LSUPER , "LWin" },
|
||||
{ SDLK_RSUPER , "RWin" },
|
||||
{ SDLK_MODE , "AltGr" },
|
||||
{ SDLK_COMPOSE , "Comp" },
|
||||
{ SDLK_HELP , "Help" },
|
||||
{ SDLK_PRINT , "Print" },
|
||||
{ SDLK_SYSREQ , "SysReq" },
|
||||
{ SDLK_BREAK , "Break" },
|
||||
{ SDLK_MENU , "Menu" },
|
||||
{ SDLK_POWER , "Power" },
|
||||
{ SDLK_EURO , "Euro" },
|
||||
{ SDLK_UNDO , "Undo" }
|
||||
};
|
||||
|
||||
int Indice;
|
||||
static char Buffer[41];
|
||||
Buffer[0] = '\0';
|
||||
|
||||
if (Touche & 0x2000)
|
||||
strcat(Buffer, "<Ctrl> + ");
|
||||
if (Touche & 0x4000)
|
||||
strcat(Buffer, "<Alt> + ");
|
||||
if (Touche & 0x1000)
|
||||
strcat(Buffer, "<Shift> + ");
|
||||
|
||||
if (Touche & 0x8000)
|
||||
{
|
||||
sprintf(Buffer+strlen(Buffer), "[%d]", Touche & 0xFFF);
|
||||
return Buffer;
|
||||
}
|
||||
Touche = Touche & 0xFFF;
|
||||
// Touches ASCII
|
||||
if (Touche>=' ' && Touche < 127)
|
||||
{
|
||||
sprintf(Buffer+strlen(Buffer), "'%c'", Touche);
|
||||
return Buffer;
|
||||
}
|
||||
// Touches 'World'
|
||||
if (Touche>=SDLK_WORLD_0 && Touche <= SDLK_WORLD_95)
|
||||
{
|
||||
sprintf(Buffer+strlen(Buffer), "w%d", Touche - SDLK_WORLD_0);
|
||||
return Buffer;
|
||||
}
|
||||
|
||||
// Touches au libellé connu
|
||||
for (Indice=0; Indice < sizeof(Table_touches)/sizeof(S_Libelle_touche);Indice++)
|
||||
{
|
||||
if (Touche == Table_touches[Indice].Sym)
|
||||
{
|
||||
sprintf(Buffer+strlen(Buffer), "%s", Table_touches[Indice].Nom_touche);
|
||||
return Buffer;
|
||||
}
|
||||
}
|
||||
// Autres touches inconnues
|
||||
sprintf(Buffer+strlen(Buffer), "(%d)", Touche);
|
||||
return Buffer;
|
||||
|
||||
}
|
||||
|
||||
// Obtient le caractère ANSI tapé, à partir d'un keysym.
|
||||
// (Valeur 32 à 255)
|
||||
// Renvoie 0 s'il n'y a pas de caractère associé (shift, backspace, etc)
|
||||
word Conversion_ANSI(SDL_keysym Sym)
|
||||
{
|
||||
if ( Sym.unicode == 0)
|
||||
{
|
||||
return Sym.sym;
|
||||
}
|
||||
if ( Sym.unicode > 32 && Sym.unicode < 127)
|
||||
{
|
||||
return Sym.unicode; // Pas de souci, on est en ASCII standard
|
||||
}
|
||||
|
||||
// Quelques conversions Unicode-ANSI
|
||||
switch(Sym.unicode)
|
||||
{
|
||||
case 0x8100:
|
||||
return 'ü'; // ü
|
||||
case 0x1A20:
|
||||
return 'é'; // é
|
||||
case 0x201A:
|
||||
return 'è'; // è
|
||||
case 0x9201:
|
||||
return 'â'; // â
|
||||
case 0x1E20:
|
||||
return 'ä'; // ä
|
||||
case 0x2620:
|
||||
return 'à'; // à
|
||||
case 0x2020:
|
||||
return 'å'; // å
|
||||
case 0x2120:
|
||||
return 'ç'; // ç
|
||||
case 0xC602:
|
||||
return 'ê'; // ê
|
||||
case 0x3020:
|
||||
return 'ë'; // ë
|
||||
case 0x6001:
|
||||
return 'è'; // è
|
||||
case 0x3920:
|
||||
return 'ï'; // ï
|
||||
case 0x5201:
|
||||
return 'î'; // î
|
||||
case 0x8D00:
|
||||
return 'ì'; // ì
|
||||
case 0x1C20:
|
||||
return 'ô'; // ô
|
||||
case 0x1D20:
|
||||
return 'ö'; // ö
|
||||
case 0x2220:
|
||||
return 'ò'; // ò
|
||||
case 0x1320:
|
||||
return 'û'; // û
|
||||
case 0x1420:
|
||||
return 'ù'; // ù
|
||||
case 0xDC02:
|
||||
return 'ÿ'; // ÿ
|
||||
case 0x5301:
|
||||
return '£'; // £
|
||||
case 0xA000:
|
||||
return 'á'; // á
|
||||
case 0xA100:
|
||||
return 'í'; // í
|
||||
case 0xA200:
|
||||
return 'ó'; // ó
|
||||
case 0xA300:
|
||||
return 'ú'; // ú
|
||||
case 0xA400:
|
||||
return 'ñ'; // ñ
|
||||
case 0xA700:
|
||||
return 'º'; // º
|
||||
case 0xC600:
|
||||
return 'ã'; // ã
|
||||
}
|
||||
// Touche entre 127 et 255
|
||||
if (Sym.unicode<256)
|
||||
{
|
||||
return Sym.unicode;
|
||||
}
|
||||
// Sinon c'est une touche spéciale, on retourne son scancode
|
||||
return Sym.sym;
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user