.include "system.h65" .include "string.h65" .include "keypad.h65" .include "lcd.h65" .include "ps2_keyboard_simple_handler.h65" .include "ps2_keyboard_text_handler.h65" .export ps2_keyboard_util .import home:absolute .code ;;******************************************************************************** ;; @brief Send various commands to the keyboard and print the response bytes ;; @details ;; - `0`: `0xf0` query scancode set ;; - `1`: `0xee` echo ;; - `2`: `0xf2` identify ;; - `3`: `0xf3` set typematic min speed and delay (`0b0111111`) ;; - `4`: `0xf4` enable ;; - `5`: `0xf5` disable ;; - `6`: `0xf3` set typematic max speed and min delay (`0b00000000`) ;; - `7`: `0xf7` set typematic all ;; - `8`: `0xf8` set make/release all ;; - `9`: `0xed` set CAPSLOCK led ;; - `#`: `0xed` set SCROLLLOCK led ;; - `C`: `0xed` set NUMLOCK led ;; - `D`: `0xed` turn all leds off ;; - `A`: reprint menu ;; - `B`: reprint menu ;; - `*`: jump home ;; For more details, see https://wiki.osdev.org/PS/2_Keyboard ;; @ingroup applications ;;******************************************************************************** .proc ps2_keyboard_util stz kp::_DEBUG_VAL jsr skb::init beq print_menu ps2kb_PrintCmdFailed bra loop print_menu: Print MENU loop: wai lda skb::scancode beq @read_keypad Printf FMT_CODE,skb::scancode stz skb::scancode @read_keypad: lda kp::_DEBUG_VAL jeq loop stz kp::_DEBUG_VAL cmp #'*' jeq home pha jsr lcd::clear pla ldy #0 ; arg for commands ldx #ps2kb::NO_DATA cmp #'0' beq @l0 cmp #'1' beq @l1 cmp #'2' beq @l2 cmp #'3' beq @l3 cmp #'4' beq @l4 cmp #'5' beq @l5 cmp #'6' beq @l6 cmp #'7' beq @l7 cmp #'8' beq @l8 cmp #'9' beq @l9 cmp #'#' beq @lhash cmp #'A' beq @lA cmp #'B' beq @lB cmp #'C' beq @lC cmp #'D' beq @lD jsr lcd::print_char jmp loop @l0: ; get scancode set lda #$f0 ldx #0 ldy #1 bra @send_cmd @l1: ; echo lda #$ee bra @send_cmd @l2: ; identify lda #$f2 ldy #2 bra @send_cmd @l3: ; set typematic min speed and delay lda #$f3 ldx #%01111111 bra @send_cmd @l4: ; enable lda #$f4 bra @send_cmd @l5: ; disable lda #$f5 bra @send_cmd @l6: ; set typematic max speed and min delay lda #$f3 ldx #0 bra @send_cmd @l7: ; set typematic all lda #$f7 bra @send_cmd @l8: ; set make/release all lda #$f8 bra @send_cmd @l9: ; set CAPSLOCK led lda #$ed ldx #kb::MOD::CAPSLOCK bra @send_cmd @lhash: ; set SCROLLLOCK led lda #$ed ldx #kb::MOD::SCROLLLOCK bra @send_cmd @lC: ; set NUMLOCK led lda #$ed ldx #kb::MOD::NUMLOCK bra @send_cmd @lD: ; turn all leds off lda #$ed ldx #0 bra @send_cmd @lA: ; TODO @lB: ; reprint menu jmp print_menu @send_cmd: jsr ps2kb::send_command ps2kb_WaitFinishCmd Printf FMT_CMD_DATA, ps2kb::send_cmd, ps2kb::send_data, ps2kb::cmd_response, ps2kb::cmd_response+1, ps2kb::cmd_response+2 jmp loop .endproc .rodata FMT_CODE: .asciiz "K %x " FMT_CMD_DATA: .asciiz "C %x-%x > %x%x%x" MENU: .byte " EE F2 F3 " .byte " F4 F5 F3' MEN" .byte " T1 T0 LC LN " .asciiz " RET F0 LS L0 "