diff --git a/src/device/keyboard.c b/src/device/keyboard.c index 30b6f53a8..800e7fb8e 100644 --- a/src/device/keyboard.c +++ b/src/device/keyboard.c @@ -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 diff --git a/src/device/keyboard_at.c b/src/device/keyboard_at.c index 605f51e90..fbf167e3f 100644 --- a/src/device/keyboard_at.c +++ b/src/device/keyboard_at.c @@ -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; diff --git a/src/device/keyboard_xt.c b/src/device/keyboard_xt.c index bafc80d88..7e419b39d 100644 --- a/src/device/keyboard_xt.c +++ b/src/device/keyboard_xt.c @@ -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) diff --git a/src/include/86box/keyboard.h b/src/include/86box/keyboard.h index 024b16169..f62896106 100644 --- a/src/include/86box/keyboard.h +++ b/src/include/86box/keyboard.h @@ -271,9 +271,9 @@ extern void keyboard_process(void); extern uint16_t keyboard_convert(int ch); extern void keyboard_input(int down, uint16_t scan); extern void keyboard_all_up(void); -extern void keyboard_update_states(uint8_t cl, uint8_t nl, uint8_t sl); +extern void keyboard_update_states(uint8_t cl, uint8_t nl, uint8_t sl, uint8_t kl); extern uint8_t keyboard_get_shift(void); -extern void keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl); +extern void keyboard_get_states(uint8_t *cl, uint8_t *nl, uint8_t *sl, uint8_t *kl); extern void keyboard_set_states(uint8_t cl, uint8_t nl, uint8_t sl); extern int keyboard_recv(uint16_t key); extern int keyboard_recv_ui(uint16_t key); diff --git a/src/include/86box/machine.h b/src/include/86box/machine.h index fb979172c..d8c213d53 100644 --- a/src/include/86box/machine.h +++ b/src/include/86box/machine.h @@ -101,7 +101,7 @@ #define MACHINE_GAMEPORT 0x00008000 /* sys has int game port */ #define MACHINE_SOUND 0x00010000 /* sys has int sound */ #define MACHINE_NIC 0x00020000 /* sys has int NIC */ -#define MACHINE_MODEM 0x00040000 /* sys has int modem */ +#define MACHINE_AX 0x00040000 /* sys adheres to Japanese AX standard */ /* Feature flags for advanced devices. */ #define MACHINE_APM 0x00080000 /* sys has APM */ #define MACHINE_ACPI 0x00100000 /* sys has ACPI */ diff --git a/src/machine/machine_table.c b/src/machine/machine_table.c index 47320e6fe..7e0ae8d64 100644 --- a/src/machine/machine_table.c +++ b/src/machine/machine_table.c @@ -4804,7 +4804,7 @@ const machine_t machines[] = { .max_multi = 0 }, .bus_flags = MACHINE_AT, - .flags = MACHINE_VIDEO_FIXED, + .flags = MACHINE_VIDEO_FIXED | MACHINE_AX, .ram = { .min = 1024, .max = 4096, diff --git a/src/qt/qt_mainwindow.cpp b/src/qt/qt_mainwindow.cpp index 905a100f4..e966e043a 100644 --- a/src/qt/qt_mainwindow.cpp +++ b/src/qt/qt_mainwindow.cpp @@ -193,7 +193,8 @@ MainWindow::MainWindow(QWidget *parent) scroll_icon_off = QIcon(":/settings/qt/icons/scroll_lock_off.ico"); caps_icon = QIcon(":/settings/qt/icons/caps_lock_on.ico"); caps_icon_off = QIcon(":/settings/qt/icons/caps_lock_off.ico"); - /* TODO: Add Kana indicator here after the keyboard type work is done. */ + kana_icon = QIcon(":/settings/qt/icons/kana_lock_on.ico"); + kana_icon_off = QIcon(":/settings/qt/icons/kana_lock_off.ico"); num_label = new QLabel; num_label->setPixmap(num_icon_off.pixmap(QSize(16, 16))); @@ -207,19 +208,28 @@ MainWindow::MainWindow(QWidget *parent) scroll_label->setPixmap(scroll_icon_off.pixmap(QSize(16, 16))); statusBar()->addPermanentWidget(scroll_label); + kana_label = new QLabel; + kana_label->setPixmap(kana_icon_off.pixmap(QSize(16, 16))); + statusBar()->addPermanentWidget(kana_label); + QTimer* ledKeyboardTimer = new QTimer(this); ledKeyboardTimer->setTimerType(Qt::CoarseTimer); ledKeyboardTimer->setInterval(1); connect(ledKeyboardTimer, &QTimer::timeout, this, [this] () { - uint8_t caps, num, scroll; - keyboard_get_states(&caps, &num, &scroll); + uint8_t caps, num, scroll, kana; + keyboard_get_states(&caps, &num, &scroll, &kana); if (num_label->isVisible()) num_label->setPixmap(num ? this->num_icon.pixmap(QSize(16, 16)) : this->num_icon_off.pixmap(QSize(16, 16))); if (caps_label->isVisible()) caps_label->setPixmap(caps ? this->caps_icon.pixmap(QSize(16, 16)) : this->caps_icon_off.pixmap(QSize(16, 16))); if (scroll_label->isVisible()) - scroll_label->setPixmap(scroll ? this->scroll_icon.pixmap(QSize(16, 16)) : this->scroll_icon_off.pixmap(QSize(16, 16))); + scroll_label->setPixmap(scroll ? this->scroll_icon.pixmap(QSize(16, 16)) : + this->scroll_icon_off.pixmap(QSize(16, 16))); + + if (kana_label->isVisible()) + kana_label->setPixmap(kana ? this->kana_icon.pixmap(QSize(16, 16)) : + this->kana_icon_off.pixmap(QSize(16, 16))); }); ledKeyboardTimer->start(); @@ -253,6 +263,9 @@ MainWindow::MainWindow(QWidget *parent) num_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); scroll_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); caps_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); + /* TODO: Base this on keyboard type instead when that's done. */ + kana_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) && + machine_has_flags(machine, MACHINE_AX)); while (QApplication::overrideCursor()) QApplication::restoreOverrideCursor(); #ifdef USE_WACOM @@ -1499,6 +1512,8 @@ MainWindow::refreshMediaMenu() num_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); scroll_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); caps_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD)); + kana_label->setVisible(machine_has_bus(machine, MACHINE_BUS_PS2_PORTS | MACHINE_BUS_AT_KBD) && + machine_has_flags(machine, MACHINE_AX)); } void diff --git a/src/qt/qt_mainwindow.hpp b/src/qt/qt_mainwindow.hpp index 421b9ce15..917fd43f5 100644 --- a/src/qt/qt_mainwindow.hpp +++ b/src/qt/qt_mainwindow.hpp @@ -191,9 +191,9 @@ private: friend class RendererStack; // For UI variable access by non-primary renderer windows. friend class WindowsRawInputFilter; // Needed to reload renderers on style sheet changes. - QLabel *caps_label, *scroll_label, *num_label; - QIcon caps_icon, scroll_icon, num_icon; - QIcon caps_icon_off, scroll_icon_off, num_icon_off; + QLabel *caps_label, *scroll_label, *num_label, *kana_label; + QIcon caps_icon, scroll_icon, num_icon, kana_icon; + QIcon caps_icon_off, scroll_icon_off, num_icon_off, kana_icon_off; bool isShowMessage = false; };