Instead of "eax" and "edx" in asm constraints use "a" and "d"
[tangerine.git] / rom / intuition / setprefs.c
blobf20afdef83f6c2aee81918e971958f273976b9e7
1 /*
2 Copyright © 1995-2003, 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/graphics.h>
9 #include "intuition_intern.h"
10 #include <intuition/preferences.h>
11 #include <devices/input.h>
12 #include <devices/inputevent.h>
13 #include <stddef.h>
15 /*****************************************************************************
17 NAME */
18 #include <proto/intuition.h>
20 AROS_LH3(struct Preferences *, SetPrefs,
22 /* SYNOPSIS */
23 AROS_LHA(struct Preferences * , prefbuffer, A0),
24 AROS_LHA(LONG , size, D0),
25 AROS_LHA(BOOL , inform, D1),
27 /* LOCATION */
28 struct IntuitionBase *, IntuitionBase, 54, Intuition)
30 /* FUNCTION
31 Sets the current Preferences structure.
33 INPUTS
34 prefbuffer - The buffer which contains your settings for the
35 preferences.
36 size - The number of bytes of the buffer you want to be copied.
37 inform - If TRUE, all windows with IDCMP_NEWPREFS IDCMPFlags set
38 get an IDCMP_NEWPREFS message.
40 RESULT
41 Returns your parameter buffer.
43 NOTES
45 EXAMPLE
47 BUGS
49 SEE ALSO
50 GetDefPrefs(), GetPrefs()
52 INTERNALS
54 HISTORY
56 *****************************************************************************/
58 AROS_LIBFUNC_INIT
59 AROS_LIBBASE_EXT_DECL(struct IntuitionBase *,IntuitionBase)
61 DEBUG_SETPREFS(dprintf("SetPrefs: Buffer 0x%lx Size 0x%lx Inform %d\n",
62 (ULONG) prefbuffer, size, inform));
63 if (size > 0 && NULL != prefbuffer)
65 ULONG lock = LockIBase(0);
66 BOOL changepointer = FALSE;
68 if (size > offsetof(struct Preferences, PointerMatrix))
70 if (memcmp(&prefbuffer->PointerMatrix,&GetPrivIBase(IntuitionBase)->ActivePreferences->PointerMatrix,POINTERSIZE) != 0)
71 changepointer = TRUE;
74 CopyMem(prefbuffer,
75 GetPrivIBase(IntuitionBase)->ActivePreferences,
76 size <= sizeof(struct Preferences) ? size : sizeof(struct Preferences));
78 UnlockIBase(lock);
80 DEBUG_SETPREFS(dprintf("SetPrefs: DoubleClick %ld.%ld\n",
81 GetPrivIBase(IntuitionBase)->ActivePreferences->DoubleClick.tv_secs,
82 GetPrivIBase(IntuitionBase)->ActivePreferences->DoubleClick.tv_micro));
84 if (GetPrivIBase(IntuitionBase)->InputIO)
86 struct timerequest req =
88 {{{0}, 0}, 0},
89 {0}
92 if (size > offsetof(struct Preferences, KeyRptDelay))
94 #ifdef __MORPHOS__
95 /* No need to setup a reply port, this command is guaranteed to support
96 * quick I/O.
98 #else
99 struct MsgPort *port = CreateMsgPort();
101 if (port)
103 req.tr_node.io_Message.mn_ReplyPort = port;
105 #endif
106 DEBUG_SETPREFS(dprintf("SetPrefs: KeyRptDelay %ld secs micros %ld\n",
107 GetPrivIBase(IntuitionBase)->ActivePreferences->KeyRptDelay.tv_secs,
108 GetPrivIBase(IntuitionBase)->ActivePreferences->KeyRptDelay.tv_micro));
109 req.tr_node.io_Device = GetPrivIBase(IntuitionBase)->InputIO->io_Device;
110 req.tr_node.io_Unit = GetPrivIBase(IntuitionBase)->InputIO->io_Unit;
111 req.tr_node.io_Command = IND_SETTHRESH;
112 req.tr_time = GetPrivIBase(IntuitionBase)->ActivePreferences->KeyRptDelay;
113 DoIO(&req.tr_node);
115 #ifndef __MORPHOS__
116 DeleteMsgPort(port);
118 #endif
121 if (size > offsetof(struct Preferences, KeyRptSpeed))
123 #ifdef __MORPHOS__
124 /* No need to setup a reply port, this command is guaranteed to support
125 * quick I/O.
127 #else
128 struct MsgPort *port = CreateMsgPort();
130 if (port)
132 req.tr_node.io_Message.mn_ReplyPort = port;
133 #endif
135 DEBUG_SETPREFS(dprintf("SetPrefs: KeyRptSpeed secs %ld micros %ld\n",
136 GetPrivIBase(IntuitionBase)->ActivePreferences->KeyRptSpeed.tv_secs,
137 GetPrivIBase(IntuitionBase)->ActivePreferences->KeyRptSpeed.tv_micro));
139 req.tr_node.io_Device = GetPrivIBase(IntuitionBase)->InputIO->io_Device;
140 req.tr_node.io_Unit = GetPrivIBase(IntuitionBase)->InputIO->io_Unit;
141 req.tr_node.io_Command = IND_SETPERIOD;
142 req.tr_time = GetPrivIBase(IntuitionBase)->ActivePreferences->KeyRptSpeed;
143 DoIO(&req.tr_node);
145 #ifndef __MORPHOS__
146 DeleteMsgPort(port);
148 #endif
151 else
153 DEBUG_SETPREFS(dprintf("SetPrefs: no InputIO..don't set Key prefs\n"));
156 //#ifndef __MORPHOS__
157 if (size > offsetof(struct Preferences, PointerMatrix) && changepointer)
159 Object *pointer = MakePointerFromPrefs(IntuitionBase, GetPrivIBase(IntuitionBase)->ActivePreferences);
160 if (pointer)
162 InstallPointer(IntuitionBase, &GetPrivIBase(IntuitionBase)->DefaultPointer, pointer);
165 //#endif
168 ** If inform == TRUE then notify all windows that want to know about
169 ** an update on the preferences.
170 ** Do that by creating an inputevent, that will be handled by our
171 ** handler and converted to idcmp messages, as well as by all other
172 ** input handlers (not sure it should be that way, but that shouldn't
173 ** do any harm).
176 if (inform)
178 struct MsgPort *port = CreateMsgPort();
180 DEBUG_SETPREFS(dprintf("SetPrefs: Send NEWPREFS event\n"));
182 if (port)
184 struct InputEvent ie;
185 struct IOStdReq req;
187 ie.ie_NextEvent = NULL;
188 ie.ie_Class = IECLASS_NEWPREFS;
189 ie.ie_SubClass = 0;
190 ie.ie_Code = 0;
191 ie.ie_Qualifier = 0;
192 ie.ie_EventAddress = NULL;
194 req.io_Message.mn_ReplyPort = port;
195 req.io_Device = GetPrivIBase(IntuitionBase)->InputIO->io_Device;
196 req.io_Unit = GetPrivIBase(IntuitionBase)->InputIO->io_Unit;
197 req.io_Command = IND_WRITEEVENT;
198 req.io_Length = sizeof(ie);
199 req.io_Data = &ie;
201 DoIO((struct IORequest *)&req);
203 DeleteMsgPort(port);
208 #warning Is there any further immediate action to be taken when the prefences are updated?
210 return (struct Preferences *) prefbuffer;
212 AROS_LIBFUNC_EXIT
213 } /* SetPrefs() */