2 Copyright © 1995-2012, 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
*InvertStringForwd(
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(), InvertString(), 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
;
71 while(str
&& *str
!= '\0')
73 ie
= AllocMem(sizeof(struct InputEvent
), MEMF_PUBLIC
| MEMF_CLEAR
);
85 ieChain
->ie_NextEvent
= ie
;
89 ie
->ie_Class
= IECLASS_RAWKEY
;
90 ie
->ie_EventAddress
= NULL
;
109 /* FIXME: What to do if "\x" comes? */
115 if(InvertKeyMap(ansiCode
, ie
, km
) == FALSE
)
128 while(*str
&& (*str
!= '>')) str
++;
135 err
= ParseIX(start
, &ix
);
144 ie
->ie_Class
= ix
.ix_Class
;
145 ie
->ie_Code
= ix
.ix_Code
;
146 ie
->ie_Qualifier
= ix
.ix_Qualifier
;
151 if(InvertKeyMap(*str
++, ie
, km
) == FALSE
)
163 } /* InvertStringForwd */