2 Copyright © 1995-2004, The AROS Development Team. All rights reserved.
15 #include <aros/debug.h>
17 #include <libraries/commodities.h>
18 #include <proto/commodities.h>
19 #include <proto/utility.h>
20 #define __NOLIBBASE__ 1
21 #include <proto/keymap.h>
23 #include <devices/inputevent.h>
24 #include <devices/keymap.h>
29 #define DEBUG_PARSEIX(x) ;
30 #define DEBUG_PMATCH(x) ;
32 BOOL
pMatch(pix_S
[], CONST_STRPTR
, LONG
*, BOOL
*, struct Library
*CxBase
);
33 VOID
GetNext(CONST_STRPTR
*);
34 BOOL
IsSeparator(char);
36 /*****************************************************************************
40 AROS_LH2(LONG
, ParseIX
,
44 AROS_LHA(CONST_STRPTR
, desc
, A0
),
45 AROS_LHA(IX
* , ix
, A1
),
49 struct Library
*, CxBase
, 22, Commodities
)
53 Fill in an InputXpression 'ix' according to the specifications given
54 in the string pointed to by 'desc'.
56 The string should be formatted according to:
58 [class] {[-] (qualifier|synonym)} [[-] upstroke] [HighMap|ANSICode]
60 For more information on this, consult "xxx/CxParse.doc".
64 desc -- pointer to the string specifying the conditions and codes of
66 ix -- pointer to an (uninitizlized) InputXpression structure that
67 will be filled according to 'desc'.
71 0 -- Everything went OK.
72 -1 -- Tokens after end
83 MatchIX(), <libraries/commodities.h>
89 10.05.97 SDuvan implemented
91 ******************************************************************************/
97 BOOL dash
, upstrdash
= TRUE
;
98 BOOL upstroke
= FALSE
;
100 struct InputEvent event
;
102 /* Set as standard if no class is specified in the description */
104 /* Caller is expected to set this! */
105 ix
->ix_Version
= IX_VERSION
;
107 ix
->ix_Class
= IECLASS_RAWKEY
;
109 ix
->ix_CodeMask
= 0xFFFF;
110 ix
->ix_Qualifier
= 0;
111 ix
->ix_QualMask
= IX_NORMALQUALS
& ~(IEQUALIFIER_INTERRUPT
| IEQUALIFIER_MULTIBROADCAST
);
116 ix
->ix_Code
= 0xFFFF;
121 DEBUG_PARSEIX(dprintf("ParseIX: ix = 0x%lx, desc = \"%s\"\n", ix
, desc
));
123 while (IsSeparator(*desc
))
130 if (pMatch(pix_Class
, desc
, &val
, &dash
, CxBase
))
140 if (pMatch(pix_IEvent
, desc
, &val
, &dash
, CxBase
))
144 ix
->ix_QualMask
&= ~val
;
148 ix
->ix_Qualifier
|= val
;
157 if (pMatch(pix_Synonyms
, desc
, &val
, &dash
, CxBase
))
159 ix
->ix_QualSame
|= val
;
166 ix
->ix_QualMask
&= ~IXSYM_SHIFTMASK
;
170 ix
->ix_QualMask
&= ~IXSYM_ALTMASK
;
174 ix
->ix_QualMask
&= ~IXSYM_CAPSMASK
;
183 ix
->ix_Qualifier
|= IXSYM_SHIFTMASK
;
187 ix
->ix_Qualifier
|= IXSYM_ALTMASK
;
191 ix
->ix_Qualifier
|= IXSYM_CAPSMASK
;
205 if (pMatch(pix_Upstroke
, desc
, &val
, &upstrdash
, CxBase
))
213 if (pMatch(pix_Highmap
, desc
, &val
, &dash
, CxBase
))
221 if (InvertKeyMap(*desc
, &event
, NULL
))
223 ix
->ix_Code
= event
.ie_Code
;
232 ix
->ix_CodeMask
&= ~IECODE_UP_PREFIX
;
236 ix
->ix_Code
|= IECODE_UP_PREFIX
;
240 while (!(IsSeparator(*desc
)))
245 DEBUG_PARSEIX(dprintf("ParseIX: Class 0x%lx Code 0x%lx CodeMask 0x%lx\n"
246 "ParseIX: Qualifier 0x%lx QualMask 0x%lx QualSame 0x%lx\n",
260 DEBUG_PARSEIX(dprintf("ParseIX: fail, desc 0x%lx *desc 0x%lx\n", desc
, *desc
));
268 BOOL
pMatch(pix_S words
[], CONST_STRPTR string
, LONG
*v
, BOOL
*dash
,
269 struct Library
*CxBase
)
271 CONST_STRPTR nstr
= string
;
274 DEBUG_PMATCH(dprintf("pMatch: words[0] = \"%s\" string \"%s\" dash %d\n",
275 words
[0].name
, string
, *dash
));
290 for (i
= 0; words
[i
].name
!= NULL
; i
++)
292 if (Strnicmp(nstr
, words
[i
].name
, strlen(words
[i
].name
)) == 0)
295 DEBUG_PMATCH(dprintf("pMatch: value 0x%lx\n", *v
));
300 DEBUG_PMATCH(dprintf("pMatch: not found\n"));
305 VOID
GetNext(CONST_STRPTR
*str
)
307 while (!(IsSeparator(**str
)))
312 while (IsSeparator(**str
) && !(**str
=='\0'))
319 BOOL
IsSeparator(char a
)
321 if (a
== ' ' || a
== '\n' || a
== '\t' || a
== ',' || a
== '\0')