grub2: bring back build of aros-side grub2 tools
[AROS.git] / rom / hidds / mouse / mouse_init.c
blobc08fb6a5e638625e51350692392e3ef5bcdeb41a
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 #include <aros/debug.h>
7 #include <aros/symbolsets.h>
8 #include <hidd/hidd.h>
9 #include <hidd/mouse.h>
10 #include <proto/alib.h>
11 #include <proto/exec.h>
12 #include <proto/oop.h>
14 #include "mouse.h"
16 /* Class initialization and destruction */
17 #define SysBase LIBBASE->csd.cs_SysBase
18 #define OOPBase LIBBASE->csd.cs_OOPBase
19 #undef HWBase
20 #define HWBase LIBBASE->csd.hwMethodBase
22 static int Mouse_InitClass(struct mousebase *LIBBASE)
24 D(bug("[Mouse] base class initialization\n"));
26 LIBBASE->csd.cs_UtilityBase = OpenLibrary("utility.library", 36);
27 if (!LIBBASE->csd.cs_UtilityBase)
28 return FALSE;
30 LIBBASE->csd.hwAttrBase = OOP_ObtainAttrBase(IID_HW);
31 LIBBASE->csd.hiddMouseAB = OOP_ObtainAttrBase(IID_Hidd_Mouse);
32 LIBBASE->csd.driverdataAB = OOP_ObtainAttrBase(IID_DriverData);
33 LIBBASE->csd.hwMethodBase = OOP_GetMethodID(IID_HW, 0);
35 if (LIBBASE->csd.hwAttrBase && LIBBASE->csd.hiddMouseAB &&
36 LIBBASE->csd.driverdataAB)
38 OOP_Object *root = OOP_NewObject(NULL, CLID_HW_Root, NULL);
40 NewList((struct List *)&LIBBASE->csd.callbacks);
42 if (HW_AddDriver(root, LIBBASE->csd.hwClass, NULL))
44 D(bug("[Mouse] Everything OK\n"));
45 return TRUE;
49 return FALSE;
52 static int Mouse_ExpungeClass(struct mousebase *LIBBASE)
54 D(bug("[Mouse] Base Class destruction\n"));
56 if (LIBBASE->csd.driverdataAB)
57 OOP_ReleaseAttrBase(IID_DriverData);
58 if (LIBBASE->csd.hiddMouseAB)
59 OOP_ReleaseAttrBase(IID_Hidd_Mouse);
60 if (LIBBASE->csd.hwAttrBase)
61 OOP_ReleaseAttrBase(IID_HW);
63 if (LIBBASE->csd.cs_UtilityBase)
64 CloseLibrary(LIBBASE->csd.cs_UtilityBase);
66 return TRUE;
69 ADD2INITLIB(Mouse_InitClass, 0)
70 ADD2EXPUNGELIB(Mouse_ExpungeClass, 0)