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