home *** CD-ROM | disk | FTP | other *** search
/ ST-Computer Leser-CD 2000 January / LCD_01_2000.iso / tools / clock237 / source / ehc_lib.txt < prev    next >
Encoding:
Text File  |  1998-03-19  |  2.0 KB  |  79 lines

  1. [E]xternal [H]otkeys [C]lient library
  2. -------------------------------------
  3.  
  4. This small library provides a simple interface to Clocky's external
  5. hotkeys (see the Clocky docs for more information). Feel free to
  6. use/spread/modify/whatever this library.
  7.  
  8. Note: This library needs Clocky v.2.20 or newer. It will not compile
  9. with earlier versions of jclktool.h.
  10.  
  11.  
  12. Example code
  13. ------------
  14.  
  15. First you must initialise the library:
  16.  
  17.     int hotkeysActive;
  18.  
  19.     hotkeysActive = initHotkeys();
  20.  
  21. initHotkeys() returns either 0 (initialisation failed) or a positive
  22. number (initialisation OK).
  23.  
  24. Then register the hotkeys you want to use. Note: The hotkey-functions
  25. always works with *scancodes*, but there are two functions in the
  26. library to convert between ascii and scancode, scan2ascii() and
  27. ascii2scan(). See ech-lib.h for details.
  28.  
  29.     registerHotkey(0x0f);            /* TAB */
  30.     registerHotkey(ascii2scan('p')); /* p */
  31.  
  32. If the hotkey is already registered by another application, this
  33. function will return 0, otherwise a positive number.
  34.  
  35. Use the function checkHotkeys() to check for pressed hotkeys. Note:
  36. This must be done atleast every 100ms, otherwise the keys won't be
  37. detected properly. The following piece of code is usually triggered by
  38. a timer-event.
  39.  
  40.     char hotKey;
  41.  
  42.     if (hotkeysActive)
  43.         if ((hotKey = checkHotkeys()) != 0)
  44.         {
  45.             /* First we checked for keys with no ASCII-value */
  46.             switch (hotKey)
  47.             {
  48.                 case 0x0f:    /* TAB */
  49.                     do_something();
  50.                     break;
  51.             }
  52.  
  53.             /* Then we check for characters */
  54.             hotKey = scan2ascii(hotKey);
  55.             switch (hotKey)
  56.             {
  57.                 case 'p':    /* p */
  58.                     do_something_else();
  59.                     break;
  60.             }
  61.         }
  62.  
  63. When your application exits, you should free your registered hotkeys
  64. with the following call:
  65.  
  66.     removeHotkeys(-1);
  67.  
  68. If you pass -1 as parameter, all you registered hotkeys will be
  69. removed. If you for some reason want to remove one specific hotkey,
  70. kall removeHotkeys() with the scancode of this key as parameter.
  71.  
  72. That's it...
  73.  
  74.  
  75. Jo Even Skarstein
  76. <joska@nuts.edu>
  77.  
  78. 19/03/98
  79.