Copyright clean-up (part 1):
[AROS.git] / arch / all-hosted / hidd / x11 / startup.c
blob3f1fa24e2d9cacbbb5ca65681659452033e67c10
1 /*
2 Copyright © 1995-2014, The AROS Development Team. All rights reserved.
3 $Id$
4 */
6 /*
7 * A newstyle startup code for resident display drivers.
9 * Now it's the job of the driver to add ifself to the system.
10 * The driver does not have to be a library anymore, it can be
11 * plain executable which is started from DEVS:Monitors.
13 * The job of driver startup code is to create all necessary
14 * classes (driver class and bitmap class) and create as many
15 * driver objects as possible. Every object needs to be given
16 * to AddDisplayDriverA() in order to become functional.
18 * When the transition completes, kludges from bootmenu and
19 * dosboot will be removed. Noone will care about library
20 * open etc.
23 #include <aros/debug.h>
24 #include <aros/symbolsets.h>
25 #include <hidd/hidd.h>
26 #include <hidd/keyboard.h>
27 #include <hidd/mouse.h>
28 #include <graphics/gfxbase.h>
29 #include <proto/exec.h>
30 #include <proto/graphics.h>
31 #include <proto/oop.h>
33 #include LC_LIBDEFS_FILE
35 static int X11_Startup(LIBBASETYPEPTR LIBBASE)
37 struct TagItem kbd_tags[] =
39 {aHidd_Name , (IPTR)"X11Kbd" },
40 {aHidd_HardwareName, (IPTR)"X Window keyboard input"},
41 {aHidd_ProducerName, (IPTR)"X.Org Foundation" },
42 {TAG_DONE , 0 }
44 struct TagItem mouse_tags[] =
46 {aHidd_Name , (IPTR)"X11Mouse" },
47 {aHidd_HardwareName, (IPTR)"X Window pointer input"},
48 {aHidd_ProducerName, (IPTR)"X.Org Foundation" },
49 {TAG_DONE , 0 }
51 struct GfxBase *GfxBase;
52 OOP_Object *kbd, *ms;
53 OOP_Object *kbdriver = NULL;
54 OOP_Object *msdriver = NULL;
55 int res = FALSE;
56 ULONG err;
58 D(bug("[X11] X11_Startup()\n"));
60 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 41);
61 D(bug("[X11_Startup] GfxBase 0x%p\n", GfxBase));
62 if (!GfxBase)
63 return FALSE;
65 /* Add keyboard and mouse driver to the system */
66 kbd = OOP_NewObject(NULL, CLID_Hidd_Kbd, NULL);
67 ms = OOP_NewObject(NULL, CLID_Hidd_Mouse, NULL);
69 if ((!kbd) || !(ms))
71 CloseLibrary(&GfxBase->LibNode);
72 return FALSE;
75 kbdriver = HW_AddDriver(kbd, LIBBASE->xsd.kbdclass, kbd_tags);
76 if (kbdriver)
77 msdriver = HW_AddDriver(ms, LIBBASE->xsd.mouseclass, mouse_tags);
79 /* If we got no input, we can't work, fail */
80 if (!msdriver)
82 CloseLibrary(&GfxBase->LibNode);
83 return FALSE;
86 err = AddDisplayDriverA(LIBBASE->xsd.gfxclass, NULL, NULL);
88 D(bug("[X11_Startup] AddDisplayDriver() result: %u\n", err));
89 if (!err)
91 LIBBASE->library.lib_OpenCnt = 1;
92 res = TRUE;
94 else
96 if (kbdriver)
97 HW_RemoveDriver(kbd, kbdriver);
98 if (msdriver)
99 HW_RemoveDriver(ms, msdriver);
102 CloseLibrary(&GfxBase->LibNode);
104 return res;
107 /* This routine must be called AFTER everything all other initialization was run */
108 ADD2INITLIB(X11_Startup, 10);