home *** CD-ROM | disk | FTP | other *** search
/ RISCWORLD 7 / RISCWORLD_VOL7.iso / Software / Issue4 / SDL / gcc346 / !SDL / man / SDL_keysym.3 < prev    next >
Encoding:
Text File  |  2006-09-20  |  2.6 KB  |  106 lines

  1. <!-- manual page source format generated by PolyglotMan v3.0.8+X.Org, -->
  2. <!-- available at http://polyglotman.sourceforge.net/ -->
  3.  
  4. <html>
  5. <head>
  6. <title>"SDL_keysym"("3") manual page</title>
  7. </head>
  8. <body bgcolor='#efefef' text='black' link='blue' vlink='#551A8B' alink='red'>
  9. <a href='#toc'>Table of Contents</a><p>
  10.  
  11. <h2><a name='sect0' href='#toc0'>Name</a></h2>
  12. SDL_keysym- Keysym structure 
  13. <h2><a name='sect1' href='#toc1'>Structure Definition</a></h2>
  14. <p>
  15. <br>
  16. <pre>CWtypedef struct{
  17.   Uint8 scancode;
  18.   SDLKey sym;
  19.   SDLMod mod;
  20.   Uint16 unicode;
  21. } SDL_keysym;
  22. </pre><p>
  23.  
  24. <h2><a name='sect2' href='#toc2'>Structure Data</a></h2>
  25.  
  26. <dl>
  27.  
  28. <dt><b>scancode</b> </dt>
  29. <dd>Hardware specific scancode </dd>
  30.  
  31. <dt><b>sym</b> </dt>
  32. <dd>SDL virtual keysym
  33. </dd>
  34.  
  35. <dt><b>mod</b> </dt>
  36. <dd>Current key modifiers </dd>
  37.  
  38. <dt><b>unicode</b> </dt>
  39. <dd>Translated character </dd>
  40. </dl>
  41.  
  42. <h2><a name='sect3' href='#toc3'>Description</a></h2>
  43. <p>
  44. The <b>SDL_keysym</b>
  45. structure is used by reporting key presses and releases since it is a part
  46. of the <i><b>SDL_KeyboardEvent</b></i>. <p>
  47. The <b>scancode</b> field should generally be left alone,
  48. it is the hardware dependent scancode returned by the keyboard. The <b>sym</b>
  49. field is extremely useful. It is the SDL-defined value of the key (see <i>SDL
  50. Key Syms</i>. This field is very useful when you are checking for certain key
  51. presses, like so:  <p>
  52. <br>
  53. <pre>CW.
  54. .
  55. while(SDL_PollEvent(&event)){
  56.   switch(event.type){
  57.     case SDL_KEYDOWN:
  58.       if(event.key.keysym.sym==SDLK_LEFT)
  59.         move_left();
  60.       break;
  61.     .
  62.     .
  63.     .
  64.   }
  65. }
  66. .
  67. .
  68. </pre><p>
  69.  <b>mod</b> stores the current state of the keyboard modifiers as explained in
  70. <i><b>SDL_GetModState</b></i>. The <b>unicode</b> is only used when UNICODE translation is enabled
  71. with <i><b>SDL_EnableUNICODE</b></i>. If <b>unicode</b> is non-zero then this a the UNICODE character
  72. corresponding to the keypress. If the high 9 bits of the character are 0,
  73. then this maps to the equivalent ASCII character: <br>
  74.  <p>
  75. <br>
  76. <pre>CWchar ch;
  77. if ( (keysym.unicode & 0xFF80) == 0 ) {
  78.   ch = keysym.unicode & 0x7F;
  79. }
  80. else {
  81.   printf("An International Character.
  82. ");
  83. }
  84. </pre><p>
  85.  UNICODE translation does have a slight overhead so don't enable it unless
  86. its needed.<br>
  87.  
  88. <h2><a name='sect4' href='#toc4'>See Also</a></h2>
  89. <p>
  90. <i><b>SDLKey</b></i> 
  91. <!--
  92.   
  93.  <p>
  94.  
  95. <hr><p>
  96. <a name='toc'><b>Table of Contents</b></a><p>
  97. <ul>
  98. <li><a name='toc0' href='#sect0'>Name</a></li>
  99. <li><a name='toc1' href='#sect1'>Structure Definition</a></li>
  100. <li><a name='toc2' href='#sect2'>Structure Data</a></li>
  101. <li><a name='toc3' href='#sect3'>Description</a></li>
  102. <li><a name='toc4' href='#sect4'>See Also</a></li>
  103. </ul>
  104. </body>
  105. </html>
  106.