Updated PCI IDs to latest snapshot.
[tangerine.git] / workbench / libs / commodities / invertkeymap.c
blob56401a2aef1320c961ce2bee64d1ac46117e6f32
1 /*
2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
8 #include <devices/inputevent.h>
9 #include <devices/keymap.h>
10 #include "cxintern.h"
11 #include <proto/keymap.h>
12 #define __NOLIBBASE__ 1
13 #include <proto/timer.h>
14 #undef __NOLIBBASE__
15 #include <aros/debug.h>
17 /*****************************************************************************
19 NAME */
20 #include <proto/commodities.h>
22 AROS_LH3(BOOL, InvertKeyMap,
24 /* SYNOPSIS */
26 AROS_LHA(ULONG , ansiCode , D0),
27 AROS_LHA(struct InputEvent *, event , A0),
28 AROS_LHA(struct KeyMap *, km , A1),
30 /* LOCATION */
32 struct Library *, CxBase, 29, Commodities)
34 /* FUNCTION
36 Translate a given ANSI character code to an InputEvent. The InputEvent
37 pointed to by 'event' is initialized to match the 'ansiCode'. The
38 translation is done using the keymap 'km'. If 'km' is NULL, the default
39 system keymap is used.
41 INPUTS
43 ansiCode - the ANSI character code to be translated
44 event - the inputevent that will contain the translation
45 km - keymap used for the translation (if 'km' is NULL the system
46 default keymap is used).
48 RESULT
50 TRUE if the translation was successful, otherwise FALSE.
52 NOTES
54 EXAMPLE
56 BUGS
58 Only one-deep dead keys are handled, for instance <alt f>e. It doesn't
59 look up the high key map (keycodes with scan codes greater than 0x40).
61 SEE ALSO
63 cx_lib/InvertString()
65 INTERNALS
67 HISTORY
69 ******************************************************************************/
72 AROS_LIBFUNC_INIT
74 char buf[4];
75 char str[2] = { 0, 0 };
76 LONG k;
78 event->ie_SubClass = 0;
80 GetSysTime(&event->ie_TimeStamp);
82 event->ie_EventAddress = NULL;
83 event->ie_Class = IECLASS_RAWKEY;
84 str[0] = ansiCode;
85 k = MapANSI((STRPTR) &str, 1, (STRPTR) &buf, 3, km);
87 switch(k)
89 case 1 : /* One code / qualifier */
90 event->ie_Prev1DownCode = 0;
91 event->ie_Prev1DownQual = 0;
92 D(bug("Buf 0: %i\n", buf[0]));
93 event->ie_Code = (WORD)(buf[0]);
94 event->ie_Qualifier = (WORD) buf[1];
96 return TRUE;
98 case 2 : /* Two codes / qualifiers */
99 event->ie_Prev1DownCode = buf[0];
100 event->ie_Prev1DownQual = buf[1];
101 event->ie_Code = (WORD) buf[2];
102 event->ie_Qualifier = (WORD) buf[3];
104 return TRUE;
106 default :
107 return FALSE; /* Error mapping ANSI */
110 AROS_LIBFUNC_EXIT
111 } /* InvertKeyMap */