templeos-info/public/Wb/Home/Src/Kernel/SerialDev/Keyboard.HC.HTML

524 lines
65 KiB
HTML
Executable File

<!DOCTYPE html>
<html lang="en">
<head>
<meta charset="UTF-8">
<meta name="generator" content="TempleOS V5.03">
<meta name="viewport" content="width=device-width">
<link rel="stylesheet" href="/style/templeos.css">
<script src="/script/templeos.js"></script>
<style type="text/css">
.cF0{color:#000000;background-color:#ffffff;}
.cF1{color:#0000aa;background-color:#ffffff;}
.cF2{color:#00aa00;background-color:#ffffff;}
.cF3{color:#00aaaa;background-color:#ffffff;}
.cF4{color:#aa0000;background-color:#ffffff;}
.cF5{color:#aa00aa;background-color:#ffffff;}
.cF6{color:#aa5500;background-color:#ffffff;}
.cF7{color:#aaaaaa;background-color:#ffffff;}
.cF8{color:#555555;background-color:#ffffff;}
.cF9{color:#5555ff;background-color:#ffffff;}
.cFA{color:#55ff55;background-color:#ffffff;}
.cFB{color:#55ffff;background-color:#ffffff;}
.cFC{color:#ff5555;background-color:#ffffff;}
.cFD{color:#ff55ff;background-color:#ffffff;}
.cFE{color:#ffff55;background-color:#ffffff;}
.cFF{color:#ffffff;background-color:#ffffff;}
</style>
</head>
<body>
<pre id="content">
<a name="l1"></a><span class=cF1>asm</span><span class=cF0> {
<a name="l2"></a></span><span class=cFD>NORMAL_KEY_SCAN_DECODE_TABLE</span><span class=cF0>::
<a name="l3"></a> </span><span class=cF1>DU8</span><span class=cF0> 0,</span><span class=cF3>CH_ESC</span><span class=cF0>,</span><span class=cF6>&quot;1234567890-=&quot;</span><span class=cF0>,</span><span class=cF3>CH_BACKSPACE</span><span class=cF0>,</span><span class=cF6>'\t'</span><span class=cF0>;
<a name="l4"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF6>&quot;qwertyuiop[]&quot;</span><span class=cF0>,</span><span class=cF6>'\n'</span><span class=cF0>,0,</span><span class=cF6>&quot;as&quot;</span><span class=cF0>;
<a name="l5"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF6>&quot;dfghjkl;'\`&quot;</span><span class=cF0>,0,</span><span class=cF6>&quot;\\zxcv&quot;</span><span class=cF0>;
<a name="l6"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF6>&quot;bnm,./&quot;</span><span class=cF0>,0,</span><span class=cF6>'*'</span><span class=cF0>,0,</span><span class=cF3>CH_SPACE</span><span class=cF0>,0,0,0,0,0,0;
<a name="l7"></a> </span><span class=cF1>DU8</span><span class=cF0> 0,0,0,0,0,0,0,0,0,0,</span><span class=cF6>'-'</span><span class=cF0>,0,0,0,</span><span class=cF6>'+'</span><span class=cF0>,0;
<a name="l8"></a></span><span class=cFD>SHIFT_KEY_SCAN_DECODE_TABLE</span><span class=cF0>::
<a name="l9"></a> </span><span class=cF1>DU8</span><span class=cF0> 0,</span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>,</span><span class=cF6>&quot;!@#$%^&amp;*()_+&quot;</span><span class=cF0>,</span><span class=cF3>CH_BACKSPACE</span><span class=cF0>,</span><span class=cF6>'\t'</span><span class=cF0>;
<a name="l10"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF6>&quot;QWERTYUIOP{}&quot;</span><span class=cF0>,</span><span class=cF6>'\n'</span><span class=cF0>,0,</span><span class=cF6>&quot;AS&quot;</span><span class=cF0>;
<a name="l11"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF6>&quot;DFGHJKL:\&quot;~&quot;</span><span class=cF0>,0,</span><span class=cF6>&quot;|ZXCV&quot;</span><span class=cF0>;
<a name="l12"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF6>&quot;BNM&lt;&gt;?&quot;</span><span class=cF0>,0,</span><span class=cF6>'*'</span><span class=cF0>,0,</span><span class=cF3>CH_SHIFT_SPACE</span><span class=cF0>,0,0,0,0,0,0;
<a name="l13"></a> </span><span class=cF1>DU8</span><span class=cF0> 0,0,0,0,0,0,0,0,0,0,</span><span class=cF6>'-'</span><span class=cF0>,0,0,0,</span><span class=cF6>'+'</span><span class=cF0>,0;
<a name="l14"></a></span><span class=cFD>CTRL_KEY_SCAN_DECODE_TABLE</span><span class=cF0>::
<a name="l15"></a> </span><span class=cF1>DU8</span><span class=cF0> 0,</span><span class=cF3>CH_ESC</span><span class=cF0>,</span><span class=cF6>&quot;1234567890-=&quot;</span><span class=cF0>,</span><span class=cF3>CH_BACKSPACE</span><span class=cF0>,</span><span class=cF6>'\t'</span><span class=cF0>;
<a name="l16"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF3>CH_CTRLQ</span><span class=cF0>,</span><span class=cF3>CH_CTRLW</span><span class=cF0>,</span><span class=cF3>CH_CTRLE</span><span class=cF0>,</span><span class=cF3>CH_CTRLR</span><span class=cF0>,</span><span class=cF3>CH_CTRLT</span><span class=cF0>,</span><span class=cF3>CH_CTRLY</span><span class=cF0>,</span><span class=cF3>CH_CTRLU</span><span class=cF0>,
<a name="l17"></a> </span><span class=cF3>CH_CTRLI</span><span class=cF0>,</span><span class=cF3>CH_CTRLO</span><span class=cF0>,</span><span class=cF3>CH_CTRLP</span><span class=cF0>,</span><span class=cF6>&quot;[]&quot;</span><span class=cF0>,</span><span class=cF6>'\n'</span><span class=cF0>,0,</span><span class=cF3>CH_CTRLA</span><span class=cF0>,</span><span class=cF3>CH_CTRLS</span><span class=cF0>;
<a name="l18"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF3>CH_CTRLD</span><span class=cF0>,</span><span class=cF3>CH_CTRLF</span><span class=cF0>,</span><span class=cF3>CH_CTRLG</span><span class=cF0>,</span><span class=cF3>CH_CTRLH</span><span class=cF0>,</span><span class=cF3>CH_CTRLJ</span><span class=cF0>,</span><span class=cF3>CH_CTRLK</span><span class=cF0>,</span><span class=cF3>CH_CTRLL</span><span class=cF0>,
<a name="l19"></a> </span><span class=cF6>&quot;;'\`&quot;</span><span class=cF0>,0,</span><span class=cF6>&quot;\\&quot;</span><span class=cF0>,</span><span class=cF3>CH_CTRLZ</span><span class=cF0>,</span><span class=cF3>CH_CTRLX</span><span class=cF0>,</span><span class=cF3>CH_CTRLC</span><span class=cF0>,</span><span class=cF3>CH_CTRLV</span><span class=cF0>;
<a name="l20"></a> </span><span class=cF1>DU8</span><span class=cF0> </span><span class=cF3>CH_CTRLB</span><span class=cF0>,</span><span class=cF3>CH_CTRLN</span><span class=cF0>,</span><span class=cF3>CH_CTRLM</span><span class=cF0>,</span><span class=cF6>&quot;,./&quot;</span><span class=cF0>,0,</span><span class=cF6>'*'</span><span class=cF0>,0,</span><span class=cF3>CH_SPACE</span><span class=cF0>,0,0,0,0,0,0;
<a name="l21"></a> </span><span class=cF1>DU8</span><span class=cF0> 0,0,0,0,0,0,0,0,0,0,</span><span class=cF6>'-'</span><span class=cF0>,0,0,0,</span><span class=cF6>'+'</span><span class=cF0>,0;
<a name="l22"></a>}
<a name="l23"></a>
<a name="l24"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> port, </span><span class=cF1>U8</span><span class=cF0> val)
<a name="l25"></a>{
<a name="l26"></a> </span><span class=cF1>F64</span><span class=cF0> timeout=</span><span class=cF5>tS</span><span class=cF0>+0.125;
<a name="l27"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>&lt;timeout) </span><span class=cF7>{</span><span class=cF0>
<a name="l28"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF5>InU8</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>)&amp;2</span><span class=cF7>)</span><span class=cF0>) {
<a name="l29"></a> </span><span class=cF5>OutU8</span><span class=cF0>(port,val);
<a name="l30"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l31"></a> }
<a name="l32"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l33"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l34"></a>}
<a name="l35"></a>
<a name="l36"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cFD>KbdCmdRead</span><span class=cF0>()
<a name="l37"></a>{
<a name="l38"></a> </span><span class=cF1>F64</span><span class=cF0> timeout=</span><span class=cF5>tS</span><span class=cF0>+0.125;
<a name="l39"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>&lt;timeout)
<a name="l40"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF3>KBD_CTRL</span><span class=cF7>)</span><span class=cF0>&amp;1)
<a name="l41"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>InU8</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>);
<a name="l42"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l43"></a>}
<a name="l44"></a>
<a name="l45"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>KbdCmdFlush</span><span class=cF0>()
<a name="l46"></a>{
<a name="l47"></a> </span><span class=cF1>F64</span><span class=cF0> timeout=</span><span class=cF5>tS</span><span class=cF0>+0.03;
<a name="l48"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>tS</span><span class=cF0>&lt;timeout)
<a name="l49"></a> </span><span class=cF5>InU8</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>);
<a name="l50"></a>}
<a name="l51"></a>
<a name="l52"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>KbdLEDsSet</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> sc)
<a name="l53"></a>{
<a name="l54"></a> </span><span class=cF1>U8</span><span class=cF0> v=0;
<a name="l55"></a> </span><span class=cF5>BEqu</span><span class=cF0>(&amp;v,0,</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;sc,</span><span class=cF3>SCf_SCROLL</span><span class=cF7>)</span><span class=cF0>);
<a name="l56"></a> </span><span class=cF5>BEqu</span><span class=cF0>(&amp;v,1,</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;sc,</span><span class=cF3>SCf_NUM</span><span class=cF7>)</span><span class=cF0>);
<a name="l57"></a> </span><span class=cF5>BEqu</span><span class=cF0>(&amp;v,2,</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;sc,</span><span class=cF3>SCf_CAPS</span><span class=cF7>)</span><span class=cF0>);
<a name="l58"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l59"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>,0xED);
<a name="l60"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>,v);
<a name="l61"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0>
<a name="l62"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l63"></a>}
<a name="l64"></a>
<a name="l65"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>KbdMsCmdAck</span><span class=cF0>(...)
<a name="l66"></a>{
<a name="l67"></a> </span><span class=cF9>I64</span><span class=cF0> i,ack,timeout;
<a name="l68"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;argc;i++) </span><span class=cF7>{</span><span class=cF0>
<a name="l69"></a> timeout=5;
<a name="l70"></a> </span><span class=cF1>do</span><span class=cF0> {
<a name="l71"></a> ack=0;
<a name="l72"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l73"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xD4);
<a name="l74"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>,argv[i]);
<a name="l75"></a> ack=</span><span class=cFD>KbdCmdRead</span><span class=cF0>;
<a name="l76"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l77"></a> </span><span class=cFD>KbdCmdFlush</span><span class=cF0>;
<a name="l78"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l79"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l80"></a> } </span><span class=cF1>while</span><span class=cF0> (ack!=0xFA &amp;&amp; --timeout);
<a name="l81"></a> </span><span class=cF1>if</span><span class=cF0> (!timeout)
<a name="l82"></a> </span><span class=cF5>throw</span><span class=cF0>;
<a name="l83"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l84"></a>}
<a name="l85"></a>
<a name="l86"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>KbdTypeMatic</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> delay)
<a name="l87"></a>{</span><span class=cF2>//Set speed of repeated keys.</span><span class=cF0>
<a name="l88"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l89"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xA7); </span><span class=cF2>//Disable Mouse</span><span class=cF0>
<a name="l90"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xAE); </span><span class=cF2>//Enable Keyboard</span><span class=cF0>
<a name="l91"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>,0xF3);
<a name="l92"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>,delay); </span><span class=cF2>//Typematic rate</span><span class=cF0>
<a name="l93"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xA8); </span><span class=cF2>//Enable Mouse</span><span class=cF0>
<a name="l94"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l95"></a> </span><span class=cFD>KbdCmdFlush</span><span class=cF0>;
<a name="l96"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l97"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l98"></a>}
<a name="l99"></a>
<a name="l100"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>Char2ScanCode</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> ch,</span><span class=cF9>I64</span><span class=cF0> sc_flags=0)
<a name="l101"></a>{</span><span class=cF2>//ASCII val to scan code (Slow).</span><span class=cF0>
<a name="l102"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l103"></a> </span><span class=cF1>U8</span><span class=cF0> *table;
<a name="l104"></a> </span><span class=cF1>if</span><span class=cF0> (sc_flags) </span><span class=cF7>{</span><span class=cF0>
<a name="l105"></a> table=</span><span class=cFD>NORMAL_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l106"></a> </span><span class=cF1>if</span><span class=cF0> (sc_flags &amp; </span><span class=cF3>SCF_CTRL</span><span class=cF0> || ch&lt;26)
<a name="l107"></a> table=</span><span class=cFD>CTRL_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l108"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (sc_flags &amp; </span><span class=cF3>SCF_SHIFT</span><span class=cF0> || </span><span class=cF6>'A'</span><span class=cF0>&lt;=ch&lt;=</span><span class=cF6>'Z'</span><span class=cF0>) {
<a name="l109"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>sc_flags &amp; </span><span class=cF3>SCF_CAPS</span><span class=cF7>)</span><span class=cF0>)
<a name="l110"></a> table=</span><span class=cFD>SHIFT_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l111"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l112"></a> </span><span class=cF1>if</span><span class=cF0> (sc_flags &amp; </span><span class=cF3>SCF_CAPS</span><span class=cF0>)
<a name="l113"></a> table=</span><span class=cFD>SHIFT_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l114"></a> }
<a name="l115"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;0x50;i++)
<a name="l116"></a> </span><span class=cF1>if</span><span class=cF0> (table[i]==ch)
<a name="l117"></a> </span><span class=cF1>return</span><span class=cF0> i|sc_flags;
<a name="l118"></a> </span><span class=cF1>return</span><span class=cF0> sc_flags;
<a name="l119"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l120"></a> table=</span><span class=cFD>NORMAL_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l121"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;0x50;i++)
<a name="l122"></a> </span><span class=cF1>if</span><span class=cF0> (table[i]==ch)
<a name="l123"></a> </span><span class=cF1>return</span><span class=cF0> i;
<a name="l124"></a> table=</span><span class=cFD>SHIFT_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l125"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;0x50;i++)
<a name="l126"></a> </span><span class=cF1>if</span><span class=cF0> (table[i]==ch)
<a name="l127"></a> </span><span class=cF1>return</span><span class=cF0> i|</span><span class=cF3>SCF_SHIFT</span><span class=cF0>;
<a name="l128"></a> table=</span><span class=cFD>CTRL_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l129"></a> </span><span class=cF1>for</span><span class=cF0> (i=0;i&lt;0x50;i++)
<a name="l130"></a> </span><span class=cF1>if</span><span class=cF0> (table[i]==ch)
<a name="l131"></a> </span><span class=cF1>return</span><span class=cF0> i|</span><span class=cF3>SCF_CTRL</span><span class=cF0>;
<a name="l132"></a> </span><span class=cF1>return</span><span class=cF0> 0;
<a name="l133"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l134"></a>}
<a name="l135"></a>
<a name="l136"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cF5>ScanCode2Char</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> sc)
<a name="l137"></a>{</span><span class=cF2>//Scan code to ASCII val.</span><span class=cF0>
<a name="l138"></a> </span><span class=cF1>U8</span><span class=cF0> *table=</span><span class=cFD>NORMAL_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l139"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_E0_PREFIX</span><span class=cF0>)
<a name="l140"></a> </span><span class=cF1>return</span><span class=cF0> 0;
<a name="l141"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_CTRL</span><span class=cF0>)
<a name="l142"></a> table=</span><span class=cFD>CTRL_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l143"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_SHIFT</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l144"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>sc&amp;</span><span class=cF3>SCF_CAPS</span><span class=cF7>)</span><span class=cF0>)
<a name="l145"></a> table=</span><span class=cFD>SHIFT_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l146"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l147"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_CAPS</span><span class=cF0>)
<a name="l148"></a> table=</span><span class=cFD>SHIFT_KEY_SCAN_DECODE_TABLE</span><span class=cF0>;
<a name="l149"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l150"></a> sc&amp;=0x7F;
<a name="l151"></a> </span><span class=cF1>if</span><span class=cF0> (sc&gt;=0x50)
<a name="l152"></a> </span><span class=cF1>return</span><span class=cF0> 0;
<a name="l153"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l154"></a> </span><span class=cF1>return</span><span class=cF0> table[sc];
<a name="l155"></a>}
<a name="l156"></a>
<a name="l157"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cFD>scan_code_map</span><span class=cF0>[0x100]={
<a name="l158"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l159"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l160"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l161"></a> 0,0,0,0,0,0,</span><span class=cF3>SC_SHIFT</span><span class=cF0>,0,0,0,0,0,0,0,0,0,
<a name="l162"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l163"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l164"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l165"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l166"></a>
<a name="l167"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l168"></a> 0,0,0,0,0,0,0,0,0,0,0,0,</span><span class=cF3>SC_ENTER</span><span class=cF0>,</span><span class=cF3>SC_CTRL</span><span class=cF0>,0,0,
<a name="l169"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l170"></a> 0,0,0,0,0,0x35,0,0,</span><span class=cF3>SC_ALT</span><span class=cF0>,0,0,0,0,0,0,0,
<a name="l171"></a> 0,0,0,0,0,0,0,</span><span class=cF3>SC_HOME</span><span class=cF0>,
<a name="l172"></a> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>,</span><span class=cF3>SC_PAGE_UP</span><span class=cF0>,0,</span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>,0,</span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>,0,</span><span class=cF3>SC_END</span><span class=cF0>,
<a name="l173"></a> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>,</span><span class=cF3>SC_PAGE_DOWN</span><span class=cF0>,</span><span class=cF3>SC_INS</span><span class=cF0>,</span><span class=cF3>SC_DELETE</span><span class=cF0>,0,0,0,0,
<a name="l174"></a> 0,0,0,0,</span><span class=cF3>SC_GUI</span><span class=cF0>,0,0,0,
<a name="l175"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l176"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l177"></a>};
<a name="l178"></a>
<a name="l179"></a></span><span class=cF1>U8</span><span class=cF0> </span><span class=cFD>num_lock_map</span><span class=cF0>[0x100]={
<a name="l180"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l181"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l182"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l183"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l184"></a> 0,0,0,0,0,0,0,8,9,10,0,5,6,7,0,2,
<a name="l185"></a> 3,4,11,0x34,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l186"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l187"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l188"></a>
<a name="l189"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l190"></a> 0,0,0,0,0,0,0,0,0,0,0,0,</span><span class=cF3>SC_ENTER</span><span class=cF0>,</span><span class=cF3>SC_CTRL</span><span class=cF0>,0,0,
<a name="l191"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l192"></a> 0,0,0,0,0,0x35,0,0,</span><span class=cF3>SC_ALT</span><span class=cF0>,0,0,0,0,0,0,0,
<a name="l193"></a> 0,0,0,0,0,0,0,</span><span class=cF3>SC_HOME</span><span class=cF0>,
<a name="l194"></a> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>,</span><span class=cF3>SC_PAGE_UP</span><span class=cF0>,0,</span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>,0,</span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>,0,</span><span class=cF3>SC_END</span><span class=cF0>,
<a name="l195"></a> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>,</span><span class=cF3>SC_PAGE_DOWN</span><span class=cF0>,</span><span class=cF3>SC_INS</span><span class=cF0>,</span><span class=cF3>SC_DELETE</span><span class=cF0>,0,0,0,0,
<a name="l196"></a> 0,0,0,0,</span><span class=cF3>SC_GUI</span><span class=cF0>,0,0,0,
<a name="l197"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l198"></a> 0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,0,
<a name="l199"></a>};
<a name="l200"></a>
<a name="l201"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>Char2KeyName</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> ch,</span><span class=cF1>Bool</span><span class=cF0> include_ctrl=</span><span class=cF3>TRUE</span><span class=cF0>)
<a name="l202"></a>{</span><span class=cF2>//ASCII val to key name.</span><span class=cF0>
<a name="l203"></a> </span><span class=cF9>I64</span><span class=cF0> i;
<a name="l204"></a> </span><span class=cF1>U8</span><span class=cF0> buf[</span><span class=cF3>STR_LEN</span><span class=cF0>];
<a name="l205"></a> </span><span class=cF1>if</span><span class=cF0> (ch&lt;=</span><span class=cF3>CH_SPACE</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l206"></a> </span><span class=cF1>switch</span><span class=cF0> [ch] {
<a name="l207"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\n'</span><span class=cF0>:
<a name="l208"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;ENTER&quot;</span><span class=cF0>);
<a name="l209"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l210"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_BACKSPACE</span><span class=cF0>:
<a name="l211"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;BACKSPACE&quot;</span><span class=cF0>);
<a name="l212"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l213"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF6>'\t'</span><span class=cF0>:
<a name="l214"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;TAB&quot;</span><span class=cF0>);
<a name="l215"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l216"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_ESC</span><span class=cF0>:
<a name="l217"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;ESC&quot;</span><span class=cF0>);
<a name="l218"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l219"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_ESC</span><span class=cF0>:
<a name="l220"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;SHIFT_ESC&quot;</span><span class=cF0>);
<a name="l221"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l222"></a> </span><span class=cF1>case</span><span class=cF0> 0: </span><span class=cF2>//nobound switch</span><span class=cF0>
<a name="l223"></a> </span><span class=cF1>case</span><span class=cF0> 29:
<a name="l224"></a> </span><span class=cF1>case</span><span class=cF0> 30:
<a name="l225"></a> *buf=0;
<a name="l226"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l227"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SHIFT_SPACE</span><span class=cF0>:
<a name="l228"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;SHIFT_SPACE&quot;</span><span class=cF0>);
<a name="l229"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l230"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>CH_SPACE</span><span class=cF0>:
<a name="l231"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;SPACE&quot;</span><span class=cF0>);
<a name="l232"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l233"></a> </span><span class=cF1>default</span><span class=cF0>:
<a name="l234"></a> </span><span class=cF1>if</span><span class=cF0> (include_ctrl)
<a name="l235"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf,</span><span class=cF6>&quot;CTRL &quot;</span><span class=cF0>);
<a name="l236"></a> buf[i=</span><span class=cF5>StrLen</span><span class=cF0>(buf)]=ch-1+</span><span class=cF6>'a'</span><span class=cF0>;
<a name="l237"></a> buf[i+1]=0;
<a name="l238"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l239"></a> }
<a name="l240"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cFB>char_bmp_printable</span><span class=cF0>,ch</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l241"></a> *buf=ch;
<a name="l242"></a> buf[1]=0;
<a name="l243"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0>
<a name="l244"></a> *buf=0;
<a name="l245"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrNew</span><span class=cF0>(buf);
<a name="l246"></a>}
<a name="l247"></a>
<a name="l248"></a></span><span class=cF1>U8</span><span class=cF0> *</span><span class=cF5>ScanCode2KeyName</span><span class=cF0>(</span><span class=cF9>I64</span><span class=cF0> sc)
<a name="l249"></a>{</span><span class=cF2>//Scan code to key name.</span><span class=cF0>
<a name="l250"></a> </span><span class=cF9>I64</span><span class=cF0> ch;
<a name="l251"></a> </span><span class=cF1>U8</span><span class=cF0> buf[</span><span class=cF3>STR_LEN</span><span class=cF0>],*st;
<a name="l252"></a> *buf=0;
<a name="l253"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_CTRL</span><span class=cF0>)
<a name="l254"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;CTRL &quot;</span><span class=cF0>);
<a name="l255"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_ALT</span><span class=cF0>)
<a name="l256"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;ALT &quot;</span><span class=cF0>);
<a name="l257"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_SHIFT</span><span class=cF0>)
<a name="l258"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;SHIFT &quot;</span><span class=cF0>);
<a name="l259"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_NO_SHIFT</span><span class=cF0>)
<a name="l260"></a> </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot; &quot;</span><span class=cF0>);
<a name="l261"></a> </span><span class=cF1>if</span><span class=cF0> (ch=</span><span class=cF5>ScanCode2Char</span><span class=cF7>(</span><span class=cF0>sc&amp;255</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l262"></a> st=</span><span class=cF5>Char2KeyName</span><span class=cF0>(ch,</span><span class=cF3>FALSE</span><span class=cF0>);
<a name="l263"></a> </span><span class=cF5>StrCpy</span><span class=cF0>(buf+</span><span class=cF5>StrLen</span><span class=cF7>(</span><span class=cF0>buf</span><span class=cF7>)</span><span class=cF0>,st);
<a name="l264"></a> </span><span class=cF5>Free</span><span class=cF0>(st);
<a name="l265"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l266"></a> </span><span class=cF1>switch</span><span class=cF0> (sc&amp;255) {
<a name="l267"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_BACKSPACE</span><span class=cF0>:</span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;BACK&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l268"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CAPS</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;CAPS&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l269"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_NUM</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;NUM&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l270"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_SCROLL</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;SCROLL&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l271"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_UP</span><span class=cF0>:</span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;UP&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l272"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_DOWN</span><span class=cF0>:</span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;DOWN&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l273"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_LEFT</span><span class=cF0>:</span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;LEFT&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l274"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CURSOR_RIGHT</span><span class=cF0>:</span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;RIGHT&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l275"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_PAGE_UP</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;PAGE_UP&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l276"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_PAGE_DOWN</span><span class=cF0>:</span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;PAGE_DOWN&quot;</span><span class=cF0>);</span><span class=cF1>break</span><span class=cF0>;
<a name="l277"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_HOME</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;HOME&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l278"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_END</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;END&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l279"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_INS</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;INS&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l280"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_DELETE</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;DELETE&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l281"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F1</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F1&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l282"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F2</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F2&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l283"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F3</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F3&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l284"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F4</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F4&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l285"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F5</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F5&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l286"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F6</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F6&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l287"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F7</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F7&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l288"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F8</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F8&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l289"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F9</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F9&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l290"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F10</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F10&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l291"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F11</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F11&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l292"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_F12</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;F12&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l293"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_GUI</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;WINDOWS&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l294"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_PRTSCRN1</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;PRTSCRN1&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l295"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_PRTSCRN2</span><span class=cF0>: </span><span class=cF5>CatPrint</span><span class=cF0>(buf,</span><span class=cF6>&quot;PRTSCRN2&quot;</span><span class=cF0>); </span><span class=cF1>break</span><span class=cF0>;
<a name="l296"></a> }
<a name="l297"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l298"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cF5>StrNew</span><span class=cF0>(buf);
<a name="l299"></a>}
<a name="l300"></a>
<a name="l301"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>KbdBuildSC</span><span class=cF0>(</span><span class=cF1>U8</span><span class=cF0> raw_byte,</span><span class=cF1>Bool</span><span class=cF0> in_irq,</span><span class=cF1>U8</span><span class=cF0> *_last_raw_byte,</span><span class=cF9>I64</span><span class=cF0> *_last_sc)
<a name="l302"></a>{
<a name="l303"></a> </span><span class=cF9>I64</span><span class=cF0> ch,sc_flags,sc,sc2,sc_raw,new_key_f;
<a name="l304"></a> </span><span class=cF1>Bool</span><span class=cF0> set_LEDs=</span><span class=cF3>FALSE</span><span class=cF0>;
<a name="l305"></a> </span><span class=cF1>if</span><span class=cF0> (raw_byte==0xE0) </span><span class=cF7>{</span><span class=cF0>
<a name="l306"></a> *_last_sc&amp;=~0x1FF;
<a name="l307"></a> *_last_raw_byte=raw_byte;
<a name="l308"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l309"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l310"></a> sc=raw_byte;
<a name="l311"></a> </span><span class=cF5>BEqu</span><span class=cF0>(&amp;sc,</span><span class=cF3>SCf_E0_PREFIX</span><span class=cF0>,*_last_raw_byte==0xE0);
<a name="l312"></a> </span><span class=cF5>BEqu</span><span class=cF0>(&amp;sc,</span><span class=cF3>SCf_KEY_UP</span><span class=cF0>,raw_byte &amp; 0x80);
<a name="l313"></a> *_last_raw_byte=raw_byte;
<a name="l314"></a>
<a name="l315"></a> sc_flags=_last_sc-&gt;u32[0]&amp;~0x1FF;
<a name="l316"></a> sc_raw=sc;
<a name="l317"></a>
<a name="l318"></a> </span><span class=cF1>if</span><span class=cF0> (sc_flags &amp; </span><span class=cF3>SCF_NUM</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l319"></a> </span><span class=cF1>if</span><span class=cF0> (sc2=</span><span class=cFD>num_lock_map</span><span class=cF0>[sc.u8[0]])
<a name="l320"></a> sc.u8[0]=sc2;
<a name="l321"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l322"></a> </span><span class=cF1>if</span><span class=cF0> (sc2=</span><span class=cFD>scan_code_map</span><span class=cF0>[sc.u8[0]])
<a name="l323"></a> sc.u8[0]=sc2;
<a name="l324"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l325"></a>
<a name="l326"></a> new_key_f=</span><span class=cF3>SCF_NEW_KEY</span><span class=cF0>;
<a name="l327"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;</span><span class=cF3>SCF_KEY_UP</span><span class=cF0>)
<a name="l328"></a> </span><span class=cF1>switch</span><span class=cF0> (sc&amp;~</span><span class=cF3>SCF_KEY_UP</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l329"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_SHIFT</span><span class=cF0>: sc_flags&amp;=~</span><span class=cF3>SCF_SHIFT</span><span class=cF0>; </span><span class=cF1>break</span><span class=cF0>;
<a name="l330"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CTRL</span><span class=cF0>: sc_flags&amp;=~</span><span class=cF3>SCF_CTRL</span><span class=cF0>; </span><span class=cF1>break</span><span class=cF0>;
<a name="l331"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_ALT</span><span class=cF0>: sc_flags&amp;=~</span><span class=cF3>SCF_ALT</span><span class=cF0>; </span><span class=cF1>break</span><span class=cF0>;
<a name="l332"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_DELETE</span><span class=cF0>: sc_flags&amp;=~</span><span class=cF3>SCF_DELETE</span><span class=cF0>; </span><span class=cF1>break</span><span class=cF0>;
<a name="l333"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_INS</span><span class=cF0>: sc_flags&amp;=~</span><span class=cF3>SCF_INS</span><span class=cF0>; </span><span class=cF1>break</span><span class=cF0>;
<a name="l334"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CAPS</span><span class=cF0>: sc_flags^=</span><span class=cF3>SCF_CAPS</span><span class=cF0>; set_LEDs=</span><span class=cF3>TRUE</span><span class=cF0>; </span><span class=cF1>break</span><span class=cF0>;
<a name="l335"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_NUM</span><span class=cF0>: sc_flags^=</span><span class=cF3>SCF_NUM</span><span class=cF0>; set_LEDs=</span><span class=cF3>TRUE</span><span class=cF0>; </span><span class=cF1>break</span><span class=cF0>;
<a name="l336"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_SCROLL</span><span class=cF0>: sc_flags^=</span><span class=cF3>SCF_SCROLL</span><span class=cF0>; set_LEDs=</span><span class=cF3>TRUE</span><span class=cF0>; </span><span class=cF1>break</span><span class=cF0>;
<a name="l337"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l338"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l339"></a> </span><span class=cF1>switch</span><span class=cF0> (sc) </span><span class=cF7>{</span><span class=cF0>
<a name="l340"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_SHIFT</span><span class=cF0>:
<a name="l341"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bts</span><span class=cF7>(</span><span class=cF0>&amp;sc_flags,</span><span class=cF3>SCf_SHIFT</span><span class=cF7>)</span><span class=cF0>) new_key_f=0;
<a name="l342"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l343"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_CTRL</span><span class=cF0>:
<a name="l344"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bts</span><span class=cF7>(</span><span class=cF0>&amp;sc_flags,</span><span class=cF3>SCf_CTRL</span><span class=cF7>)</span><span class=cF0>) new_key_f=0;
<a name="l345"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l346"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_ALT</span><span class=cF0>:
<a name="l347"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Bts</span><span class=cF7>(</span><span class=cF0>&amp;sc_flags,</span><span class=cF3>SCf_ALT</span><span class=cF7>)</span><span class=cF0>) new_key_f=0;
<a name="l348"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l349"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_DELETE</span><span class=cF0>:
<a name="l350"></a> sc_flags|=</span><span class=cF3>SCF_DELETE</span><span class=cF0>;
<a name="l351"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l352"></a> </span><span class=cF1>case</span><span class=cF0> </span><span class=cF3>SC_INS</span><span class=cF0>:
<a name="l353"></a> sc_flags|=</span><span class=cF3>SCF_INS</span><span class=cF0>;
<a name="l354"></a> </span><span class=cF1>break</span><span class=cF0>;
<a name="l355"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l356"></a>
<a name="l357"></a> sc_flags|=new_key_f;
<a name="l358"></a> sc=sc_flags|sc|(sc_flags|sc_raw)&lt;&lt;32;
<a name="l359"></a> </span><span class=cF1>if</span><span class=cF0> (sc_flags &amp; </span><span class=cF3>SCF_CTRL</span><span class=cF0> &amp;&amp; sc_flags &amp; </span><span class=cF3>SCF_ALT</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l360"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cF0>sc&amp;</span><span class=cF3>SCF_KEY_UP</span><span class=cF7>)</span><span class=cF0>) {
<a name="l361"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;255==</span><span class=cF3>SC_DELETE</span><span class=cF0> &amp;&amp; !</span><span class=cF7>(</span><span class=cF0>sc_flags &amp; </span><span class=cF3>SCF_SHIFT</span><span class=cF7>)</span><span class=cF0>)
<a name="l362"></a> </span><span class=cFD>CtrlAltDel</span><span class=cF0>(sc);
<a name="l363"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l364"></a> </span><span class=cF1>if</span><span class=cF0> (sc&amp;255==</span><span class=cF3>SC_ESC</span><span class=cF0>)
<a name="l365"></a> ch=</span><span class=cF6>'t'</span><span class=cF0>;
<a name="l366"></a> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF1>if</span><span class=cF0> (sc&amp;255==</span><span class=cF3>SC_TAB</span><span class=cF0>)
<a name="l367"></a> ch=</span><span class=cF6>'n'</span><span class=cF0>;
<a name="l368"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l369"></a> ch=</span><span class=cF5>ScanCode2Char</span><span class=cF0>(sc&amp;255);
<a name="l370"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF6>'a'</span><span class=cF0>&lt;=ch&lt;=</span><span class=cF6>'z'</span><span class=cF0>) {
<a name="l371"></a> sc&amp;=~(</span><span class=cF3>SCF_NEW_KEY</span><span class=cF0>|</span><span class=cF3>SCF_NEW_KEY</span><span class=cF0>&lt;&lt;32);
<a name="l372"></a> ch-=</span><span class=cF6>'a'</span><span class=cF0>;
<a name="l373"></a> </span><span class=cFB>kbd</span><span class=cF0>.last_down_scan_code=sc;
<a name="l374"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>keydev</span><span class=cF0>.fp_ctrl_alt_cbs[ch] &amp;&amp;
<a name="l375"></a> </span><span class=cF5>Bt</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>keydev</span><span class=cF0>.ctrl_alt_in_irq_flags,ch</span><span class=cF7>)</span><span class=cF0>==in_irq &amp;&amp;
<a name="l376"></a> </span><span class=cF7>(</span><span class=cF0>!(sc_flags &amp; </span><span class=cF3>SCF_SHIFT</span><span class=cF0>)&amp;&amp;</span><span class=cFB>keydev</span><span class=cF0>.ctrl_alt_no_shift_descs[ch]</span><span class=cF7>)</span><span class=cF0> ||
<a name="l377"></a> sc_flags &amp; </span><span class=cF3>SCF_SHIFT</span><span class=cF0> &amp;&amp; </span><span class=cFB>keydev</span><span class=cF0>.ctrl_alt_shift_descs[ch])
<a name="l378"></a> (*</span><span class=cFB>keydev</span><span class=cF0>.fp_ctrl_alt_cbs[ch])(sc);
<a name="l379"></a> }
<a name="l380"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l381"></a> }
<a name="l382"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l383"></a> </span><span class=cF1>if</span><span class=cF0> (set_LEDs &amp;&amp; !in_irq)
<a name="l384"></a> </span><span class=cFD>KbdLEDsSet</span><span class=cF0>(sc);
<a name="l385"></a> *_last_sc=sc;
<a name="l386"></a>}
<a name="l387"></a>
<a name="l388"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>KbdPktRead</span><span class=cF0>()
<a name="l389"></a>{
<a name="l390"></a> </span><span class=cF1>static</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> last_raw_byte=0;
<a name="l391"></a> </span><span class=cF1>static</span><span class=cF0> </span><span class=cF9>I64</span><span class=cF0> last_sc=0;
<a name="l392"></a> </span><span class=cF1>U8</span><span class=cF0> raw_byte;
<a name="l393"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>GetTSC</span><span class=cF0>&gt;</span><span class=cFB>kbd</span><span class=cF0>.timestamp+</span><span class=cFB>cnts</span><span class=cF0>.time_stamp_freq&gt;&gt;3)
<a name="l394"></a> </span><span class=cF5>FifoU8Flush</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.fifo);
<a name="l395"></a> </span><span class=cFB>kbd</span><span class=cF0>.timestamp=</span><span class=cF5>GetTSC</span><span class=cF0>;
<a name="l396"></a> raw_byte=</span><span class=cF5>InU8</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>);
<a name="l397"></a> </span><span class=cFD>KbdBuildSC</span><span class=cF0>(raw_byte,</span><span class=cF3>TRUE</span><span class=cF0>,&amp;last_raw_byte,&amp;last_sc);
<a name="l398"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF5>FifoU8Cnt</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.fifo</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l399"></a> </span><span class=cF5>FifoU8Ins</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.fifo,raw_byte);
<a name="l400"></a> </span><span class=cF1>if</span><span class=cF0> (raw_byte!=0xE0) {
<a name="l401"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>FifoU8Rem</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.fifo,&amp;raw_byte</span><span class=cF7>)</span><span class=cF0>)
<a name="l402"></a> </span><span class=cF5>FifoU8Ins</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.fifo2,raw_byte);
<a name="l403"></a> }
<a name="l404"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l405"></a> </span><span class=cF5>FifoU8Ins</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.fifo,raw_byte);
<a name="l406"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>FifoU8Rem</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.fifo,&amp;raw_byte</span><span class=cF7>)</span><span class=cF0>)
<a name="l407"></a> </span><span class=cF5>FifoU8Ins</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.fifo2,raw_byte);
<a name="l408"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l409"></a>}
<a name="l410"></a>
<a name="l411"></a></span><span class=cF1>interrupt</span><span class=cF0> </span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>IRQKbd</span><span class=cF0>()
<a name="l412"></a>{
<a name="l413"></a> </span><span class=cF1>CLD</span><span class=cF0>
<a name="l414"></a> </span><span class=cF5>OutU8</span><span class=cF0>(0x20,0x20);
<a name="l415"></a> </span><span class=cFB>kbd</span><span class=cF0>.irqs_working=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l416"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_hard</span><span class=cF0>.install_in_progress) </span><span class=cF7>{</span><span class=cF0>
<a name="l417"></a> </span><span class=cFB>kbd</span><span class=cF0>.rst=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l418"></a> </span><span class=cF1>return</span><span class=cF0>;
<a name="l419"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l420"></a> </span><span class=cFB>keydev</span><span class=cF0>.ctrl_alt_ret_addr=</span><span class=cF5>GetRBP</span><span class=cF0>()(</span><span class=cF9>I64</span><span class=cF0>)+8;
<a name="l421"></a> </span><span class=cFD>KbdPktRead</span><span class=cF0>;
<a name="l422"></a>}
<a name="l423"></a>
<a name="l424"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cF5>KbdInit</span><span class=cF0>()
<a name="l425"></a>{
<a name="l426"></a> </span><span class=cF1>try</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l427"></a> </span><span class=cFD>KbdCmdFlush</span><span class=cF0>;
<a name="l428"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xA7); </span><span class=cF2>//Disable Mouse</span><span class=cF0>
<a name="l429"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_CTRL</span><span class=cF0>,0xAE); </span><span class=cF2>//Enable Keyboard</span><span class=cF0>
<a name="l430"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>,0xF0);
<a name="l431"></a> </span><span class=cFD>KbdCmdSend</span><span class=cF0>(</span><span class=cF3>KBD_PORT</span><span class=cF0>,0x02);
<a name="l432"></a> </span><span class=cFD>KbdLEDsSet</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.scan_code);
<a name="l433"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>catch</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l434"></a> </span><span class=cFD>KbdCmdFlush</span><span class=cF0>;
<a name="l435"></a> </span><span class=cF5>Fs</span><span class=cF0>-&gt;catch_except=</span><span class=cF3>TRUE</span><span class=cF0>;
<a name="l436"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l437"></a> </span><span class=cF5>IntEntrySet</span><span class=cF0>(0x21,&amp;</span><span class=cFD>IRQKbd</span><span class=cF0>);
<a name="l438"></a> </span><span class=cF5>OutU8</span><span class=cF0>(0x21,</span><span class=cF5>InU8</span><span class=cF7>(</span><span class=cF0>0x21</span><span class=cF7>)</span><span class=cF0>&amp;~2);
<a name="l439"></a>}
<a name="l440"></a>
<a name="l441"></a></span><span class=cF1>U0</span><span class=cF0> </span><span class=cFD>KbdHndlr</span><span class=cF0>()
<a name="l442"></a>{
<a name="l443"></a> </span><span class=cF1>static</span><span class=cF0> </span><span class=cF1>U8</span><span class=cF0> last_raw_byte=0;
<a name="l444"></a> </span><span class=cF1>U8</span><span class=cF0> raw_byte;
<a name="l445"></a> </span><span class=cF5>FifoU8Rem</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.fifo2,&amp;raw_byte);
<a name="l446"></a> </span><span class=cFD>KbdBuildSC</span><span class=cF0>(raw_byte,</span><span class=cF3>FALSE</span><span class=cF0>,&amp;last_raw_byte,&amp;</span><span class=cFB>kbd</span><span class=cF0>.scan_code);
<a name="l447"></a> </span><span class=cF1>if</span><span class=cF0> (raw_byte==0xE0) </span><span class=cF7>{</span><span class=cF0>
<a name="l448"></a> </span><span class=cF5>FifoU8Rem</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.fifo2,&amp;raw_byte);
<a name="l449"></a> </span><span class=cFD>KbdBuildSC</span><span class=cF0>(raw_byte,</span><span class=cF3>FALSE</span><span class=cF0>,&amp;last_raw_byte,&amp;</span><span class=cFB>kbd</span><span class=cF0>.scan_code);
<a name="l450"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l451"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cF5>Btr</span><span class=cF7>(</span><span class=cF0>&amp;</span><span class=cFB>kbd</span><span class=cF0>.scan_code,</span><span class=cF3>SCf_NEW_KEY</span><span class=cF7>)</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l452"></a> </span><span class=cFB>kbd</span><span class=cF0>.new_key_timestamp=</span><span class=cFB>kbd</span><span class=cF0>.timestamp;
<a name="l453"></a> </span><span class=cF5>Btr</span><span class=cF0>(&amp;</span><span class=cFB>kbd</span><span class=cF0>.scan_code,32+</span><span class=cF3>SCf_NEW_KEY</span><span class=cF0>);
<a name="l454"></a> </span><span class=cF5>FifoI64Ins</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.scan_code_fifo,</span><span class=cFB>kbd</span><span class=cF0>.scan_code);
<a name="l455"></a> </span><span class=cFB>kbd</span><span class=cF0>.cnt++;
<a name="l456"></a> </span><span class=cF1>if</span><span class=cF0> (!</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.scan_code&amp;</span><span class=cF3>SCF_KEY_UP</span><span class=cF7>)</span><span class=cF0>) {
<a name="l457"></a> </span><span class=cFB>kbd</span><span class=cF0>.last_down_scan_code=</span><span class=cFB>kbd</span><span class=cF0>.scan_code;
<a name="l458"></a> </span><span class=cF5>Bts</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap,</span><span class=cFB>kbd</span><span class=cF0>.scan_code.u8[0]);
<a name="l459"></a> </span><span class=cF5>Bts</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap2,</span><span class=cFB>kbd</span><span class=cF0>.scan_code.u8[4]);
<a name="l460"></a> } </span><span class=cF1>else</span><span class=cF0> {
<a name="l461"></a> </span><span class=cF5>Btr</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap,</span><span class=cFB>kbd</span><span class=cF0>.scan_code.u8[0]);
<a name="l462"></a> </span><span class=cF5>Btr</span><span class=cF0>(</span><span class=cFB>kbd</span><span class=cF0>.down_bitmap2,</span><span class=cFB>kbd</span><span class=cF0>.scan_code.u8[4]);
<a name="l463"></a> }
<a name="l464"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l465"></a>}
<a name="l466"></a>
<a name="l467"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>KbdMsgsQue</span><span class=cF0>()
<a name="l468"></a>{
<a name="l469"></a> </span><span class=cF9>I64</span><span class=cF0> arg1,arg2,msg_code=</span><span class=cF3>MSG_NULL</span><span class=cF0>;
<a name="l470"></a> </span><span class=cF9>CTask</span><span class=cF0> *task_focus;
<a name="l471"></a> </span><span class=cF1>if</span><span class=cF0> (task_focus=</span><span class=cFB>sys_focus_task</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l472"></a> </span><span class=cF1>while</span><span class=cF0> (</span><span class=cF5>FifoI64Rem</span><span class=cF7>(</span><span class=cFB>kbd</span><span class=cF0>.scan_code_fifo,&amp;arg2</span><span class=cF7>)</span><span class=cF0>) {
<a name="l473"></a> arg1=</span><span class=cF5>ScanCode2Char</span><span class=cF0>(arg2);
<a name="l474"></a> </span><span class=cF1>if</span><span class=cF0> (arg2 &amp; </span><span class=cF3>SCF_KEY_UP</span><span class=cF0>) </span><span class=cF7>{</span><span class=cF0>
<a name="l475"></a> </span><span class=cF5>TaskMsg</span><span class=cF0>(task_focus,0,</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>,arg1,arg2,0);
<a name="l476"></a> msg_code=</span><span class=cF3>MSG_KEY_UP</span><span class=cF0>;
<a name="l477"></a> </span><span class=cF7>}</span><span class=cF0> </span><span class=cF1>else</span><span class=cF0> </span><span class=cF7>{</span><span class=cF0>
<a name="l478"></a> </span><span class=cF5>TaskMsg</span><span class=cF0>(task_focus,0,</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>,arg1,arg2,0);
<a name="l479"></a> msg_code=</span><span class=cF3>MSG_KEY_DOWN</span><span class=cF0>;
<a name="l480"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l481"></a> }
<a name="l482"></a> </span><span class=cF7>}</span><span class=cF0>
<a name="l483"></a> </span><span class=cF1>return</span><span class=cF0> msg_code;
<a name="l484"></a>}
<a name="l485"></a>
<a name="l486"></a></span><span class=cF9>I64</span><span class=cF0> </span><span class=cF5>KbdMsEvtTime</span><span class=cF0>()
<a name="l487"></a>{</span><span class=cF2>//Timestamp of last key or mouse event.</span><span class=cF0>
<a name="l488"></a> </span><span class=cF1>if</span><span class=cF0> (</span><span class=cFB>ms_hard</span><span class=cF0>.timestamp&gt;</span><span class=cFB>kbd</span><span class=cF0>.timestamp)
<a name="l489"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFB>ms_hard</span><span class=cF0>.timestamp;
<a name="l490"></a> </span><span class=cF1>else</span><span class=cF0>
<a name="l491"></a> </span><span class=cF1>return</span><span class=cF0> </span><span class=cFB>kbd</span><span class=cF0>.new_key_timestamp;
<a name="l492"></a>}
</span></pre></body>
</html>