Updated PCI IDs to latest snapshot.
[tangerine.git] / rom / intuition / sysreqhandler_morphos.c
blob292e308edc6c106ef5c5cd662f55ebcadb03bfd6
1 /*
2 Copyright © 1995-2007, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
4 $Id$
5 */
7 #include <proto/exec.h>
8 #include <proto/keymap.h>
10 #include "intuition_intern.h"
11 #include "intuition_customizesupport.h"
12 #include "requesters.h"
14 #include <ctype.h>
16 #define DEBUG_SYSREQHANDLER(x) ;
18 /*****************************************************************************
20 NAME */
21 #include <proto/intuition.h>
22 #include <exec/types.h>
23 #include <intuition/intuition.h>
25 AROS_LH3(LONG, SysReqHandler,
27 /* SYNOPSIS */
28 AROS_LHA(struct Window *, window, A0),
29 AROS_LHA(ULONG *, IDCMPFlagsPtr, A1),
30 AROS_LHA(BOOL , WaitInput, D0),
32 /* LOCATION */
33 struct IntuitionBase *, IntuitionBase, 100, Intuition)
35 /* FUNCTION
36 Handles a requester, which was opened with BuildSysRequest() or
37 BuildEasyRequestArgs(). When this function is called all outstanding
38 IDCMP requests are processed. If an IDCMP request that would close
39 a normal EasyRequestArgs() is encountered, SysReqHandler() returns
40 with a return code equally to the return code EasyRequestArgs()
41 would have returned. You may call this function in synchronous or
42 asynchronous mode, by setting the WaitInput parameter.
44 INPUTS
45 Window - The window pointer returned by either BuildSysRequest() or
46 BuildEasyRequestArgs().
47 IDCMPFlagsPtr - Pointer to a ULONG to store the IDCMP flag that was
48 received by the window. This will be set if you
49 provided additional IDCMP flags to BuildSysRequest() or
50 BuildEasyRequest(). You may set this to NULL. You must
51 initialize the pointed to ULONG every time you call
52 SysReqHandler().
53 WaitInput - Set this to TRUE, if you want this function to wait for
54 the next IDCMP request, if there is none at the moment
55 the function is called.
57 RESULT
58 -2, if the requester was not satisfied. Normally you want to call
59 this function at least until this function returns something
60 different than -2.
61 -1, if one of the IDCMP flags of idcmpPTR was set.
62 0, if the rightmost button was clicked or an error occured.
63 n, if the n-th button from the left was clicked.
65 NOTES
67 EXAMPLE
69 BUGS
70 Gadget placing is still untidy.
71 Does not support BuildSysRequest() requesters, yet.
73 SEE ALSO
74 BuildSysRequest(), BuildEasyRequestArgs()
76 INTERNALS
78 HISTORY
80 *****************************************************************************/
82 AROS_LIBFUNC_INIT
84 LONG result;
85 struct IntuiMessage *msg;
86 struct IntRequestUserData *udata = (struct IntRequestUserData *)window->UserData;
88 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: window 0x%lx IDCMPPtr 0x%lx WaitInput 0x%lx\n",
89 (ULONG) window,
90 (ULONG) IDCMPFlagsPtr,
91 (ULONG) WaitInput));
93 if (window == 0)
95 result = 0;
97 else if (window == (struct Window *)1)
99 result = 1;
101 else
103 result = -2;
105 if (WaitInput)
107 WaitPort(window->UserPort);
109 while ((msg = (struct IntuiMessage *)GetMsg(window->UserPort)))
111 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: msg 0x%lx class 0x%lx\n", (ULONG) msg, msg->Class));
112 switch (msg->Class)
114 /* we don't use VANILLA (filtered from useridcmp!) to get
115 all events we need */
116 case IDCMP_RAWKEY:
118 #define RKBUFLEN 1
119 struct InputEvent ie;
120 char rawbuffer[RKBUFLEN];
122 if (msg->Code & IECODE_UP_PREFIX) break;
124 //hilight support
125 if (udata->NumGadgets > 1)
127 if (((msg->Code == 66) && (msg->Qualifier & (IEQUALIFIER_LSHIFT | IEQUALIFIER_RSHIFT))) ||
128 (msg->Code == 79))
130 intrequest_hilightgadget(udata,udata->ActiveGad,FALSE,IntuitionBase);
131 if (udata->ActiveGad > 0)
133 udata->ActiveGad --;
134 } else {
135 udata->ActiveGad = udata->NumGadgets - 1;
137 intrequest_hilightgadget(udata,udata->ActiveGad,TRUE,IntuitionBase);
138 } else if ((msg->Code == 66) || (msg->Code == 78))
140 intrequest_hilightgadget(udata,udata->ActiveGad,FALSE,IntuitionBase);
141 if (udata->ActiveGad < udata->NumGadgets - 1)
143 udata->ActiveGad ++;
144 } else {
145 udata->ActiveGad = 0;
147 intrequest_hilightgadget(udata,udata->ActiveGad,TRUE,IntuitionBase);
151 ie.ie_Class = IECLASS_RAWKEY;
152 ie.ie_SubClass = 0;
153 ie.ie_Code = msg->Code;
154 ie.ie_Qualifier = 0;
155 ie.ie_EventAddress = (APTR *) *((ULONG *)msg->IAddress);
157 if (KeymapBase && MapRawKey(&ie,rawbuffer,RKBUFLEN,0))
159 if (rawbuffer[0] == 13) //enter key
161 if (udata->ActiveGad != udata->NumGadgets - 1)
163 result = udata->ActiveGad + 1;
164 } else {
165 result = 0;
169 if (rawbuffer[0] == 27) //escape key
171 result = 0;
175 ie.ie_Qualifier = msg->Qualifier;
176 if (MatchHotkey(&ie,IA_REQUESTERCANCEL,IntuitionBase)) result = 0;
178 if (MatchHotkey(&ie,IA_REQUESTEROK,IntuitionBase))
180 if (((struct IntRequestUserData *)window->UserData)->NumGadgets > 1)
182 result = 1;
183 } else {
184 result = 0;
188 break;
190 case IDCMP_GADGETUP:
191 result = ((struct Gadget *)msg->IAddress)->GadgetID;
192 break;
194 case IDCMP_REFRESHWINDOW:
195 BeginRefresh(window);
196 intrequest_drawrequester(udata,IntuitionBase);
197 EndRefresh(window,TRUE);
198 break;
200 default:
201 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: unknown IDCMP\n"));
202 if (result == -2)
204 if (msg->Class &
205 ((struct IntRequestUserData *)window->UserData)->IDCMP)
207 if (IDCMPFlagsPtr)
208 *IDCMPFlagsPtr = msg->Class;
209 result = -1;
212 break;
214 ReplyMsg((struct Message *)msg);
216 } /* while ((msg = (struct IntuiMessage *)GetMsg(window->UserPort))) */
220 DEBUG_SYSREQHANDLER(dprintf("SysReqHandler: Result 0x%lx\n",result));
222 return result;
223 AROS_LIBFUNC_EXIT
224 } /* SysReqHandler() */