int XInputEventNotifier::getNewDeviceEventType(XEvent* event) { int newDeviceType = DEVICE_NONE; if( xinputEventType != -1 && event->type == xinputEventType ) { XDevicePresenceNotifyEvent *xdpne = (XDevicePresenceNotifyEvent*) event; if( xdpne->devchange == DeviceEnabled ) { int ndevices; XDeviceInfo *devices = XListInputDevices(xdpne->display, &ndevices); if( devices != NULL ) { // kDebug() << "New device id:" << xdpne->deviceid; for(int i=0; i<ndevices; i++) { // kDebug() << "id:" << devices[i].id << "name:" << devices[i].name << "used as:" << devices[i].use; if( devices[i].id == xdpne->deviceid ) { if( devices[i].use == IsXKeyboard || devices[i].use == IsXExtensionKeyboard ) { if( isRealKeyboard(devices[i].name) ) { newDeviceType = DEVICE_KEYBOARD; kDebug() << "new keyboard device, id:" << devices[i].id << "name:" << devices[i].name << "used as:" << devices[i].use; break; } } if( devices[i].use == IsXPointer || devices[i].use == IsXExtensionPointer ) { newDeviceType = DEVICE_POINTER; kDebug() << "new pointer device, id:" << devices[i].id << "name:" << devices[i].name << "used as:" << devices[i].use; break; } } } XFreeDeviceList(devices); } } } return newDeviceType; }
int XInputEventNotifier::getNewDeviceEventType(xcb_generic_event_t* event) { int newDeviceType = DEVICE_NONE; if( xinputEventType != -1 && event->response_type == xinputEventType ) { xcb_input_device_presence_notify_event_t *xdpne = reinterpret_cast<xcb_input_device_presence_notify_event_t *>(event); if( xdpne->devchange == DeviceEnabled ) { int ndevices; XDeviceInfo *devices = XListInputDevices(display, &ndevices); if( devices != NULL ) { qCDebug(KCM_KEYBOARD) << "New device id:" << xdpne->device_id; for(int i=0; i<ndevices; i++) { qCDebug(KCM_KEYBOARD) << "id:" << devices[i].id << "name:" << devices[i].name << "used as:" << devices[i].use; if( devices[i].id == xdpne->device_id ) { if( devices[i].use == IsXKeyboard || devices[i].use == IsXExtensionKeyboard ) { if( isRealKeyboard(devices[i].name) ) { newDeviceType = DEVICE_KEYBOARD; qCDebug(KCM_KEYBOARD) << "new keyboard device, id:" << devices[i].id << "name:" << devices[i].name << "used as:" << devices[i].use; break; } } if( devices[i].use == IsXPointer || devices[i].use == IsXExtensionPointer ) { newDeviceType = DEVICE_POINTER; qCDebug(KCM_KEYBOARD) << "new pointer device, id:" << devices[i].id << "name:" << devices[i].name << "used as:" << devices[i].use; break; } } } XFreeDeviceList(devices); } } } return newDeviceType; }