xfreerdp: partial cleanup of multitouch code

This commit is contained in:
Marc-André Moreau 2013-05-14 19:26:01 -04:00
parent e6aec6c936
commit c3efeccbd6
5 changed files with 40 additions and 91 deletions

View File

@ -117,8 +117,10 @@ int rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId,
status = callback->channel->Write(callback->channel, Stream_Length(s), Stream_Buffer(s), NULL); status = callback->channel->Write(callback->channel, Stream_Length(s), Stream_Buffer(s), NULL);
#ifdef WITH_DEBUG_RDPEI
printf("rdpei_send_pdu: eventId: %d (%s) length: %d status: %d\n", printf("rdpei_send_pdu: eventId: %d (%s) length: %d status: %d\n",
eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status); eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status);
#endif
return status; return status;
} }
@ -172,8 +174,10 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
int index; int index;
RDPINPUT_CONTACT_DATA* contact; RDPINPUT_CONTACT_DATA* contact;
#ifdef WITH_DEBUG_RDPEI
printf("contactCount: %d\n", frame->contactCount); printf("contactCount: %d\n", frame->contactCount);
printf("frameOffset: 0x%08X\n", (UINT32) frame->frameOffset); printf("frameOffset: 0x%08X\n", (UINT32) frame->frameOffset);
#endif
rdpei_write_2byte_unsigned(s, frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */ rdpei_write_2byte_unsigned(s, frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */
rdpei_write_8byte_unsigned(s, frame->frameOffset); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */ rdpei_write_8byte_unsigned(s, frame->frameOffset); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */
@ -184,6 +188,7 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
{ {
contact = &frame->contacts[index]; contact = &frame->contacts[index];
#ifdef WITH_DEBUG_RDPEI
printf("contact[%d].contactId: %d\n", index, contact->contactId); printf("contact[%d].contactId: %d\n", index, contact->contactId);
printf("contact[%d].fieldsPresent: %d\n", index, contact->fieldsPresent); printf("contact[%d].fieldsPresent: %d\n", index, contact->fieldsPresent);
printf("contact[%d].x: %d\n", index, contact->x); printf("contact[%d].x: %d\n", index, contact->x);
@ -191,6 +196,7 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
printf("contact[%d].contactFlags: 0x%04X", index, contact->contactFlags); printf("contact[%d].contactFlags: 0x%04X", index, contact->contactFlags);
rdpei_print_contact_flags(contact->contactFlags); rdpei_print_contact_flags(contact->contactFlags);
printf("\n"); printf("\n");
#endif
Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */ Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */
@ -243,7 +249,7 @@ int rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_
Stream_Seek(s, RDPINPUT_HEADER_LENGTH); Stream_Seek(s, RDPINPUT_HEADER_LENGTH);
rdpei_write_4byte_unsigned(s, frame->frameOffset); /* FOUR_BYTE_UNSIGNED_INTEGER */ rdpei_write_4byte_unsigned(s, frame->frameOffset); /* FOUR_BYTE_UNSIGNED_INTEGER */
rdpei_write_2byte_unsigned(s, frame->contactCount); /* TWO_BYTE_UNSIGNED_INTEGER */ rdpei_write_2byte_unsigned(s, 1); /* TWO_BYTE_UNSIGNED_INTEGER */
rdpei_write_touch_frame(s, frame); rdpei_write_touch_frame(s, frame);
@ -289,8 +295,10 @@ int rdpei_recv_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s)
Stream_Read_UINT16(s, eventId); /* eventId (2 bytes) */ Stream_Read_UINT16(s, eventId); /* eventId (2 bytes) */
Stream_Read_UINT32(s, pduLength); /* pduLength (4 bytes) */ Stream_Read_UINT32(s, pduLength); /* pduLength (4 bytes) */
#ifdef WITH_DEBUG_RDPEI
printf("rdpei_recv_pdu: eventId: %d (%s) length: %d\n", printf("rdpei_recv_pdu: eventId: %d (%s) length: %d\n",
eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength); eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength);
#endif
switch (eventId) switch (eventId)
{ {
@ -407,32 +415,22 @@ int rdpei_get_version(RdpeiClientContext* context)
return rdpei->version; return rdpei->version;
} }
int rdpei_begin_frame(RdpeiClientContext* context) int rdpei_send_frame(RdpeiClientContext* context)
{
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
rdpei->frame.contactCount = 0;
rdpei->frame.frameOffset = 0;
return 1;
}
int rdpei_end_frame(RdpeiClientContext* context)
{ {
UINT64 currentTime;
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
RDPEI_CHANNEL_CALLBACK* callback = rdpei->listener_callback->channel_callback; RDPEI_CHANNEL_CALLBACK* callback = rdpei->listener_callback->channel_callback;
//if (rdpei->frame.contactCount < 8) currentTime = GetTickCount64();
// return 0;
if (!rdpei->previousFrameTime && !rdpei->currentFrameTime) if (!rdpei->previousFrameTime && !rdpei->currentFrameTime)
{ {
rdpei->currentFrameTime = (UINT64) GetTickCount64(); rdpei->currentFrameTime = currentTime;
rdpei->frame.frameOffset = 0; rdpei->frame.frameOffset = 0;
} }
else else
{ {
rdpei->currentFrameTime = (UINT64) GetTickCount64(); rdpei->currentFrameTime = currentTime;
rdpei->frame.frameOffset = rdpei->currentFrameTime - rdpei->previousFrameTime; rdpei->frame.frameOffset = rdpei->currentFrameTime - rdpei->previousFrameTime;
} }
@ -453,12 +451,14 @@ int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contac
rdpei->frame.contactCount++; rdpei->frame.contactCount++;
} }
rdpei_send_frame(context);
return 1; return 1;
} }
int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int y) int rdpei_contact_begin(RdpeiClientContext* context, int externalId)
{ {
int i, j; int i;
int contactId = -1; int contactId = -1;
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
@ -470,30 +470,22 @@ int rdpei_contact_begin(RdpeiClientContext* context, int externalId, int x, int
{ {
rdpei->contactPoints[i].flags = 1; rdpei->contactPoints[i].flags = 1;
rdpei->contactPoints[i].contactId = i; rdpei->contactPoints[i].contactId = i;
rdpei->contactPoints[i].touchDownX = x;
rdpei->contactPoints[i].touchDownX = y;
for (j = 0; j < MAX_EXTERNAL_IDS; j++) if (!rdpei->contactPoints[i].externalId)
{ {
if (!rdpei->contactPoints[i].externalIds[j]) rdpei->contactPoints[i].externalId = externalId;
{
rdpei->contactPoints[i].externalIds[j] = externalId;
rdpei->contactPoints[i].externalIdCount++;
break;
}
}
contactId = rdpei->contactPoints[i].contactId; contactId = rdpei->contactPoints[i].contactId;
break; break;
} }
} }
}
return contactId; return contactId;
} }
int rdpei_contact_update(RdpeiClientContext* context, int externalId) int rdpei_contact_update(RdpeiClientContext* context, int externalId)
{ {
int i, j; int i;
int contactId = -1; int contactId = -1;
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
@ -502,25 +494,19 @@ int rdpei_contact_update(RdpeiClientContext* context, int externalId)
if (!rdpei->contactPoints[i].flags) if (!rdpei->contactPoints[i].flags)
continue; continue;
for (j = 0; j < MAX_EXTERNAL_IDS; j++) if (rdpei->contactPoints[i].externalId == externalId)
{
if (rdpei->contactPoints[i].externalIds[j] == externalId)
{ {
contactId = rdpei->contactPoints[i].contactId; contactId = rdpei->contactPoints[i].contactId;
break; break;
} }
} }
if (contactId != -1)
break;
}
return contactId; return contactId;
} }
int rdpei_contact_end(RdpeiClientContext* context, int externalId) int rdpei_contact_end(RdpeiClientContext* context, int externalId)
{ {
int i, j; int i;
int contactId = -1; int contactId = -1;
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle; RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
@ -529,28 +515,16 @@ int rdpei_contact_end(RdpeiClientContext* context, int externalId)
if (!rdpei->contactPoints[i].flags) if (!rdpei->contactPoints[i].flags)
continue; continue;
for (j = 0; j < MAX_EXTERNAL_IDS; j++) if (rdpei->contactPoints[i].externalId == externalId)
{
if (rdpei->contactPoints[i].externalIds[j] == externalId)
{ {
contactId = rdpei->contactPoints[i].contactId; contactId = rdpei->contactPoints[i].contactId;
rdpei->contactPoints[i].externalIds[j] = 0; rdpei->contactPoints[i].externalId = 0;
rdpei->contactPoints[i].externalIdCount--;
if (rdpei->contactPoints[i].externalIdCount < 1)
{
rdpei->contactPoints[i].flags = 0; rdpei->contactPoints[i].flags = 0;
rdpei->contactPoints[i].contactId = 0; rdpei->contactPoints[i].contactId = 0;
}
break; break;
} }
} }
if (contactId != -1)
break;
}
return contactId; return contactId;
} }
@ -592,8 +566,6 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
context->handle = (void*) rdpei; context->handle = (void*) rdpei;
context->GetVersion = rdpei_get_version; context->GetVersion = rdpei_get_version;
context->BeginFrame = rdpei_begin_frame;
context->EndFrame = rdpei_end_frame;
context->AddContact = rdpei_add_contact; context->AddContact = rdpei_add_contact;
context->ContactBegin = rdpei_contact_begin; context->ContactBegin = rdpei_contact_begin;

