|
|
1.1 root 1: //
2: // nono
1.1.1.3 root 3: // Copyright (C) 2020 nono project
4: // Licensed under nono-license.txt
1.1 root 5: //
6:
7: #pragma once
8:
9: #include "keyboard.h"
1.1.1.8 root 10: #include "monitor.h"
1.1.1.2 root 11: #include "scheduler.h"
1.1.1.9 root 12: #include <array>
1.1 root 13:
14: class LunaKeyboard : public Keyboard
15: {
1.1.1.3 root 16: using inherited = Keyboard;
1.1 root 17: public:
18: LunaKeyboard();
1.1.1.6 root 19: virtual ~LunaKeyboard() override;
1.1 root 20:
1.1.1.7 root 21: bool PowerOn() override;
1.1.1.3 root 22: void ResetHard() override;
1.1.1.2 root 23:
1.1.1.7 root 24: // シフト状態なら true を返す
25: bool IsShift() const override;
26:
1.1.1.2 root 27: // マウス入力
1.1.1.3 root 28: void MouseInput(int x, int y, bool rb, bool lb, bool mb) override;
29:
1.1.1.9 root 30: // マウスデータを VM に送信する MD 処理
31: void MouseSendStart() override;
32:
1.1.1.3 root 33: // ホストからの制御コマンド
34: void Command(uint32 data) override;
1.1 root 35:
36: private:
1.1.1.7 root 37: // MD キーコードに変換
1.1.1.10! root 38: uint KeyToMDKey(uint keystat) const override;
1.1.1.7 root 39:
1.1.1.8 root 40: // キーを1つ処理する
41: void KeyInput(uint keystat) override;
1.1.1.3 root 42:
1.1.1.7 root 43: // キーイベントを起こせる空きスロットを計算して、イベントを開始
44: void SendStart() override;
1.1.1.2 root 45:
1.1.1.10! root 46: // イベントを開始
! 47: void Start(uint64 period);
! 48:
! 49: // コールバック
! 50: void Callback(Event& ev);
1.1.1.2 root 51:
1.1.1.7 root 52: // 共通キーコードから LED 番号を取得。
1.1.1.3 root 53: // 0: かな
54: // 1: CAPS
1.1.1.7 root 55: int Keycode2LED(uint keycode) const;
1.1.1.10! root 56: // LED 番号から共通キーコードを取得。
! 57: uint LED2Keycode(int ledcode) const;
! 58:
! 59: // マウスサンプリング
! 60: void MouseSampling();
! 61: void MouseOn();
! 62: void MouseOff();
1.1.1.3 root 63:
1.1.1.8 root 64: DECLARE_MONITOR_CALLBACK(MonitorUpdate);
65:
1.1.1.10! root 66: // マウスサンプリング
! 67: bool mouse_on {};
1.1.1.2 root 68:
1.1.1.10! root 69: // ブザー
! 70: bool buzzer_on {}; // ブザー発音中なら true
! 71: uint buzzer_msec {}; // コマンドで指定した発音時間 [msec]
! 72: uint buzzer_freq {}; // コマンドで指定した発音周波数 [Hz]
! 73: uint64 buzzer_end {}; // ブザーを鳴らし終わる仮想時刻
! 74:
! 75: // イベント
! 76: Event event { this };
1.1.1.2 root 77:
1.1.1.8 root 78: Monitor monitor { this };
79:
1.1 root 80: // 変換テーブル
1.1.1.10! root 81: static const uint keycode2lunakey_table[KC_max];
1.1 root 82:
83: // LUNA キーコード
84: static const uint NoKey = 0;
85: static const uint LunaKey_TAB = 0x09;
86: static const uint LunaKey_CTRL = 0x0a;
87: static const uint LunaKey_kana = 0x0b;
88: static const uint LunaKey_SHIFT_L = 0x0c;
89: static const uint LunaKey_SHIFT_R = 0x0d;
90: static const uint LunaKey_CAPS = 0x0e;
91: static const uint LunaKey_SF = 0x0f;
92:
93: static const uint LunaKey_ESC = 0x10;
94: static const uint LunaKey_BS = 0x11;
95: static const uint LunaKey_enter = 0x12;
96: static const uint LunaKey_space = 0x14;
97: static const uint LunaKey_DEL = 0x15;
98: static const uint LunaKey_XFER = 0x16;
99: static const uint LunaKey_VALID = 0x17;
100: static const uint LunaKey_PF11 = 0x18;
101: static const uint LunaKey_PF12 = 0x19;
102: static const uint LunaKey_PF13 = 0x1a;
103: static const uint LunaKey_PF14 = 0x1b;
104: static const uint LunaKey_up = 0x1c;
105: static const uint LunaKey_left = 0x1d;
106: static const uint LunaKey_right = 0x1e;
107: static const uint LunaKey_down = 0x1f;
108:
109: static const uint LunaKey_1 = 0x22;
110: static const uint LunaKey_2 = 0x23;
111: static const uint LunaKey_3 = 0x24;
112: static const uint LunaKey_4 = 0x25;
113: static const uint LunaKey_5 = 0x26;
114: static const uint LunaKey_6 = 0x27;
115: static const uint LunaKey_7 = 0x28;
116: static const uint LunaKey_8 = 0x29;
117: static const uint LunaKey_9 = 0x2a;
118: static const uint LunaKey_0 = 0x2b;
119: static const uint LunaKey_minus = 0x2c;
120: static const uint LunaKey_circum = 0x2d;
121: static const uint LunaKey_backslash = 0x2e;
122:
123: static const uint LunaKey_Q = 0x32;
124: static const uint LunaKey_W = 0x33;
125: static const uint LunaKey_E = 0x34;
126: static const uint LunaKey_R = 0x35;
127: static const uint LunaKey_T = 0x36;
128: static const uint LunaKey_Y = 0x37;
129: static const uint LunaKey_U = 0x38;
130: static const uint LunaKey_I = 0x39;
131: static const uint LunaKey_O = 0x3a;
132: static const uint LunaKey_P = 0x3b;
133: static const uint LunaKey_at = 0x3c;
134: static const uint LunaKey_bracketleft = 0x3d;
135:
136: static const uint LunaKey_A = 0x42;
137: static const uint LunaKey_S = 0x43;
138: static const uint LunaKey_D = 0x44;
139: static const uint LunaKey_F = 0x45;
140: static const uint LunaKey_G = 0x46;
141: static const uint LunaKey_H = 0x47;
142: static const uint LunaKey_J = 0x48;
143: static const uint LunaKey_K = 0x49;
144: static const uint LunaKey_L = 0x4a;
145: static const uint LunaKey_semicolon = 0x4b;
146: static const uint LunaKey_colon = 0x4c;
147: static const uint LunaKey_bracketright = 0x4d;
148:
149: static const uint LunaKey_Z = 0x52;
150: static const uint LunaKey_X = 0x53;
151: static const uint LunaKey_C = 0x54;
152: static const uint LunaKey_V = 0x55;
153: static const uint LunaKey_B = 0x56;
154: static const uint LunaKey_N = 0x57;
155: static const uint LunaKey_M = 0x58;
156: static const uint LunaKey_comma = 0x59;
157: static const uint LunaKey_period = 0x5a;
158: static const uint LunaKey_slash = 0x5b;
159: static const uint LunaKey_underscore = 0x5c;
160:
161: static const uint LunaKey_PAD_plus = 0x61;
162: static const uint LunaKey_PAD_minus = 0x62;
163: static const uint LunaKey_PAD_7 = 0x63;
164: static const uint LunaKey_PAD_8 = 0x64;
165: static const uint LunaKey_PAD_9 = 0x65;
166: static const uint LunaKey_PAD_4 = 0x66;
167: static const uint LunaKey_PAD_5 = 0x67;
168: static const uint LunaKey_PAD_6 = 0x68;
169: static const uint LunaKey_PAD_1 = 0x69;
170: static const uint LunaKey_PAD_2 = 0x6a;
171: static const uint LunaKey_PAD_3 = 0x6b;
172: static const uint LunaKey_PAD_0 = 0x6c;
173: static const uint LunaKey_PAD_decimal = 0x6d;
174: static const uint LunaKey_PAD_enter = 0x6e;
175:
176: static const uint LunaKey_F1 = 0x72;
177: static const uint LunaKey_F2 = 0x73;
178: static const uint LunaKey_F3 = 0x74;
179: static const uint LunaKey_F4 = 0x75;
180: static const uint LunaKey_F5 = 0x76;
181: static const uint LunaKey_F6 = 0x77;
182: static const uint LunaKey_F7 = 0x78;
183: static const uint LunaKey_F8 = 0x79;
184: static const uint LunaKey_F9 = 0x7a;
185: static const uint LunaKey_F10 = 0x7b;
186: static const uint LunaKey_PAD_multiply = 0x7c;
187: static const uint LunaKey_PAD_divide = 0x7d;
188: static const uint LunaKey_PAD_equal = 0x7e;
189: static const uint LunaKey_PAD_comma = 0x7f;
190: };
This archive runs on limited infrastructure. Preserving old code on modern bandwidth. Automated agents are requested to crawl responsibly.