keymap

keymap

Post by Ilan Sharo » Mon, 11 Dec 1995 04:00:00



I want to let the user to change the local keymap from within the program,
but I can not find how to do it.

SetKeyMap() requires preintialized KeyMap structure to be present, and the
RKM send me to a keymap.resource, somewhere in the domain of exec.
I found nowhere an explanation on how to load a keymap from disk, nor
how to search the keymap.resource for resident keymap.

Another problem is that AskDefaultKeyMap() returns a pointer to a keymap
structure, but this structure does not contain a *name*, and I have to
place the name of the keymep somwhere where the user can read it.

ilan

 
 
 

keymap

Post by Arno Eigenwill » Mon, 11 Dec 1995 04:00:00



> I found nowhere an explanation on how to load a keymap from disk, nor
> how to search the keymap.resource for resident keymap.

keymap.resource is documented in <devices/keymap.h>. To search a
keymap, just traverse kr_List and compare pointers (&kn_KeyMap) (if
you want to find the one returned by AskDefaultKeyMap()) or names
(kn_Node.ln_Name). As no arbitration protocol is defined, Forbid()
will have to be used as locking mechanism.

Loading from disk is presumably done via LoadSeg(). I have found a
reference to CATS' Amiga Mail IX which is said to describe details.
Seeing the problems with getting CATS material, it certainly would
be nice if someone who has got that issue could shed a bit light on
it (hint, hint :).

-- __



 
 
 

keymap

Post by Ilan Sharo » Tue, 12 Dec 1995 04:00:00


I want to let the user to change the local keymap from within the program,
but I can not find how to do it.

SetKeyMap() requires preintialized KeyMap structure to be present, and the
RKM send me to a keymap.resource, somewhere in the domain of exec.
I found nowhere an explanation on how to load a keymap from disk, nor
how to search the keymap.resource for resident keymap.

Another problem is that AskDefaultKeyMap() returns a pointer to a keymap
structure, but this structure does not contain a *name*, and I have to
place the name of the keymep somwhere where the user can read it.

ilan

 
 
 

keymap

Post by Christian Stieb » Sat, 16 Dec 1995 04:00:00



> >keymap.resource is documented in <devices/keymap.h>. To search a

   ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^

Quote:> but where do I find the keymap.resource in the *system*?

I don't have an Amiga available here, but did you ever consider
using OpenResource("keymap.resource")?

Quote:> >Loading from disk is presumably done via LoadSeg(). I have found a
> LoadSeg() is not documented in the books I have: RKM includes and RKM devices.
> The outodoc say that it is used for loading of an exacutable. The keymap data
> is only data.

Well, fonts are stored in executables as well. I remember writing a
program that read a keymap from disk, but that was long ago. But
it used LoadSeg(), too. Let's see, maybe I can find the things we
need in the includes... hm, this is plain guessing (I only have
includes & autodocs here, RKMs are at home), so take care:
devices/keymap.h documents a "struct KeyMapNode". It seems reasonable
that the keymap file contains such a node.

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.

Christian

--

\//    Certified Amiga Developer       http://www.leo.org/~stieber/
--------------------------------------------------------------------------
                          Nobody, just nobody

 
 
 

keymap

Post by Ilan Sharo » Sat, 16 Dec 1995 04:00:00



Quote:>> I found nowhere an explanation on how to load a keymap from disk, nor
>> how to search the keymap.resource for resident keymap.
>keymap.resource is documented in <devices/keymap.h>. To search a
>keymap, just traverse kr_List and compare pointers (&kn_KeyMap) (if
>you want to find the one returned by AskDefaultKeyMap()) or names
>(kn_Node.ln_Name). As no arbitration protocol is defined, Forbid()
>will have to be used as locking mechanism.

but where do I find the keymap.resource in the *system*? I have to get a
pointer to a KeyMapResource structure where I could find the pointers to the
nodes.

Quote:>Loading from disk is presumably done via LoadSeg(). I have found a
>reference to CATS' Amiga Mail IX which is said to describe details.
>Seeing the problems with getting CATS material, it certainly would
>be nice if someone who has got that issue could shed a bit light on
>it (hint, hint :).

LoadSeg() is not documented in the books I have: RKM includes and RKM devices.
The outodoc say that it is used for loading of an exacutable. The keymap data
is only data.
 can you send an example?

ilan

 
 
 

keymap

Post by Ilan Sharo » Tue, 19 Dec 1995 04:00:00



Wrote:

Quote:>I don't have an Amiga available here, but did you ever consider
>using OpenResource("keymap.resource")?

No, how could I guess this? that is why I placed the question here.
I hope I will find some time next week to try it.

Quote:>Well, fonts are stored in executables as well. I remember writing a

So wouldn't it be nice with OpenKeyMap() equivalent to OpenFont()?

Quote:>program that read a keymap from disk, but that was long ago. But
>it used LoadSeg(), too. Let's see, maybe I can find the things we
>need in the includes... hm, this is plain guessing (I only have
>includes & autodocs here, RKMs are at home), so take care:
>devices/keymap.h documents a "struct KeyMapNode". It seems reasonable
>that the keymap file contains such a node.

