getkey_8cpp.html 15 KB

123456789101112131415161718192021222324252627282930313233343536373839404142434445464748495051525354555657585960616263646566676869707172737475767778798081828384858687888990919293949596979899100101102103104105106107108109110111112113114115116117118119120121122123124125126127128129130131132133134135136137138139140141142143144145146147148149150151152153154155156157158159160161162163164165166167168169170171172173174175176177178179180181182183184185186187188189190191192193194195196197198199200201202203204205206207208209210211212213214215216217218219220221222223224225226227228229230231232233234235236237238239240241242243244245246247248249250251252253254255256257258259260261262263264265266267268269270271272273274275276277278279280281282283284285286287288
  1. <!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "https://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd">
  2. <html xmlns="http://www.w3.org/1999/xhtml">
  3. <head>
  4. <meta http-equiv="Content-Type" content="text/xhtml;charset=UTF-8"/>
  5. <meta http-equiv="X-UA-Compatible" content="IE=9"/>
  6. <meta name="generator" content="Doxygen 1.8.17"/>
  7. <meta name="viewport" content="width=device-width, initial-scale=1"/>
  8. <title>Bugz Door Project: getkey.cpp File Reference</title>
  9. <link href="tabs.css" rel="stylesheet" type="text/css"/>
  10. <script type="text/javascript" src="jquery.js"></script>
  11. <script type="text/javascript" src="dynsections.js"></script>
  12. <link href="search/search.css" rel="stylesheet" type="text/css"/>
  13. <script type="text/javascript" src="search/searchdata.js"></script>
  14. <script type="text/javascript" src="search/search.js"></script>
  15. <link href="doxygen.css" rel="stylesheet" type="text/css" />
  16. </head>
  17. <body>
  18. <div id="top"><!-- do not remove this div, it is closed by doxygen! -->
  19. <div id="titlearea">
  20. <table cellspacing="0" cellpadding="0">
  21. <tbody>
  22. <tr style="height: 56px;">
  23. <td id="projectalign" style="padding-left: 0.5em;">
  24. <div id="projectname">Bugz Door Project
  25. </div>
  26. </td>
  27. </tr>
  28. </tbody>
  29. </table>
  30. </div>
  31. <!-- end header part -->
  32. <!-- Generated by Doxygen 1.8.17 -->
  33. <script type="text/javascript">
  34. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  35. var searchBox = new SearchBox("searchBox", "search",false,'Search');
  36. /* @license-end */
  37. </script>
  38. <script type="text/javascript" src="menudata.js"></script>
  39. <script type="text/javascript" src="menu.js"></script>
  40. <script type="text/javascript">
  41. /* @license magnet:?xt=urn:btih:cf05388f2679ee054f2beb29a391d25f4e673ac3&amp;dn=gpl-2.0.txt GPL-v2 */
  42. $(function() {
  43. initMenu('',true,false,'search.php','Search');
  44. $(document).ready(function() { init_search(); });
  45. });
  46. /* @license-end */</script>
  47. <div id="main-nav"></div>
  48. <!-- window showing the filter options -->
  49. <div id="MSearchSelectWindow"
  50. onmouseover="return searchBox.OnSearchSelectShow()"
  51. onmouseout="return searchBox.OnSearchSelectHide()"
  52. onkeydown="return searchBox.OnSearchSelectKey(event)">
  53. </div>
  54. <!-- iframe showing the search results (closed by default) -->
  55. <div id="MSearchResultsWindow">
  56. <iframe src="javascript:void(0)" frameborder="0"
  57. name="MSearchResults" id="MSearchResults">
  58. </iframe>
  59. </div>
  60. </div><!-- top -->
  61. <div class="header">
  62. <div class="summary">
  63. <a href="#define-members">Macros</a> &#124;
  64. <a href="#func-members">Functions</a> &#124;
  65. <a href="#var-members">Variables</a> </div>
  66. <div class="headertitle">
  67. <div class="title">getkey.cpp File Reference</div> </div>
  68. </div><!--header-->
  69. <div class="contents">
  70. <p>Key and door input routines.
  71. <a href="#details">More...</a></p>
  72. <div class="textblock"><code>#include &lt;iostream&gt;</code><br />
  73. <code>#include &lt;termios.h&gt;</code><br />
  74. <code>#include &lt;unistd.h&gt;</code><br />
  75. <code>#include &quot;door.h&quot;</code><br />
  76. <code>#include &lt;signal.h&gt;</code><br />
  77. <code>#include &lt;ctype.h&gt;</code><br />
  78. </div><div class="textblock"><div class="dynheader">
  79. Include dependency graph for getkey.cpp:</div>
  80. <div class="dyncontent">
  81. <div class="center"><img src="getkey_8cpp__incl.png" border="0" usemap="#getkey_8cpp" alt=""/></div>
  82. <map name="getkey_8cpp" id="getkey_8cpp">
  83. <area shape="rect" title="Key and door input routines." alt="" coords="373,5,464,32"/>
  84. <area shape="rect" title=" " alt="" coords="5,155,85,181"/>
  85. <area shape="rect" title=" " alt="" coords="110,155,194,181"/>
  86. <area shape="rect" title=" " alt="" coords="219,155,293,181"/>
  87. <area shape="rect" href="door_8h_source.html" title=" " alt="" coords="442,80,505,107"/>
  88. <area shape="rect" title=" " alt="" coords="529,80,602,107"/>
  89. <area shape="rect" title=" " alt="" coords="626,80,697,107"/>
  90. <area shape="rect" title=" " alt="" coords="317,155,416,181"/>
  91. <area shape="rect" title=" " alt="" coords="440,155,507,181"/>
  92. <area shape="rect" title=" " alt="" coords="531,155,589,181"/>
  93. <area shape="rect" title=" " alt="" coords="614,155,687,181"/>
  94. <area shape="rect" title=" " alt="" coords="711,155,798,181"/>
  95. <area shape="rect" title=" " alt="" coords="823,155,884,181"/>
  96. <area shape="rect" title=" " alt="" coords="908,155,985,181"/>
  97. <area shape="rect" title=" " alt="" coords="1010,155,1086,181"/>
  98. <area shape="rect" title=" " alt="" coords="1110,155,1173,181"/>
  99. </map>
  100. </div>
  101. </div><table class="memberdecls">
  102. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="define-members"></a>
  103. Macros</h2></td></tr>
  104. <tr class="memitem:a05e8779289398e4e8028b7f94f6b8009"><td class="memItemLeft" align="right" valign="top">#define&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#a05e8779289398e4e8028b7f94f6b8009">CRNL</a>&#160;&#160;&#160;&quot;\r\n&quot;</td></tr>
  105. <tr class="memdesc:a05e8779289398e4e8028b7f94f6b8009"><td class="mdescLeft">&#160;</td><td class="mdescRight">used by output routines. <a href="getkey_8cpp.html#a05e8779289398e4e8028b7f94f6b8009">More...</a><br /></td></tr>
  106. <tr class="separator:a05e8779289398e4e8028b7f94f6b8009"><td class="memSeparator" colspan="2">&#160;</td></tr>
  107. </table><table class="memberdecls">
  108. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="func-members"></a>
  109. Functions</h2></td></tr>
  110. <tr class="memitem:a4d28072fff7bfaa3de3d1a6357fba261"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#a4d28072fff7bfaa3de3d1a6357fba261">raw</a> (void)</td></tr>
  111. <tr class="memdesc:a4d28072fff7bfaa3de3d1a6357fba261"><td class="mdescLeft">&#160;</td><td class="mdescRight">Enable terminal raw mode. <a href="getkey_8cpp.html#a4d28072fff7bfaa3de3d1a6357fba261">More...</a><br /></td></tr>
  112. <tr class="separator:a4d28072fff7bfaa3de3d1a6357fba261"><td class="memSeparator" colspan="2">&#160;</td></tr>
  113. <tr class="memitem:a3aea9deb2a0bfea9ff05a898f4822e31"><td class="memItemLeft" align="right" valign="top"><a id="a3aea9deb2a0bfea9ff05a898f4822e31"></a>
  114. void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#a3aea9deb2a0bfea9ff05a898f4822e31">reset</a> (void)</td></tr>
  115. <tr class="memdesc:a3aea9deb2a0bfea9ff05a898f4822e31"><td class="mdescLeft">&#160;</td><td class="mdescRight">Reset the terminal termios to the original values. <br /></td></tr>
  116. <tr class="separator:a3aea9deb2a0bfea9ff05a898f4822e31"><td class="memSeparator" colspan="2">&#160;</td></tr>
  117. <tr class="memitem:abbfe4f963938c288581211cdee6cb818"><td class="memItemLeft" align="right" valign="top">signed int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#abbfe4f963938c288581211cdee6cb818">getch</a> (void)</td></tr>
  118. <tr class="memdesc:abbfe4f963938c288581211cdee6cb818"><td class="mdescLeft">&#160;</td><td class="mdescRight">low level getch key read <a href="getkey_8cpp.html#abbfe4f963938c288581211cdee6cb818">More...</a><br /></td></tr>
  119. <tr class="separator:abbfe4f963938c288581211cdee6cb818"><td class="memSeparator" colspan="2">&#160;</td></tr>
  120. <tr class="memitem:a37118b1ee911d1447a495aa49f2926a5"><td class="memItemLeft" align="right" valign="top">void&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#a37118b1ee911d1447a495aa49f2926a5">unget</a> (char c)</td></tr>
  121. <tr class="memdesc:a37118b1ee911d1447a495aa49f2926a5"><td class="mdescLeft">&#160;</td><td class="mdescRight">ungets (pushes key back) <a href="getkey_8cpp.html#a37118b1ee911d1447a495aa49f2926a5">More...</a><br /></td></tr>
  122. <tr class="separator:a37118b1ee911d1447a495aa49f2926a5"><td class="memSeparator" colspan="2">&#160;</td></tr>
  123. <tr class="memitem:a5a392181fdf6b261a23c6996b6f65765"><td class="memItemLeft" align="right" valign="top">char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#a5a392181fdf6b261a23c6996b6f65765">get</a> (void)</td></tr>
  124. <tr class="memdesc:a5a392181fdf6b261a23c6996b6f65765"><td class="mdescLeft">&#160;</td><td class="mdescRight">get a key from the pushback buffer. <a href="getkey_8cpp.html#a5a392181fdf6b261a23c6996b6f65765">More...</a><br /></td></tr>
  125. <tr class="separator:a5a392181fdf6b261a23c6996b6f65765"><td class="memSeparator" colspan="2">&#160;</td></tr>
  126. <tr class="memitem:a48210bb765c651a12818ca2551ace8e2"><td class="memItemLeft" align="right" valign="top">signed int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#a48210bb765c651a12818ca2551ace8e2">getkey</a> (void)</td></tr>
  127. <tr class="memdesc:a48210bb765c651a12818ca2551ace8e2"><td class="mdescLeft">&#160;</td><td class="mdescRight">high level getkey <a href="getkey_8cpp.html#a48210bb765c651a12818ca2551ace8e2">More...</a><br /></td></tr>
  128. <tr class="separator:a48210bb765c651a12818ca2551ace8e2"><td class="memSeparator" colspan="2">&#160;</td></tr>
  129. </table><table class="memberdecls">
  130. <tr class="heading"><td colspan="2"><h2 class="groupheader"><a name="var-members"></a>
  131. Variables</h2></td></tr>
  132. <tr class="memitem:ac317ff25d1fad1066feec2dd66179eec"><td class="memItemLeft" align="right" valign="top"><a id="ac317ff25d1fad1066feec2dd66179eec"></a>
  133. struct termios&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#ac317ff25d1fad1066feec2dd66179eec">tio_default</a></td></tr>
  134. <tr class="memdesc:ac317ff25d1fad1066feec2dd66179eec"><td class="mdescLeft">&#160;</td><td class="mdescRight">Original terminal termios defaults. <br /></td></tr>
  135. <tr class="separator:ac317ff25d1fad1066feec2dd66179eec"><td class="memSeparator" colspan="2">&#160;</td></tr>
  136. <tr class="memitem:a92dfe6e9243e862063a0c3869f784557"><td class="memItemLeft" align="right" valign="top"><a id="a92dfe6e9243e862063a0c3869f784557"></a>
  137. char&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#a92dfe6e9243e862063a0c3869f784557">buffer</a> [10]</td></tr>
  138. <tr class="memdesc:a92dfe6e9243e862063a0c3869f784557"><td class="mdescLeft">&#160;</td><td class="mdescRight">pushback buffer to store keys we're not ready for yet. <br /></td></tr>
  139. <tr class="separator:a92dfe6e9243e862063a0c3869f784557"><td class="memSeparator" colspan="2">&#160;</td></tr>
  140. <tr class="memitem:aaa0e5be04b9ee83acfdd443145061f47"><td class="memItemLeft" align="right" valign="top"><a id="aaa0e5be04b9ee83acfdd443145061f47"></a>
  141. int&#160;</td><td class="memItemRight" valign="bottom"><a class="el" href="getkey_8cpp.html#aaa0e5be04b9ee83acfdd443145061f47">bpos</a> = 0</td></tr>
  142. <tr class="memdesc:aaa0e5be04b9ee83acfdd443145061f47"><td class="mdescLeft">&#160;</td><td class="mdescRight">pushback buffer position <br /></td></tr>
  143. <tr class="separator:aaa0e5be04b9ee83acfdd443145061f47"><td class="memSeparator" colspan="2">&#160;</td></tr>
  144. </table>
  145. <a name="details" id="details"></a><h2 class="groupheader">Detailed Description</h2>
  146. <div class="textblock"><p>Key and door input routines. </p>
  147. </div><h2 class="groupheader">Macro Definition Documentation</h2>
  148. <a id="a05e8779289398e4e8028b7f94f6b8009"></a>
  149. <h2 class="memtitle"><span class="permalink"><a href="#a05e8779289398e4e8028b7f94f6b8009">&#9670;&nbsp;</a></span>CRNL</h2>
  150. <div class="memitem">
  151. <div class="memproto">
  152. <table class="memname">
  153. <tr>
  154. <td class="memname">#define CRNL&#160;&#160;&#160;&quot;\r\n&quot;</td>
  155. </tr>
  156. </table>
  157. </div><div class="memdoc">
  158. <p>used by output routines. </p>
  159. <p>Sending "\n" isn't enough. </p>
  160. </div>
  161. </div>
  162. <h2 class="groupheader">Function Documentation</h2>
  163. <a id="a5a392181fdf6b261a23c6996b6f65765"></a>
  164. <h2 class="memtitle"><span class="permalink"><a href="#a5a392181fdf6b261a23c6996b6f65765">&#9670;&nbsp;</a></span>get()</h2>
  165. <div class="memitem">
  166. <div class="memproto">
  167. <table class="memname">
  168. <tr>
  169. <td class="memname">char get </td>
  170. <td>(</td>
  171. <td class="paramtype">void&#160;</td>
  172. <td class="paramname"></td><td>)</td>
  173. <td></td>
  174. </tr>
  175. </table>
  176. </div><div class="memdoc">
  177. <p>get a key from the pushback buffer. </p>
  178. <dl class="section return"><dt>Returns</dt><dd>char </dd></dl>
  179. </div>
  180. </div>
  181. <a id="abbfe4f963938c288581211cdee6cb818"></a>
  182. <h2 class="memtitle"><span class="permalink"><a href="#abbfe4f963938c288581211cdee6cb818">&#9670;&nbsp;</a></span>getch()</h2>
  183. <div class="memitem">
  184. <div class="memproto">
  185. <table class="memname">
  186. <tr>
  187. <td class="memname">signed int getch </td>
  188. <td>(</td>
  189. <td class="paramtype">void&#160;</td>
  190. <td class="paramname"></td><td>)</td>
  191. <td></td>
  192. </tr>
  193. </table>
  194. </div><div class="memdoc">
  195. <p>low level getch key read </p>
  196. <p>This reads a key with a defined timeout value. This is called by other routines to handle arrow keys, F-keys. returns -1 on timeout (no key), -2 on error (connection closed) </p><dl class="section return"><dt>Returns</dt><dd>signed int </dd></dl>
  197. </div>
  198. </div>
  199. <a id="a48210bb765c651a12818ca2551ace8e2"></a>
  200. <h2 class="memtitle"><span class="permalink"><a href="#a48210bb765c651a12818ca2551ace8e2">&#9670;&nbsp;</a></span>getkey()</h2>
  201. <div class="memitem">
  202. <div class="memproto">
  203. <table class="memname">
  204. <tr>
  205. <td class="memname">signed int getkey </td>
  206. <td>(</td>
  207. <td class="paramtype">void&#160;</td>
  208. <td class="paramname"></td><td>)</td>
  209. <td></td>
  210. </tr>
  211. </table>
  212. </div><div class="memdoc">
  213. <p>high level getkey </p>
  214. <p>This returns function keys, arrow keys, see XKEY_* defines. returns -1 (no key avaiable) or -2 (hangup) or XKEY_UNKNOWN (don't know what it is)</p>
  215. <dl class="section return"><dt>Returns</dt><dd>signed int </dd></dl>
  216. </div>
  217. </div>
  218. <a id="a4d28072fff7bfaa3de3d1a6357fba261"></a>
  219. <h2 class="memtitle"><span class="permalink"><a href="#a4d28072fff7bfaa3de3d1a6357fba261">&#9670;&nbsp;</a></span>raw()</h2>
  220. <div class="memitem">
  221. <div class="memproto">
  222. <table class="memname">
  223. <tr>
  224. <td class="memname">void raw </td>
  225. <td>(</td>
  226. <td class="paramtype">void&#160;</td>
  227. <td class="paramname"></td><td>)</td>
  228. <td></td>
  229. </tr>
  230. </table>
  231. </div><div class="memdoc">
  232. <p>Enable terminal raw mode. </p>
  233. <p>This sets up the linux console so the door library will work correctly in local mode. </p>
  234. </div>
  235. </div>
  236. <a id="a37118b1ee911d1447a495aa49f2926a5"></a>
  237. <h2 class="memtitle"><span class="permalink"><a href="#a37118b1ee911d1447a495aa49f2926a5">&#9670;&nbsp;</a></span>unget()</h2>
  238. <div class="memitem">
  239. <div class="memproto">
  240. <table class="memname">
  241. <tr>
  242. <td class="memname">void unget </td>
  243. <td>(</td>
  244. <td class="paramtype">char&#160;</td>
  245. <td class="paramname"><em>c</em></td><td>)</td>
  246. <td></td>
  247. </tr>
  248. </table>
  249. </div><div class="memdoc">
  250. <p>ungets (pushes key back) </p>
  251. <p>If we read ahead, and we can't use it, we push it back into the buffer for next time. </p><dl class="params"><dt>Parameters</dt><dd>
  252. <table class="params">
  253. <tr><td class="paramname">c</td><td></td></tr>
  254. </table>
  255. </dd>
  256. </dl>
  257. </div>
  258. </div>
  259. </div><!-- contents -->
  260. <!-- start footer part -->
  261. <hr class="footer"/><address class="footer"><small>
  262. Generated by &#160;<a href="http://www.doxygen.org/index.html">
  263. <img class="footer" src="doxygen.png" alt="doxygen"/>
  264. </a> 1.8.17
  265. </small></address>
  266. </body>
  267. </html>