2 Copyright © 1995-2015, The AROS Development Team. All rights reserved.
9 #include <devices/inputevent.h>
10 #include <devices/input.h>
11 #include <devices/newstyle.h>
12 #include <proto/exec.h>
13 #include <proto/input.h>
14 #include <exec/memory.h>
15 #include <exec/errors.h>
16 #include <exec/initializers.h>
17 #include <aros/symbolsets.h>
19 #include LC_LIBDEFS_FILE
21 #include "input_intern.h"
24 #include <aros/debug.h>
26 #define NEWSTYLE_DEVICE 1
30 #include <devices/newstyle.h>
32 static const UWORD SupportedCommands
[] =
47 static int GM_UNIQUENAME(Init
) (LIBBASETYPEPTR InputDevice
)
49 NEWLIST(&(InputDevice
->HandlerList
));
52 These defaults are in terms of 50 Hz ticks. The real VBlank frequency
55 InputDevice
->KeyRepeatThreshold
.tv_secs
=
56 DEFAULT_KEY_REPEAT_THRESHOLD
/ 50;
57 InputDevice
->KeyRepeatThreshold
.tv_micro
=
58 (DEFAULT_KEY_REPEAT_THRESHOLD
% 50) * 1000000 / 50;
60 InputDevice
->KeyRepeatInterval
.tv_secs
=
61 DEFAULT_KEY_REPEAT_INTERVAL
/ 50;
62 InputDevice
->KeyRepeatInterval
.tv_micro
=
63 (DEFAULT_KEY_REPEAT_INTERVAL
% 50) * 1000000 / 50;
65 D(bug("[InputDev] Starting up task, inputbase 0x%P\n", InputDevice
));
67 InputDevice
->InputTask
= NewCreateTask(TASKTAG_NAME
, "input.device",
68 TASKTAG_PRI
, IDTASK_PRIORITY
,
69 TASKTAG_STACKSIZE
, IDTASK_STACKSIZE
,
70 TASKTAG_TASKMSGPORT
, &InputDevice
->CommandPort
,
71 TASKTAG_PC
, ProcessEvents
, TASKTAG_ARG1
, InputDevice
, TAG_DONE
);
73 if (InputDevice
->InputTask
)
75 D(bug("[InputDev] Done\n"));
83 static int GM_UNIQUENAME(Open
)
84 (LIBBASETYPEPTR InputDevice
,
85 struct IORequest
*ioreq
, ULONG unitnum
, ULONG flags
)
87 D(bug("id: open()\n"));
89 /* Too many AOS programs do not initialize mn_Length. AOS input.device
91 if (ioreq
->io_Message
.mn_Length
< sizeof(struct IOStdReq
))
93 bug("[InputDev] Open: IORequest structure passed to OpenDevice is"
95 ioreq
->io_Error
= IOERR_OPENFAIL
;
102 ADD2INITLIB(GM_UNIQUENAME(Init
), 0)
103 ADD2OPENDEV(GM_UNIQUENAME(Open
), 0)
105 #define ioStd(x) ((struct IOStdReq *)x)
108 AROS_LH1(void, beginio
,
109 AROS_LHA(struct IOStdReq
*, ioreq
, A1
),
110 struct inputbase
*, InputDevice
, 5, Input
)
115 BOOL done_quick
= TRUE
;
117 D(bug("id: beginio(ioreq=%p)\n", ioreq
));
119 /* WaitIO will look into this */
120 ioreq
->io_Message
.mn_Node
.ln_Type
= NT_MESSAGE
;
122 switch (ioreq
->io_Command
)
125 case NSCMD_DEVICEQUERY
:
126 if (ioStd(ioreq
)->io_Length
< ((LONG
) OFFSET(NSDeviceQueryResult
,
127 SupportedCommands
)) + sizeof(UWORD
*))
129 ioreq
->io_Error
= IOERR_BADLENGTH
;
133 struct NSDeviceQueryResult
*d
;
135 d
= (struct NSDeviceQueryResult
*)ioStd(ioreq
)->io_Data
;
137 d
->DevQueryFormat
= 0;
138 d
->SizeAvailable
= sizeof(struct NSDeviceQueryResult
);
139 d
->DeviceType
= NSDEVTYPE_INPUT
;
140 d
->DeviceSubType
= 0;
141 d
->SupportedCommands
= (UWORD
*) SupportedCommands
;
143 ioStd(ioreq
)->io_Actual
= sizeof(struct NSDeviceQueryResult
);
164 /* Mark IO request to be done non-quick */
165 ioreq
->io_Flags
&= ~IOF_QUICK
;
166 /* Send to input device task */
167 PutMsg(InputDevice
->CommandPort
, &ioreq
->io_Message
);
172 /* If the quick bit is not set but the IO request was done quick,
173 * reply the message to tell we're through
175 ioreq
->io_Error
= error
;
176 if (!(ioreq
->io_Flags
& IOF_QUICK
))
177 ReplyMsg(&ioreq
->io_Message
);
180 D(bug("id: Return from BeginIO()\n"));
186 AROS_LH1(LONG
, abortio
,
187 AROS_LHA(struct IORequest
*, ioreq
, A1
),
188 struct inputbase
*, InputDevice
, 6, Input
)
192 /* Everything already done. */