muimaster.library: migrate event handling from Listview to List
[AROS.git] / workbench / c / SetKeyboard.c
blob22e5e8d3f94f5ffd7002e292f812fc316a671959
1 /*
2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /******************************************************************************
11 NAME
13 SetKeyboard
15 SYNOPSIS
17 KEYMAP/A
19 LOCATION
23 FUNCTION
25 Set the keymap for the current shell.
27 INPUTS
29 KEYMAP -- the keymap to use with the current shell
31 RESULT
33 NOTES
35 To make a certain keymap be the default for all shells, use the
36 preferences input program so specify your default choice.
38 EXAMPLE
40 SetKeyboard s
42 Makes the current shell use the Swedish keymap.
44 BUGS
46 SEE ALSO
48 INTERNALS
50 HISTORY
52 ******************************************************************************/
55 #include <exec/exec.h>
56 #include <dos/dos.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>
63 #include <proto/kms.h>
65 #include <string.h>
67 const TEXT version[] = "$VER: SetKeyboard 41.3 (03.03.2011)\n";
69 #define ARG_TEMPLATE "KEYMAP/A"
71 enum
73 ARG_NAME = 0,
74 NOOFARGS
77 __startup AROS_PROCH(Start, argstr, argsize, SysBase)
79 AROS_PROCFUNC_INIT
81 struct DosLibrary *DOSBase;
82 struct Library *KeymapBase;
83 struct KMSLibrary *KMSBase;
84 STRPTR err = NULL;
85 ULONG rc = RETURN_FAIL;
87 DOSBase = (struct DosLibrary *)OpenLibrary("dos.library", 36);
88 if (!DOSBase)
89 return RETURN_FAIL;
91 KeymapBase = OpenLibrary("keymap.library", 0);
92 if (KeymapBase)
94 KMSBase = (struct KMSLibrary *)OpenLibrary("kms.library", 0);
95 if (KMSBase)
97 IPTR args[NOOFARGS];
98 struct RDArgs *myargs = ReadArgs(ARG_TEMPLATE, args, 0);
100 if (myargs)
102 struct KeyMapNode *kmn = OpenKeymap((STRPTR)args[ARG_NAME]);
104 if (kmn)
106 SetKeyMapDefault(&kmn->kn_KeyMap);
107 rc = RETURN_OK;
111 if (rc != RETURN_OK)
112 PrintFault(IoErr(), "SetKeyboard");
114 if (myargs)
115 FreeArgs(myargs);
117 CloseLibrary(&KMSBase->kms_Lib);
119 else
120 err = "Can't opem kms.library!";
122 CloseLibrary(KeymapBase);
124 else
125 err = "Can't open keymap.library!";
127 if (err)
128 Printf("SetKeyboard: %s\n", err);
130 CloseLibrary(&DOSBase->dl_lib);
132 return rc;
134 AROS_PROCFUNC_EXIT