Implement the Kana lock LED for AX machines.

This commit is contained in:
OBattler
2025-05-07 01:54:34 +02:00
parent ac820dbc25
commit a48f9bc7ba
8 changed files with 40 additions and 20 deletions

View File

@@ -67,6 +67,7 @@ static scancode *scan_table; /* scancode table for keyboard */
static volatile uint8_t caps_lock = 0;
static volatile uint8_t num_lock = 0;
static volatile uint8_t scroll_lock = 0;
static volatile uint8_t kana_lock = 0;
static uint8_t shift = 0;
static int key5576mode = 0;
@@ -108,6 +109,7 @@ keyboard_init(void)
num_lock = 0;
caps_lock = 0;
scroll_lock = 0;
kana_lock = 0;
shift = 0;
memset(recv_key, 0x00, sizeof(recv_key));
@@ -370,11 +372,12 @@ keyboard_do_break(uint16_t scan)
Caps Lock, Num Lock, and Scroll Lock when receving the "Set keyboard LEDs"
command. */
void
keyboard_update_states(uint8_t cl, uint8_t nl, uint8_t sl)
keyboard_update_states(uint8_t cl, uint8_t nl, uint8_t sl, uint8_t kl)
{
caps_lock = cl;
num_lock = nl;
scroll_lock = sl;
kana_lock = kl;
}
uint8_t
@@ -384,7 +387,7 @@ keyboard_get_shift(void)
}
void
keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl)
keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl, uint8_t *kl)
{
if (cl)
*cl = caps_lock;
@@ -392,6 +395,8 @@ keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl)
*nl = num_lock;
if (sl)
*sl = scroll_lock;
if (kl)
*kl = kana_lock;
}
/* Called by the UI to update the states of Caps Lock, Num Lock, and Scroll Lock. */
@@ -435,7 +440,7 @@ keyboard_set_states(uint8_t cl, uint8_t nl, uint8_t sl)
}
}
keyboard_update_states(cl, nl, sl);
keyboard_update_states(cl, nl, sl, kana_lock);
}
int

View File

@@ -3276,7 +3276,7 @@ add_data_kbd(uint16_t val)
dev->ignore = 1;
keyboard_get_states(NULL, &num_lock, NULL);
keyboard_get_states(NULL, &num_lock, NULL, NULL);
shift_states = keyboard_get_shift() & STATE_SHIFT_MASK;
switch (val) {
@@ -3476,7 +3476,7 @@ keyboard_at_bat(void *priv)
keyboard_scan = 1;
keyboard_update_states(0, 0, 0);
keyboard_update_states(0, 0, 0, 0);
kbc_at_dev_queue_add(dev, 0xaa, 0);
} else {
bat_counter--;
@@ -3511,7 +3511,7 @@ keyboard_at_write(void *priv)
switch (dev->command) {
case 0xed: /* Set/reset LEDs */
kbc_at_dev_queue_add(dev, 0xfa, 0);
keyboard_update_states(!!(val & 0x4), !!(val & 0x2), val & 0x1);
keyboard_update_states(!!(val & 0x4), !!(val & 0x2), val & 0x1, !!(val & 0x8));
keyboard_at_log("%s: Set/reset LEDs [%02X]\n", dev->name, val);
break;
@@ -3769,7 +3769,7 @@ keyboard_at_init(const device_t *info)
keyboard_send = add_data_kbd;
SavedKbd = dev;
keyboard_update_states(0, 0, 0);
keyboard_update_states(0, 0, 0, 0);
inv_cmd_response = (dev->type & FLAG_PS2) ? 0xfe : 0xfa;
@@ -3788,7 +3788,7 @@ keyboard_at_close(void *priv)
/* Disable the scancode maps. */
keyboard_set_table(NULL);
keyboard_update_states(0, 0, 0);
keyboard_update_states(0, 0, 0, 0);
SavedKbd = NULL;

View File

@@ -742,7 +742,7 @@ kbd_adddata_process(uint16_t val, void (*adddata)(uint16_t val))
if (!adddata)
return;
keyboard_get_states(NULL, &num_lock, NULL);
keyboard_get_states(NULL, &num_lock, NULL, NULL);
shift_states = keyboard_get_shift() & STATE_LSHIFT;
if (is_amstrad)