add AZERTY layout as toggable option
so no need to update that thing seperately anymore
This commit is contained in:
1 parent
33501b6798
commit
6e59fdacb5
9 files changed
+337
-21
No files matched your search
+53
-5
@@ -643,6 +643,30 @@ INT32 CON_ShiftChar(INT32 ch)
|
||||
return ch;
|
||||
}
|
||||
|
||||
INT32 CON_ShitAndAltGrChar(INT32 ch)
|
||||
{
|
||||
if ((ch >= 'a' && ch <= 'z') || (ch >= 'A' && ch <= 'Z'))
|
||||
{
|
||||
if (shiftdown ^ capslock)
|
||||
ch = shiftxform[ch];
|
||||
}
|
||||
else // if we're holding shift we should still shift non letter symbols
|
||||
{
|
||||
if (shiftdown)
|
||||
ch = shiftxform[ch];
|
||||
else if (altdown & 0x2)
|
||||
{
|
||||
ch = french_altgrxform[ch];
|
||||
}
|
||||
else
|
||||
{
|
||||
ch = HU_FallBackFrSpecialLetter(ch);
|
||||
}
|
||||
}
|
||||
|
||||
return ch;
|
||||
}
|
||||
|
||||
// Clear time of console heads up messages
|
||||
//
|
||||
void CON_ClearHUD(void)
|
||||
@@ -941,7 +965,7 @@ boolean CON_Responder(event_t *ev)
|
||||
return true;
|
||||
|
||||
// ctrl modifier -- changes behavior, adds shortcuts
|
||||
if (ctrldown)
|
||||
if ((cv_keyboardlayout.value != 3 && ctrldown) || (cv_keyboardlayout.value == 3 && ctrldown && !altdown))
|
||||
{
|
||||
// show all cvars/commands that match what we have inputted
|
||||
if (key == KEY_TAB)
|
||||
@@ -1211,13 +1235,37 @@ boolean CON_Responder(event_t *ev)
|
||||
// same capslock code as hu_stuff.c's HU_responder. Check there for details.
|
||||
if ((key >= 'a' && key <= 'z') || (key >= 'A' && key <= 'Z'))
|
||||
{
|
||||
if (shiftdown ^ capslock)
|
||||
key = shiftxform[key];
|
||||
if (cv_keyboardlayout.value == 3)
|
||||
{
|
||||
if (shiftdown ^ capslock)
|
||||
key = shiftxform[key];
|
||||
else if (altdown & 0x2)
|
||||
key = french_altgrxform[key];
|
||||
else
|
||||
key = HU_FallBackFrSpecialLetter(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftdown ^ capslock)
|
||||
key = shiftxform[key];
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftdown)
|
||||
key = shiftxform[key];
|
||||
if (cv_keyboardlayout.value == 3)
|
||||
{
|
||||
if (shiftdown)
|
||||
key = shiftxform[key];
|
||||
else if (altdown & 0x2)
|
||||
key = french_altgrxform[key];
|
||||
else
|
||||
key = HU_FallBackFrSpecialLetter(key);
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftdown)
|
||||
key = shiftxform[key];
|
||||
}
|
||||
}
|
||||
|
||||
// enter a char into the command prompt
|
||||
|
||||
@@ -46,6 +46,7 @@ extern UINT8 *yellowmap, *purplemap, *greenmap, *bluemap, *graymap, *redmap, *or
|
||||
extern UINT8 *consolebgmap;
|
||||
|
||||
INT32 CON_ShiftChar(INT32 ch);
|
||||
INT32 CON_ShitAndAltGrChar(INT32 ch);
|
||||
|
||||
void CON_SetupBackColormap(void);
|
||||
void CON_ClearHUD(void); // clear heads up messages
|
||||
|
||||
+1
-1
@@ -821,7 +821,7 @@ void D_RegisterServerCommands(void)
|
||||
CV_RegisterVar(&cv_recordmultiplayerdemos);
|
||||
CV_RegisterVar(&cv_netdemosyncquality);
|
||||
CV_RegisterVar(&cv_maxdemosize);
|
||||
CV_RegisterVar(&cv_nativekeyboard);
|
||||
CV_RegisterVar(&cv_keyboardlayout);
|
||||
}
|
||||
|
||||
// =========================================================================
|
||||
|
||||
+1
-1
@@ -8461,7 +8461,7 @@ boolean G_DemoTitleResponder(event_t *ev)
|
||||
if (len < 64)
|
||||
{
|
||||
demo.titlename[len+1] = 0;
|
||||
demo.titlename[len] = CON_ShiftChar(ch);
|
||||
demo.titlename[len] = cv_keyboardlayout.value == 3 ? CON_ShitAndAltGrChar(ch) : CON_ShiftChar(ch);
|
||||
}
|
||||
}
|
||||
else if (ch == KEY_BACKSPACE)
|
||||
|
||||
+107
-1
@@ -174,6 +174,107 @@ char english_shiftxform[] =
|
||||
'{', '|', '}', '~', 127
|
||||
};
|
||||
|
||||
char french_shiftxform[] =
|
||||
{
|
||||
0,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
|
||||
31,
|
||||
' ','$', //shift-!
|
||||
'3', //shift-"
|
||||
'#', '$', '%',
|
||||
'1', //shift-&
|
||||
'4', // shift-'
|
||||
'5', // shift-(
|
||||
')', // shift-)
|
||||
'*', '+',
|
||||
'?', // shift-,
|
||||
'6', // shift--
|
||||
'.', '/',
|
||||
'0', '1', '2', '3', '4', '5',
|
||||
'6', '7', '8', '9',
|
||||
'/', // shitf-:
|
||||
'.', // shift-;
|
||||
'>', // shift-<
|
||||
'+', // shift-=
|
||||
'>', '?', '@',
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
||||
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'[', '\\', ']', '^',
|
||||
'8', //shift-_
|
||||
'`',
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
||||
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'{', '|', '}', '~', 127,
|
||||
128, 129,
|
||||
'2',
|
||||
131, 132,
|
||||
'0',
|
||||
134,
|
||||
'9',
|
||||
136, 137,
|
||||
'7',
|
||||
139, 140,
|
||||
'%'
|
||||
};
|
||||
|
||||
char french_altgrxform[] =
|
||||
{
|
||||
0,
|
||||
1, 2, 3, 4, 5, 6, 7, 8, 9, 10,
|
||||
11, 12, 13, 14, 15, 16, 17, 18, 19, 20,
|
||||
21, 22, 23, 24, 25, 26, 27, 28, 29, 30,
|
||||
31,
|
||||
' ', '!',
|
||||
'#', //altgr-"
|
||||
'#', '$', '%', '&',
|
||||
'{', //altgr-'
|
||||
'[', //altgr-(
|
||||
']', //altgr-)
|
||||
'*', '+', ',',
|
||||
'|', //altg--
|
||||
'.', '/',
|
||||
'0', '1', '2', '3', '4', '5',
|
||||
'6', '7', '8', '9',
|
||||
':', ';', '<',
|
||||
'}', //altgr-=
|
||||
'>', '?', '@',
|
||||
'A', 'B', 'C', 'D', 'E', 'F', 'G', 'H', 'I', 'J', 'K', 'L', 'M', 'N',
|
||||
'O', 'P', 'Q', 'R', 'S', 'T', 'U', 'V', 'W', 'X', 'Y', 'Z',
|
||||
'[', '\\', ']', '^',
|
||||
'\\', //altgr-backslash
|
||||
'`',
|
||||
'a', 'b', 'c', 'd', 'E', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n',
|
||||
'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z',
|
||||
'{', '|', '}', '~', 127,
|
||||
128, 129,
|
||||
'~',
|
||||
131, 132,
|
||||
'@',
|
||||
134,
|
||||
'^',
|
||||
136, 137,
|
||||
'`',
|
||||
139, 140,
|
||||
KEY_FR_U_GRAVE
|
||||
};
|
||||
|
||||
//fallback for special letter non displayable in the game (i.e.: 'é','à',etc.)
|
||||
INT32 HU_FallBackFrSpecialLetter(INT32 key)
|
||||
{
|
||||
switch(key){
|
||||
case KEY_FR_E_AIGUE: return 'e';
|
||||
case KEY_FR_E_GRAVE: return 'e';
|
||||
case KEY_FR_C_CEDILLE: return 'c';
|
||||
case KEY_FR_A_GRAVE: return 'a';
|
||||
case KEY_FR_U_GRAVE: return 'u';
|
||||
default: return key;
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
|
||||
static char cechotext[1024];
|
||||
static tic_t cechotimer = 0;
|
||||
static tic_t cechoduration = 5*TICRATE;
|
||||
@@ -371,6 +472,11 @@ void HU_Start(void)
|
||||
headsupactive = true;
|
||||
}
|
||||
|
||||
void HU_Shiftform(void)
|
||||
{
|
||||
shiftxform = cv_keyboardlayout.value == 3 ? french_shiftxform : english_shiftxform;
|
||||
}
|
||||
|
||||
//======================================================================
|
||||
// EXECUTION
|
||||
//======================================================================
|
||||
@@ -1378,7 +1484,7 @@ boolean HU_Responder(event_t *ev)
|
||||
&& ev->data1 != gamecontrol[gc_talkkey][1]))
|
||||
return false;
|
||||
|
||||
c = CON_ShiftChar(c);
|
||||
c = cv_keyboardlayout.value == 3 ? CON_ShitAndAltGrChar(c) : CON_ShiftChar(c);
|
||||
|
||||
// pasting. pasting is cool. chat is a bit limited, though :(
|
||||
if (((c == 'v' || c == 'V') && ctrldown) && !CHAT_MUTE)
|
||||
|
||||
@@ -47,6 +47,12 @@
|
||||
extern char *shiftxform; // english translation shift table
|
||||
extern char english_shiftxform[];
|
||||
|
||||
extern char french_shiftxform[];
|
||||
extern char french_altgrxform[];
|
||||
|
||||
//fallback for special letter non displayable in the game (i.e.: 'é','à',etc.)
|
||||
INT32 HU_FallBackFrSpecialLetter(INT32 key);
|
||||
|
||||
//------------------------------------
|
||||
// sorted player lines
|
||||
//------------------------------------
|
||||
@@ -109,6 +115,8 @@ void HU_LoadGraphics(void);
|
||||
// reset heads up when consoleplayer respawns.
|
||||
void HU_Start(void);
|
||||
|
||||
void HU_Shiftform(void);
|
||||
|
||||
boolean HU_Responder(event_t *ev);
|
||||
void HU_Ticker(void);
|
||||
void HU_TickSongCredits(void);
|
||||
|
||||
+9
-1
@@ -15,7 +15,7 @@
|
||||
|
||||
#include "console.h"
|
||||
|
||||
extern consvar_t cv_nativekeyboard;
|
||||
extern consvar_t cv_keyboardlayout;
|
||||
|
||||
// These are the key codes as posted by the keyboard handler,
|
||||
// ascii codes are 0->127,
|
||||
@@ -30,6 +30,14 @@ extern consvar_t cv_nativekeyboard;
|
||||
#define KEY_MINUS 45
|
||||
#define KEY_EQUALS 61
|
||||
|
||||
//azerty special keys support
|
||||
//(necessary for being able to print 'regular' chars in azerty)
|
||||
#define KEY_FR_E_AIGUE (0x80+2)
|
||||
#define KEY_FR_E_GRAVE (0x80+10)
|
||||
#define KEY_FR_C_CEDILLE (0x80+7)
|
||||
#define KEY_FR_A_GRAVE (0x80+5)
|
||||
#define KEY_FR_U_GRAVE (0x80+13)
|
||||
|
||||
#define KEY_NUMLOCK (0x80+69)
|
||||
#define KEY_SCROLLLOCK (0x80+70)
|
||||
|
||||
|
||||
+70
-10
@@ -2011,7 +2011,7 @@ static menuitem_t OP_SaturnMenu[] =
|
||||
{IT_STRING | IT_CVAR, NULL, "Show Localskin Menus", &cv_showlocalskinmenus, 90},
|
||||
{IT_STRING | IT_CVAR, NULL, "Uppercase Menu", &cv_menucaps, 95},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Native Keyboard Layout", &cv_nativekeyboard, 105},
|
||||
{IT_STRING | IT_CVAR, NULL, "Keyboard Layout", &cv_keyboardlayout, 105},
|
||||
|
||||
{IT_STRING | IT_CVAR, NULL, "Less Midnight Channel Flicker", &cv_lessflicker, 115},
|
||||
|
||||
@@ -3300,8 +3300,23 @@ static boolean M_ChangeStringCvar(INT32 choice)
|
||||
char buf[MAXSTRINGLENGTH];
|
||||
size_t len;
|
||||
|
||||
if (shiftdown && choice >= 32 && choice <= 127)
|
||||
choice = shiftxform[choice];
|
||||
if (cv_keyboardlayout.value == 3)
|
||||
{
|
||||
if (choice >= 32 && choice <= 141)
|
||||
{
|
||||
if (shiftdown)
|
||||
choice = shiftxform[choice];
|
||||
else if (altdown & 0x2)
|
||||
choice = french_altgrxform[choice];
|
||||
else
|
||||
choice = HU_FallBackFrSpecialLetter(choice);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftdown && choice >= 32 && choice <= 127)
|
||||
choice = shiftxform[choice];
|
||||
}
|
||||
|
||||
switch (choice)
|
||||
{
|
||||
@@ -3323,7 +3338,7 @@ static boolean M_ChangeStringCvar(INT32 choice)
|
||||
}
|
||||
return true;
|
||||
default:
|
||||
if (choice >= 32 && choice <= 127)
|
||||
if ((cv_keyboardlayout.value != 3 && choice >= 32 && choice <= 127) || (cv_keyboardlayout.value == 3 && choice >= 32 && choice <= 141))
|
||||
{
|
||||
len = strlen(cv->string);
|
||||
if (len < MAXSTRINGLENGTH - 1)
|
||||
@@ -3648,8 +3663,23 @@ boolean M_Responder(event_t *ev)
|
||||
if (routine && (currentMenu->menuitems[itemOn].status & IT_TYPE) == IT_KEYHANDLER)
|
||||
{
|
||||
menu_text_input = true;
|
||||
if (shiftdown && ch >= 32 && ch <= 127)
|
||||
ch = shiftxform[ch];
|
||||
if (cv_keyboardlayout.value == 3)
|
||||
{
|
||||
if(ch >= 32 && ch <= 141)
|
||||
{
|
||||
if (shiftdown)
|
||||
ch = shiftxform[ch];
|
||||
else if (altdown & 0x2)
|
||||
ch = french_altgrxform[ch];
|
||||
else
|
||||
ch = HU_FallBackFrSpecialLetter(ch);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftdown && ch >= 32 && ch <= 127)
|
||||
ch = shiftxform[ch];
|
||||
}
|
||||
routine(ch);
|
||||
return true;
|
||||
}
|
||||
@@ -3689,8 +3719,23 @@ boolean M_Responder(event_t *ev)
|
||||
if ((currentMenu->menuitems[itemOn].status & IT_CVARTYPE) == IT_CV_STRING)
|
||||
{
|
||||
menu_text_input = true;
|
||||
if (shiftdown && ch >= 32 && ch <= 127)
|
||||
ch = shiftxform[ch];
|
||||
if (cv_keyboardlayout.value == 3)
|
||||
{
|
||||
if(ch >= 32 && ch <= 141)
|
||||
{
|
||||
if (shiftdown)
|
||||
ch = shiftxform[ch];
|
||||
else if (altdown & 0x2)
|
||||
ch = french_altgrxform[ch];
|
||||
else
|
||||
ch = HU_FallBackFrSpecialLetter(ch);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftdown && ch >= 32 && ch <= 127)
|
||||
ch = shiftxform[ch];
|
||||
}
|
||||
if (M_ChangeStringCvar(ch))
|
||||
return true;
|
||||
else
|
||||
@@ -6385,8 +6430,23 @@ static void M_AddonAutoLoad(INT32 ch)
|
||||
#define len menusearch[0]
|
||||
static boolean M_ChangeStringAddons(INT32 choice)
|
||||
{
|
||||
if (shiftdown && choice >= 32 && choice <= 127)
|
||||
choice = shiftxform[choice];
|
||||
if (cv_keyboardlayout.value == 3)
|
||||
{
|
||||
if(choice >= 32 && choice <= 141)
|
||||
{
|
||||
if(shiftdown)
|
||||
choice = shiftxform[choice];
|
||||
else if(altdown & 0x2)
|
||||
choice = french_altgrxform[choice];
|
||||
else
|
||||
choice = HU_FallBackFrSpecialLetter(choice);
|
||||
}
|
||||
}
|
||||
else
|
||||
{
|
||||
if (shiftdown && choice >= 32 && choice <= 127)
|
||||
choice = shiftxform[choice];
|
||||
}
|
||||
|
||||
switch (choice)
|
||||
{
|
||||
|
||||
+87
-2
@@ -111,7 +111,14 @@ boolean a2c = false;
|
||||
#endif
|
||||
|
||||
boolean highcolor = false;
|
||||
consvar_t cv_nativekeyboard = {"nativekeyboard", "Off", CV_SAVE, CV_OnOff, NULL, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static void KeyboardLayout_OnChange(void)
|
||||
{
|
||||
HU_Shiftform();
|
||||
}
|
||||
|
||||
static CV_PossibleValue_t keyboardlayout_cons_t[] = {{1,"Default US"}, {2, "Native"}, {3, "AZERTY"}, {0, NULL}};
|
||||
consvar_t cv_keyboardlayout = {"keyboardlayout", "Default US", CV_SAVE|CV_CALL, keyboardlayout_cons_t, KeyboardLayout_OnChange, 0, NULL, NULL, 0, 0, NULL};
|
||||
|
||||
static void Impl_SetVsync(void);
|
||||
|
||||
@@ -528,6 +535,82 @@ static INT32 GetTypedChar(SDL_Scancode code, SDL_Keysym *sym)
|
||||
return 0;
|
||||
}
|
||||
|
||||
static INT32 Impl_SDL_Keysym_To_Keycode_FR(SDL_Keysym keysym)
|
||||
{
|
||||
SDL_Keycode keycode= keysym.sym;
|
||||
SDL_Scancode scancode= keysym.scancode;
|
||||
|
||||
if (keycode >= SDLK_a && keycode <= SDLK_z){
|
||||
// get lowercase ASCII
|
||||
return keycode;
|
||||
}
|
||||
if (keycode >= SDLK_F1 && keycode <= SDLK_F10)
|
||||
{
|
||||
return KEY_F1 + (keycode - SDLK_F1);
|
||||
}
|
||||
if(scancode == SDL_SCANCODE_APOSTROPHE){
|
||||
return KEY_FR_U_GRAVE;
|
||||
}
|
||||
switch(scancode){
|
||||
case SDL_SCANCODE_APOSTROPHE: return KEY_FR_U_GRAVE;
|
||||
case SDL_SCANCODE_LEFTBRACKET: return '^';
|
||||
default: break;
|
||||
}
|
||||
switch (keycode)
|
||||
{
|
||||
// F11 and F12 are separated from the rest of the function keys
|
||||
case SDLK_F11: return KEY_F11;
|
||||
case SDLK_F12: return KEY_F12;
|
||||
|
||||
case SDLK_RETURN: return KEY_ENTER;
|
||||
case SDLK_ESCAPE: return KEY_ESCAPE;
|
||||
case SDLK_BACKSPACE: return KEY_BACKSPACE;
|
||||
case SDLK_TAB: return KEY_TAB;
|
||||
case SDLK_SPACE: return KEY_SPACE;
|
||||
case SDLK_EQUALS: return KEY_EQUALS;
|
||||
case SDLK_SEMICOLON: return ';';
|
||||
case SDLK_COMMA: return ',';
|
||||
case SDLK_COLON: return ':';
|
||||
case SDLK_EXCLAIM: return '!';
|
||||
case SDLK_DOLLAR: return '$';
|
||||
case SDLK_ASTERISK: return '*';
|
||||
case SDLK_PERCENT: return '%';
|
||||
case SDLK_0: return KEY_FR_A_GRAVE;
|
||||
case SDLK_1:
|
||||
case SDLK_AMPERSAND: return '&';
|
||||
case SDLK_2: return KEY_FR_E_AIGUE;
|
||||
case SDLK_3:
|
||||
case SDLK_QUOTEDBL: return '"';
|
||||
case SDLK_4: return '\'';
|
||||
case SDLK_5:
|
||||
case SDLK_LEFTPAREN: return '(';
|
||||
case SDLK_6:
|
||||
case SDLK_MINUS: return KEY_MINUS;
|
||||
case SDLK_7: return KEY_FR_E_GRAVE;
|
||||
case SDLK_8:
|
||||
case SDLK_UNDERSCORE: return '_';
|
||||
case SDLK_9: return KEY_FR_C_CEDILLE;
|
||||
case SDLK_RIGHTPAREN: return ')';
|
||||
case SDLK_SLASH: return '/';
|
||||
case SDLK_LESS: return '<';
|
||||
|
||||
|
||||
case SDLK_KP_0: return KEY_KEYPAD0;
|
||||
case SDLK_KP_1: return KEY_KEYPAD1;
|
||||
case SDLK_KP_2: return KEY_KEYPAD2;
|
||||
case SDLK_KP_3: return KEY_KEYPAD3;
|
||||
case SDLK_KP_4: return KEY_KEYPAD4;
|
||||
case SDLK_KP_5: return KEY_KEYPAD5;
|
||||
case SDLK_KP_6: return KEY_KEYPAD6;
|
||||
case SDLK_KP_7: return KEY_KEYPAD7;
|
||||
case SDLK_KP_8: return KEY_KEYPAD8;
|
||||
case SDLK_KP_9: return KEY_KEYPAD9;
|
||||
|
||||
default: break;
|
||||
}
|
||||
return Impl_SDL_Scancode_To_Keycode(scancode);
|
||||
}
|
||||
|
||||
static void SDLdoGrabMouse(void)
|
||||
{
|
||||
SDL_ShowCursor(SDL_DISABLE);
|
||||
@@ -843,8 +926,10 @@ static void Impl_HandleKeyboardEvent(SDL_KeyboardEvent evt, Uint32 type)
|
||||
return;
|
||||
}
|
||||
|
||||
if (cv_nativekeyboard.value && (chat_on || CON_Ready() || (menu_text_input && menuactive))) //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig)
|
||||
if (cv_keyboardlayout.value == 2 && (chat_on || CON_Ready() || (menu_text_input && menuactive))) //only use this this if on chat or console or the current menu wants inputs from us (except if its the control setup menu ig)
|
||||
event.data1 = GetTypedChar(evt.keysym.scancode, &evt.keysym);
|
||||
else if (cv_keyboardlayout.value == 3)
|
||||
event.data1 = Impl_SDL_Keysym_To_Keycode_FR(evt.keysym);
|
||||
else
|
||||
event.data1 = Impl_SDL_Scancode_To_Keycode(evt.keysym.scancode);
|
||||
|
||||
|
||||
Reference in new issue
Block a user