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