home *** CD-ROM | disk | FTP | other *** search
- Path: sn.no!not-for-mail
- From: ilan@sn.no (Ilan Sharoni)
- Newsgroups: comp.sys.amiga.programmer
- Subject: Loading a keymap in C
- Date: 5 Feb 1996 06:39:53 +0100
- Organization: SN Internett
- Message-ID: <4f4579$9no@sinsen.sn.no>
- NNTP-Posting-Host: sinsen.sn.no
- X-Newsreader: THOR 2.0 (SOUP)
-
- On 30-Jan-96 07:52:51, Eric Layton (elayton@et.byu.edu) Wrote:
- >I wonder if anyone has or knows of some C source code that will load
- >a keymap from disk and enable it. Thanks.
-
- > -- Eric elayton@spock.et.byu.edu
-
- Look at the following message, I got it from Christian Steiber.
- If you want more, I have a complete code for scanning the keymap.resource
- and loading keymap from disk (as parts of a larger project).
-
- ============================================================================
-
- Ilan Sharoni (ilan@sn.no) wrote:
-
- > So wouldn't it be nice with OpenKeyMap() equivalent to OpenFont()?
-
- You don't really need to load keymaps very often, do you?
-
- > The LoadSeg() returns a pointer to a segList, but I couldn't find what is
- > seglist.
-
- A keymap file as stored in devs:keymaps/ consists of a
- struct KeyMapNode, as defined in <devices/keymap.h>.
- To load a keymap, do this:
-
- - OpenResource("keymap.resource")
- - check whether the keymap is on kr_List
- - if not, LoadSeg() it
-
- LoadSeg() returns a BPTR, which can be turned into a
- struct KeyMapNode * using this expression:
-
- BPTR KeyMapSeglist;
-
- if ((KeyMapSeglist=LoadSeg(...)))
- {
- KeyMapNode=BADDR(KeyMapSeglist+1);
- }
-
- If you dislike adding to a BPTR, use
- KeyMapNode=(struct KeyMapNode *)(((char
- *)BADDR(KeyMapSegList))+sizeof(BPTR));
-
- Note that if you don't link the keymap into the keymap list, and
- if you don't make it the system default, you can unload the keymap
- later on with
-
- UnloadSeg(KeyMapSeglist);
-
- > >Also, note that you cannot unload a keymap (just to prevent questions
- > >like "how do I get rid of a keymap..."): because of bad design the
- > >system cannot know whether a keymap is in use.
-
- > I hope I'll get that far one day :-)
-
- Actually, I was wrong in stating that you cannot unload a keymap.
- The correct statement is: you cannot unload a keymap that another
- process might know about. As long as the keymap is kept private,
- you can unload it.
-
- Christian
-
-
- --
- // Christian Stieber Stieber@Informatik.TU-Muenchen.de
- \// Certified Amiga Developer http://www.leo.org/~stieber/
- --------------------------------------------------------------------------
- Nobody, just nobody
-
-
- ==========================================================================
-
-
- ilan
-