static Ret open_device(PrivInfo* priv, int max_x, int max_y) { int fd = 0; int mouseId = -1; int flags = O_RDWR | O_SYNC | O_EXCL;; fd = open( "/dev/input/mice", flags ); if (fd < 0) { return RET_OK; } fcntl( fd, F_SETFL, fcntl ( fd, F_GETFL ) & ~O_NONBLOCK ); mouseId = init_ps2( fd, true ); if (mouseId < 0) { close( fd ); return RET_OK; } priv->max_x = max_x; priv->max_y = max_y; priv->fd = fd; priv->mouseId = mouseId; priv->packetLength = (mouseId == PS2_ID_IMPS2) ? 4 : 3; return RET_OK; }
static void check_devices( const char *devnames[], int num ) { int i, fd; for (i=0; i<num; i++) { if ((fd = open( devnames[i], O_RDWR | O_SYNC )) < 0) continue; if (init_ps2( fd, false ) < 0) { close( fd ); continue; } devlist[ndev++] = devnames[i]; close( fd ); break; } }
void kernel_main(multiboot_info_t* mbd, unsigned int magic) { terminal_initialize(); terminal_writestring("Now booting SLU\n"); terminal_writestring("Compiled on "); terminal_writestring(__DATE__); terminal_writestring(" at "); terminal_writestring(__TIME__); terminal_writestring("\n"); print_logo(); terminal_writestringwithcolor("Current memory available: ", COLOR_GREEN, COLOR_BLACK); char mem[33]; ltoa(mbd->mem_upper + mbd -> mem_lower, mem, 10); terminal_writestring(mem); terminal_writestring(" kilobytes \n"); terminal_writestring("CPU Flags: "); char iflags[65]; ltoa(getCPUFlags(), iflags, 2); terminal_writestring(iflags); terminal_writestring("\n"); terminal_writestringwithcolor("Magic number: ", COLOR_MAGENTA, COLOR_BLACK); char mchar[33]; itoa(magic, mchar, 16); terminal_writestring(mchar); terminal_writestring("\n"); update_cursor(10, 10); terminal_writestring("Setting up tables\n"); asm("cli"); init_gdt(); init_idt(); asm("sti"); init_ps2(); terminal_writestring("Done setting up tables\n"); while(1); }
static DFBResult driver_open_device( CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data ) { int fd; int mouseId = -1; int flags; PS2MouseData *data; /* open device */ flags = (dfb_config->mouse_gpm_source) ? (O_RDONLY | O_NONBLOCK) : (O_RDWR | O_SYNC | O_EXCL); fd = open( devlist[number], flags ); if (fd < 0) { D_PERROR( "DirectFB/PS2Mouse: failed opening `%s' !\n", devlist[number] ); close( fd ); return DFB_INIT; } fcntl( fd, F_SETFL, fcntl ( fd, F_GETFL ) & ~O_NONBLOCK ); if (!dfb_config->mouse_gpm_source) { mouseId = init_ps2( fd, true ); if (mouseId < 0) { D_PERROR( "DirectFB/PS2Mouse: could not initialize mouse on `%s'!\n", devlist[number] ); close( fd ); return DFB_INIT; } } if (dfb_config->mouse_protocol) { if (strcasecmp( dfb_config->mouse_protocol, "IMPS/2" ) == 0) { mouseId = PS2_ID_IMPS2; } else if (strcasecmp( dfb_config->mouse_protocol, "PS/2" ) == 0) { mouseId = PS2_ID_PS2; } else { D_ERROR( "DirectFB/PS2Mouse: unsupported protocol `%s' !\n", dfb_config->mouse_protocol ); close( fd ); return DFB_INIT; } } /* fill device info structure */ snprintf( info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, (mouseId == PS2_ID_IMPS2) ? "IMPS/2 Mouse" : "PS/2 Mouse" ); snprintf( info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "Unknown" ); info->prefered_id = DIDID_MOUSE; info->desc.type = DIDTF_MOUSE; #ifndef DIRECTFB_DISABLE_DEPRECATED info->desc.caps = DICAPS_AXES | DICAPS_BUTTONS; #else info->desc.caps = DIDCAPS_AXES | DIDCAPS_BUTTONS; #endif info->desc.max_axis = (mouseId == PS2_ID_IMPS2) ? DIAI_Z : DIAI_Y; info->desc.max_button = DIBI_MIDDLE; /* TODO: probe!? */ /* allocate and fill private data */ data = D_CALLOC( 1, sizeof(PS2MouseData) ); if (!data) { close( fd ); return D_OOM(); } data->fd = fd; data->device = device; data->mouseId = mouseId; data->packetLength = (mouseId == PS2_ID_IMPS2) ? 4 : 3; /* start input thread */ data->thread = direct_thread_create( DTT_INPUT, ps2mouseEventThread, data, "PS/2 Input" ); /* set private data pointer */ *driver_data = data; return DFB_OK; }