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