2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
6 #include <libraries/commodities.h>
7 #include <proto/commodities.h>
8 #include <proto/exec.h>
9 #include <proto/alib.h>
10 #include <exec/memory.h>
11 #include <devices/keymap.h>
12 #include <devices/inputevent.h>
14 extern struct Library
*CxBase
;
16 /*****************************************************************************
20 struct InputEvent
*InvertString(
28 Return a linked list of input events which would produce the string
29 'str' with the keymap 'km'.
32 str -- pointer to a (NULL-terminated) string that may contain
33 * ANSI character codes
34 * backslash-escaped characters:
39 * a description of an input event a la ParseIX() surrounded
42 km -- keymap to use for the conversion or NULL to use the default
46 A linked list of input events or NULL if something went wrong.
51 An example string: "Hello <shift alt a>\n"
56 commodities.library/ParseIX(), FreeIEvents()
59 Ought to have an extra \< for < not starting an IX expression.
63 ******************************************************************************/
65 struct InputEvent
*ieChain
= NULL
;
66 struct InputEvent
*ie
;
67 struct InputEvent
*first
= NULL
;
73 ie
= AllocMem(sizeof(struct InputEvent
), MEMF_PUBLIC
| MEMF_CLEAR
);
76 if (first
) FreeIEvents(first
);
80 if (!first
) first
= ie
;
83 ieChain
->ie_NextEvent
= ie
;
87 ie
->ie_Class
= IECLASS_RAWKEY
;
88 ie
->ie_EventAddress
= NULL
;
107 #warning FIXME: What to do if "\x" comes?
113 if(InvertKeyMap(ansiCode
, ie
, km
) == FALSE
)
124 while(*str
&& (*str
!= '>')) str
++;
131 err
= ParseIX(start
, &ix
);
140 ie
->ie_Class
= ix
.ix_Class
;
141 ie
->ie_Code
= ix
.ix_Code
;
142 ie
->ie_Qualifier
= ix
.ix_Qualifier
;
147 if(InvertKeyMap(*str
++, ie
, km
) == FALSE
)