Commit 748971fd authored by David Skywalker's avatar David Skywalker
Browse files

kbdauto: update kbd_table with lang reference. Fixes #73

Thanks @vbe75 for your report!
parent 5c1d2dfd
......@@ -192,6 +192,7 @@ int autoboot_delay=0;
extern void kbd_buf_feed(char *s);
extern void kbd_buf_update();
extern void kbd_update_table(int lang);
extern char DISKA_NAME[512];
extern char DISKB_NAME[512];
......@@ -1721,6 +1722,7 @@ void loadConfiguration (void)
CPC.mf2 = getConfigValueInt(chFileName, "system", "mf2", 0) & 1;
//CPC.keyboard = getConfigValueInt(chFileName, "system", "keyboard", 0);
CPC.keyboard = retro_computer_cfg.lang;
kbd_update_table(retro_computer_cfg.lang);
if (CPC.keyboard > MAX_ROM_MODS)
CPC.keyboard = 0;
......@@ -2013,6 +2015,7 @@ size_t get_ram_size(void) {
void change_lang(int val){
CPC.keyboard=val;
kbd_update_table(val);
retro_computer_cfg.is_dirty = true;
}
......
......@@ -3,6 +3,7 @@
#include <stdio.h>
#include <string.h>
#define KDB_AZERTY 1
#define KBD_MAX_ENTRIES 143
#define MOD_CPC_SHIFT (0x01 << 8)
......@@ -487,7 +488,6 @@ int kbd_layout[KBD_MAX_ENTRIES][2] = {
0xff // CAP32_SCREEN
};
int cpc_get_key_from_ascii(char ascii)
{
int index;
......@@ -500,6 +500,7 @@ int cpc_get_key_from_ascii(char ascii)
char kbd_feedbuf[255];
int kbd_feedbuf_pos;
bool kbd_runcmd=false;
int kbd_mode = 0;
extern void play_tape();
......@@ -587,3 +588,58 @@ void vkbd_key(int key,int pressed){
}
}
void kbd_update_table(int lang) {
switch (lang)
{
case KDB_AZERTY:
kbd_layout[CPC_A][1] = 'Q';
kbd_layout[CPC_Q][1] = 'A';
kbd_layout[CPC_W][1] = 'Z';
kbd_layout[CPC_Z][1] = 'W';
kbd_layout[CPC_M][1] = '*';
kbd_layout[CPC_ASTERISK][1] = 'M';
kbd_layout[CPC_HASH][1] = '"';
kbd_layout[CPC_DBLQUOTE][1] = '#';
cpc_kbd[CPC_0] = 0x40 | MOD_CPC_SHIFT;
cpc_kbd[CPC_1] = 0x80 | MOD_CPC_SHIFT;
cpc_kbd[CPC_2] = 0x81 | MOD_CPC_SHIFT;
cpc_kbd[CPC_3] = 0x71 | MOD_CPC_SHIFT;
cpc_kbd[CPC_4] = 0x70 | MOD_CPC_SHIFT;
cpc_kbd[CPC_5] = 0x61 | MOD_CPC_SHIFT;
cpc_kbd[CPC_6] = 0x60 | MOD_CPC_SHIFT;
cpc_kbd[CPC_7] = 0x51 | MOD_CPC_SHIFT;
cpc_kbd[CPC_8] = 0x50 | MOD_CPC_SHIFT;
cpc_kbd[CPC_9] = 0x41 | MOD_CPC_SHIFT;
cpc_kbd[CPC_HASH] = 0x71; // CPC_DBLQUOTE
kbd_mode = KDB_AZERTY;
break;
default:
if (kbd_mode != KDB_AZERTY)
return;
kbd_layout[CPC_A][1] = 'A';
kbd_layout[CPC_Q][1] = 'Q';
kbd_layout[CPC_W][1] = 'W';
kbd_layout[CPC_Z][1] = 'Z';
kbd_layout[CPC_M][1] = 'M';
kbd_layout[CPC_ASTERISK][1] = '*';
kbd_layout[CPC_HASH][1] = '#';
kbd_layout[CPC_DBLQUOTE][1] = '"';
cpc_kbd[CPC_0] = 0x40;
cpc_kbd[CPC_1] = 0x80;
cpc_kbd[CPC_2] = 0x81;
cpc_kbd[CPC_3] = 0x71;
cpc_kbd[CPC_4] = 0x70;
cpc_kbd[CPC_5] = 0x61;
cpc_kbd[CPC_6] = 0x60;
cpc_kbd[CPC_7] = 0x51;
cpc_kbd[CPC_8] = 0x50;
cpc_kbd[CPC_9] = 0x41;
cpc_kbd[CPC_HASH] = 0x71 | MOD_CPC_SHIFT;
kbd_mode = 0;
break;
}
}
......@@ -864,7 +864,7 @@ void computer_load_file() {
{
int error = tape_insert ((char *)RPATH);
if (!error) {
kbd_buf_feed("|tape\nrun\"\n^");
kbd_buf_feed("|TAPE\nRUN\"\n^");
LOGI("Tape inserted: %s\n", (char *)RPATH);
} else {
LOGI("Tape Error (%d): %s\n", error, (char *)RPATH);
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment