> KBDDemo 1.10 H Display keyboard keyvalues and demo character conversion functions L Note, the fiddly platform tests may mean this code is not 100% correct (: 2=A%=0:X%=1:os%=((&FFF4)&FF00)256:(K%-128)<>128:K%=128 :escOn$="":escOff$="":11,11:60;13; P5 A%=0 7:"FX"+(221+A%)+","+((A%4)*16+112): Z"FX225,1":"FX4":escOn$ d4"Keypress input/character output test"'36,"-") n/"Program running on ";s(host(os%));". "; x$ (K% 64):"K"; "Native k"; "eycodes are:":kbdinfo(-1) = 8:wdt%=:': wdt%: wdt%<31 wdt%>79:wdt%=79: : 11 : P"Native keycodes: RISCOS-mapped keycodes: Regular keycodes:" F" 1: GET 6: GET A: GET" M" 2: INKEY(100) 7: INKEY(100) B: INKEY(100)" S" 3: INKEY(100+&8000) 8: INKEY(100+&8000) C: INKEY(100+&8000)" $" 4: ADVAL(128-1), buffer read" h" 5: Test ADVAL(-1), EOF#0 9: Toggle kbd map (";"Native RISC OS",(K%192)*7+1,7+(K%<192));")" "Press a key: "; ,:type$=: type$>"`":type$=(type$-32) ' 9+"0123456789ABC",type$):type$ " type$="9":K%=(K%64)128::  type$=9::  type$="0": : "adval%=: adval%=0 , adval%:adval%=(0)1 6 '''::': =17: @5 A%=0 7:"FX"+(221+A%)+","+((A%4)*16+128): J@ os%>4: "678ABC",type$): A%=0 7:"FX"+(221+A%)+",2": T%"FX219,9":"FX254,"+K%:"FX4,2" ^ type$="5":buftest: h escOff$ r6 "Esc+Esc to end"''"Returned keycodes should be:" |D type$<"5":kbdinfo(-1) type$>"8":kbdinfo(8) kbdinfo(6) col%=0:key%=0  last%=key%  type$="1":key%=  type$="6":key%=rok_GET  type$="A":key%=kbd_GET  type$="2":key%=(100) $ type$="7":key%=rok_INKEY(100) $ type$="B":key%=kbd_INKEY(100) ! type$="3":key%=(&8000+100) * type$="8":key%=rok_INKEY(&8000+100) * type$="C":key%=kbd_INKEY(&8000+100)  type$="4":key%=buf_rd(0)  h0(key%,3)'col%,9);  A%=0 3: A%=2:A%=3 )A$=("FNc"+(A%)+"("+(key%255)+")") & A$'col%,9); 0 A% :! 4,11);5,9);:col%=col%+5 DE (wdt%>0 (col%>wdt%-4 (<5 >0))) col%>70:8'''':col%=0 Nkey%=key% 255 X* (key%=27 last%=27) (-1 -113) b '''' l v:  buftest eof%=: eof%=0  eof%:A%=#0 ptr%=: ptr%=0  ptr%:A%=#0 ext%=: ext%=0  ext%:A%=#0  '''::': =17: F'"Type at the keyboard, press SHIFT to fetch, "'"Escape to quit"'  < "ADVAL(-1)=";:A%=(-1):;A%;" not",A%<>0);" empty";4 O "EOF#0=";: eof%=0: "unsupported" A%=#0:;A%;" no",A%);" pending";4 3 "PTR#0=";: ptr%=0: "unsupported" ;#0;3 3 "EXT#0=";: ext%=0: "unsupported" ;#0;3  % "INKEY=";: -1:;(0);" " $ 11,11,11,11,11: -1 -113:   *: 4kbdinfo(A%) >_ A%=-1: (-256&DB)=&53:"&8x: c<-,c->,Home,End,PgUp,PgDn,Ins,Del,<-,->,Dn, Up,MsDn,MsUp" Hh A%=-1: (-256&DB)=&53:"&9x: F0, F1, F2, F3, F4, F5, F6, F7, F8,F9,F10,F11,F12,f13,f14,f15": R A%=-1:A%=os% \T A%<8 (K%64):"&8x: F0,F1,F2,F3,F4,F5,F6,F7,F8,F9,Break,Copy,<-,->, Dn , Up" fH A%<8 (K%64):"&9x:"48"PgDn,PgUp"'"&Cx:"32"F10, F11,F12,Ins": pN A%>7:"&8x: F0,F1,F2,F3,F4,F5,F6, F7, F8, F9, F10, F11, F12,f13,f14,f15" zA A%>7:"&Cx:"18"Ins,Del,Home,End,PgDn,PgUp, <-, ->, Dn, Up"  : ݤhost(A%) v A%>27: A%<33:="Commodore 64/128TI Calculator Amstrad CPC ZX Spectrum DOS/Windows ",A%*16-447,16) q A%<11:="ElectronBBC B BBC B+ Master MasterETCompact RISC OS SpringbdUnix 6809UnixApple ",A%*8+1,8) Y A%=17:="6809Beeb" A%=24:="CP/M" A%=43:="RT11/RSX/RSTS" A%=57:="6809DOS" ="unknown" : #ݤh0(A%,N%)="0000000"+~A%,N%) /ݤs(A$):A$,1)=" ":A$=A$,2):A$,1)<>" " +A$,1)=" ":A$=A$,A$-1):A$,1)<>" " =A$ :  Character conversions )ݤc0(A%): A%>127:="|!"+c0(A% 127) @ A%<32 A%=127:="|"+(A% 64) ="|",A%=34 A%=124)+A% $7ݤc1(A%): ((A%+1) 127)<33:="^"+(A% 64) =A% .)ݤc2(A%): A%<32 A%=127:="." =A% 8,ݤc3(A%): ((A%+1) 127)<33:="." =A% B: L Buffer read Vݤbuf_rd(X%) `) adval%::A%=(127-X%):A%<&8000:=A% j*:A%=&91:A%=&FFF4: (A% &1000000)=0 t=(A% &FF0000) 65536 ~:  Return RISC OS key mapping 4ݤrok_GET: A%: A%=rok_INKEY(100): A%<>-1:=A% +ݤrok_INKEY(T%): os%>7:=ro2_INKEY(T%) "A%=(T%): A%>&7F:A%=A% &100 1 os%>4: A%=0:A%=(T%): A%>&7F:A%=A% &100 =A% ݤro2_INKEY(T%) "A%=kbd_INKEY(T%):A%<&100:=A% (A%&CE)=&C4:=A%+10 (A%&CF)=&C6:=A%+7 (A%&CF)=&C8:=&1E (A%&CF)=&C9:=A%-&3E (A%&CE)=&CA:=(A%&50)+4  =A%((A%15)>9&40) : . General cross-platform regular key input (4ݤkbd_GET: A%: A%=kbd_INKEY(100): A%<>-1:=A% 2ݤkbd_INKEY(T%) <% (-256&DB)=&53:=kbd_Inkey(T%) F A%=(T%) P A%=&AA: -2=0:=A% Z A%=&DD: -1=0:=A% d A%=&9C: -30=0:=A% n A%>&7F:A%=A% &100 x1 os%>4: A%=0:A%=(T%): A%>&7F:A%=A% &100  os%>7:=A%  A%<&100: A%<>30:=A% + A%=30:=&1C8+(-116)+(-232) : Home 4 (A%&CF)=&CD:=A%-7 : Ins > (A%15)>9:A%=A%&40 : F10-F12/cursors 4 (A%&CF)=&CB:=A%-2 : End K (A%&DE)=&CE:=A%+(-112) : Down/Up or Shift-PgDn/Shift-PgUp K (A%&DE)=&DE:=A%-20+(-120) : Shift-Down/Shift-Up or PgDn/PgUp =A% :  > BLib.Win.Keyboard 0.11  03-Dec-2005: J.G.Harston : 4ݤkbd_Get: A%: A%=kbd_Inkey(100): A%<>-1:=A% %ݤkbd_Inkey(T%):A%,S%:T%<0:=T% 4A%=T%:S%=(-116)+(-232)+(-348):A%<128:=A% "A%=&80:-3:=&A4 ,A%=&A6:-3:=A% 6A%=&A3:-18:=A% @A%=&AC:-46:=A% JA%<&82:=A%+&16C TA%>&9F:=A%-16+&100 ^*A%>&9B:S%32:=(A%+&14C)((A%>&9D)1) hA%=&9A:S%16:=&1D1 rA%>&8F:=A%-16+&100 |-=("&"+"89BA67CDEF45",A%-129,1))+S%+&1C0