> KBDDEMO # Needs to run in I/O processor : ( debug%= 2 128 < "USB Keyboard Demo 1 v0.10" F< M%(32),K% 255,data% 31: A%=128 255 4:K%!A%=0: A% P9 A%=0 143: A$: A$=1:K%?A%=A$ K%?A%=("&"+A$) Z A% d: n"Waiting for HID device"; x"usb_Init:usb_Sync:usb_Flush -usb_Cmd("IPH") : I/O IN BINARY ; If IPH gives Bad command we're already in binary mode ':usb_Cmd("QP2") : QUERY PORT 2 hid%=?usb_result%:usb_Sync  (hid% 8)=0:A%=(100)  (hid% 8) 1usb_Cmd("SC "+0) : SET CURRENT DEVICE 0 :  " - Connected"'"Data:"''' col%=0:caps%=0 : -usb_WrStr("DRD"+13) : DEVICE READ DATA 9num%=usb_Rd: num%: T%=0 num%:M%(T%)=usb_Rd: T%  usb_Sync  num%=8 (M%(1) M%(3)) Ex%=:y%=:6,2);: T%=1 num%:h0(M%(T%),2);" ";:T%:x%,y%); "0T%=3::key(M%(1),M%(T%)):T%=T%+1: M%(T%)<4 , 6 @: Jkey(shift%,keycode%) T# keycode%<4:: Keyboard error ^ 11,11 hkey%=K%?keycode% rshift%=shift% (shift%16) | key%=&C0:caps%= caps% 6 (shift% 1): key%>63: key%<127:key%=key% 31 5 (shift% 2): key%>32: key%<64:key%=key% 16 > (shift% 2) caps%: key%>63: key%<127:key%=key% 32 col%,);h0(keycode%,3) col%,);h0(key%,3) col%,);c0(key%255) col%,-1);5,9);  col%=col%+5: <5:'':col%=0  : #ݤh0(A%,N%)="0000000"+~A%,N%) &ݤc0(A%):A%>127:="|!"+c0(A%127) 7A%<32A%=127:="|"+(A%64)="|",A%=34A%=124)+A% : E E0,E1,E2,E2,a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,q,r,s,t,u,v,w,x,y,z 8 1,2,3,4,5,6,7,8,9,0,0D,1B,08,09,20,-,=,[,],\,#,;,' &8 `,2C,.,/,C0,81,82,83,84,85,86,87,88,89,8A,8B,8C,80 0) C3,CA,8D,C8,DF,7F,CB,DE,CD,CC,CE,CF :, C2,EF,EA,ED,EB,E0,F1,F2,F3,F4,F5,F6,F7 D4 F8,F9,F0,EE,\,C1,C0,FD,CD,CE,CF,D0,D1,D2,D3,D4 N5 D5,D6,D7,D8,D9,DA,C1,97,98,99,9A,9B,9C,9D,9E,9F X3 80,81,82,83,84,85,86,\,C7,\,C6,C5,8C,8D,8E,8F b: l: v > USBLib 1.00 :  USB access routines  =================== +usb_Sync:A%=?usb_D:(?usb_S 128): !usb_Flush:(?usb_S 128): 2'"Flushing USB";::A%=?usb_D:(?usb_S 128) $A%=+20:>A%:(?usb_S 128): Vݤusb_Err:?usb_result%=13 usb_result%?1=":":=0 "USB Error: "$usb_result%:= 1usb_Cmd(A$):usb_WrStr(A$+13):usb_RdStr: (ݤusb_Cmd(A$):usb_Cmd(A$):=usb_Err #usb_WrStr(A$):debug%:0:129 O A%=1 A$:(?usb_S 64)=0:?usb_D=A$,A%,1):debug%:c0(A$,A%,1)); :debug%:1:128   ?usb_RdStr:A%=usb_result%-1:A%=A%+1:?A%=usb_Rd:?A%=13: .usb_Wr(A%):(?usb_S 64)=0:?usb_D=A%:  Eݤusb_Rd:(?usb_S 128)=0:Z%=?usb_D:debug%:c0(Z%);:=Z% =Z% *usb_Init 4usb_D=&FCF8:usb_S=&FCF9 >+usb_result%=usb_result%: usb_result%: H usb_result% 63,mc% 99 R P=0 1:P%=mc%:[OPT P*2 \.usb_RdData f'TAY:LDA #data% 255:STA usb_RdLp+4 p*LDA #data% 256:STA usb_RdLp+5:LDX #0 z5.usb_RdLp:JSR usb_Rd:STA data%,X:INX:BNE usb_RdLp 'INC usb_RdLp+5:DEY:BNE usb_RdLp:RTS 4.usb_Rd:BIT usb_S:BPL usb_Rd2:BIT &FF:BPL usb_Rd .usb_Rd2:LDA usb_D:RTS .usb_WrData 'TAY:LDA #data% 255:STA usb_WrLp+1 *LDA #data% 256:STA usb_WrLp+2:LDX #0 $.usb_WrLp:LDA data%,X:JSR usb_Wr 0.usb_WrLp2:LDA usb_D:BIT usb_S:BPL usb_WrLp2 INX:BNE usb_WrLp 'INC usb_WrLp+2:DEY:BNE usb_WrLp:RTS 4.usb_Wr:BIT usb_S:BVC usb_Wr2:BIT &FF:BPL usb_Wr .usb_Wr2:STA usb_D:RTS ]: :