As I understand it, the keymap file (the disk file) contains only conversion
data. The keymap struct containes some pointers to sections of this data when
the file is loaded into memory.
The LoadSeg() returns a pointer to a segList, but I couldn't find what is
seglist.

Quote:>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 :-)

ilan

 
 
 

keymap

Post by Christian Stieb » Tue, 19 Dec 1995 04:00:00



> As I understand it, the keymap file (the disk file) contains only conversion
> data. The keymap struct containes some pointers to sections of this data when
> the file is loaded into memory.
> The LoadSeg() returns a pointer to a segList, but I couldn't find what is
> seglist.

A seglist-pointer is a BPTR. To get a real pointer, use the BADDR() macro.
A seglist is a linked list of "next/size" entries (BPTR/ULONG),
followed by the actual data. I don't remember where the seglist pointer
points to; consult the Guru book (if you have it), or use a disassembler
to look at the result of LoadSeg() to find out.

Quote:> I hope I'll get that far one day :-)

If I can somehow prevent this information from getting lost between
now (7:34pm) and the time i get home (around 10pm), I'll see if I still
have the source for my old SetMap replacement (remember... with
AmigaOS 2.0, c:SetMap caused the initial shell window to appear, so
I had to write my own setmap).

Christian

--

\//    Certified Amiga Developer       http://www.leo.org/~stieber/
--------------------------------------------------------------------------
                          Nobody, just nobody

 
 
 

keymap

Post by Christian Stieb » Wed, 20 Dec 1995 04:00:00



> So wouldn't it be nice with OpenKeyMap() equivalent to OpenFont()?

You don't really need to load keymaps very often, do you?

Quote:> 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);

Quote:> >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

--

\//    Certified Amiga Developer       http://www.leo.org/~stieber/
--------------------------------------------------------------------------
                          Nobody, just nobody

 
 
 

keymap

Post by Ilan Sharo » Sat, 23 Dec 1995 04:00:00



Wrote:

Quote:>> So wouldn't it be nice with OpenKeyMap() equivalent to OpenFont()?
>You don't really need to load keymaps very often, do you?

I am writing a multilingual wordprocessor. Two keymaps should be available all
the time, while others should be accessable through a filerequester.

Quote:>> 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>.

The node is not a part of the kaymap struct, the keymap structure is pointed
from the KeyMapNode

Quote:>To load a keymap, do this:

I followd your instructions and wrote this test.
This is the first time I access exec's lists. Now I know why they didn't call
this part of the system "intuition".

Why the ->ln_Succ of the last node is not NULL?

 /*  ---------------------------------------------------- */

/* searching the keymap resource */
/* December 1995                 */
/* ilan sharoni                  */

#include   <stdio.h>
#include   <stdlib.h>
#include   <proto/exec.h>
#include   <devices/keymap.h>

#include   <proto/dos.h>
#include   <proto/keymap.h>
#include   <dos/dos.h>

main()
{
    struct KeyMapResource *resource_p;
    struct List *my_list_p;
    struct Node *my_node_p;
    BPTR   KeyMapSeglist;
    struct KeyMapNode *KeyMapNode;

    resource_p = (struct KeyMapResource *)OpenResource("keymap.resource");

    Disable();

    my_list_p = &resource_p->kr_List;
    if(my_list_p->lh_TailPred != (struct Node *)my_list_p)
    {
        printf(" Resident keymaps: ");
        my_node_p = my_list_p->lh_Head;
        while(my_node_p)
        {
            printf("%s, ",my_node_p->ln_Name);
            /* The ln_Succ of the last Node is not NULL!!!! */
            if(my_node_p==my_list_p->lh_TailPred){break;}
            my_node_p=my_node_p->ln_Succ;
        }
    }
    Enable();
    printf("  and no more\n");

/* try to load keymap from disk */

    if ((KeyMapSeglist=LoadSeg("devs:keymaps/h")))
    {
        KeyMapNode=BADDR(KeyMapSeglist+1);
        SetKeyMapDefault(&KeyMapNode->kn_KeyMap);
    }

Quote:}

/* ------------------------------------------------------------- */

Thank you

ilan

 
 
 

keymap

Post by Ilan Sharo » Fri, 05 Jan 1996 04:00:00



Wrote:

Quote:>- OpenResource("keymap.resource")
>- check whether the keymap is on kr_List
>- if not, LoadSeg() it

It became more complicated:
The Input editor shows a listview with the names of the *languages*, rather
then the names of the *files*.
Where does it find this strings?

ilan

 
 
 

1. PC Keymap

Please excuse me if this is a dim question..

Now I'm towered up, is there a keymap for my PC style keyboard?  my
\|~ etc are in the wrong place.  (Or rather, the keys are marked
wrongly!)

Thanks

Nick Elliott

2. Range syntax

3. what keymap?

4. Kolor Questions

5. Keymap Editor

6. question about NOT IN

7. How to convert SUN keymap to Amiga?

8. URGENT HELP NEEDED - DRAW has VANISHED!!!!

9. keymap.library where?

10. HELP ME HACK THE KEYMAP PLEASE

11. A keymap editor !

12. keymaps

13. KeyMaps/Console