mirror of
https://github.com/linuxdeepin/dde-dock.git
synced 2025-06-04 17:33:05 +00:00
inputdevices: add touchscreen checker
tower:https://tower.im/projects/21ff955a5d71481b8f5a5087b5013396/todos/994a45846f104a23b6e4e723328b40a6/ Change-Id: Ia68f62a2e7081e0405f769295386e7e58bf15dc2
This commit is contained in:
parent
de791faefb
commit
37b0aafef0
@ -26,6 +26,7 @@ typedef struct _DeviceInfo {
|
||||
char *name;
|
||||
int deviceid;
|
||||
int enabled;
|
||||
int is_touchscreen;
|
||||
} DeviceInfo;
|
||||
|
||||
DeviceInfo *get_device_info_list(int *n_devices);
|
||||
|
@ -29,6 +29,49 @@
|
||||
#include "utils.h"
|
||||
#include "devices.h"
|
||||
|
||||
#define AXIS_MODE_REL 1 //relative
|
||||
#define AXIS_MODE_ABS 2 //absolte --> touchscreen
|
||||
|
||||
#define TOUCH_MODE_DEPENDENT 1 //touchpad
|
||||
#define TOUCH_MODE_DIRECT 2 // touchscreen
|
||||
|
||||
static int is_touchscreen_device(const XIDeviceInfo* info);
|
||||
|
||||
static int
|
||||
is_touchscreen_device(const XIDeviceInfo* info)
|
||||
{
|
||||
if (info->num_classes <= 0) {
|
||||
return 0;
|
||||
}
|
||||
|
||||
int i = 0;
|
||||
for (; i < info->num_classes; i++) {
|
||||
XIAnyClassInfo* any = info->classes[i];
|
||||
switch (any->type) {
|
||||
case XIValuatorClass: {
|
||||
XIValuatorClassInfo *v = (XIValuatorClassInfo*)any;
|
||||
if (v->mode == XIModeAbsolute) {
|
||||
//dev is touchscreen
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
case XITouchClass: {
|
||||
XITouchClassInfo* t = (XITouchClassInfo*)any;
|
||||
if (t->mode == XIDirectTouch) {
|
||||
//dev is touchscreen
|
||||
return 1;
|
||||
} else {
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
|
||||
DeviceInfo*
|
||||
get_device_info_list(int *n_devices)
|
||||
{
|
||||
@ -79,6 +122,7 @@ get_device_info_list(int *n_devices)
|
||||
/*tmp[j].name = infos[i].name;*/
|
||||
tmp[j].deviceid = infos[i].deviceid;
|
||||
tmp[j].enabled = (int)infos[i].enabled;
|
||||
tmp[j].is_touchscreen = is_touchscreen_device(&infos[i]);
|
||||
|
||||
if (j != 0) {
|
||||
free(list);
|
||||
|
@ -55,7 +55,11 @@ func GetDevicesList() ([]XIDeviceInfo, []XIDeviceInfo, []XIDeviceInfo) {
|
||||
length := unsafe.Sizeof(*devices)
|
||||
for i := C.int(0); i < n_devices; i++ {
|
||||
devInfo := (*C.DeviceInfo)(unsafe.Pointer(tmpList + uintptr(i)*length))
|
||||
if C.is_mouse_device(devInfo.deviceid) == 1 {
|
||||
switch {
|
||||
// Touch screen
|
||||
case (devInfo.is_touchscreen == 1):
|
||||
continue
|
||||
case (C.is_mouse_device(devInfo.deviceid) == 1):
|
||||
info := XIDeviceInfo{
|
||||
C.GoString(devInfo.name),
|
||||
int32(devInfo.deviceid),
|
||||
@ -67,7 +71,7 @@ func GetDevicesList() ([]XIDeviceInfo, []XIDeviceInfo, []XIDeviceInfo) {
|
||||
}
|
||||
|
||||
mouseList = append(mouseList, info)
|
||||
} else if C.is_tpad_device(devInfo.deviceid) == 1 {
|
||||
case (C.is_tpad_device(devInfo.deviceid) == 1):
|
||||
info := XIDeviceInfo{
|
||||
C.GoString(devInfo.name),
|
||||
int32(devInfo.deviceid),
|
||||
@ -79,7 +83,7 @@ func GetDevicesList() ([]XIDeviceInfo, []XIDeviceInfo, []XIDeviceInfo) {
|
||||
}
|
||||
|
||||
tpadList = append(tpadList, info)
|
||||
} else if C.is_wacom_device(devInfo.deviceid) == 1 {
|
||||
case (C.is_wacom_device(devInfo.deviceid) == 1):
|
||||
info := XIDeviceInfo{
|
||||
C.GoString(devInfo.name),
|
||||
int32(devInfo.deviceid),
|
||||
|
Loading…
x
Reference in New Issue
Block a user