home *** CD-ROM | disk | FTP | other *** search
/ NetNews Offline 2 / NetNews Offline Volume 2.iso / news / comp / sys / amiga / programmer / 2806 < prev    next >
Encoding:
Text File  |  1996-08-05  |  2.5 KB  |  85 lines

  1. Path: sn.no!not-for-mail
  2. From: ilan@sn.no (Ilan Sharoni)
  3. Newsgroups: comp.sys.amiga.programmer
  4. Subject: Loading a keymap in C
  5. Date: 5 Feb 1996 06:39:53 +0100
  6. Organization: SN Internett
  7. Message-ID: <4f4579$9no@sinsen.sn.no>
  8. NNTP-Posting-Host: sinsen.sn.no
  9. X-Newsreader: THOR 2.0 (SOUP)
  10.  
  11. On 30-Jan-96 07:52:51, Eric Layton (elayton@et.byu.edu) Wrote:
  12. >I wonder if anyone has or knows of some C source code that will load
  13. >a keymap from disk and enable it.  Thanks.
  14.  
  15. > -- Eric  elayton@spock.et.byu.edu
  16.  
  17. Look at the following message, I got it from Christian Steiber.
  18. If you want more, I have a complete code for scanning the keymap.resource
  19. and loading keymap from disk (as parts of a larger project).
  20.  
  21. ============================================================================
  22.  
  23. Ilan Sharoni (ilan@sn.no) wrote:
  24.  
  25. > So wouldn't it be nice with OpenKeyMap() equivalent to OpenFont()?
  26.  
  27. You don't really need to load keymaps very often, do you?
  28.  
  29. > The LoadSeg() returns a pointer to a segList, but I couldn't find what is
  30. > seglist.
  31.  
  32. A keymap file as stored in devs:keymaps/ consists of a
  33. struct KeyMapNode, as defined in <devices/keymap.h>.
  34. To load a keymap, do this:
  35.  
  36. - OpenResource("keymap.resource")
  37. - check whether the keymap is on kr_List
  38. - if not, LoadSeg() it
  39.  
  40. LoadSeg() returns a BPTR, which can be turned into a
  41. struct KeyMapNode * using this expression:
  42.  
  43. BPTR KeyMapSeglist;
  44.  
  45. if ((KeyMapSeglist=LoadSeg(...)))
  46.   {
  47.     KeyMapNode=BADDR(KeyMapSeglist+1);
  48.   }
  49.  
  50. If you dislike adding to a BPTR, use
  51.     KeyMapNode=(struct KeyMapNode *)(((char
  52. *)BADDR(KeyMapSegList))+sizeof(BPTR));
  53.  
  54. Note that if you don't link the keymap into the keymap list, and
  55. if you don't make it the system default, you can unload the keymap
  56. later on with
  57.  
  58. UnloadSeg(KeyMapSeglist);
  59.  
  60. > >Also, note that you cannot unload a keymap (just to prevent questions
  61. > >like "how do I get rid of a keymap..."): because of bad design the
  62. > >system cannot know whether a keymap is in use.
  63.  
  64. > I hope I'll get that far one day :-)
  65.  
  66. Actually, I was wrong in stating that you cannot unload a keymap.
  67. The correct statement is: you cannot unload a keymap that another
  68. process might know about. As long as the keymap is kept private,
  69. you can unload it.
  70.  
  71. Christian
  72.  
  73.  
  74. --
  75.   //   Christian Stieber               Stieber@Informatik.TU-Muenchen.de
  76. \//    Certified Amiga Developer       http://www.leo.org/~stieber/
  77. --------------------------------------------------------------------------
  78.                           Nobody, just nobody
  79.  
  80.  
  81. ==========================================================================
  82.  
  83.  
  84. ilan
  85.