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 <prefs/palette.h>
10 #include <intuition/pointerclass.h>
11 #include <devices/input.h>
13 #include "intuition_intern.h"
15 #include "inputhandler_support.h"
17 #include <cybergraphx/cybergraphics.h>
18 #include <ppcinline/cybergraphics.h>
22 #include <aros/debug.h>
29 #define MODENOTAVAILABLE
34 UWORD ip_PointerTicks
;
35 struct timeval ip_DoubleClick
;
36 struct timeval ip_KeyRptDelay
;
37 struct timeval ip_KeyRptSpeed
;
43 struct TextAttr fp_TextAttr
;
51 struct TextAttr fp_TextAttr
;
57 struct IPointerColorPrefs
67 struct IOldPointerPrefs
69 struct BitMap
*BitMap
;
80 struct BitMap
*BitMap
;
95 UWORD PenTable
[NUMDRIPENS
+1];
98 struct IOldOverScanPrefs
103 struct Rectangle Standard
;
106 /*****************************************************************************
109 #include <proto/intuition.h>
111 AROS_LH3(ULONG
, SetIPrefs
,
114 AROS_LHA(APTR
, data
, A0
),
115 AROS_LHA(ULONG
, length
, D0
),
116 AROS_LHA(ULONG
, type
, D1
),
119 struct IntuitionBase
*, IntuitionBase
, 96, Intuition
)
126 Depending on the operation
139 29-10-95 digulla automatically created from
140 intuition_lib.fd and clib/intuition_protos.h
142 *****************************************************************************/
145 AROS_LIBBASE_EXT_DECL(struct IntuitionBase
*,IntuitionBase
)
147 ULONG lock
= LockIBase(0);
149 DEBUG_SETIPREFS(bug("SetIPrefs: data %p length %lu type %lu\n", data
, length
, type
));
156 #ifdef MODENOTAVAILABLE
159 ULONG RecalcID
= FALSE
;
162 DEBUG_SETIPREFS(bug("SetIPrefs: IP_SCREENMODE\n"));
163 if (length
> sizeof(struct IScreenModePrefs
))
164 length
= sizeof(struct IScreenModePrefs
);
165 CopyMem(data
, &GetPrivIBase(IntuitionBase
)->ScreenModePrefs
, length
);
167 #ifdef MODENOTAVAILABLE
168 modeid
= GetPrivIBase(IntuitionBase
)->ScreenModePrefs
.smp_DisplayID
;
169 width
= (WORD
)GetPrivIBase(IntuitionBase
)->ScreenModePrefs
.smp_Width
;
170 height
= (WORD
)GetPrivIBase(IntuitionBase
)->ScreenModePrefs
.smp_Height
;
172 if (ModeNotAvailable(modeid
))
178 if ((RecalcID
== TRUE
) && (CyberGfxBase
= OpenLibrary("cybergraphics.library",40)))
182 // mode specified is not available
184 GetPrivIBase(IntuitionBase
)->ScreenModePrefs
.smp_Depth
= 8;
186 DEBUG_SETIPREFS(bug("WB ModeID %08lx not available (w %ld h %ld)\n",modeid
,width
,height
));
188 // try to find a 800x600x16bit mode first
189 modeid
=BestCModeIDTags( CYBRBIDTG_NominalWidth
, (width
== -1) ? 800 : width
,
190 CYBRBIDTG_NominalHeight
, (height
== -1) ? 600 : height
,
194 if(modeid
== INVALID_ID
)
196 // find a 640x480x8bit fallback mode if there is no 16bit one
198 modeid
=BestCModeIDTags( CYBRBIDTG_NominalWidth
, (width
== -1) ? 640 : width
,
199 CYBRBIDTG_NominalHeight
, (height
== -1) ? 480 : height
,
205 if (modeid
!= INVALID_ID
)
207 DEBUG_SETIPREFS(bug(" Using replacement ID %08lx\n",modeid
));
209 GetPrivIBase(IntuitionBase
)->ScreenModePrefs
.smp_DisplayID
= modeid
;
212 CloseLibrary(CyberGfxBase
);
220 DEBUG_SETIPREFS(bug("SetIPrefs: IP_OLDICONTROL\n"));
221 if (length
> sizeof(struct IIControlPrefs
))
222 length
= sizeof(struct IIControlPrefs
);
223 CopyMem(data
, &GetPrivIBase(IntuitionBase
)->IControlPrefs
, length
);
224 FireMenuMessage(MMCODE_STARTCLOCK
,NULL
,NULL
,IntuitionBase
);//test if we need to restart clock
228 DEBUG_SETIPREFS(bug("SetIPrefs: IP_IEXTENSIONS\n"));
230 if (length
> sizeof(struct IControlExtensions
))
231 length
= sizeof(struct IControlExtensions
);
232 CopyMem(data
, &GetPrivIBase(IntuitionBase
)->IControlExtensions
, length
);
237 DEBUG_SETIPREFS(bug("SetIPrefs: IP_INPUTEXT\n"));
239 if (length
> sizeof(struct InputPrefsExt
))
240 length
= sizeof(struct InputPrefsExt
);
242 CopyMem(data
, &GetPrivIBase(IntuitionBase
)->InputPrefsExt
, length
);
247 memclr(&req
,sizeof (struct IOStdReq
));
249 req
.io_Device
= GetPrivIBase(IntuitionBase
)->InputIO
->io_Device
;
250 req
.io_Unit
= GetPrivIBase(IntuitionBase
)->InputIO
->io_Unit
;
251 req
.io_Command
= IND_SETMOUSETYPE
;
252 req
.io_Data
= &GetPrivIBase(IntuitionBase
)->InputPrefsExt
.ip_MouseMode
;
261 DEBUG_SETIPREFS(bug("SetIPrefs: IP_IACTIONS\n"));
266 ObtainSemaphore(&GetPrivIBase(IntuitionBase
)->InputHandlerLock
);
268 mem
= GetPrivIBase(IntuitionBase
)->NumIControlActions
* (sizeof (struct IAction
));
270 GetPrivIBase(IntuitionBase
)->NumIControlActions
= 0;
272 FreeMem(GetPrivIBase(IntuitionBase
)->IControlActions
,mem
);
274 mem
= (length
/(sizeof (struct IAction
)) * (sizeof (struct IAction
)));
276 if ((GetPrivIBase(IntuitionBase
)->IControlActions
= AllocMem(mem
,MEMF_ANY
)))
279 GetPrivIBase(IntuitionBase
)->NumIControlActions
= mem
/ (sizeof (struct IAction
));
280 CopyMem(data
, GetPrivIBase(IntuitionBase
)->IControlActions
, mem
);
283 ReleaseSemaphore(&GetPrivIBase(IntuitionBase
)->InputHandlerLock
);
289 DEBUG_SETIPREFS(bug("SetIPrefs: IP_OLDFONT\n"));
291 struct IOldFontPrefs
*fp
= data
;
292 struct TextFont
*font
= OpenFont(&fp
->fp_TextAttr
);
294 DEBUG_SETIPREFS(bug("SetIPrefs: Type %d Name <%s> Size %d Font %p\n", fp
->fp_Type
, fp
->fp_Name
, fp
->fp_TextAttr
.ta_YSize
, font
));
298 struct TextFont
**fontptr
;
302 * We can't free graphics defaultfont..it`s shared
304 fontptr
= &GfxBase
->DefaultFont
;
308 fontptr
= &GetPrivIBase(IntuitionBase
)->ScreenFont
;
316 DEBUG_SETIPREFS(bug("SetIPrefs: IP_FONT\n"));
318 struct IFontPrefs
*fp
= data
;
319 struct TextFont
*font
= OpenFont(&fp
->fp_TextAttr
);
320 struct TextFont
**fontptr
;
322 DEBUG_SETIPREFS(bug("SetIPrefs: Type %d Name <%s> Size %d Font %p\n", fp
->fp_ScrFont
, fp
->fp_Name
, fp
->fp_TextAttr
.ta_YSize
, font
));
326 if (fp
->fp_ScrFont
==0)
329 * We can't free graphics defaultfont..it`s shared
331 fontptr
= &GfxBase
->DefaultFont
;
335 fontptr
= &GetPrivIBase(IntuitionBase
)->ScreenFont
;
344 DEBUG_SETIPREFS(bug("SetIPrefs: IP_OLDPOINTER\n"));
346 struct IOldPointerPrefs
*fp
= data
;
350 DEBUG_SETIPREFS(bug("SetIPrefs: Bitmap 0x%lx XOffset %ld YOffset %ld XResolution %ld YResolution %ld WordWidth %ld Type %ld\n",
354 (LONG
) fp
->XResolution
,
355 (LONG
) fp
->YResolution
,
356 (LONG
) fp
->WordWidth
,
360 struct TagItem pointertags
[] =
363 POINTERA_BitMap
, (ULONG
) fp
->BitMap
365 {POINTERA_XOffset
, fp
->XOffset
},
366 {POINTERA_YOffset
, fp
->YOffset
},
367 {POINTERA_XResolution
, fp
->XResolution
},
368 {POINTERA_YResolution
, fp
->YResolution
},
369 {POINTERA_WordWidth
, fp
->WordWidth
},
373 pointer
= NewObjectA(
374 GetPrivIBase(IntuitionBase
)->pointerclass
,
381 &GetPrivIBase(IntuitionBase
)->BusyPointer
:
382 &GetPrivIBase(IntuitionBase
)->DefaultPointer
;
384 InstallPointer(IntuitionBase
, oldptr
, pointer
);
386 * Original iprefs checks for a 0 or -1 return
387 * otherwise it expects a returned bitmap..sigh
393 DEBUG_SETIPREFS(bug("SetIPrefs: IP_POINTER\n"));
395 struct IPointerPrefs
*fp
= data
;
396 struct TagItem pointertags
[] =
399 POINTERA_BitMap
, (ULONG
) fp
->BitMap
401 {POINTERA_XOffset
, fp
->XOffset
},
402 {POINTERA_YOffset
, fp
->YOffset
},
406 Object
*pointer
= NewObjectA(
407 GetPrivIBase(IntuitionBase
)->pointerclass
,
411 Object
**oldptr
= fp
->Which
?
412 &GetPrivIBase(IntuitionBase
)->BusyPointer
:
413 &GetPrivIBase(IntuitionBase
)->DefaultPointer
;
415 InstallPointer(IntuitionBase
, oldptr
, pointer
);
420 DEBUG_SETIPREFS(bug("SetIPrefs: IP_OLDPENS\n"));
422 struct IOldPenPrefs
*fp
= data
;
425 DEBUG_SETIPREFS(bug("SetIPrefs: Count %ld Type %ld\n",
431 dataptr
= &GetPrivIBase(IntuitionBase
)->DriPens4
[0];
432 DEBUG_SETIPREFS(bug("SetIPrefs: Pens4[]\n"));
436 dataptr
= &GetPrivIBase(IntuitionBase
)->DriPens8
[0];
437 DEBUG_SETIPREFS(bug("SetIPrefs: Pens8[]\n"));
439 for (i
=0;i
<NUMDRIPENS
;i
++)
441 if (fp
->PenTable
[i
]==(UWORD
)~0UL)
446 DEBUG_SETIPREFS(bug("SetIPrefs: PenTable end at entry %ld\n", (LONG
) i
));
451 DEBUG_SETIPREFS(bug("SetIPrefs: Pens[%ld] %ld\n",
453 (LONG
) fp
->PenTable
[i
]));
454 dataptr
[i
] = fp
->PenTable
[i
];
461 DEBUG_SETIPREFS(bug("SetIPrefs: IP_OLDOVERSCAN\n"));
463 struct IOldOverScanPrefs
*fp
= data
;
464 DEBUG_SETIPREFS(bug("SetIPrefs: DisplayID 0x%lx\n",
467 DEBUG_SETIPREFS(bug("SetIPrefs: ViewPos.x %ld ViewPos.y %ld\n",
468 (LONG
) fp
->ViewPos
.x
,
469 (LONG
) fp
->ViewPos
.y
));
471 DEBUG_SETIPREFS(bug("SetIPrefs: Text.x %ld Text.y %ld\n",
475 DEBUG_SETIPREFS(bug("SetIPrefs: MinX %ld MinY %ld MaxX %ld MaxY %ld\n",
476 (LONG
) fp
->Standard
.MinX
,
477 (LONG
) fp
->Standard
.MinY
,
478 (LONG
) fp
->Standard
.MaxX
,
479 (LONG
) fp
->Standard
.MaxY
));
484 DEBUG_SETIPREFS(bug("SetIPrefs: IP_PTRCOLOR\n"));
485 if (IntuitionBase
->ActiveScreen
)
487 struct IPointerColorPrefs
*fp
= data
;
488 if (fp
->Num
>= 8 && fp
->Num
<= 10)
490 (&GetPrivIBase(IntuitionBase
)->ActivePreferences
->color17
)[fp
->Num
- 8] =
491 ((fp
->Red
<< 4) & 0xf00) | (fp
->Green
& 0x0f0) | (fp
->Blue
>> 4);
492 SetPointerColors(IntuitionBase
);
498 DEBUG_SETIPREFS(bug("SetIPrefs: IP_OLDPALETTE\n"));
500 struct ColorSpec
*pp
= data
;
501 struct Color32
*p
= GetPrivIBase(IntuitionBase
)->Colors
;
503 // COLORTABLEENTRIES == 32
505 DEBUG_SETIPREFS(bug("SetIPrefs: Intuition Color32 Table 0x%lx\n", (ULONG
) p
));
507 while (pp
->ColorIndex
!= ~0x0)
509 DEBUG_SETIPREFS(bug("SetIPrefs: Index %ld Red 0x%lx Green 0x%lx Blue 0x%lx\n",
510 (LONG
) pp
->ColorIndex
,
514 if (pp
->ColorIndex
< COLORTABLEENTRIES
)
516 struct Preferences
*ActivePrefs
;
518 p
[pp
->ColorIndex
].red
= (pp
->Red
<<16)|pp
->Red
;
519 p
[pp
->ColorIndex
].green
= (pp
->Green
<<16)|pp
->Green
;
520 p
[pp
->ColorIndex
].blue
= (pp
->Blue
<<16)|pp
->Blue
;
522 // check for pointer colors
523 if ((ActivePrefs
= GetPrivIBase(IntuitionBase
)->ActivePreferences
))
525 if (pp
->ColorIndex
>= 8 && pp
->ColorIndex
<= 10)
527 UWORD
*ptrcols
=&ActivePrefs
->color17
;
529 ptrcols
[pp
->ColorIndex
- 8] =
530 ((pp
->Red
>> 4) & 0xf00) | ((pp
->Green
>> 8) & 0x0f0) | (pp
->Blue
>> 12);
533 if (IntuitionBase
->ActiveScreen
)
535 SetPointerColors(IntuitionBase
);
539 DEBUG_SETIPREFS(bug("SetIPrefs: Set Color32 %ld Red 0x%lx Green 0x%lx Blue 0x%lx\n",
540 (LONG
) pp
->ColorIndex
,
541 p
[pp
->ColorIndex
].red
,
542 p
[pp
->ColorIndex
].green
,
543 p
[pp
->ColorIndex
].blue
));
547 DEBUG_SETIPREFS(bug("SetIPrefs: ColorIndex %ld > TableSize %ld\n",
548 (LONG
) pp
->ColorIndex
, (LONG
) COLORTABLEENTRIES
));
556 DEBUG_SETIPREFS(bug("SetIPrefs: IP_PALETTE\n"));
558 struct PalettePrefs
*pp
= data
;
560 struct Color32
*p
= GetPrivIBase(IntuitionBase
)->Colors
;
562 CopyMem(pp
->pap_4ColorPens
, GetPrivIBase(IntuitionBase
)->DriPens4
, NUMDRIPENS
* sizeof(UWORD
));
563 CopyMem(pp
->pap_8ColorPens
, GetPrivIBase(IntuitionBase
)->DriPens8
, NUMDRIPENS
* sizeof(UWORD
));
564 for (k
= 0; k
< COLORTABLEENTRIES
; ++k
)
566 int n
= pp
->pap_Colors
[k
].ColorIndex
;
569 else if (n
>= 0 && n
< 8)
571 p
[n
].red
= pp
->pap_Colors
[k
].Red
* 0x10001;
572 p
[n
].green
= pp
->pap_Colors
[k
].Green
* 0x10001;
573 p
[n
].blue
= pp
->pap_Colors
[k
].Blue
* 0x10001;
575 DEBUG_SETIPREFS(bug("SetIPrefs: Set Color32 %ld Red 0x%lx Green 0x%lx Blue 0x%lx\n",
585 DEBUG_SETIPREFS(bug("SetIPrefs: Unknown Prefs Type\n"));
592 DEBUG_SETIPREFS(bug("SetIPrefs: Result 0x%lx\n",Result
));