2 Copyright © 1995-2007, 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 *****************************************************************************/
60 DEBUG_SETPREFS(dprintf("SetPrefs: Buffer 0x%lx Size 0x%lx Inform %d\n",
61 (ULONG
) prefbuffer
, size
, inform
));
62 if (size
> 0 && NULL
!= prefbuffer
)
64 ULONG lock
= LockIBase(0);
65 BOOL changepointer
= FALSE
;
67 if (size
> offsetof(struct Preferences
, PointerMatrix
))
69 if (memcmp(&prefbuffer
->PointerMatrix
,&GetPrivIBase(IntuitionBase
)->ActivePreferences
->PointerMatrix
,POINTERSIZE
) != 0)
74 GetPrivIBase(IntuitionBase
)->ActivePreferences
,
75 size
<= sizeof(struct Preferences
) ? size
: sizeof(struct Preferences
));
79 DEBUG_SETPREFS(dprintf("SetPrefs: DoubleClick %ld.%ld\n",
80 GetPrivIBase(IntuitionBase
)->ActivePreferences
->DoubleClick
.tv_secs
,
81 GetPrivIBase(IntuitionBase
)->ActivePreferences
->DoubleClick
.tv_micro
));
83 if (GetPrivIBase(IntuitionBase
)->InputIO
)
85 struct timerequest req
=
91 if (size
> offsetof(struct Preferences
, KeyRptDelay
))
94 /* No need to setup a reply port, this command is guaranteed to support
98 struct MsgPort
*port
= CreateMsgPort();
102 req
.tr_node
.io_Message
.mn_ReplyPort
= port
;
105 DEBUG_SETPREFS(dprintf("SetPrefs: KeyRptDelay %ld secs micros %ld\n",
106 GetPrivIBase(IntuitionBase
)->ActivePreferences
->KeyRptDelay
.tv_secs
,
107 GetPrivIBase(IntuitionBase
)->ActivePreferences
->KeyRptDelay
.tv_micro
));
108 req
.tr_node
.io_Device
= GetPrivIBase(IntuitionBase
)->InputIO
->io_Device
;
109 req
.tr_node
.io_Unit
= GetPrivIBase(IntuitionBase
)->InputIO
->io_Unit
;
110 req
.tr_node
.io_Command
= IND_SETTHRESH
;
111 req
.tr_time
= GetPrivIBase(IntuitionBase
)->ActivePreferences
->KeyRptDelay
;
120 if (size
> offsetof(struct Preferences
, KeyRptSpeed
))
123 /* No need to setup a reply port, this command is guaranteed to support
127 struct MsgPort
*port
= CreateMsgPort();
131 req
.tr_node
.io_Message
.mn_ReplyPort
= port
;
134 DEBUG_SETPREFS(dprintf("SetPrefs: KeyRptSpeed secs %ld micros %ld\n",
135 GetPrivIBase(IntuitionBase
)->ActivePreferences
->KeyRptSpeed
.tv_secs
,
136 GetPrivIBase(IntuitionBase
)->ActivePreferences
->KeyRptSpeed
.tv_micro
));
138 req
.tr_node
.io_Device
= GetPrivIBase(IntuitionBase
)->InputIO
->io_Device
;
139 req
.tr_node
.io_Unit
= GetPrivIBase(IntuitionBase
)->InputIO
->io_Unit
;
140 req
.tr_node
.io_Command
= IND_SETPERIOD
;
141 req
.tr_time
= GetPrivIBase(IntuitionBase
)->ActivePreferences
->KeyRptSpeed
;
152 DEBUG_SETPREFS(dprintf("SetPrefs: no InputIO..don't set Key prefs\n"));
155 //#ifndef __MORPHOS__
156 if (size
> offsetof(struct Preferences
, PointerMatrix
) && changepointer
)
158 Object
*pointer
= MakePointerFromPrefs(IntuitionBase
, GetPrivIBase(IntuitionBase
)->ActivePreferences
);
161 InstallPointer(IntuitionBase
, &GetPrivIBase(IntuitionBase
)->DefaultPointer
, pointer
);
167 ** If inform == TRUE then notify all windows that want to know about
168 ** an update on the preferences.
169 ** Do that by creating an inputevent, that will be handled by our
170 ** handler and converted to idcmp messages, as well as by all other
171 ** input handlers (not sure it should be that way, but that shouldn't
177 struct MsgPort
*port
= CreateMsgPort();
179 DEBUG_SETPREFS(dprintf("SetPrefs: Send NEWPREFS event\n"));
183 struct InputEvent ie
;
186 ie
.ie_NextEvent
= NULL
;
187 ie
.ie_Class
= IECLASS_NEWPREFS
;
191 ie
.ie_EventAddress
= NULL
;
193 req
.io_Message
.mn_ReplyPort
= port
;
194 req
.io_Device
= GetPrivIBase(IntuitionBase
)->InputIO
->io_Device
;
195 req
.io_Unit
= GetPrivIBase(IntuitionBase
)->InputIO
->io_Unit
;
196 req
.io_Command
= IND_WRITEEVENT
;
197 req
.io_Length
= sizeof(ie
);
200 DoIO((struct IORequest
*)&req
);
207 #warning Is there any further immediate action to be taken when the prefences are updated?
209 return (struct Preferences
*) prefbuffer
;