static DFBResult driver_open_device(CoreInputDevice *device, unsigned int number, InputDeviceInfo *info, void **driver_data){ int fd; PeMData *data; /* open device */ fd = PeMOpenDevice (dfb_config->penmount_device); if (fd < 0) { D_PERROR("DirectFB/PenMount: Error opening '%s'!\n", dfb_config->penmount_device); return DFB_INIT; } data = D_CALLOC (1, sizeof(PeMData)); if (!data) { close (fd); return D_OOM (); } data->fd = fd; data->device = device; /* Must define the correct resolution of screen */ data->screen_width = PeM_SCREENWIDTH; data->screen_height = PeM_SCREENHEIGHT; /* The following variable are defined to adjust the orientation of * the touchscreen. Variables are either max screen height/width or 0. */ data->min_x = PeM_MINX; data->min_y = PeM_MINY; /* fill device info structure */ snprintf(info->desc.name, DFB_INPUT_DEVICE_DESC_NAME_LENGTH, "PenMount 9509"); snprintf(info->desc.vendor, DFB_INPUT_DEVICE_DESC_VENDOR_LENGTH, "AMT"); 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 = DIAI_Y; info->desc.max_button = DIBI_LEFT; /* start input thread */ data->thread = direct_thread_create (DTT_INPUT, PenMountEventThread, data, "PenMount Input"); /* set private data pointer */ *driver_data = data; return DFB_OK; }
static int driver_get_available( void ){ int fd; if (!dfb_config->penmount_device) return 0; fd = PeMOpenDevice (dfb_config->penmount_device); if (fd < 0) return 0; close(fd); return 1; }