xfree86: Implement gesture support for test input driver
This commit is contained in:
parent
dccc0275f4
commit
1cdc3b5d14
|
@ -31,7 +31,7 @@ extern "C" {
|
||||||
#include <stdint.h>
|
#include <stdint.h>
|
||||||
|
|
||||||
#define XF86IT_PROTOCOL_VERSION_MAJOR 1
|
#define XF86IT_PROTOCOL_VERSION_MAJOR 1
|
||||||
#define XF86IT_PROTOCOL_VERSION_MINOR 0
|
#define XF86IT_PROTOCOL_VERSION_MINOR 1
|
||||||
|
|
||||||
enum xf86ITResponseType {
|
enum xf86ITResponseType {
|
||||||
XF86IT_RESPONSE_SERVER_VERSION,
|
XF86IT_RESPONSE_SERVER_VERSION,
|
||||||
|
@ -70,6 +70,8 @@ enum xf86ITEventType {
|
||||||
XF86IT_EVENT_BUTTON,
|
XF86IT_EVENT_BUTTON,
|
||||||
XF86IT_EVENT_KEY,
|
XF86IT_EVENT_KEY,
|
||||||
XF86IT_EVENT_TOUCH,
|
XF86IT_EVENT_TOUCH,
|
||||||
|
XF86IT_EVENT_GESTURE_PINCH,
|
||||||
|
XF86IT_EVENT_GESTURE_SWIPE,
|
||||||
};
|
};
|
||||||
|
|
||||||
typedef struct {
|
typedef struct {
|
||||||
|
@ -127,6 +129,30 @@ typedef struct {
|
||||||
xf86ITValuatorData valuators;
|
xf86ITValuatorData valuators;
|
||||||
} xf86ITEventTouch;
|
} xf86ITEventTouch;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
xf86ITEventHeader header;
|
||||||
|
uint16_t gesture_type;
|
||||||
|
uint16_t num_touches;
|
||||||
|
uint32_t flags;
|
||||||
|
double delta_x;
|
||||||
|
double delta_y;
|
||||||
|
double delta_unaccel_x;
|
||||||
|
double delta_unaccel_y;
|
||||||
|
double scale;
|
||||||
|
double delta_angle;
|
||||||
|
} xf86ITEventGesturePinch;
|
||||||
|
|
||||||
|
typedef struct {
|
||||||
|
xf86ITEventHeader header;
|
||||||
|
uint16_t gesture_type;
|
||||||
|
uint16_t num_touches;
|
||||||
|
uint32_t flags;
|
||||||
|
double delta_x;
|
||||||
|
double delta_y;
|
||||||
|
double delta_unaccel_x;
|
||||||
|
double delta_unaccel_y;
|
||||||
|
} xf86ITEventGestureSwipe;
|
||||||
|
|
||||||
typedef union {
|
typedef union {
|
||||||
xf86ITEventHeader header;
|
xf86ITEventHeader header;
|
||||||
xf86ITEventClientVersion version;
|
xf86ITEventClientVersion version;
|
||||||
|
@ -135,6 +161,8 @@ typedef union {
|
||||||
xf86ITEventButton button;
|
xf86ITEventButton button;
|
||||||
xf86ITEventKey key;
|
xf86ITEventKey key;
|
||||||
xf86ITEventTouch touch;
|
xf86ITEventTouch touch;
|
||||||
|
xf86ITEventGesturePinch pinch;
|
||||||
|
xf86ITEventGestureSwipe swipe;
|
||||||
} xf86ITEventAny;
|
} xf86ITEventAny;
|
||||||
|
|
||||||
#ifdef __cplusplus
|
#ifdef __cplusplus
|
||||||
|
|
|
@ -58,6 +58,7 @@
|
||||||
enum xf86ITDeviceType {
|
enum xf86ITDeviceType {
|
||||||
DEVICE_KEYBOARD = 1,
|
DEVICE_KEYBOARD = 1,
|
||||||
DEVICE_POINTER,
|
DEVICE_POINTER,
|
||||||
|
DEVICE_POINTER_GESTURE,
|
||||||
DEVICE_POINTER_ABS,
|
DEVICE_POINTER_ABS,
|
||||||
DEVICE_POINTER_ABS_PROXIMITY,
|
DEVICE_POINTER_ABS_PROXIMITY,
|
||||||
DEVICE_TOUCH,
|
DEVICE_TOUCH,
|
||||||
|
@ -474,6 +475,14 @@ init_touch(InputInfoPtr pInfo)
|
||||||
InitTouchClassDeviceStruct(dev, ntouches, XIDirectTouch, 2);
|
InitTouchClassDeviceStruct(dev, ntouches, XIDirectTouch, 2);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
init_gesture(InputInfoPtr pInfo)
|
||||||
|
{
|
||||||
|
DeviceIntPtr dev = pInfo->dev;
|
||||||
|
int ntouches = TOUCH_MAX_SLOTS;
|
||||||
|
InitGestureClassDeviceStruct(dev, ntouches);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
device_init(DeviceIntPtr dev)
|
device_init(DeviceIntPtr dev)
|
||||||
{
|
{
|
||||||
|
@ -489,6 +498,10 @@ device_init(DeviceIntPtr dev)
|
||||||
case DEVICE_POINTER:
|
case DEVICE_POINTER:
|
||||||
init_pointer(pInfo);
|
init_pointer(pInfo);
|
||||||
break;
|
break;
|
||||||
|
case DEVICE_POINTER_GESTURE:
|
||||||
|
init_pointer(pInfo);
|
||||||
|
init_gesture(pInfo);
|
||||||
|
break;
|
||||||
case DEVICE_POINTER_ABS:
|
case DEVICE_POINTER_ABS:
|
||||||
init_pointer_absolute(pInfo);
|
init_pointer_absolute(pInfo);
|
||||||
break;
|
break;
|
||||||
|
@ -678,6 +691,37 @@ handle_touch(InputInfoPtr pInfo, xf86ITEventTouch *event)
|
||||||
xf86PostTouchEvent(dev, event->touchid, event->touch_type, 0, mask);
|
xf86PostTouchEvent(dev, event->touchid, event->touch_type, 0, mask);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_gesture_swipe(InputInfoPtr pInfo, xf86ITEventGestureSwipe *event)
|
||||||
|
{
|
||||||
|
DeviceIntPtr dev = pInfo->dev;
|
||||||
|
xf86ITDevicePtr driver_data = pInfo->private;
|
||||||
|
|
||||||
|
xf86IDrvMsg(pInfo, X_DEBUG, "Handling gesture swipe event\n");
|
||||||
|
|
||||||
|
driver_data->last_event_num++;
|
||||||
|
|
||||||
|
xf86PostGestureSwipeEvent(dev, event->gesture_type, event->num_touches, event->flags,
|
||||||
|
event->delta_x, event->delta_y,
|
||||||
|
event->delta_unaccel_x, event->delta_unaccel_y);
|
||||||
|
}
|
||||||
|
|
||||||
|
static void
|
||||||
|
handle_gesture_pinch(InputInfoPtr pInfo, xf86ITEventGesturePinch *event)
|
||||||
|
{
|
||||||
|
DeviceIntPtr dev = pInfo->dev;
|
||||||
|
xf86ITDevicePtr driver_data = pInfo->private;
|
||||||
|
|
||||||
|
xf86IDrvMsg(pInfo, X_DEBUG, "Handling gesture pinch event\n");
|
||||||
|
|
||||||
|
driver_data->last_event_num++;
|
||||||
|
|
||||||
|
xf86PostGesturePinchEvent(dev, event->gesture_type, event->num_touches, event->flags,
|
||||||
|
event->delta_x, event->delta_y,
|
||||||
|
event->delta_unaccel_x, event->delta_unaccel_y,
|
||||||
|
event->scale, event->delta_angle);
|
||||||
|
}
|
||||||
|
|
||||||
static void
|
static void
|
||||||
client_new_handle_event(InputInfoPtr pInfo, xf86ITEventAny *event)
|
client_new_handle_event(InputInfoPtr pInfo, xf86ITEventAny *event)
|
||||||
{
|
{
|
||||||
|
@ -715,6 +759,12 @@ client_ready_handle_event(InputInfoPtr pInfo, xf86ITEventAny *event)
|
||||||
case XF86IT_EVENT_TOUCH:
|
case XF86IT_EVENT_TOUCH:
|
||||||
handle_touch(pInfo, &event->touch);
|
handle_touch(pInfo, &event->touch);
|
||||||
break;
|
break;
|
||||||
|
case XF86IT_EVENT_GESTURE_PINCH:
|
||||||
|
handle_gesture_pinch(pInfo, &(event->pinch));
|
||||||
|
break;
|
||||||
|
case XF86IT_EVENT_GESTURE_SWIPE:
|
||||||
|
handle_gesture_swipe(pInfo, &(event->swipe));
|
||||||
|
break;
|
||||||
case XF86IT_EVENT_CLIENT_VERSION:
|
case XF86IT_EVENT_CLIENT_VERSION:
|
||||||
xf86IDrvMsg(pInfo, X_ERROR, "Only single ClientVersion event is allowed\n");
|
xf86IDrvMsg(pInfo, X_ERROR, "Only single ClientVersion event is allowed\n");
|
||||||
teardown_client_connection(pInfo);
|
teardown_client_connection(pInfo);
|
||||||
|
@ -759,6 +809,8 @@ is_supported_event(enum xf86ITEventType type)
|
||||||
case XF86IT_EVENT_BUTTON:
|
case XF86IT_EVENT_BUTTON:
|
||||||
case XF86IT_EVENT_KEY:
|
case XF86IT_EVENT_KEY:
|
||||||
case XF86IT_EVENT_TOUCH:
|
case XF86IT_EVENT_TOUCH:
|
||||||
|
case XF86IT_EVENT_GESTURE_PINCH:
|
||||||
|
case XF86IT_EVENT_GESTURE_SWIPE:
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
return false;
|
return false;
|
||||||
|
@ -775,6 +827,8 @@ get_event_size(enum xf86ITEventType type)
|
||||||
case XF86IT_EVENT_BUTTON: return sizeof(xf86ITEventButton);
|
case XF86IT_EVENT_BUTTON: return sizeof(xf86ITEventButton);
|
||||||
case XF86IT_EVENT_KEY: return sizeof(xf86ITEventKey);
|
case XF86IT_EVENT_KEY: return sizeof(xf86ITEventKey);
|
||||||
case XF86IT_EVENT_TOUCH: return sizeof(xf86ITEventTouch);
|
case XF86IT_EVENT_TOUCH: return sizeof(xf86ITEventTouch);
|
||||||
|
case XF86IT_EVENT_GESTURE_PINCH: return sizeof(xf86ITEventGesturePinch);
|
||||||
|
case XF86IT_EVENT_GESTURE_SWIPE: return sizeof(xf86ITEventGestureSwipe);
|
||||||
}
|
}
|
||||||
abort();
|
abort();
|
||||||
}
|
}
|
||||||
|
@ -864,6 +918,7 @@ get_type_name(InputInfoPtr pInfo, xf86ITDevicePtr driver_data)
|
||||||
switch (driver_data->device_type) {
|
switch (driver_data->device_type) {
|
||||||
case DEVICE_TOUCH: return XI_TOUCHSCREEN;
|
case DEVICE_TOUCH: return XI_TOUCHSCREEN;
|
||||||
case DEVICE_POINTER: return XI_MOUSE;
|
case DEVICE_POINTER: return XI_MOUSE;
|
||||||
|
case DEVICE_POINTER_GESTURE: return XI_TOUCHPAD;
|
||||||
case DEVICE_POINTER_ABS: return XI_MOUSE;
|
case DEVICE_POINTER_ABS: return XI_MOUSE;
|
||||||
case DEVICE_POINTER_ABS_PROXIMITY: return XI_TABLET;
|
case DEVICE_POINTER_ABS_PROXIMITY: return XI_TABLET;
|
||||||
case DEVICE_KEYBOARD: return XI_KEYBOARD;
|
case DEVICE_KEYBOARD: return XI_KEYBOARD;
|
||||||
|
@ -986,6 +1041,8 @@ pre_init(InputDriverPtr drv, InputInfoPtr pInfo, int flags)
|
||||||
driver_data->device_type = DEVICE_KEYBOARD;
|
driver_data->device_type = DEVICE_KEYBOARD;
|
||||||
} else if (strcmp(device_type_option, "Pointer") == 0) {
|
} else if (strcmp(device_type_option, "Pointer") == 0) {
|
||||||
driver_data->device_type = DEVICE_POINTER;
|
driver_data->device_type = DEVICE_POINTER;
|
||||||
|
} else if (strcmp(device_type_option, "PointerGesture") == 0) {
|
||||||
|
driver_data->device_type = DEVICE_POINTER_GESTURE;
|
||||||
} else if (strcmp(device_type_option, "PointerAbsolute") == 0) {
|
} else if (strcmp(device_type_option, "PointerAbsolute") == 0) {
|
||||||
driver_data->device_type = DEVICE_POINTER_ABS;
|
driver_data->device_type = DEVICE_POINTER_ABS;
|
||||||
} else if (strcmp(device_type_option, "PointerAbsoluteProximity") == 0) {
|
} else if (strcmp(device_type_option, "PointerAbsoluteProximity") == 0) {
|
||||||
|
|
Loading…
Reference in New Issue