2 Copyright © 1995-2011, The AROS Development Team. All rights reserved.
9 /****************************************************************************************/
11 #include <devices/inputevent.h>
12 #include <devices/input.h>
13 #include <devices/newstyle.h>
14 #include <proto/exec.h>
15 #include <proto/input.h>
16 #include <exec/memory.h>
17 #include <exec/errors.h>
18 #include <exec/initializers.h>
19 #include <aros/symbolsets.h>
21 #include LC_LIBDEFS_FILE
23 #include "input_intern.h"
26 #include <aros/debug.h>
28 /****************************************************************************************/
30 #define NEWSTYLE_DEVICE 1
32 /****************************************************************************************/
36 #include <devices/newstyle.h>
37 static const UWORD SupportedCommands
[] =
51 /****************************************************************************************/
53 static int GM_UNIQUENAME(Init
)(LIBBASETYPEPTR InputDevice
)
55 NEWLIST( &(InputDevice
->HandlerList
) );
58 These defaults are in terms of 50 Hz ticks. The real VBlank frequency
61 InputDevice
->KeyRepeatThreshold
.tv_secs
= DEFAULT_KEY_REPEAT_THRESHOLD
/ 50;
62 InputDevice
->KeyRepeatThreshold
.tv_micro
63 = (DEFAULT_KEY_REPEAT_THRESHOLD
% 50) * 1000000 / 50;
65 InputDevice
->KeyRepeatInterval
.tv_secs
= DEFAULT_KEY_REPEAT_INTERVAL
/ 50;
66 InputDevice
->KeyRepeatInterval
.tv_micro
67 = (DEFAULT_KEY_REPEAT_INTERVAL
% 50) * 1000000 / 50;
69 D(bug("[InputDev] Starting up task, inputbase 0x%P\n", InputDevice
));
71 InputDevice
->InputTask
= NewCreateTask(TASKTAG_NAME
, "input.device",
72 TASKTAG_PRI
, IDTASK_PRIORITY
,
73 TASKTAG_STACKSIZE
, IDTASK_STACKSIZE
,
74 TASKTAG_TASKMSGPORT
, &InputDevice
->CommandPort
,
75 TASKTAG_PC
, ProcessEvents
,
76 TASKTAG_ARG1
, InputDevice
,
79 if(InputDevice
->InputTask
)
81 D(bug("[InputDev] Done\n"));
88 /****************************************************************************************/
90 static int GM_UNIQUENAME(Open
)
92 LIBBASETYPEPTR InputDevice
,
93 struct IORequest
*ioreq
,
98 D(bug("id: open()\n"));
100 /* Too many AOS programs do not initialize mn_Length. AOS input.device does not care. */
101 if (ioreq
->io_Message
.mn_Length
< sizeof(struct IOStdReq
))
103 bug("[InputDev] Open: IORequest structure passed to OpenDevice is too small\n");
104 ioreq
->io_Error
= IOERR_OPENFAIL
;
111 ADD2INITLIB(GM_UNIQUENAME(Init
),0)
112 ADD2OPENDEV(GM_UNIQUENAME(Open
),0)
114 /****************************************************************************************/
116 #define ioStd(x) ((struct IOStdReq *)x)
117 AROS_LH1(void, beginio
,
118 AROS_LHA(struct IOStdReq
*, ioreq
, A1
),
119 struct inputbase
*, InputDevice
, 5, Input
)
124 BOOL done_quick
= TRUE
;
126 D(bug("id: beginio(ioreq=%p)\n", ioreq
));
128 /* WaitIO will look into this */
129 ioreq
->io_Message
.mn_Node
.ln_Type
=NT_MESSAGE
;
131 switch (ioreq
->io_Command
)
134 case NSCMD_DEVICEQUERY
:
135 if(ioStd(ioreq
)->io_Length
< ((LONG
)OFFSET(NSDeviceQueryResult
, SupportedCommands
)) + sizeof(UWORD
*))
137 ioreq
->io_Error
= IOERR_BADLENGTH
;
141 struct NSDeviceQueryResult
*d
;
143 d
= (struct NSDeviceQueryResult
*)ioStd(ioreq
)->io_Data
;
145 d
->DevQueryFormat
= 0;
146 d
->SizeAvailable
= sizeof(struct NSDeviceQueryResult
);
147 d
->DeviceType
= NSDEVTYPE_INPUT
;
148 d
->DeviceSubType
= 0;
149 d
->SupportedCommands
= (UWORD
*)SupportedCommands
;
151 ioStd(ioreq
)->io_Actual
= sizeof(struct NSDeviceQueryResult
);
172 /* Mark IO request to be done non-quick */
173 ioreq
->io_Flags
&= ~IOF_QUICK
;
174 /* Send to input device task */
175 PutMsg(InputDevice
->CommandPort
, &ioreq
->io_Message
);
180 /* If the quick bit is not set but the IO request was done quick,
181 ** reply the message to tell we're throgh
183 ioreq
->io_Error
= error
;
184 if (!(ioreq
->io_Flags
& IOF_QUICK
))
185 ReplyMsg (&ioreq
->io_Message
);
188 D(bug("id: Return from BeginIO()\n"));
193 /****************************************************************************************/
195 AROS_LH1(LONG
, abortio
,
196 AROS_LHA(struct IORequest
*, ioreq
, A1
),
197 struct inputbase
*, InputDevice
, 6, Input
)
201 /* Everything already done. */
207 /****************************************************************************************/
209 static const char end
=0;
211 /****************************************************************************************/