(C) 1998 AROS - The Amiga Research OS


NAME

()

SYNOPSIS

FUNCTION

INPUTS
RESULT

EXAMPLE
SEE ALSO

NOTES

BUGS

INTERNALS

HISTORY
#define HIDDPATH "Sys:hidds/"#define BUFSIZE 100#define HIDDPREFSFILE "Sys:s/hidd.prefs"/* We don't link with c library so I mus implement this separately */static BOOL isblank(int c){ if (c == 9 || c == 32) return TRUE; return FALSE;}BOOL init_hidds(struct ExecBase *sysBase, struct DosLibrary *dosBase){/* This is the initialisation code for InitHIDDs module */ struct initbase stack_b, *base = &stack_b; BOOL success = TRUE; UBYTE buf[BUFSIZE]; UBYTE gfxname[BUFSIZE], kbdname[BUFSIZE], mousename[BUFSIZE]; BOOL got_gfx = FALSE, got_kbd = FALSE, got_mouse = FALSE; base->sysbase = sysBase; base->dosbase = dosBase; EnterFunc(bug("init_hidds\n")); OOPBase = OpenLibrary(AROSOOP_NAME, 0); if (!OOPBase) { success = FALSE; } else { BPTR fh; D(bug("OOP opened\n")); /* Open the hidd prefsfile */ fh = Open(HIDDPREFSFILE, MODE_OLDFILE); if (!fh) { success = FALSE; } else { D(bug("hiddprefs file opened\n")); while (FGets(fh, buf, BUFSIZE)) { STRPTR keyword = buf, arg, end; D(bug("Got line\n")); D(bug("Line: %s\n", buf)); /* Get keywoard */ while ((*keyword != 0) && isspace(*keyword)) keyword ++; if (*keyword == 0) continue; /* terminate keyword */ arg = keyword; while ((*arg != 0) && (!isblank(*arg))) { arg ++; } if (*arg == 0) continue; *arg = 0; arg ++; /* Find start of argument */ D(bug("Find argument at %s\n", arg)); while ((*arg != 0) && isblank(*arg)) arg ++; if (*arg == 0) continue; D(bug("Terminate argument at %s\n", arg)); /* terminate argument */ end = arg; while ( (*end != 0) && (!isblank(*end))) end ++; if (*end != 0) *end = 0; D(bug("Got keyword \"%s\"\n", keyword)); D(bug("Got arg \"%s\"\n", arg)); if (0 == strcmp(keyword, "library")) { D(bug("Opening library\n")); /* Open a specified library */ if (NULL == OpenLibrary(arg, 0)) { success = FALSE; break; } } else if (0 == strcmp(keyword, "gfx")) { strncpy(gfxname, arg, BUFSIZE - 1); got_gfx = TRUE; } else if (0 == strcmp(keyword, "mouse")) { strncpy(mousename, arg, BUFSIZE - 1); got_mouse = TRUE; } else if (0 == strcmp(keyword, "kbd")) { strncpy(kbdname, arg, BUFSIZE - 1); got_kbd = TRUE; } } Close(fh); if (!got_gfx) { success = FALSE; kprintf("No configureation for gfx hidd\n"); goto end; } if (!got_mouse) { success = FALSE; kprintf("No configureation for mouse hidd\n"); goto end; } if (!got_kbd) { success = FALSE; kprintf("No configureation for keyboard hidd\n"); goto end; } if (!init_gfx(gfxname, base)) { kprintf("Could not init gfx hidd %s\n", gfxname); success = FALSE; goto end; } if (!init_device(kbdname, "keyboard.device", base)) { kprintf("Could not init keyboard hidd %s\n", kbdname); success = FALSE; goto end; } if (!init_device(mousename, "gameport.device", base)) { kprintf("Could not init mouse hidd %s\n", mousename); success = FALSE; goto end; }end: } CloseLibrary(OOPBase); } ReturnBool("init_hidds", success);}