alsa.audio: limit the supported frequencies to common set
[AROS.git] / workbench / libs / commodities / matchix.c
blob0f1639eea6a55a2f99c9cbf8d331821da5cdb8d4
1 /*
2 Copyright © 1995-2001, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: English
7 */
9 /*****************************************************************************
11 NAME */
13 #include "cxintern.h"
14 #include <libraries/commodities.h>
15 #include <devices/inputevent.h>
16 #include <proto/commodities.h>
18 #include <aros/debug.h>
20 #define DEBUG_MATCHIX(x) ;//if ((event->ie_Class == IECLASS_RAWMOUSE) || (event->ie_Class == IECLASS_POINTERPOS) || (event->ie_Class == IECLASS_NEWPOINTERPOS)) x;
23 AROS_LH2(BOOL, MatchIX,
25 /* SYNOPSIS */
27 AROS_LHA(struct InputEvent *, event, A0),
28 AROS_LHA(IX * , ix , A1),
30 /* LOCATION */
32 struct Library *, CxBase, 34, Commodities)
34 /* FUNCTION
36 Check if an input event matches an input expression.
38 INPUTS
40 event -- the input event to match against the input expression
41 ix -- the input expression
43 RESULT
45 TRUE if the input event matches the input expression, FALSE otherwise.
47 NOTES
49 Applications don't normally need this function as filter objects take
50 care of the event filtering. However, this function is in some cases
51 nice to have.
53 EXAMPLE
55 BUGS
57 SEE ALSO
59 <libraries/commodities.h>, ParseIX()
61 INTERNALS
63 HISTORY
65 ******************************************************************************/
68 AROS_LIBFUNC_INIT
70 UWORD temp = 0;
71 UWORD qual;
73 DEBUG_MATCHIX(dprintf("MatchIX: ev[0x%lx, 0x%lx, 0x%lx] ix[0x%lx, (0x%lx, 0x%lx), (0x%lx, 0x%lx, 0x%lx)]\n",
74 event->ie_Class, event->ie_Code, event->ie_Qualifier,
75 ix->ix_Class, ix->ix_Code, ix->ix_CodeMask,
76 ix->ix_Qualifier, ix->ix_QualMask, ix->ix_QualSame));
78 if (ix->ix_Class == IECLASS_NULL)
80 DEBUG_MATCHIX(dprintf("MatchIX: IECLASS_NULL\n"));
81 return TRUE;
84 if (event->ie_Class != ix->ix_Class)
86 DEBUG_MATCHIX(dprintf("MatchIX: fail\n"));
87 return FALSE;
90 DEBUG_MATCHIX(dprintf("Code: ie %lx ix: %lx\n", event->ie_Code, ix->ix_Code));
92 if (((ix->ix_Code ^ event->ie_Code) & ix->ix_CodeMask) != 0)
94 DEBUG_MATCHIX(dprintf("MatchIX: fail\n"));
95 return FALSE;
98 temp = event->ie_Qualifier;
99 DEBUG_MATCHIX(dprintf("Code: temp %lx\n", temp));
101 if ((qual = ix->ix_QualSame) != 0)
103 if ((qual & IXSYM_SHIFT) != 0)
105 if ((temp & IXSYM_SHIFTMASK) != 0)
107 temp |= IXSYM_SHIFTMASK;
111 if ((qual & IXSYM_CAPS) != 0)
113 if ((temp & IXSYM_CAPSMASK) != 0)
115 temp |= IXSYM_CAPSMASK;
119 if ((qual & IXSYM_ALT) != 0)
121 if ((temp & IXSYM_ALTMASK) != 0)
123 temp |= IXSYM_ALTMASK;
127 DEBUG_MATCHIX(dprintf("Code: temp %lx\n", temp));
129 if (((temp ^ ix->ix_Qualifier) & ix->ix_QualMask) == 0)
131 DEBUG_MATCHIX(dprintf("MatchIX: ok\n"));
132 return TRUE;
134 else
136 DEBUG_MATCHIX(dprintf("MatchIX: fail\n"));
137 return FALSE;
140 AROS_LIBFUNC_EXIT
141 } /* MatchIX */