added concrete implementations of putc(), getc(), getchar() and gets()
[tangerine.git] / workbench / prefs / input / main.c
blob591c4af3bb4e5735647dc6a9b13635bce464e39f
1 /*
2 Copyright 2003-2004, The AROS Development Team. All rights reserved.
3 $Id$
4 */
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>
17 #include "locale.h"
18 #include "args.h"
19 #include "ipeditor.h"
20 #include "prefs.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;
29 extern IPTR mempool;
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);
43 return TRUE;
46 return FALSE;
49 /*********************************************************************************************/
51 static void CloseInputDev(void)
53 if (InputIO)
55 CloseDevice((struct IORequest *)InputIO);
56 DeleteIORequest((struct IORequest *)InputIO);
59 if (InputMP)
61 DeleteMsgPort(InputMP);
65 /*********************************************************************************************/
67 struct StringifyData
69 UWORD Type;
70 char buf[16];
73 AROS_UFH3S(IPTR, StringifyDispatcher,
74 AROS_UFHA(Class *, cl, A0),
75 AROS_UFHA(Object *, obj, A2),
76 AROS_UFHA(Msg , msg, A1))
78 AROS_USERFUNC_INIT
80 if (msg->MethodID==OM_NEW)
82 obj = (Object*) DoSuperMethodA(cl,obj,msg);
83 if (obj != NULL)
85 struct StringifyData *data = INST_DATA(cl,obj);
86 data->Type = (UWORD) GetTagData(MUIA_MyStringifyType, 0, ((struct opSet *)msg)->ops_AttrList);
88 return (IPTR) obj;
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);
113 AROS_USERFUNC_EXIT
116 int main(void)
118 Object *application, *window;
120 Locale_Initialize();
122 if (ReadArguments())
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.
130 FreeArguments();
133 if (!OpenInputDev()) return 0;
135 DefaultPrefs();
136 CopyPrefs(&inputprefs, &restore_prefs);
138 NewList(&keymap_list);
140 mempool = (IPTR) CreatePool(MEMF_PUBLIC | MEMF_CLEAR, 2048, 2048);
142 if (mempool != NULL)
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,
157 TAG_DONE),
158 End),
159 End;
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);
172 DeletePool(mempool);
175 kbd_cleanup();
177 CloseInputDev();
179 Locale_Deinitialize();
181 return 0;