2 Copyright © 1995-2003, The AROS Development Team. All rights reserved.
3 Copyright © 2001-2003, The MorphOS Development Team. All Rights Reserved.
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>
15 /*****************************************************************************
18 #include <proto/intuition.h>
20 AROS_LH3(struct Preferences
*, SetPrefs
,
23 AROS_LHA(struct Preferences
* , prefbuffer
, A0
),
24 AROS_LHA(LONG
, size
, D0
),
25 AROS_LHA(BOOL
, inform
, D1
),
28 struct IntuitionBase
*, IntuitionBase
, 54, Intuition
)
31 Sets the current Preferences structure.
34 prefbuffer - The buffer which contains your settings for the
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.
41 Returns your parameter buffer.
50 GetDefPrefs(), GetPrefs()
56 *****************************************************************************/
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)
75 GetPrivIBase(IntuitionBase
)->ActivePreferences
,
76 size
<= sizeof(struct Preferences
) ? size
: sizeof(struct Preferences
));
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
=
92 if (size
> offsetof(struct Preferences
, KeyRptDelay
))
95 /* No need to setup a reply port, this command is guaranteed to support
99 struct MsgPort
*port
= CreateMsgPort();
103 req
.tr_node
.io_Message
.mn_ReplyPort
= port
;
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
;
121 if (size
> offsetof(struct Preferences
, KeyRptSpeed
))
124 /* No need to setup a reply port, this command is guaranteed to support
128 struct MsgPort
*port
= CreateMsgPort();
132 req
.tr_node
.io_Message
.mn_ReplyPort
= port
;
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
;
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
);
162 InstallPointer(IntuitionBase
, &GetPrivIBase(IntuitionBase
)->DefaultPointer
, pointer
);
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
178 struct MsgPort
*port
= CreateMsgPort();
180 DEBUG_SETPREFS(dprintf("SetPrefs: Send NEWPREFS event\n"));
184 struct InputEvent ie
;
187 ie
.ie_NextEvent
= NULL
;
188 ie
.ie_Class
= IECLASS_NEWPREFS
;
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
);
201 DoIO((struct IORequest
*)&req
);
208 #warning Is there any further immediate action to be taken when the prefences are updated?
210 return (struct Preferences
*) prefbuffer
;