?? kbusb.asm
字號(hào):
.send_error:
mov A,[usb_tx_flags]
and A,~TX_KBD_MASK
mov [usb_tx_flags],A
mov [usb_current_state],A ; mark as such
.exit:
ret
;========================================================================
; FUNCTION:usbkey_putkey
;
;handles key presses in usb environment.
;
; This function is called from within the key scanning loop, each time a
; valid key event has been recognized. A key event is defined as whenever
; an individual key changes state, either up or down. the key is
; identified by a unique number in the accumulator from 1 to XXX,
; where XXX is GENERALLY the corresponding AT101 keyboard number, with
; few execptions (see at101.inc).
;========================================================================
usbkey_putkey:
call usb_alternate_key
jc .done_putkey
call ksc_modifier ;check for a modifier
jnc .non_modifiers
mov A,[usb_tx_flags]
and A,~TX_KBD_MASK
or A, USB_REPORT_KEY ; show that a report is required
mov [usb_tx_flags], A
mov A,[ksc_mod0]
mov [usb_last_mod],A
jmp .done_putkey
.non_modifiers:
index usb_usage_table
push X ; save X on stack
push A ; save key code on stack
mov A,[usb_tx_flags]
and A,~TX_KBD_MASK
or A, USB_REPORT_KEY ; show that a report is required
mov [usb_tx_flags], A
mov A, [ksc_down_up]
cmp A, 0
jnz .add_key_to_buffer ; key down
; otherwise, key is up
.remove_key_from_buffer: ; key is up, so remove if from buffer
mov A, [usb_key_count]
cmp A, 0 ; decrement key count (unless it's 0)
jz .skip_decrement_key_count
dec [usb_key_count]
.skip_decrement_key_count:
mov X, 2
.find_key_in_buffer: ; find the key in the report buffer
pop A
push A
cmp A, [X + usb_report_buffer]
jz .clear_buffer_position
inc X
mov A, X
cmp A, 8
jc .find_key_in_buffer
pop A
jmp .non_modifiers_done ; done search
.clear_buffer_position: ; key found in buffer, so clear position
pop A
mov A, 0
mov [X + usb_report_buffer], A
jmp .non_modifiers_done
.add_key_to_buffer: ; key went down, so put it in the buffer
mov A, [usb_key_count]
cmp A, FFh ; increment key count (unless it's 255)
jz .skip_increment_key_count
inc [usb_key_count]
.skip_increment_key_count:
mov X, 2
.find_free_buffer_position: ; find a free buffer position
mov A, 0
cmp A, [X + usb_report_buffer]
jz .put_key_in_buffer_position
inc X
mov A, X
cmp A, 8
jc .find_free_buffer_position
pop A
jmp .non_modifiers_done ; could not find a free position
; more than 6 keys pressed
.put_key_in_buffer_position: ; found a free buffer position, so put key code there
pop A
mov [X + usb_report_buffer], A
.non_modifiers_done:
pop X
.done_putkey:
ret
XPAGEOFF
;tables for alternate keys
;lookup table for special keys. The keys in this table
;are treated differently.
alt_key_table:
db AT101KB_SLEEP,AT101KB_POWER,AT101KB_WAKE
db AT101KB_MUTE,AT101KB_VOL_INC,AT101KB_VOL_DEC,AT101KB_PLAY_PAUSE
db AT101KB_STOP,AT101KB_SCAN_PREV,AT101KB_SCAN_NEXT,AT101KB_EMAIL,
db AT101KB_CALCULATOR,AT101KB_WWW_SEARCH,AT101KB_WWW_HOME,AT101KB_WWW_FAVORITES
;each key above is represented in a report as a single bit -- 1 == pressed.
;this table contains the masks for the bits representing each key
bit_mask_table:
db 1,2,4,
db 1,2,4,8
db 10h,20h,40h,80h
db 1,2,4,8
;each key's bit mask must be applied to the data byte corresponding to it.
;this table points to the data byte's position in RAM.
pointer_table:
db usb_power_keys,usb_power_keys,usb_power_keys,
db usb_mm_keys,usb_mm_keys,usb_mm_keys,usb_mm_keys
db usb_mm_keys,usb_mm_keys,usb_mm_keys,usb_mm_keys
db usb_mm_keys+1,usb_mm_keys+1,usb_mm_keys+1,usb_mm_keys+1
XPAGEON
NUM_POWER_KEYS: equ 3
NUM_CONSUMER_KEYS: equ 12
NUM_ALT_KEYS: equ NUM_POWER_KEYS + NUM_CONSUMER_KEYS
;========================================================================
; FUNCTION:usb_power_key
;
;handles power, sleep, and wake key presses in usb environment.
;
; This function was invented to trap the power, sleep, and wake key presses
; and maintain a single byte whose format is as follows:
;
; bit 1: 1 = power key pressed
; bit 2: 1 = sleep key pressed
; bit 3 1 = wake key pressed
;
; if any of these three keys changes state, the corresponding bit in the
; bit field is modified and the usb_power_flag is set to indicate that the
; state of the power keys has changed.
;========================================================================
usb_alternate_key:
mov [ksc_work],A ;store key in work byte
mov A,(NUM_ALT_KEYS - 1) ;initialize A to number of power keys
.lp1:
push A ;save index
index alt_key_table ;get lookup
cmp A,[ksc_work] ;compare to key
pop A ;restore index
jz .lp2 ;compare was a success, key found
dec A
jnc .lp1 ;
CLEARC
jmp .exit ;done, get out
.lp2:
;A contains index of found alternate key
push X ;save X
push A ;save index
index pointer_table ;get locale of buffer
mov X,A ;init X to buffer location
pop A ;retrieve index
index bit_mask_table ;now get bit mask into A
push A ;save it
mov A, [ksc_down_up] ; depending on if key went
cmp A, 00h ; up or down
pop A ; restore bit pattern
jz .mod0_up ; key went down
or [X + 0], A ; set bit
jmp .done_putkey
.mod0_up: ; else, key went up
cpl ; so clear bit
and [X + 0], A
.done_putkey:
mov A,X ;get buffer pointer
cmp A,usb_power_keys ;if pointing at power buffer,
mov A,TX_POWER_MASK ;set power flag
jz .set
mov A,TX_MM_MASK ;else set MM flag
.set:
pop X ;restore X
or [usb_tx_flags],A ;set flag
SETC ;set carry indicating key found
.exit:
mov A,[ksc_work] ;restore key code
ret ;and out
XPAGEOFF
usb_usage_table:
db 000h,035h,01eh,01fh,020h,021h,022h,023h ;0-7
db 024h,025h,026h,027h,02dh,02eh,000h,02ah ;8-15
db 02bh,014h,01ah,008h,015h,017h,01ch,018h ;16-23
db 00ch,012h,013h,2fh,030h,031h,039h,004h ;24-31
db 016h,007h,009h,00ah,00bh,00dh,00eh,00fh ;32-39
db 033h,034h,032h,028h,0e1h,064h,01dh,01bh ;40-47
db 006h,019h,005h,011h,010h,036h,037h,038h ;48-55
db 000h,0e5h,0e0h,000h,0e2h,02ch,0e6h,000h ;56-63
db 0e4h,000h,000h,000h,000h,000h,000h,000h ;64-71
db 000h,000h,000h,049h,04ch,000h,000h,050h ;72-79
db 04ah,04dh,000h,052h,051h,04bh,04eh,000h ;80-87
db 000h,04fh,053h,05fh,05ch,059h,000h,054h ;88-95
db 060h,05dh,05ah,062h,055h,061h,05eh,05bh ;96-103
db 063h,056h,057h,000h,058h,000h,029h,000h ;104-111
db 03ah,03bh,03ch,03dh,03eh,03fh,040h,041h ;112-119
db 042h,043h,044h,045h,046h,047h,048h,0e3h ;120-127
db 0e7h,065h,066h,067h,068h,000h,000h,000h ;128-235
XPAGEON
?? 快捷鍵說(shuō)明
復(fù)制代碼
Ctrl + C
搜索代碼
Ctrl + F
全屏模式
F11
切換主題
Ctrl + Shift + D
顯示快捷鍵
?
增大字號(hào)
Ctrl + =
減小字號(hào)
Ctrl + -