revert between 56095 -> 55830 in arch
[AROS.git] / rom / hidds / kbd / kbd_init.c
blob19e0a29a9be6af74f7c0dc16cef9c86e47513de4
1 /*
2 Copyright (C) 2004-2013, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <oop/oop.h>
8 #include <hidd/hidd.h>
9 #include <hidd/keyboard.h>
10 #include <proto/alib.h>
11 #include <proto/exec.h>
12 #include <proto/oop.h>
14 #include "kbd.h"
16 #undef HWBase
17 #define HWBase (LIBBASE->csd.hwMB)
19 static int KBD_InitClass(struct kbdbase *LIBBASE)
21 struct Library *OOPBase = LIBBASE->csd.cs_OOPBase;
23 D(bug("[KBD] base class initialization\n"));
25 LIBBASE->csd.cs_UtilityBase = OpenLibrary("utility.library", 0);
26 if (!LIBBASE->csd.cs_UtilityBase)
27 return FALSE;
29 LIBBASE->csd.hiddKbdAB = OOP_ObtainAttrBase(IID_Hidd_Kbd);
30 LIBBASE->csd.hwAB = OOP_ObtainAttrBase(IID_HW);
31 LIBBASE->csd.hwMB = OOP_GetMethodID(IID_HW, 0);
33 if (LIBBASE->csd.hiddKbdAB && LIBBASE->csd.hwAB)
35 OOP_Object *root = OOP_NewObject(NULL, CLID_HW_Root, NULL);
37 NewList((struct List *)&LIBBASE->csd.callbacks);
39 if (HW_AddDriver(root, LIBBASE->csd.hwClass, NULL))
41 D(bug("[KBD] Everything OK\n"));
42 return TRUE;
46 return FALSE;
49 static int KBD_ExpungeClass(struct kbdbase *LIBBASE)
51 struct Library *OOPBase = LIBBASE->csd.cs_OOPBase;
53 D(bug("[KBD] Base Class destruction\n"));
55 if (LIBBASE->csd.hiddKbdAB)
56 OOP_ReleaseAttrBase(IID_Hidd_Kbd);
57 if (LIBBASE->csd.cs_UtilityBase)
58 CloseLibrary(LIBBASE->csd.cs_UtilityBase);
60 return TRUE;
63 ADD2INITLIB(KBD_InitClass, 0)
64 ADD2EXPUNGELIB(KBD_ExpungeClass, 0)