View File

@ -51,16 +51,11 @@
#define EVENTID_RESUME_TOUCH 0x0005 #define EVENTID_RESUME_TOUCH 0x0005
#define EVENTID_DISMISS_HOVERING_CONTACT 0x0006 #define EVENTID_DISMISS_HOVERING_CONTACT 0x0006
#define MAX_EXTERNAL_IDS 32
struct _RDPINPUT_CONTACT_POINT struct _RDPINPUT_CONTACT_POINT
{ {
UINT32 flags; UINT32 flags;
UINT32 contactId; UINT32 contactId;
int touchDownX; int externalId;
int touchDownY;
int externalIdCount;
int externalIds[MAX_EXTERNAL_IDS];
}; };
typedef struct _RDPINPUT_CONTACT_POINT RDPINPUT_CONTACT_POINT; typedef struct _RDPINPUT_CONTACT_POINT RDPINPUT_CONTACT_POINT;

View File

@ -132,13 +132,10 @@ static BOOL xf_event_VisibilityNotify(xfInfo* xfi, XEvent* event, BOOL app)
static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app) static BOOL xf_event_MotionNotify(xfInfo* xfi, XEvent* event, BOOL app)
{ {
rdpInput* input;
int x, y; int x, y;
rdpInput* input;
Window childWindow; Window childWindow;
if (xfi->settings->MultiTouchInput)
return TRUE;
input = xfi->instance->input; input = xfi->instance->input;
x = event->xmotion.x; x = event->xmotion.x;
y = event->xmotion.y; y = event->xmotion.y;
@ -184,13 +181,10 @@ static BOOL xf_event_ButtonPress(xfInfo* xfi, XEvent* event, BOOL app)
{ {
int x, y; int x, y;
int flags; int flags;
Window childWindow;
BOOL wheel; BOOL wheel;
BOOL extended; BOOL extended;
rdpInput* input; rdpInput* input;
Window childWindow;
if (xfi->settings->MultiTouchInput)
return TRUE;
input = xfi->instance->input; input = xfi->instance->input;
@ -297,12 +291,9 @@ static BOOL xf_event_ButtonRelease(xfInfo* xfi, XEvent* event, BOOL app)
{ {
int x, y; int x, y;
int flags; int flags;
Window childWindow;
BOOL extended; BOOL extended;
rdpInput* input; rdpInput* input;
Window childWindow;
if (xfi->settings->MultiTouchInput)
return TRUE;
input = xfi->instance->input; input = xfi->instance->input;

View File

@ -338,9 +338,6 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags)
y = (int) event->event_y; y = (int) event->event_y;
ZeroMemory(&contact, sizeof(RDPINPUT_CONTACT_DATA)); ZeroMemory(&contact, sizeof(RDPINPUT_CONTACT_DATA));
//if ((x < 0) || (y < 0))
// return 0;
contact.fieldsPresent = 0; contact.fieldsPresent = 0;
contact.x = x; contact.x = x;
contact.y = y; contact.y = y;
@ -348,7 +345,7 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags)
if (flags & CONTACT_FLAG_DOWN) if (flags & CONTACT_FLAG_DOWN)
{ {
contact.contactId = rdpei->ContactBegin(rdpei, touchId, x, y); contact.contactId = rdpei->ContactBegin(rdpei, touchId);
contact.contactFlags |= CONTACT_FLAG_INRANGE; contact.contactFlags |= CONTACT_FLAG_INRANGE;
contact.contactFlags |= CONTACT_FLAG_INCONTACT; contact.contactFlags |= CONTACT_FLAG_INCONTACT;
} }
@ -363,9 +360,7 @@ int xf_input_touch_remote(xfInfo* xfi, XIDeviceEvent* event, DWORD flags)
contact.contactId = rdpei->ContactEnd(rdpei, touchId); contact.contactId = rdpei->ContactEnd(rdpei, touchId);
} }
rdpei->BeginFrame(rdpei);
rdpei->AddContact(rdpei, &contact); rdpei->AddContact(rdpei, &contact);
rdpei->EndFrame(rdpei);
return 0; return 0;
} }

