2 Copyright (C) 2004-2013, The AROS Development Team. All rights reserved.
6 #define __OOP_NOATTRBASES__
8 #include <aros/debug.h>
9 #include <aros/symbolsets.h>
10 #include <hidd/hidd.h>
11 #include <hidd/keyboard.h>
13 #include <utility/tagitem.h>
14 #include <proto/alib.h>
15 #include <proto/exec.h>
16 #include <proto/utility.h>
17 #include <proto/oop.h>
21 /*****************************************************************************************
24 --background_kbdclass--
30 Instances of this class are virtual devices being clients of the
31 keyboard input subsystem. In order to receive keyboard events, you
32 have to create an object of this class and supply a callback using
33 aoHidd_Kbd_IrqHandler attribute. After this your callback will be
34 called every time the event arrives until you dispose your object.
36 Every client receives events from all keyboard devices merged into
39 *****************************************************************************************/
41 /*****************************************************************************************
53 Specifies a keyboard event handler. The handler will called be every time a
54 keyboard event happens. A "C" calling convention is used, declare the handler
57 void KeyboardIRQ(APTR data, UWORD keyCode)
59 Handler parameters are:
60 data - Anything you specify using aoHidd_Kbd_IrqHandlerData
61 keyCode - A raw key code as specified in devices/rawkeycodes.h.
62 Key release event is indicated by ORing this value
63 with IECODE_UP_PREFIX (defined in devices/inputevent.h)
65 The handler is called inside interrupts, so usual restrictions apply to it.
72 Not all hosted drivers provide this attribute.
75 aoHidd_Kbd_IrqHandlerData
79 *****************************************************************************************/
81 /*****************************************************************************************
84 aoHidd_Kbd_IrqHandlerData
93 Specifies a user-defined value that will be passed to IRQ handler as a first
94 parameter. The purpose of this is to pass some static data to the handler.
95 The system will not assume anything about this value.
97 Defaults to NULL if not specified.
106 aoHidd_Kbd_IrqHandler
110 ******************************************************************************************/
112 OOP_Object
*KBD__Root__New(OOP_Class
*cl
, OOP_Object
*o
, struct pRoot_New
*msg
)
114 struct kbd_data
*data
;
115 struct TagItem
*tag
, *tstate
;
116 struct Library
*UtilityBase
= CSD(cl
)->cs_UtilityBase
;
118 o
= (OOP_Object
*)OOP_DoSuperMethod(cl
, o
, (OOP_Msg
)msg
);
122 data
= OOP_INST_DATA(cl
, o
);
123 data
->callback
= NULL
;
124 data
->callbackdata
= NULL
;
126 tstate
= msg
->attrList
;
127 D(bug("tstate: %p\n", tstate
));
129 while ((tag
= NextTagItem(&tstate
)))
133 D(bug("Got tag %d, data %x\n", tag
->ti_Tag
, tag
->ti_Data
));
135 if (IS_HIDDKBD_ATTR(tag
->ti_Tag
, idx
))
137 D(bug("Kbd hidd tag\n"));
140 case aoHidd_Kbd_IrqHandler
:
141 data
->callback
= (APTR
)tag
->ti_Data
;
142 D(bug("Got callback %p\n", (APTR
)tag
->ti_Data
));
145 case aoHidd_Kbd_IrqHandlerData
:
146 data
->callbackdata
= (APTR
)tag
->ti_Data
;
147 D(bug("Got data %p\n", (APTR
)tag
->ti_Data
));
151 } /* while (tags to process) */
154 * Add to interrupts list if we have a callback.
155 * Creating an object without callback is a legacy way of
156 * installing hardware drivers. It should be removed.
161 ADDTAIL(&CSD(cl
)->callbacks
, data
);
168 VOID
KBD__Root__Dispose(OOP_Class
*cl
, OOP_Object
*o
, OOP_Msg msg
)
170 struct kbd_data
*data
= OOP_INST_DATA(cl
, o
);
172 /* This condition is a legacy and should be removed */
179 OOP_DoSuperMethod(cl
, o
, msg
);
183 * The following two methods are legacy and strongly deprecated.
184 * They are present only for backward compatibility with the old code.
187 /*****************************************************************************************
190 moHidd_Kbd_AddHardwareDriver
193 OOP_Object *OOP_DoMethod(OOP_Object *obj, struct pHidd_Kbd_AddHardwareDriver *Msg);
195 OOP_Object *HIDD_Kbd_AddHardwareDriver(OOP_Object *obj, OOP_Class *driverClass,
196 struct TagItem *tags);
202 Creates a hardware driver object and registers it in the system.
204 It does not matter on which instance of CLID_Hidd_Kbd class this method is
205 used. Hardware driver objects are shared between all of them.
207 Since V2 this interface is obsolete and deprecated. Use moHW_AddDriver
208 method on CLID_HW_Kbd class in order to install the driver.
211 obj - Any object of CLID_Hidd_Kbd class.
212 driverClass - A pointer to OOP class of the driver. In order to create an object
213 of some previously registered public class, use
214 oop.library/OOP_FindClass().
215 tags - An optional taglist which will be passed to driver class' New() method.
218 A pointer to driver object.
221 Do not dispose the returned object yourself, use HIDD_Kbd_RemHardwareDriver() for it.
228 moHidd_Kbd_RemHardwareDriver
231 This method supplies own interrupt handler to the driver, do not override this.
233 *****************************************************************************************/
235 OOP_Object
*KBD__Hidd_Kbd__AddHardwareDriver(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Kbd_AddHardwareDriver
*Msg
)
237 return HW_AddDriver(CSD(cl
)->hwObj
, Msg
->driverClass
, Msg
->tags
);
240 /*****************************************************************************************
243 moHidd_Kbd_RemHardwareDriver
246 void OOP_DoMethod(OOP_Object *obj, struct pHidd_Kbd_RemHardwareDriver *Msg);
248 void HIDD_Kbd_RemHardwareDriver(OOP_Object *obj, OOP_Object *driver);
254 Unregisters and disposes keyboard hardware driver object.
256 It does not matter on which instance of CLID_Hidd_Kbd class this method is
257 used. Hardware driver objects are shared between all of them.
259 Since V2 this interface is obsolete and deprecated. Use moHW_RemoveDriver
260 method on CLID_HW_Kbd class in order to remove the driver.
263 obj - Any object of CLID_Hidd_Kbd class.
264 driver - A pointer to a driver object, returned by HIDD_Kbd_AddHardwareDriver().
276 moHidd_Kbd_AddHardwareDriver
280 *****************************************************************************************/
282 void KBD__Hidd_Kbd__RemHardwareDriver(OOP_Class
*cl
, OOP_Object
*o
, struct pHidd_Kbd_RemHardwareDriver
*Msg
)
284 HW_RemoveDriver(CSD(cl
)->hwObj
, Msg
->driverObject
);