2 Copyright 2003-2004, The AROS Development Team. All rights reserved.
6 // #define MUIMASTER_YES_INLINE_STDARG
8 #include <proto/intuition.h>
9 #include <proto/muimaster.h>
10 #include <proto/utility.h>
12 #include <libraries/mui.h>
13 #include <prefs/input.h>
15 #include <zune/systemprefswindow.h>
22 #include <aros/debug.h>
24 #define VERSION "$VER: Input 0.1 ("ADATE") AROS Dev Team"
26 extern struct List keymap_list
;
27 extern struct InputPrefs inputprefs
;
28 extern struct InputPrefs restore_prefs
;
30 extern struct MsgPort
*InputMP
;
31 extern struct timerequest
*InputIO
;
32 struct MUI_CustomClass
*StringifyClass
;
34 /*********************************************************************************************/
36 static BOOL
OpenInputDev(void)
38 if ((InputMP
= CreateMsgPort()))
40 if ((InputIO
= (struct timerequest
*) CreateIORequest(InputMP
, sizeof(struct IOStdReq
))))
42 OpenDevice("input.device", 0, (struct IORequest
*)InputIO
, 0);
49 /*********************************************************************************************/
51 static void CloseInputDev(void)
55 CloseDevice((struct IORequest
*)InputIO
);
56 DeleteIORequest((struct IORequest
*)InputIO
);
61 DeleteMsgPort(InputMP
);
65 /*********************************************************************************************/
73 AROS_UFH3S(IPTR
, StringifyDispatcher
,
74 AROS_UFHA(Class
*, cl
, A0
),
75 AROS_UFHA(Object
*, obj
, A2
),
76 AROS_UFHA(Msg
, msg
, A1
))
80 if (msg
->MethodID
==OM_NEW
)
82 obj
= (Object
*) DoSuperMethodA(cl
,obj
,msg
);
85 struct StringifyData
*data
= INST_DATA(cl
,obj
);
86 data
->Type
= (UWORD
) GetTagData(MUIA_MyStringifyType
, 0, ((struct opSet
*)msg
)->ops_AttrList
);
90 else if (msg
->MethodID
==MUIM_Numeric_Stringify
)
92 struct StringifyData
*data
= INST_DATA(cl
,obj
);
94 struct MUIP_Numeric_Stringify
*m
= (APTR
)msg
;
96 if (data
->Type
== STRINGIFY_RepeatRate
)
98 sprintf((char *)data
->buf
,"%3.2fs", 0.02*(12-m
->value
));
100 else if (data
->Type
== STRINGIFY_RepeatDelay
)
102 sprintf((char *)data
->buf
,"%ldms", 20+20*m
->value
);
104 else if (data
->Type
== STRINGIFY_DoubleClickDelay
)
106 sprintf((char *)data
->buf
,"%3.2fs", 0.02 + 0.02 * m
->value
);
108 return((IPTR
) data
->buf
);
111 return (IPTR
) DoSuperMethodA(cl
,obj
,msg
);
118 Object
*application
, *window
;
124 /* FIXME: handle arguments... */
126 // FROM - import prefs from this file at start
127 // USE - 'use' the loaded prefs immediately, don't open window.
128 // SAVE - 'save' the lodaed prefs immediately, don't open window.
133 if (!OpenInputDev()) return 0;
136 CopyPrefs(&inputprefs
, &restore_prefs
);
138 NewList(&keymap_list
);
140 mempool
= (IPTR
) CreatePool(MEMF_PUBLIC
| MEMF_CLEAR
, 2048, 2048);
144 ScanDirectory("DEVS:Keymaps/#?_~(#?.info)", &keymap_list
, sizeof(struct KeymapEntry
));
146 StringifyClass
= (struct MUI_CustomClass
*) MUI_CreateCustomClass(NULL
, MUIC_Slider
, NULL
, sizeof(struct StringifyData
), StringifyDispatcher
);
147 if (StringifyClass
!= NULL
)
149 application
= ApplicationObject
,
150 MUIA_Application_Title
, __(MSG_NAME
),
151 MUIA_Application_Version
, (IPTR
) VERSION
,
152 MUIA_Application_Description
, __(MSG_DESCRIPTION
),
153 MUIA_Application_Base
, (IPTR
) "INPUTPREF",
154 SubWindow
, (IPTR
) (window
= SystemPrefsWindowObject
,
155 MUIA_Window_ID
, MAKE_ID('I','W','I','N'),
156 WindowContents
, (IPTR
) IPEditorObject
,
161 if (application
!= NULL
)
163 SET(window
, MUIA_Window_Open
, TRUE
);
164 DoMethod(application
, MUIM_Application_Execute
);
165 SET(window
, MUIA_Window_Open
, FALSE
);
167 MUI_DisposeObject(application
);
169 MUI_DeleteCustomClass(StringifyClass
);
179 Locale_Deinitialize();