View File

@ -64,11 +64,9 @@ typedef struct _RDPINPUT_TOUCH_FRAME RDPINPUT_TOUCH_FRAME;
typedef struct _rdpei_client_context RdpeiClientContext; typedef struct _rdpei_client_context RdpeiClientContext;
typedef int (*pcRdpeiGetVersion)(RdpeiClientContext* context); typedef int (*pcRdpeiGetVersion)(RdpeiClientContext* context);
typedef int (*pcRdpeiBeginFrame)(RdpeiClientContext* context);
typedef int (*pcRdpeiEndFrame)(RdpeiClientContext* context);
typedef int (*pcRdpeiAddContact)(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact); typedef int (*pcRdpeiAddContact)(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact);
typedef int (*pcRdpeiContactBegin)(RdpeiClientContext* context, int externalId, int x, int y); typedef int (*pcRdpeiContactBegin)(RdpeiClientContext* context, int externalId);
typedef int (*pcRdpeiContactUpdate)(RdpeiClientContext* context, int externalId); typedef int (*pcRdpeiContactUpdate)(RdpeiClientContext* context, int externalId);
typedef int (*pcRdpeiContactEnd)(RdpeiClientContext* context, int externalId); typedef int (*pcRdpeiContactEnd)(RdpeiClientContext* context, int externalId);
@ -78,10 +76,8 @@ struct _rdpei_client_context
void* custom; void* custom;
pcRdpeiGetVersion GetVersion; pcRdpeiGetVersion GetVersion;
pcRdpeiBeginFrame BeginFrame;
pcRdpeiEndFrame EndFrame;
pcRdpeiAddContact AddContact;
pcRdpeiAddContact AddContact;
pcRdpeiContactBegin ContactBegin; pcRdpeiContactBegin ContactBegin;
pcRdpeiContactUpdate ContactUpdate; pcRdpeiContactUpdate ContactUpdate;
pcRdpeiContactEnd ContactEnd; pcRdpeiContactEnd ContactEnd;