2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
9 /******************************************************************************
25 Set the keymap for the current shell.
29 KEYMAP -- the keymap to use with the current shell
35 To make a certain keymap be the default for all shells, use the
36 preferences input program so specify your default choice.
42 Makes the current shell use the Swedish keymap.
52 ******************************************************************************/
55 #include <exec/exec.h>
57 #include <devices/keymap.h>
58 #include <devices/console.h>
59 #include <devices/keymap.h>
60 #include <proto/exec.h>
61 #include <proto/dos.h>
62 #include <proto/keymap.h>
67 static const char version
[] = "$VER: SetKeyboard 41.2 (16.01.2000)\n";
69 #define ARG_TEMPLATE "KEYMAP/A"
77 struct Library
*KeymapBase
= NULL
;
78 struct KeyMapResource
*KeyMapResource
;
80 static struct RDArgs
*myargs
;
81 static struct KeyMapNode
*kmn
;
83 static IPTR args
[NOOFARGS
];
85 static char *filename
, *name
;
87 static void Cleanup(char *msg
, WORD rc
)
91 Printf("SetKeyboard: %s\n",msg
);
106 CloseLibrary(KeymapBase
);
113 static void OpenLibs(void)
115 if (!(KeymapBase
= OpenLibrary("keymap.library", 0)))
117 Cleanup("Can´t open keymap.library!", RETURN_FAIL
);
122 static void OpenKeyMapResoure(void)
124 if (!(KeyMapResource
= OpenResource("keymap.resource")))
126 Cleanup("Can´t open keymap.resoure!", RETURN_FAIL
);
131 static void GetArguments(void)
133 if (!(myargs
= ReadArgs(ARG_TEMPLATE
, args
, 0)))
135 Fault(IoErr(), 0, s
, 255);
136 Cleanup(s
, RETURN_FAIL
);
139 filename
= (char *)args
[ARG_NAME
];
140 name
= FilePart(filename
);
144 static struct KeyMapNode
*KeymapAlreadyOpen(void)
147 struct KeyMapNode
*kmn
= NULL
;
151 ForeachNode(&KeyMapResource
->kr_List
, node
)
153 if (!stricmp(name
, node
->ln_Name
))
155 kmn
= (struct KeyMapNode
*)node
;
166 static void Action(void)
168 kmn
= KeymapAlreadyOpen();
172 struct KeyMapNode
*kmn_check
;
174 if (name
== filename
)
176 strcpy(s
, "DEVS:Keymaps");
177 AddPart(s
, name
, 255);
184 if (!(seg
= LoadSeg(s
)))
186 Fault(IoErr(), 0, s
, 255);
187 Cleanup(s
, RETURN_FAIL
);
190 kmn
= (struct KeyMapNode
*) (((UBYTE
*)BADDR(seg
)) + sizeof(APTR
));
194 if ((kmn_check
= KeymapAlreadyOpen()))
200 AddHead(&KeyMapResource
->kr_List
, &kmn
->kn_Node
);
208 SetKeyMapDefault(&kmn
->kn_KeyMap
);
221 Cleanup(0, RETURN_OK
);