diff --git a/Source/HBIOS/ch376-native/keyboard/class_hid.c.s b/Source/HBIOS/ch376-native/keyboard/class_hid.c.s index 06fc1a0e..a893b7fd 100644 --- a/Source/HBIOS/ch376-native/keyboard/class_hid.c.s +++ b/Source/HBIOS/ch376-native/keyboard/class_hid.c.s @@ -168,73 +168,3 @@ _hid_set_idle: pop hl inc sp jp (hl) -;source-doc/keyboard/class_hid.c:26: usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1) { -; --------------------------------- -; Function hid_get_input_report -; --------------------------------- -_hid_get_input_report: - push ix - ld ix,0 - add ix,sp - ld c, l - ld b, h - ld hl, -9 - add hl, sp - ld sp, hl - ld l, c - ld h, b -;source-doc/keyboard/class_hid.c:28: cmd = cmd_hid_set; - push de - push hl - ex de, hl - ld hl,4 - add hl, sp - ex de, hl - ld bc,0x0008 - ld hl,_cmd_hid_set - ldir - pop bc - pop de -;source-doc/keyboard/class_hid.c:30: cmd.bmRequestType = 0xA1; - ld (ix-9),0xa1 -;source-doc/keyboard/class_hid.c:31: cmd.bValue[0] = 1; -;source-doc/keyboard/class_hid.c:32: cmd.bValue[1] = 1; -;source-doc/keyboard/class_hid.c:33: cmd.bRequest = HID_GET_REPORT; - ld a,0x01 - ld (ix-7),a - ld (ix-6),a - ld (ix-8),a -;source-doc/keyboard/class_hid.c:34: cmd.wLength = 8; - ld (ix-3),0x08 - xor a - ld (ix-2),a -;source-doc/keyboard/class_hid.c:36: return usb_control_transfer(&cmd, report, dev->address, dev->max_packet_size); - ld l, c - ld h, b - inc hl - ld a, (hl) - ld (ix-1),a - ld l, c - ld h, b - ld a, (hl) - rlca - rlca - rlca - rlca - and 0x0f - ld h,(ix-1) - ld l,a - push hl - push de - ld hl,4 - add hl, sp - push hl - call _usb_control_transfer - pop af - pop af - pop af - ld a, l -;source-doc/keyboard/class_hid.c:37: } - ld sp, ix - pop ix - ret diff --git a/Source/HBIOS/ch376-native/keyboard/class_hid_keyboard.c.s b/Source/HBIOS/ch376-native/keyboard/class_hid_keyboard.c.s index 185b058b..44aa6d22 100644 --- a/Source/HBIOS/ch376-native/keyboard/class_hid_keyboard.c.s +++ b/Source/HBIOS/ch376-native/keyboard/class_hid_keyboard.c.s @@ -107,29 +107,96 @@ _scancode_to_char: jr C,l_scancode_to_char_00102 ;source-doc/keyboard/class_hid_keyboard.c:352: char scancode_to_char(const uint8_t modifier_keys, const uint8_t code) __sdcccall(1) { xor a - jr l_scancode_to_char_00105 + jr l_scancode_to_char_00123 l_scancode_to_char_00102: ;source-doc/keyboard/class_hid_keyboard.c:354: return 0; ld a, c - and 0x22 - jr Z,l_scancode_to_char_00104 + and 0x11 + jr Z,l_scancode_to_char_00120 ;source-doc/keyboard/class_hid_keyboard.c:355: + ld a, e + sub 0x04 + jr C,l_scancode_to_char_00104 + ld a,0x1d + sub e + jr C,l_scancode_to_char_00104 +;source-doc/keyboard/class_hid_keyboard.c:356: if ((modifier_keys & (KEY_MOD_LCTRL | KEY_MOD_RCTRL))) { + ld a, e + add a,0xfd + jr l_scancode_to_char_00123 +l_scancode_to_char_00104: +;source-doc/keyboard/class_hid_keyboard.c:358: return code - 3; + ld a,e + cp 0x1f + jr Z,l_scancode_to_char_00106 + sub 0x2c + jr NZ,l_scancode_to_char_00107 +l_scancode_to_char_00106: +;source-doc/keyboard/class_hid_keyboard.c:359: + xor a + jr l_scancode_to_char_00123 +l_scancode_to_char_00107: +;source-doc/keyboard/class_hid_keyboard.c:361: return 0; + ld a, e + sub 0x2f + jr NZ,l_scancode_to_char_00110 +;source-doc/keyboard/class_hid_keyboard.c:362: + ld a,0x1b + jr l_scancode_to_char_00123 +l_scancode_to_char_00110: +;source-doc/keyboard/class_hid_keyboard.c:364: return 27; + ld a, e + sub 0x31 + jr NZ,l_scancode_to_char_00112 +;source-doc/keyboard/class_hid_keyboard.c:365: + ld a,0x1c + jr l_scancode_to_char_00123 +l_scancode_to_char_00112: +;source-doc/keyboard/class_hid_keyboard.c:367: return 28; + ld a, e + sub 0x30 + jr NZ,l_scancode_to_char_00114 +;source-doc/keyboard/class_hid_keyboard.c:368: + ld a,0x1d + jr l_scancode_to_char_00123 +l_scancode_to_char_00114: +;source-doc/keyboard/class_hid_keyboard.c:370: return 29; + ld a, e + sub 0x23 + jr NZ,l_scancode_to_char_00116 +;source-doc/keyboard/class_hid_keyboard.c:371: + ld a,0x1e + jr l_scancode_to_char_00123 +l_scancode_to_char_00116: +;source-doc/keyboard/class_hid_keyboard.c:373: return 30; + ld a, e + sub 0x2d + jr NZ,l_scancode_to_char_00120 +;source-doc/keyboard/class_hid_keyboard.c:374: + ld a,0x1f + jr l_scancode_to_char_00123 +l_scancode_to_char_00120: +;source-doc/keyboard/class_hid_keyboard.c:377: } + ld a, c + and 0x22 + jr Z,l_scancode_to_char_00122 +;source-doc/keyboard/class_hid_keyboard.c:378: ld d,0x00 ld hl,_scancodes_shift_table add hl, de ld a,(hl) ld c,a jp _char_with_caps_lock -l_scancode_to_char_00104: -;source-doc/keyboard/class_hid_keyboard.c:357: return char_with_caps_lock(scancodes_shift_table[code]); +l_scancode_to_char_00122: +;source-doc/keyboard/class_hid_keyboard.c:380: return char_with_caps_lock(scancodes_shift_table[code]); ld d,0x00 ld hl,_scancodes_table add hl, de ld a,(hl) ld c,a jp _char_with_caps_lock -l_scancode_to_char_00105: -;source-doc/keyboard/class_hid_keyboard.c:358: +l_scancode_to_char_00123: +;source-doc/keyboard/class_hid_keyboard.c:381: ret _caps_lock_engaged: DEFB +0x01 diff --git a/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.c b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.c index 781d9d9f..e8c0a7b3 100644 --- a/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.c +++ b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid.c @@ -22,16 +22,3 @@ usb_error hid_set_idle(const device_config_keyboard *const dev, const uint8_t du return usb_control_transfer(&cmd, NULL, dev->address, dev->max_packet_size); } - -usb_error hid_get_input_report(const device_config_keyboard *const dev, uint8_t const *report) __sdcccall(1) { - setup_packet cmd; - cmd = cmd_hid_set; - - cmd.bmRequestType = 0xA1; - cmd.bValue[0] = 1; - cmd.bValue[1] = 1; - cmd.bRequest = HID_GET_REPORT; - cmd.wLength = 8; - - return usb_control_transfer(&cmd, report, dev->address, dev->max_packet_size); -} diff --git a/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid_keyboard.c b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid_keyboard.c index 7522a3c1..94c1d2c3 100644 --- a/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid_keyboard.c +++ b/Source/HBIOS/ch376-native/source-doc/keyboard/class_hid_keyboard.c @@ -353,6 +353,29 @@ char scancode_to_char(const uint8_t modifier_keys, const uint8_t code) __sdcccal if (code >= 0x80) return 0; + if ((modifier_keys & (KEY_MOD_LCTRL | KEY_MOD_RCTRL))) { + if (code >= 4 && code <= 0x1d) + return code - 3; + + if (code == 0x1F || code == 0x2C) //@ or SPACE + return 0; + + if (code == 0x2F) // [ + return 27; + + if (code == 0x31) // back slash + return 28; + + if (code == 0x30) // ] + return 29; + + if (code == 0x23) //^ + return 30; + + if (code == 0x2D) //_ + return 31; + } + if (modifier_keys & (KEY_MOD_LSHIFT | KEY_MOD_RSHIFT)) return char_with_caps_lock(scancodes_shift_table[code]);