Indentation fix, cleanup.
[AROS.git] / rom / devs / input / support.c
blobbec56ea2c2612b0c59587477dc0bdb78cfbe44d0
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
5 Desc:
6 Lang: english
7 */
10 #include <proto/exec.h>
11 #include <exec/tasks.h>
12 #include <exec/lists.h>
13 #include <exec/memory.h>
14 #include <devices/rawkeycodes.h>
16 #include "input_intern.h"
18 /***************************
19 ** GetEventsFromQueue() **
20 ***************************/
21 struct InputEvent *GetEventsFromQueue(struct inputbase *InputDevice)
23 struct InputEvent *ie;
25 ie = InputDevice->EventQueueHead;
27 /* No more events in the queue */
28 InputDevice->EventQueueHead = NULL;
29 InputDevice->EventQueueTail = NULL;
31 return (ie);
36 /******************
37 ** AddEQTail() **
38 ******************/
39 /* Adds a chian of InputEvents to the eventqueue */
40 VOID AddEQTail(struct InputEvent *ie, struct inputbase *InputDevice)
42 UWORD code;
44 /* Perform any necessary modifications to event */
45 switch (ie->ie_Class)
47 case IECLASS_RAWKEY:
48 /* Add previous codes and qualifiers to the event for dead key
49 handling */
50 ie->ie_Prev1DownCode = InputDevice->Prev1DownCode;
51 ie->ie_Prev1DownQual = InputDevice->Prev1DownQual;
52 ie->ie_Prev2DownCode = InputDevice->Prev2DownCode;
53 ie->ie_Prev2DownQual = InputDevice->Prev2DownQual;
55 /* Cache/rotate old codes and qualifiers for next event */
56 if ((ie->ie_Code & IECODE_UP_PREFIX) == 0
57 && !(ie->ie_Code >= RAWKEY_LSHIFT
58 && ie->ie_Code <= RAWKEY_RAMIGA))
60 InputDevice->Prev2DownCode = InputDevice->Prev1DownCode;
61 InputDevice->Prev2DownQual = InputDevice->Prev1DownQual;
62 InputDevice->Prev1DownCode = (UBYTE) ie->ie_Code;
63 InputDevice->Prev1DownQual = (UBYTE) ie->ie_Qualifier;
65 break;
67 /* FIXME: add more event classes to which this is applicable */
68 case IECLASS_RAWMOUSE:
69 /* Experimental */
70 if (InputDevice->pub.id_Flags & IDF_SWAP_BUTTONS)
72 code = ie->ie_Code & ~IECODE_UP_PREFIX;
74 switch (code)
76 case IECODE_LBUTTON:
77 code = IECODE_RBUTTON;
78 break;
79 case IECODE_RBUTTON:
80 code = IECODE_LBUTTON;
81 break;
83 ie->ie_Code = code | (ie->ie_Code & IECODE_UP_PREFIX);
87 if (!InputDevice->EventQueueHead) /* Empty queue? */
89 InputDevice->EventQueueHead = ie;
91 else
93 InputDevice->EventQueueTail->ie_NextEvent = ie;
96 /* Get last event in eventchain to add */
97 while (ie->ie_NextEvent)
98 ie = ie->ie_NextEvent;
100 InputDevice->EventQueueTail = ie;
102 return;
105 /*********************
106 ** IsQualifierKey **
107 *********************/
108 BOOL IsQualifierKey(UWORD key)
110 BOOL result = FALSE;
112 key &= ~IECODE_UP_PREFIX;
114 if ((key >= 0x60) && (key <= 0x67))
116 result = TRUE;
119 return result;
122 /************************
123 ** IsKeyRepeatable() **
124 ************************/
125 BOOL IsRepeatableKey(UWORD key)
127 BOOL result = TRUE;
129 key &= ~IECODE_UP_PREFIX;
131 /* stegerg: It looks like this is really all so no need to
132 check the keymap->repeatable tables. I have checked this
133 on the Amiga. All keys except the qualifier keys are
134 treated as repeatable raw (!!!) keys. Here in input.device
135 we have only raw keys. For vanilla keys there's MapRawKey()
136 and this function takes care of filtering out repeated
137 raw keys if the corresponding KeyMap->repeatable table says
138 that this key is not repeatable */
140 if (IsQualifierKey(key))
142 result = FALSE;
145 return result;