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