2013-04-26 02:58:22 +04:00
|
|
|
/**
|
|
|
|
* FreeRDP: A Remote Desktop Protocol Implementation
|
|
|
|
* X11 Input
|
|
|
|
*
|
|
|
|
* Copyright 2013 Corey Clayton <can.of.tuna@gmail.com>
|
|
|
|
*
|
|
|
|
* Licensed under the Apache License, Version 2.0 (the "License");
|
|
|
|
* you may not use this file except in compliance with the License.
|
|
|
|
* You may obtain a copy of the License at
|
|
|
|
*
|
|
|
|
* http://www.apache.org/licenses/LICENSE-2.0
|
|
|
|
*
|
|
|
|
* Unless required by applicable law or agreed to in writing, software
|
|
|
|
* distributed under the License is distributed on an "AS IS" BASIS,
|
|
|
|
* WITHOUT WARRANTIES OR CONDITIONS OF ANY KIND, either express or implied.
|
|
|
|
* See the License for the specific language governing permissions and
|
|
|
|
* limitations under the License.
|
|
|
|
*/
|
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
#ifdef HAVE_CONFIG_H
|
|
|
|
#include "config.h"
|
|
|
|
#endif
|
|
|
|
|
|
|
|
#ifdef WITH_XI
|
|
|
|
#include <X11/extensions/XInput2.h>
|
|
|
|
#endif
|
|
|
|
|
2013-04-26 06:04:35 +04:00
|
|
|
#include <math.h>
|
2013-04-26 02:58:22 +04:00
|
|
|
|
|
|
|
#include "xf_input.h"
|
|
|
|
|
2013-05-06 23:43:34 +04:00
|
|
|
#ifdef WITH_XI
|
|
|
|
|
2013-04-26 06:04:35 +04:00
|
|
|
#define MAX_CONTACTS 2
|
|
|
|
|
|
|
|
typedef struct touch_contact
|
|
|
|
{
|
|
|
|
int id;
|
|
|
|
int count;
|
|
|
|
double pos_x;
|
|
|
|
double pos_y;
|
|
|
|
double last_x;
|
|
|
|
double last_y;
|
|
|
|
|
|
|
|
} touchContact;
|
|
|
|
|
|
|
|
touchContact contacts[MAX_CONTACTS];
|
|
|
|
|
|
|
|
int active_contacts;
|
2013-05-16 01:35:16 +04:00
|
|
|
int lastEvType;
|
2013-04-27 00:23:52 +04:00
|
|
|
XIDeviceEvent lastEvent;
|
2013-04-27 01:42:23 +04:00
|
|
|
double firstDist = -1.0;
|
2013-05-09 02:14:55 +04:00
|
|
|
double lastDist;
|
|
|
|
|
|
|
|
double z_vector;
|
2013-05-30 22:36:13 +04:00
|
|
|
double px_vector;
|
|
|
|
double py_vector;
|
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
int xinput_opcode;
|
|
|
|
int scale_cnt;
|
2013-04-27 00:23:52 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
int xf_input_init(xfInfo* xfi, Window window)
|
|
|
|
{
|
|
|
|
int i, j;
|
|
|
|
int ndevices;
|
|
|
|
int major = 2;
|
|
|
|
int minor = 2;
|
|
|
|
Status xstatus;
|
|
|
|
XIEventMask evmask;
|
|
|
|
XIDeviceInfo* info;
|
|
|
|
int opcode, event, error;
|
|
|
|
unsigned char mask[XIMaskLen(XI_LASTEVENT)];
|
2013-04-26 03:52:17 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
active_contacts = 0;
|
|
|
|
ZeroMemory(contacts, sizeof(touchContact) * MAX_CONTACTS);
|
|
|
|
|
|
|
|
if (!XQueryExtension(xfi->display, "XInputExtension", &opcode, &event, &error))
|
|
|
|
{
|
|
|
|
printf("XInput extension not available.\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
xfi->XInputOpcode = opcode;
|
|
|
|
|
|
|
|
XIQueryVersion(xfi->display, &major, &minor);
|
|
|
|
|
|
|
|
if (major * 1000 + minor < 2002)
|
|
|
|
{
|
|
|
|
printf("Server does not support XI 2.2\n");
|
|
|
|
return -1;
|
|
|
|
}
|
|
|
|
|
|
|
|
info = XIQueryDevice(xfi->display, XIAllDevices, &ndevices);
|
|
|
|
|
|
|
|
for (i = 0; i < ndevices; i++)
|
|
|
|
{
|
|
|
|
XIDeviceInfo* dev = &info[i];
|
|
|
|
|
|
|
|
for (j = 0; j < dev->num_classes; j++)
|
|
|
|
{
|
|
|
|
XIAnyClassInfo* class = dev->classes[j];
|
|
|
|
//XITouchClassInfo* t = (XITouchClassInfo*) class;
|
|
|
|
|
|
|
|
if (class->type != XITouchClass)
|
|
|
|
continue;
|
|
|
|
|
|
|
|
//printf("%s %s touch device, supporting %d touches.\n",
|
|
|
|
// dev->name, (t->mode == XIDirectTouch) ? "direct" : "dependent", t->num_touches);
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
evmask.mask = mask;
|
|
|
|
evmask.mask_len = sizeof(mask);
|
|
|
|
ZeroMemory(mask, sizeof(mask));
|
|
|
|
evmask.deviceid = XIAllDevices;
|
|
|
|
|
|
|
|
XISetMask(mask, XI_TouchBegin);
|
|
|
|
XISetMask(mask, XI_TouchUpdate);
|
|
|
|
XISetMask(mask, XI_TouchEnd);
|
|
|
|
|
|
|
|
xstatus = XISelectEvents(xfi->display, window, &evmask, 1);
|
|
|
|
|
2013-05-30 22:36:13 +04:00
|
|
|
z_vector = 0;
|
|
|
|
px_vector = 0;
|
|
|
|
py_vector = 0;
|
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
return -1;
|
|
|
|
}
|
2013-05-08 05:42:49 +04:00
|
|
|
|
2013-05-16 01:35:16 +04:00
|
|
|
//BOOL xf_input_is_duplicate(XIDeviceEvent* event)
|
|
|
|
BOOL xf_input_is_duplicate(XGenericEventCookie* cookie)
|
2013-04-27 00:40:27 +04:00
|
|
|
{
|
2013-05-16 01:35:16 +04:00
|
|
|
XIDeviceEvent* event;
|
|
|
|
|
|
|
|
event = cookie->data;
|
|
|
|
|
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
if ( (lastEvent.time == event->time) &&
|
2013-05-16 01:35:16 +04:00
|
|
|
(lastEvType == cookie->evtype) &&
|
2013-04-27 00:40:27 +04:00
|
|
|
(lastEvent.detail == event->detail) &&
|
|
|
|
(lastEvent.event_x == event->event_x) &&
|
|
|
|
(lastEvent.event_y == event->event_y) )
|
|
|
|
{
|
2013-05-16 01:35:16 +04:00
|
|
|
// printf("duplicate: %d\n", event->detail);
|
2013-04-27 00:40:27 +04:00
|
|
|
return TRUE;
|
|
|
|
}
|
|
|
|
|
|
|
|
return FALSE;
|
|
|
|
}
|
|
|
|
|
2013-05-16 01:35:16 +04:00
|
|
|
//void xf_input_save_last_event(XIDeviceEvent* event)
|
|
|
|
void xf_input_save_last_event(XGenericEventCookie* cookie)
|
2013-04-27 00:40:27 +04:00
|
|
|
{
|
2013-05-16 01:35:16 +04:00
|
|
|
XIDeviceEvent* event;
|
|
|
|
|
|
|
|
event = cookie->data;
|
|
|
|
|
|
|
|
lastEvType = cookie->evtype;
|
|
|
|
|
2013-04-27 00:40:27 +04:00
|
|
|
lastEvent.time = event->time;
|
|
|
|
lastEvent.detail = event->detail;
|
|
|
|
lastEvent.event_x = event->event_x;
|
|
|
|
lastEvent.event_y = event->event_y;
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-30 22:36:13 +04:00
|
|
|
void xf_input_detect_pan(xfInfo* xfi)
|
|
|
|
{
|
|
|
|
double dx[2];
|
|
|
|
double dy[2];
|
|
|
|
|
|
|
|
double px;
|
|
|
|
double py;
|
|
|
|
|
|
|
|
|
|
|
|
dx[0] = contacts[0].pos_x - contacts[0].last_x;
|
|
|
|
dx[1] = contacts[1].pos_x - contacts[1].last_x;
|
|
|
|
|
|
|
|
dy[0] = contacts[0].pos_y - contacts[0].last_y;
|
|
|
|
dy[1] = contacts[1].pos_y - contacts[1].last_y;
|
|
|
|
|
|
|
|
//px = fmin(dx[0], dx[1]);
|
|
|
|
//py = fmin(dy[0], dy[1]);
|
|
|
|
|
2013-05-31 00:04:31 +04:00
|
|
|
//px = dx[0] + dx[1] / 2;
|
|
|
|
//py = dy[0] + dy[1] / 2;
|
2013-05-30 22:36:13 +04:00
|
|
|
|
2013-05-31 00:04:31 +04:00
|
|
|
|
|
|
|
px = fabs(dx[0]) < fabs(dx[1]) ? dx[0] : dx[1];
|
|
|
|
py = fabs(dy[0]) < fabs(dy[1]) ? dy[0] : dy[1];
|
2013-05-30 22:36:13 +04:00
|
|
|
|
|
|
|
px_vector += px;
|
|
|
|
py_vector += py;
|
|
|
|
|
|
|
|
|
|
|
|
//printf("px: %.2f\tpy: %.2f\n", px_vector, py_vector);
|
|
|
|
|
|
|
|
if(px_vector > 100)
|
|
|
|
{
|
2013-05-31 00:04:31 +04:00
|
|
|
xfi->offset_x += 5;
|
|
|
|
|
|
|
|
xf_transform_window(xfi);
|
|
|
|
|
|
|
|
xf_draw_screen_scaled(xfi, 0, 0, 0, 0, FALSE);
|
2013-05-30 22:36:13 +04:00
|
|
|
printf("pan ->\n");
|
|
|
|
|
|
|
|
px_vector = 0;
|
2013-05-31 00:04:31 +04:00
|
|
|
|
|
|
|
px_vector = 0;
|
|
|
|
py_vector = 0;
|
|
|
|
z_vector = 0;
|
2013-05-30 22:36:13 +04:00
|
|
|
}
|
|
|
|
else if(px_vector < -100)
|
|
|
|
{
|
2013-05-31 00:04:31 +04:00
|
|
|
xfi->offset_x -= 5;
|
|
|
|
|
|
|
|
xf_transform_window(xfi);
|
|
|
|
|
|
|
|
xf_draw_screen_scaled(xfi, 0, 0, 0, 0, FALSE);
|
2013-05-30 22:36:13 +04:00
|
|
|
printf("<- pan\n");
|
|
|
|
|
|
|
|
px_vector = 0;
|
2013-05-31 00:04:31 +04:00
|
|
|
|
|
|
|
px_vector = 0;
|
|
|
|
py_vector = 0;
|
|
|
|
z_vector = 0;
|
2013-05-30 22:36:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
if(py_vector > 100)
|
|
|
|
{
|
2013-05-31 00:04:31 +04:00
|
|
|
xfi->offset_y += 5;
|
|
|
|
|
|
|
|
xf_transform_window(xfi);
|
|
|
|
|
|
|
|
xf_draw_screen_scaled(xfi, 0, 0, 0, 0, FALSE);
|
2013-05-30 22:36:13 +04:00
|
|
|
printf("\tpan ^\n");
|
|
|
|
|
|
|
|
py_vector = 0;
|
2013-05-31 00:04:31 +04:00
|
|
|
|
|
|
|
px_vector = 0;
|
|
|
|
py_vector = 0;
|
|
|
|
z_vector = 0;
|
2013-05-30 22:36:13 +04:00
|
|
|
}
|
|
|
|
else if(py_vector < -100)
|
|
|
|
{
|
2013-05-31 00:04:31 +04:00
|
|
|
xfi->offset_y -= 5;
|
|
|
|
|
|
|
|
xf_transform_window(xfi);
|
|
|
|
|
|
|
|
xf_draw_screen_scaled(xfi, 0, 0, 0, 0, FALSE);
|
2013-05-30 22:36:13 +04:00
|
|
|
printf("\tv pan\n");
|
|
|
|
|
|
|
|
py_vector = 0;
|
2013-05-31 00:04:31 +04:00
|
|
|
|
|
|
|
px_vector = 0;
|
|
|
|
py_vector = 0;
|
|
|
|
z_vector = 0;
|
2013-05-30 22:36:13 +04:00
|
|
|
}
|
|
|
|
|
|
|
|
|
|
|
|
}
|
|
|
|
|
2013-05-08 05:42:49 +04:00
|
|
|
void xf_input_detect_pinch(xfInfo* xfi)
|
2013-04-27 01:42:23 +04:00
|
|
|
{
|
|
|
|
double dist;
|
|
|
|
double zoom;
|
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
double delta;
|
|
|
|
|
|
|
|
if (active_contacts != 2)
|
2013-04-27 01:42:23 +04:00
|
|
|
{
|
|
|
|
firstDist = -1.0;
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
2013-05-13 22:41:06 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
/* first calculate the distance */
|
2013-04-27 01:42:23 +04:00
|
|
|
dist = sqrt(pow(contacts[1].pos_x - contacts[0].last_x, 2.0) +
|
|
|
|
pow(contacts[1].pos_y - contacts[0].last_y, 2.0));
|
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
/* if this is the first 2pt touch */
|
|
|
|
if (firstDist <= 0)
|
2013-04-27 01:42:23 +04:00
|
|
|
{
|
|
|
|
firstDist = dist;
|
2013-05-09 05:51:16 +04:00
|
|
|
lastDist = firstDist;
|
|
|
|
scale_cnt = 0;
|
|
|
|
z_vector = 0;
|
2013-05-31 00:04:31 +04:00
|
|
|
|
|
|
|
px_vector = 0;
|
|
|
|
py_vector = 0;
|
|
|
|
z_vector = 0;
|
2013-04-27 01:42:23 +04:00
|
|
|
}
|
|
|
|
else
|
|
|
|
{
|
2013-05-09 05:51:16 +04:00
|
|
|
delta = lastDist - dist;
|
2013-04-27 01:42:23 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
/* compare the current distance to the first one */
|
|
|
|
zoom = (dist / firstDist);
|
2013-04-27 01:42:23 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
z_vector += delta;
|
|
|
|
//printf("d: %.2f\n", delta);
|
2013-05-06 23:43:34 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
lastDist = dist;
|
2013-04-26 02:58:22 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
if (z_vector > 10)
|
2013-04-26 02:58:22 +04:00
|
|
|
{
|
2013-05-09 05:51:16 +04:00
|
|
|
xfi->scale -= 0.05;
|
2013-04-26 02:58:22 +04:00
|
|
|
|
2013-05-16 01:35:16 +04:00
|
|
|
if (xfi->scale < 0.8)
|
|
|
|
xfi->scale = 0.8;
|
2013-04-26 03:52:17 +04:00
|
|
|
|
2013-05-17 00:42:07 +04:00
|
|
|
//XResizeWindow(xfi->display, xfi->window->handle, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale);
|
|
|
|
xf_transform_window(xfi);
|
2013-05-09 05:51:16 +04:00
|
|
|
IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale);
|
2013-05-17 00:42:07 +04:00
|
|
|
xf_draw_screen_scaled(xfi, 0, 0, 0, 0, FALSE);
|
2013-04-26 02:58:22 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
z_vector = 0;
|
2013-05-31 00:04:31 +04:00
|
|
|
|
|
|
|
px_vector = 0;
|
|
|
|
py_vector = 0;
|
|
|
|
z_vector = 0;
|
2013-05-09 05:51:16 +04:00
|
|
|
}
|
2013-05-08 05:42:49 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
if (z_vector < -10)
|
|
|
|
{
|
|
|
|
xfi->scale += 0.05;
|
2013-04-26 02:58:22 +04:00
|
|
|
|
2013-05-17 00:42:07 +04:00
|
|
|
if (xfi->scale > 1.2)
|
|
|
|
xfi->scale = 1.2;
|
2013-04-26 02:58:22 +04:00
|
|
|
|
2013-05-17 00:42:07 +04:00
|
|
|
//XResizeWindow(xfi->display, xfi->window->handle, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale);
|
|
|
|
xf_transform_window(xfi);
|
2013-05-09 05:51:16 +04:00
|
|
|
IFCALL(xfi->client->OnResizeWindow, xfi->instance, xfi->originalWidth * xfi->scale, xfi->originalHeight * xfi->scale);
|
2013-05-17 00:42:07 +04:00
|
|
|
xf_draw_screen_scaled(xfi, 0, 0, 0, 0, FALSE);
|
2013-04-26 03:38:13 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
z_vector = 0;
|
2013-05-31 00:04:31 +04:00
|
|
|
|
|
|
|
px_vector = 0;
|
|
|
|
py_vector = 0;
|
|
|
|
z_vector = 0;
|
2013-05-09 05:51:16 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-26 02:58:22 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
void xf_input_touch_begin(xfInfo* xfi, XIDeviceEvent* event)
|
|
|
|
{
|
|
|
|
int i;
|
2013-04-26 02:58:22 +04:00
|
|
|
|
2013-05-16 01:35:16 +04:00
|
|
|
// printf("Begin: %d count: %d\n", event->detail, active_contacts);
|
|
|
|
|
|
|
|
if(active_contacts == MAX_CONTACTS)
|
|
|
|
printf("Houston, we have a problem!\n\n");
|
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
for (i = 0; i < MAX_CONTACTS; i++)
|
|
|
|
{
|
|
|
|
if (contacts[i].id == 0)
|
2013-04-26 02:58:22 +04:00
|
|
|
{
|
2013-05-09 05:51:16 +04:00
|
|
|
contacts[i].id = event->detail;
|
|
|
|
contacts[i].count = 1;
|
|
|
|
contacts[i].pos_x = event->event_x;
|
|
|
|
contacts[i].pos_y = event->event_y;
|
|
|
|
|
|
|
|
active_contacts++;
|
|
|
|
break;
|
2013-04-26 02:58:22 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-26 03:38:13 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
void xf_input_touch_update(xfInfo* xfi, XIDeviceEvent* event)
|
2013-04-26 03:38:13 +04:00
|
|
|
{
|
2013-05-09 05:51:16 +04:00
|
|
|
int i;
|
2013-04-26 03:38:13 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
for (i = 0; i < MAX_CONTACTS; i++)
|
|
|
|
{
|
|
|
|
if (contacts[i].id == event->detail)
|
2013-04-26 03:38:13 +04:00
|
|
|
{
|
2013-05-09 05:51:16 +04:00
|
|
|
contacts[i].count++;
|
|
|
|
contacts[i].last_x = contacts[i].pos_x;
|
|
|
|
contacts[i].last_y = contacts[i].pos_y;
|
|
|
|
contacts[i].pos_x = event->event_x;
|
|
|
|
contacts[i].pos_y = event->event_y;
|
2013-04-27 00:23:52 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
xf_input_detect_pinch(xfi);
|
2013-05-30 22:36:13 +04:00
|
|
|
xf_input_detect_pan(xfi);
|
2013-04-27 00:23:52 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
}
|
2013-04-26 03:38:13 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
void xf_input_touch_end(xfInfo* xfi, XIDeviceEvent* event)
|
|
|
|
{
|
|
|
|
int i;
|
2013-04-27 00:47:58 +04:00
|
|
|
|
2013-05-16 01:35:16 +04:00
|
|
|
// printf("End: %d\n", event->detail);
|
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
for (i = 0; i < MAX_CONTACTS; i++)
|
|
|
|
{
|
|
|
|
if (contacts[i].id == event->detail)
|
|
|
|
{
|
|
|
|
contacts[i].id = 0;
|
|
|
|
contacts[i].count = 0;
|
|
|
|
//contacts[i].pos_x = (int)event->event_x;
|
|
|
|
//contacts[i].pos_y = (int)event->event_y;
|
2013-04-27 00:47:58 +04:00
|
|
|
|
2013-05-09 05:51:16 +04:00
|
|
|
active_contacts--;
|
|
|
|
break;
|
2013-04-26 03:38:13 +04:00
|
|
|
}
|
2013-05-09 05:51:16 +04:00
|
|
|
}
|
2013-04-26 03:38:13 +04:00
|
|
|
}
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
int xf_input_handle_event_local(xfInfo* xfi, XEvent* event)
|
2013-04-26 06:04:35 +04:00
|
|
|
{
|
2013-05-09 08:52:37 +04:00
|
|
|
XGenericEventCookie* cookie = &event->xcookie;
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
XGetEventData(xfi->display, cookie);
|
2013-04-27 01:42:23 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
if ((cookie->type == GenericEvent) && (cookie->extension == xfi->XInputOpcode))
|
2013-04-26 06:04:35 +04:00
|
|
|
{
|
2013-05-09 08:52:37 +04:00
|
|
|
switch (cookie->evtype)
|
2013-04-26 06:04:35 +04:00
|
|
|
{
|
2013-05-09 08:52:37 +04:00
|
|
|
case XI_TouchBegin:
|
2013-05-16 01:35:16 +04:00
|
|
|
if (xf_input_is_duplicate(cookie) == FALSE)
|
2013-05-09 08:52:37 +04:00
|
|
|
xf_input_touch_begin(xfi, cookie->data);
|
2013-05-16 01:35:16 +04:00
|
|
|
xf_input_save_last_event(cookie);
|
2013-05-09 08:52:37 +04:00
|
|
|
break;
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
case XI_TouchUpdate:
|
2013-05-16 01:35:16 +04:00
|
|
|
if (xf_input_is_duplicate(cookie) == FALSE)
|
2013-05-09 08:52:37 +04:00
|
|
|
xf_input_touch_update(xfi, cookie->data);
|
2013-05-16 01:35:16 +04:00
|
|
|
xf_input_save_last_event(cookie);
|
2013-05-09 08:52:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
case XI_TouchEnd:
|
2013-05-16 01:35:16 +04:00
|
|
|
if (xf_input_is_duplicate(cookie) == FALSE)
|
2013-05-09 08:52:37 +04:00
|
|
|
xf_input_touch_end(xfi, cookie->data);
|
2013-05-16 01:35:16 +04:00
|
|
|
xf_input_save_last_event(cookie);
|
2013-05-09 08:52:37 +04:00
|
|
|
break;
|
|
|
|
|
|
|
|
default:
|
|
|
|
printf("unhandled xi type= %d\n", cookie->evtype);
|
|
|
|
break;
|
2013-04-26 06:04:35 +04:00
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
XFreeEventData(xfi->display,cookie);
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
return 0;
|
|
|
|
}
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
int xf_input_touch_begin_remote(xfInfo* xfi, XIDeviceEvent* event)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-26 23:27:08 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
int xf_input_touch_update_remote(xfInfo* xfi, XIDeviceEvent* event)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-27 01:42:23 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
int xf_input_touch_end_remote(xfInfo* xfi, XIDeviceEvent* event)
|
|
|
|
{
|
|
|
|
return 0;
|
2013-04-26 06:04:35 +04:00
|
|
|
}
|
2013-05-09 08:52:37 +04:00
|
|
|
|
|
|
|
int xf_input_handle_event_remote(xfInfo* xfi, XEvent* event)
|
2013-04-26 06:04:35 +04:00
|
|
|
{
|
2013-05-09 08:52:37 +04:00
|
|
|
XGenericEventCookie* cookie = &event->xcookie;
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
XGetEventData(xfi->display, cookie);
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
if ((cookie->type == GenericEvent) && (cookie->extension == xfi->XInputOpcode))
|
|
|
|
{
|
|
|
|
switch (cookie->evtype)
|
2013-04-26 06:04:35 +04:00
|
|
|
{
|
2013-05-09 08:52:37 +04:00
|
|
|
case XI_TouchBegin:
|
|
|
|
xf_input_touch_begin_remote(xfi, cookie->data);
|
|
|
|
break;
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
case XI_TouchUpdate:
|
|
|
|
xf_input_touch_update_remote(xfi, cookie->data);
|
|
|
|
break;
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
case XI_TouchEnd:
|
|
|
|
xf_input_touch_end_remote(xfi, cookie->data);
|
2013-04-26 06:04:35 +04:00
|
|
|
break;
|
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
default:
|
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2013-04-27 00:23:52 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
XFreeEventData(xfi->display,cookie);
|
2013-04-27 01:42:23 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
return 0;
|
2013-04-26 06:04:35 +04:00
|
|
|
}
|
|
|
|
|
2013-05-11 01:51:09 +04:00
|
|
|
#else
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-11 01:51:09 +04:00
|
|
|
int xf_input_init(xfInfo* xfi, Window window)
|
|
|
|
{
|
|
|
|
return 0;
|
|
|
|
}
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-11 01:51:09 +04:00
|
|
|
#endif
|
2013-04-26 06:04:35 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
void xf_process_rdpei_event(xfInfo* xfi, wMessage* event)
|
|
|
|
{
|
|
|
|
switch (GetMessageType(event->id))
|
|
|
|
{
|
|
|
|
case RdpeiChannel_ServerReady:
|
|
|
|
break;
|
2013-04-27 00:23:52 +04:00
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
case RdpeiChannel_SuspendTouch:
|
|
|
|
break;
|
|
|
|
|
|
|
|
case RdpeiChannel_ResumeTouch:
|
|
|
|
break;
|
|
|
|
}
|
2013-04-26 06:04:35 +04:00
|
|
|
}
|
|
|
|
|
2013-05-09 08:52:37 +04:00
|
|
|
int xf_input_handle_event(xfInfo* xfi, XEvent* event)
|
|
|
|
{
|
2013-05-11 01:51:09 +04:00
|
|
|
#ifdef WITH_XI
|
2013-05-09 08:52:37 +04:00
|
|
|
if (xfi->settings->MultiTouchInput)
|
|
|
|
{
|
|
|
|
return xf_input_handle_event_remote(xfi, event);
|
|
|
|
}
|
|
|
|
|
2013-05-16 01:35:16 +04:00
|
|
|
if (1)
|
2013-05-11 00:56:24 +04:00
|
|
|
return xf_input_handle_event_local(xfi, event);
|
2013-05-06 23:43:34 +04:00
|
|
|
#endif
|
2013-05-11 00:56:24 +04:00
|
|
|
|
|
|
|
return 0;
|
2013-05-09 08:52:37 +04:00
|
|
|
}
|