|
用bascom-avr吧 sendscankbd action sends keyboard scan codes to the pc. syntax sendscankbd label | var remarks label the name of the label that contains the scan codes. var the byte variable that will be sent to the pc. the sendscankbd statement can send multiple scan codes to the pc. the label is used to specify the start of the scan codes. the first byte specifies the number of bytes that follow. you can also send the content of a variable. this way you can send dynamic information. you need to make sure you send the make and break codes. the following tables lists all scan codes. at keyboard scancodes table reprinted with permission of adam chapweske http://panda.cs.ndsu.nodak.edu/~achapwes key make break key make break key make break a 1c f0,1c 9 46 f0,46 [ 54 fo,54 b 32 f0,32 ` 0e f0,0e insert e0,70 e0,f0,70 c 21 f0,21 - 4e f0,4e home e0,6c e0,f0,6c d 23 f0,23 = 55 fo,55 pg up e0,7d e0,f0,7d e 24 f0,24 \ 5d f0,5d delete e0,71 e0,f0,71 f 2b f0,2b bksp 66 f0,66 end e0,69 e0,f0,69 g 34 f0,34 space 29 f0,29 pg dn e0,7a e0,f0,7a h 33 f0,33 tab 0d f0,0d u arrow e0,75 e0,f0,75 i 43 f0,43 caps 58 f0,58 l arrow e0,6b e0,f0,6b j 3b f0,3b l shft 12 fo,12 d arrow e0,72 e0,f0,72 k 42 f0,42 l ctrl 14 fo,14 r arrow e0,74 e0,f0,74 l 4b f0,4b l gui e0,1f e0,f0,1f num 77 f0,77 m 3a f0,3a l alt 11 f0,11 kp / e0,4a e0,f0,4a n 31 f0,31 r shft 59 f0,59 kp * 7c f0,7c o 44 f0,44 r ctrl e0,14 e0,f0,14 kp - 7b f0,7b p 4d f0,4d r gui e0,27 e0,f0,27 kp + 79 f0,79 q 15 f0,15 r alt e0,11 e0,f0,11 kp en e0,5a e0,f0,5a r 2d f0,2d apps e0,2f e0,f0,2f kp . 71 f0,71 s 1b f0,1b enter 5a f0,5a kp 0 70 f0,70 t 2c f0,2c esc 76 f0,76 kp 1 69 f0,69 u 3c f0,3c f1 05 f0,05 kp 2 72 f0,72 v 2a f0,2a f2 06 f0,06 kp 3 7a f0,7a w 1d f0,1d f3 04 f0,04 kp 4 6b f0,6b x 22 f0,22 f4 0c f0,0c kp 5 73 f0,73 y 35 f0,35 f5 03 f0,03 kp 6 74 f0,74 z 1a f0,1a f6 0b f0,0b kp 7 6c f0,6c 0 45 f0,45 f7 83 f0,83 kp 8 75 f0,75 1 16 f0,16 f8 0a f0,0a kp 9 7d f0,7d 2 1e f0,1e f9 01 f0,01 ] 5b f0,5b 3 26 f0,26 f10 09 f0,09 ; 4c f0,4c 4 25 f0,25 f11 78 f0,78 ' 52 f0,52 5 2e f0,2e f12 07 f0,07 , 41 f0,41 6 36 f0,36 prnt scrn e0,12, e0,7c e0,f0, 7c,e0, f0,12 . 49 f0,49 7 3d f0,3d scroll 7e f0,7e / 4a f0,4a 8 3e f0,3e pause e1,14,77, e1,f0,14, f0,77 -none- acpi scan codes key make code break code power e0, 37 e0, f0, 37 sleep e0, 3f e0, f0, 3f wake e0, 5e e0, f0, 5e windows multimedia scan codes key make code break code next track e0, 4d e0, f0, 4d previous track e0, 15 e0, f0, 15 stop e0, 3b e0, f0, 3b play/pause e0, 34 e0, f0, 34 mute e0, 23 e0, f0, 23 volume up e0, 32 e0, f0, 32 volume down e0, 21 e0, f0, 21 media select e0, 50 e0, f0, 50 e-mail e0, 48 e0, f0, 48 calculator e0, 2b e0, f0, 2b my computer e0, 40 e0, f0, 40 www search e0, 10 e0, f0, 10 www home e0, 3a e0, f0, 3a www back e0, 38 e0, f0, 38 www forward e0, 30 e0, f0, 30 www stop e0, 28 e0, f0, 28 www refresh e0, 20 e0, f0, 20 www favorites e0, 18 e0, f0, 18 to emulate volume up, the data line would look like this: data 5 , &he0, &h32, &he0, &hf0 , &h32 ^ send 5 bytes ^ volume up see also config atemu example '----------------------------------------------------------------------------------------- 'name : ps2_kbdemul.bas 'copyright : (c) 1995-2005, mcs electronics 'purpose : ps2 at keyboard emulator 'micro : 90s2313 'suited for demo : no, add on needed 'commercial addon needed : yes '----------------------------------------------------------------------------------------- $regfile = "2313def.dat" ' specify the used micro $crystal = 4000000 ' used crystal frequency $baud = 19200 ' use baud rate $hwstack = 32 ' default use 32 for the hardware stack $swstack = 10 ' default use 10 for the sw stack $framesize = 40 ' default use 40 for the frame space $lib "mcsbyteint.lbx" ' use optional lib since we use only bytes 'configure ps2 at pins enable interrupts ' you need to turn on interrupts yourself since an int is used config atemu = int1 , data = pind.3 , clock = pinb.0 ' ^------------------------ used interrupt ' ^----------- pin connected to data ' ^-- pin connected to clock 'note that the data must be connected to the used interrupt pin waitms 500 ' optional delay 'rcall _at_kbd_init print "press t for test, and set focus to the editor window" dim key2 as byte , key as byte do key2 = waitkey() ' get key from terminal select case key2 case "t" : waitms 1500 sendscankbd mark ' send a scan code case else end select loop print hex(key) mark: ' send mark data 12 , &h3a , &hf0 , &h3a , &h1c , &hf0 , &h1c , &h2d , &hf0 , &h2d , &h42 , &hf0 , &h42 ' ^ send 12 bytes ' m a r k
|