revert between 56095 -> 55830 in arch
[AROS.git] / arch / all-hosted / hidd / x11 / startup.c
blob926d53e165d58ff521a4a25a7b5ea462c031ac3c
1 /*
2 Copyright © 1995-2016, 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 "x11_debug.h"
25 #include <hidd/keyboard.h>
26 #include <hidd/mouse.h>
27 #include <graphics/gfxbase.h>
28 #include <proto/graphics.h>
30 #include LC_LIBDEFS_FILE
32 static int X11_Startup(LIBBASETYPEPTR LIBBASE)
34 struct TagItem kbd_tags[] =
36 {aHidd_Name , (IPTR)"X11Kbd" },
37 {aHidd_HardwareName, (IPTR)"X Window keyboard input"},
38 {aHidd_ProducerName, (IPTR)"X.Org Foundation" },
39 {TAG_DONE , 0 }
41 struct TagItem mouse_tags[] =
43 {aHidd_Name , (IPTR)"X11Mouse" },
44 {aHidd_HardwareName, (IPTR)"X Window pointer input"},
45 {aHidd_ProducerName, (IPTR)"X.Org Foundation" },
46 {TAG_DONE , 0 }
48 struct GfxBase *GfxBase;
49 OOP_Object *kbd, *ms;
50 OOP_Object *kbdriver = NULL;
51 OOP_Object *msdriver = NULL;
52 int res = FALSE;
53 ULONG err;
55 D(bug("[X11] X11_Startup()\n"));
57 GfxBase = (struct GfxBase *)OpenLibrary("graphics.library", 41);
58 D(bug("[X11_Startup] GfxBase 0x%p\n", GfxBase));
59 if (!GfxBase)
60 return FALSE;
62 /* Add keyboard and mouse driver to the system */
63 kbd = OOP_NewObject(NULL, CLID_Hidd_Kbd, NULL);
64 ms = OOP_NewObject(NULL, CLID_Hidd_Mouse, NULL);
66 if ((!kbd) || !(ms))
68 CloseLibrary(&GfxBase->LibNode);
69 return FALSE;
72 kbdriver = HW_AddDriver(kbd, LIBBASE->xsd.kbdclass, kbd_tags);
73 if (kbdriver)
74 msdriver = HW_AddDriver(ms, LIBBASE->xsd.mouseclass, mouse_tags);
76 /* If we got no input, we can't work, fail */
77 if (!msdriver)
79 CloseLibrary(&GfxBase->LibNode);
80 return FALSE;
83 err = AddDisplayDriverA(LIBBASE->xsd.gfxclass, NULL, NULL);
85 D(bug("[X11_Startup] AddDisplayDriver() result: %u\n", err));
86 if (!err)
88 LIBBASE->library.lib_OpenCnt = 1;
89 res = TRUE;
91 else
93 if (kbdriver)
94 HW_RemoveDriver(kbd, kbdriver);
95 if (msdriver)
96 HW_RemoveDriver(ms, msdriver);
99 CloseLibrary(&GfxBase->LibNode);
101 return res;
104 /* This routine must be called AFTER everything all other initialization was run */
105 ADD2INITLIB(X11_Startup, 10);