--- nono/vm/lunakbd.cpp 2026/04/29 17:04:52 1.1.1.9 +++ nono/vm/lunakbd.cpp 2026/04/29 17:04:55 1.1.1.10 @@ -20,11 +20,8 @@ // コンストラクタ LunaKeyboard::LunaKeyboard() { - monitor_size = nnSize(30, 1); - led.resize(2); - key_event.dev = this; key_event.func = (DeviceCallback_t)&LunaKeyboard::KeyboardCallback; key_event.time = 0; key_event.SetName("Keyboard Slot"); @@ -42,6 +39,10 @@ LunaKeyboard::LunaKeyboard() mouse_event[i].time = 2_msec * i; mouse_event[i].SetName(string_format("Mouse Slot%d", i)); } + + monitor.func = (MonitorCallback_t)&LunaKeyboard::MonitorUpdate; + monitor.SetSize(30, 1); + monitor.Regist(ID_MONITOR_KEYBOARD); } // デストラクタ @@ -85,10 +86,10 @@ LunaKeyboard::ResetHard() // モニター void -LunaKeyboard::MonitorUpdate(TextScreen& monitor) +LunaKeyboard::MonitorUpdate(Monitor *, TextScreen& screen) { int x, y; - monitor.Clear(); + screen.Clear(); x = mouse_x; y = mouse_y; @@ -100,7 +101,7 @@ LunaKeyboard::MonitorUpdate(TextScreen& y = -999; if (y > 999) y = 999; - monitor.Print(0, 0, "Mouse: x=%-4d y=%-4d %c %c %c", + screen.Print(0, 0, "Mouse: x=%-4d y=%-4d %c %c %c", x, y, (mouse_l ? 'L' : '-'), (mouse_m ? 'M' : '-'), @@ -126,20 +127,31 @@ LunaKeyboard::IsShift() const return pressed[KC_SHIFT_L] || pressed[KC_SHIFT_R]; } -// キー処理 (MD固有部分) -bool -LunaKeyboard::ProcessKey(uint keystat) +// キー入力を1つ処理する +void +LunaKeyboard::KeyInput(uint keystat) { - if (KC_IS_MAKE(keystat)) { + uint keycode = KC_CODE(keystat); + bool ismake = KC_IS_MAKE(keystat); + + assert(keycode < KC_max); + + // 共通処理へ + if (KeyInputCommon(keystat) == false) { + return; + } + + // LED キーの処理 + if (ismake) { // LED はトグル? - uint keycode = KC_CODE(keystat); int n = Keycode2LED(keycode); if (n >= 0) { led[n] = !led[n]; } } - return true; + // LUNA のキーボードはキーボード側でキーリピートしないので + // ここでは何もしなくてよい } // 共通キーコードから LED 番号を返す。LED キーでなければ -1 を返す。