Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Move typematic rate/delay setting from Kernal init #349

Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
8 changes: 0 additions & 8 deletions kernal/cbm/editor.s
Original file line number Diff line number Diff line change
Expand Up @@ -249,14 +249,6 @@ cint jsr iokeys
@l2
jsr kbd_config ;set keyboard layout

jsr fetch_typematic_from_nvram
bmi @l3
tax
lda #6
jsr extapi

@l3

lda #$c
sta blnct
sta blnsw
Expand Down
6 changes: 5 additions & 1 deletion kernal/drivers/x16/ps2data.s
Original file line number Diff line number Diff line change
Expand Up @@ -18,6 +18,7 @@ PS2DATA_OLD_STYLE = $01
PS2DATA_NEW_STYLE = $02

.import i2c_read_byte, i2c_read_first_byte, i2c_direct_read, i2c_read_next_byte, i2c_read_stop, i2c_write_byte
.import tpmflg
.export ps2data_init, ps2data_fetch, ps2data_kbd, ps2data_kbd_count, ps2data_mouse, ps2data_mouse_count
.export ps2data_keyboard_and_mouse, ps2data_keyboard_only, ps2data_raw

Expand All @@ -38,10 +39,13 @@ PS2DATA_NEW_STYLE = $02
; Data fecth method stored in ps2data_style
; - SMC version < 46.0.0 => PS2DATA_OLD_STYLE
; - SMC version >= 46.0.0 => PS2DATA_NEW_STYLE
;---------------------------------------------------------------
;---------------------- -----------------------------------------
ps2data_init:
KVARS_START

; Clear keyboard set typematic rate/delay flag
stz tpmflg

; Compare SMC firmare version major
ldx #I2C_ADDR
ldy #CMD_GET_VER1
Expand Down
32 changes: 25 additions & 7 deletions kernal/drivers/x16/ps2kbd.s
Original file line number Diff line number Diff line change
Expand Up @@ -32,6 +32,9 @@

.export kbd_config, kbd_scan, receive_scancode_resume, keymap, ps2kbd_typematic
.export MODIFIER_4080
.export tpmflg

.import extapi, fetch_typematic_from_nvram

I2C_ADDRESS = $42
I2C_KBD_ADDRESS = $43
Expand Down Expand Up @@ -65,7 +68,7 @@ kbtmp: .res 1 ; meant for exclusive use in kbd_scan

.segment "KVARSB0"

prefix: .res 1 ; PS/2: prefix code (e0/e1)
tpmflg: .res 1 ; Set typematic rate/delay flag
brkflg: .res 1 ; PS/2: was key-up event
curkbd: .res 1 ; current keyboard layout index
dk_shift:
Expand Down Expand Up @@ -268,31 +271,46 @@ _keymap:
_kbd_scan:
jsr fetch_key_code
ora #0
bne :+
bne @1
rts ; No key

: jsr joystick_from_ps2
; Set typematic rate/delay on first keycode
@1: ldy tpmflg
bne @3
inc tpmflg

pha
phx
jsr fetch_typematic_from_nvram
bmi @2
tax
lda #6
jsr extapi
@2: plx
pla

@3: jsr joystick_from_ps2

; Is it a modifier key?
pha ; Save key code on stack
and #%01111111 ; Clear up/down bit
ldx #0
: cmp modifier_key_codes,x
@4: cmp modifier_key_codes,x
beq is_mod_key
inx
cpx #9 ; Modifier key count = 9
bne :-
bne @4

; Is it Caps Lock down?
cmp #KEYCODE_CAPSLOCK
bne is_reg_key
pla ; Restore key code from stack
bmi :+ ; Ignore key up
bmi @5 ; Ignore key up
lda shflag
eor #MODIFIER_CAPS
sta shflag
jmp set_caps_led
: rts
@5: rts

is_mod_key:
; Restore key code from stack
Expand Down
Loading