channels/rdpei: minor improvements
This commit is contained in:
parent
b385e61bc0
commit
c23da2f80b
@ -480,23 +480,22 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value)
|
|||||||
|
|
||||||
if (value <= 0x1F)
|
if (value <= 0x1F)
|
||||||
{
|
{
|
||||||
count = 0;
|
|
||||||
byte = value & 0x1F;
|
byte = value & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte | (count << 5));
|
Stream_Write_UINT8(s, byte);
|
||||||
}
|
}
|
||||||
else if (value <= 0x1FFF)
|
else if (value <= 0x1FFF)
|
||||||
{
|
{
|
||||||
count = 1;
|
|
||||||
byte = (value >> 8) & 0x1F;
|
byte = (value >> 8) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte | (count << 5));
|
byte |= (1 << 5);
|
||||||
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value & 0xFF);
|
byte = (value & 0xFF);
|
||||||
Stream_Write_UINT8(s, byte);
|
Stream_Write_UINT8(s, byte);
|
||||||
}
|
}
|
||||||
else if (value <= 0x1FFFFF)
|
else if (value <= 0x1FFFFF)
|
||||||
{
|
{
|
||||||
count = 2;
|
|
||||||
byte = (value >> 16) & 0x1F;
|
byte = (value >> 16) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte | (count << 5));
|
byte |= (2 << 5);
|
||||||
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 8) & 0xFF;
|
byte = (value >> 8) & 0xFF;
|
||||||
Stream_Write_UINT8(s, byte);
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value & 0xFF);
|
byte = (value & 0xFF);
|
||||||
@ -504,9 +503,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value)
|
|||||||
}
|
}
|
||||||
else if (value <= 0x1FFFFF)
|
else if (value <= 0x1FFFFF)
|
||||||
{
|
{
|
||||||
count = 3;
|
|
||||||
byte = (value >> 24) & 0x1F;
|
byte = (value >> 24) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte | (count << 5));
|
byte |= (3 << 5);
|
||||||
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 16) & 0xFF;
|
byte = (value >> 16) & 0xFF;
|
||||||
Stream_Write_UINT8(s, byte);
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 8) & 0xFF;
|
byte = (value >> 8) & 0xFF;
|
||||||
@ -516,9 +515,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value)
|
|||||||
}
|
}
|
||||||
else if (value <= 0x1FFFFFFF)
|
else if (value <= 0x1FFFFFFF)
|
||||||
{
|
{
|
||||||
count = 4;
|
|
||||||
byte = (value >> 32) & 0x1F;
|
byte = (value >> 32) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte | (count << 5));
|
byte |= (4 << 5);
|
||||||
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 24) & 0x1F;
|
byte = (value >> 24) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte);
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 16) & 0xFF;
|
byte = (value >> 16) & 0xFF;
|
||||||
@ -530,9 +529,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value)
|
|||||||
}
|
}
|
||||||
else if (value <= 0x1FFFFFFFFF)
|
else if (value <= 0x1FFFFFFFFF)
|
||||||
{
|
{
|
||||||
count = 5;
|
|
||||||
byte = (value >> 40) & 0x1F;
|
byte = (value >> 40) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte | (count << 5));
|
byte |= (5 << 5);
|
||||||
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 32) & 0x1F;
|
byte = (value >> 32) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte);
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 24) & 0x1F;
|
byte = (value >> 24) & 0x1F;
|
||||||
@ -546,9 +545,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value)
|
|||||||
}
|
}
|
||||||
else if (value <= 0x1FFFFFFFFFFF)
|
else if (value <= 0x1FFFFFFFFFFF)
|
||||||
{
|
{
|
||||||
count = 6;
|
|
||||||
byte = (value >> 48) & 0x1F;
|
byte = (value >> 48) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte | (count << 5));
|
byte |= (6 << 5);
|
||||||
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 40) & 0x1F;
|
byte = (value >> 40) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte);
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 32) & 0x1F;
|
byte = (value >> 32) & 0x1F;
|
||||||
@ -564,9 +563,9 @@ BOOL rdpei_write_8byte_unsigned(wStream* s, UINT64 value)
|
|||||||
}
|
}
|
||||||
else if (value <= 0x1FFFFFFFFFFFFF)
|
else if (value <= 0x1FFFFFFFFFFFFF)
|
||||||
{
|
{
|
||||||
count = 7;
|
|
||||||
byte = (value >> 56) & 0x1F;
|
byte = (value >> 56) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte | (count << 5));
|
byte |= (7 << 5);
|
||||||
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 48) & 0x1F;
|
byte = (value >> 48) & 0x1F;
|
||||||
Stream_Write_UINT8(s, byte);
|
Stream_Write_UINT8(s, byte);
|
||||||
byte = (value >> 40) & 0x1F;
|
byte = (value >> 40) & 0x1F;
|
||||||
|
@ -66,6 +66,7 @@ struct _RDPEI_PLUGIN
|
|||||||
RDPEI_LISTENER_CALLBACK* listener_callback;
|
RDPEI_LISTENER_CALLBACK* listener_callback;
|
||||||
|
|
||||||
int version;
|
int version;
|
||||||
|
int touchIdOffset;
|
||||||
UINT64 currentFrameTime;
|
UINT64 currentFrameTime;
|
||||||
UINT64 previousFrameTime;
|
UINT64 previousFrameTime;
|
||||||
RDPINPUT_TOUCH_FRAME frame;
|
RDPINPUT_TOUCH_FRAME frame;
|
||||||
@ -93,11 +94,10 @@ int rdpei_send_pdu(RDPEI_CHANNEL_CALLBACK* callback, wStream* s, UINT16 eventId,
|
|||||||
Stream_Write_UINT32(s, pduLength); /* pduLength (4 bytes) */
|
Stream_Write_UINT32(s, pduLength); /* pduLength (4 bytes) */
|
||||||
Stream_SetPosition(s, Stream_Length(s));
|
Stream_SetPosition(s, Stream_Length(s));
|
||||||
|
|
||||||
printf("rdpei_send_pdu: eventId: %d (%s) length: %d\n",
|
status = callback->channel->Write(callback->channel, Stream_Length(s), Stream_Buffer(s), NULL);
|
||||||
eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength);
|
|
||||||
|
|
||||||
status = callback->channel->Write(callback->channel,
|
printf("rdpei_send_pdu: eventId: %d (%s) length: %d status: %d\n",
|
||||||
Stream_Length(s), Stream_Buffer(s), NULL);
|
eventId, RDPEI_EVENTID_STRINGS[eventId], pduLength, status);
|
||||||
|
|
||||||
return status;
|
return status;
|
||||||
}
|
}
|
||||||
@ -137,8 +137,11 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
|
|||||||
int index;
|
int index;
|
||||||
RDPINPUT_CONTACT_DATA* contact;
|
RDPINPUT_CONTACT_DATA* contact;
|
||||||
|
|
||||||
rdpei_write_2byte_unsigned(s, frame->contactCount);
|
printf("contactCount: %d\n", frame->contactCount);
|
||||||
rdpei_write_8byte_unsigned(s, frame->frameOffset);
|
printf("frameOffset: 0x%08X\n", (UINT32) frame->frameOffset);
|
||||||
|
|
||||||
|
rdpei_write_2byte_unsigned(s, frame->contactCount); /* contactCount (TWO_BYTE_UNSIGNED_INTEGER) */
|
||||||
|
rdpei_write_8byte_unsigned(s, frame->frameOffset); /* frameOffset (EIGHT_BYTE_UNSIGNED_INTEGER) */
|
||||||
|
|
||||||
Stream_EnsureRemainingCapacity(s, frame->contactCount * 32);
|
Stream_EnsureRemainingCapacity(s, frame->contactCount * 32);
|
||||||
|
|
||||||
@ -146,27 +149,44 @@ int rdpei_write_touch_frame(wStream* s, RDPINPUT_TOUCH_FRAME* frame)
|
|||||||
{
|
{
|
||||||
contact = &frame->contacts[index];
|
contact = &frame->contacts[index];
|
||||||
|
|
||||||
Stream_Write_UINT8(s, contact->contactId);
|
printf("contact[%d].contactId: %d\n", index, contact->contactId);
|
||||||
|
printf("contact[%d].fieldsPresent: %d\n", index, contact->fieldsPresent);
|
||||||
|
printf("contact[%d].x: %d\n", index, contact->x);
|
||||||
|
printf("contact[%d].y: %d\n", index, contact->y);
|
||||||
|
printf("contact[%d].contactFlags: 0x%04X\n", index, contact->contactFlags);
|
||||||
|
|
||||||
|
Stream_Write_UINT8(s, contact->contactId); /* contactId (1 byte) */
|
||||||
|
|
||||||
|
/* fieldsPresent (TWO_BYTE_UNSIGNED_INTEGER) */
|
||||||
rdpei_write_2byte_unsigned(s, contact->fieldsPresent);
|
rdpei_write_2byte_unsigned(s, contact->fieldsPresent);
|
||||||
rdpei_write_4byte_signed(s, contact->x);
|
|
||||||
rdpei_write_4byte_signed(s, contact->y);
|
rdpei_write_4byte_signed(s, contact->x); /* x (FOUR_BYTE_SIGNED_INTEGER) */
|
||||||
|
rdpei_write_4byte_signed(s, contact->y); /* y (FOUR_BYTE_SIGNED_INTEGER) */
|
||||||
|
|
||||||
|
/* contactFlags (FOUR_BYTE_UNSIGNED_INTEGER) */
|
||||||
rdpei_write_4byte_unsigned(s, contact->contactFlags);
|
rdpei_write_4byte_unsigned(s, contact->contactFlags);
|
||||||
|
|
||||||
if (contact->fieldsPresent & CONTACT_DATA_CONTACTRECT_PRESENT)
|
if (contact->fieldsPresent & CONTACT_DATA_CONTACTRECT_PRESENT)
|
||||||
{
|
{
|
||||||
|
/* contactRectLeft (TWO_BYTE_SIGNED_INTEGER) */
|
||||||
rdpei_write_2byte_signed(s, contact->contactRectLeft);
|
rdpei_write_2byte_signed(s, contact->contactRectLeft);
|
||||||
|
/* contactRectTop (TWO_BYTE_SIGNED_INTEGER) */
|
||||||
rdpei_write_2byte_signed(s, contact->contactRectTop);
|
rdpei_write_2byte_signed(s, contact->contactRectTop);
|
||||||
|
/* contactRectRight (TWO_BYTE_SIGNED_INTEGER) */
|
||||||
rdpei_write_2byte_signed(s, contact->contactRectRight);
|
rdpei_write_2byte_signed(s, contact->contactRectRight);
|
||||||
|
/* contactRectBottom (TWO_BYTE_SIGNED_INTEGER) */
|
||||||
rdpei_write_2byte_signed(s, contact->contactRectBottom);
|
rdpei_write_2byte_signed(s, contact->contactRectBottom);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact->fieldsPresent & CONTACT_DATA_ORIENTATION_PRESENT)
|
if (contact->fieldsPresent & CONTACT_DATA_ORIENTATION_PRESENT)
|
||||||
{
|
{
|
||||||
|
/* orientation (FOUR_BYTE_UNSIGNED_INTEGER) */
|
||||||
rdpei_write_4byte_unsigned(s, contact->orientation);
|
rdpei_write_4byte_unsigned(s, contact->orientation);
|
||||||
}
|
}
|
||||||
|
|
||||||
if (contact->fieldsPresent & CONTACT_DATA_PRESSURE_PRESENT)
|
if (contact->fieldsPresent & CONTACT_DATA_PRESSURE_PRESENT)
|
||||||
{
|
{
|
||||||
|
/* pressure (FOUR_BYTE_UNSIGNED_INTEGER) */
|
||||||
rdpei_write_4byte_unsigned(s, contact->pressure);
|
rdpei_write_4byte_unsigned(s, contact->pressure);
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
@ -179,17 +199,14 @@ int rdpei_send_touch_event_pdu(RDPEI_CHANNEL_CALLBACK* callback, RDPINPUT_TOUCH_
|
|||||||
int status;
|
int status;
|
||||||
wStream* s;
|
wStream* s;
|
||||||
UINT32 pduLength;
|
UINT32 pduLength;
|
||||||
UINT32 encodeTime;
|
|
||||||
UINT16 frameCount;
|
|
||||||
|
|
||||||
encodeTime = 0;
|
pduLength = 64 + (frame->contactCount * 32);
|
||||||
frameCount = 1;
|
|
||||||
|
|
||||||
s = Stream_New(NULL, 512);
|
s = Stream_New(NULL, pduLength);
|
||||||
Stream_Seek(s, RDPINPUT_HEADER_LENGTH);
|
Stream_Seek(s, RDPINPUT_HEADER_LENGTH);
|
||||||
|
|
||||||
rdpei_write_4byte_unsigned(s, encodeTime);
|
rdpei_write_4byte_unsigned(s, frame->frameOffset); /* FOUR_BYTE_UNSIGNED_INTEGER */
|
||||||
rdpei_write_2byte_unsigned(s, frameCount);
|
rdpei_write_2byte_unsigned(s, frame->contactCount); /* TWO_BYTE_UNSIGNED_INTEGER */
|
||||||
|
|
||||||
rdpei_write_touch_frame(s, frame);
|
rdpei_write_touch_frame(s, frame);
|
||||||
|
|
||||||
@ -368,6 +385,9 @@ int rdpei_end_frame(RdpeiClientContext* context)
|
|||||||
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)
|
||||||
|
// return 0;
|
||||||
|
|
||||||
if (!rdpei->previousFrameTime && !rdpei->currentFrameTime)
|
if (!rdpei->previousFrameTime && !rdpei->currentFrameTime)
|
||||||
{
|
{
|
||||||
rdpei->currentFrameTime = (UINT64) GetTickCount64();
|
rdpei->currentFrameTime = (UINT64) GetTickCount64();
|
||||||
@ -388,10 +408,27 @@ int rdpei_end_frame(RdpeiClientContext* context)
|
|||||||
|
|
||||||
int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact)
|
int rdpei_add_contact(RdpeiClientContext* context, RDPINPUT_CONTACT_DATA* contact)
|
||||||
{
|
{
|
||||||
|
RDPINPUT_CONTACT_DATA* previousContact;
|
||||||
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
|
RDPEI_PLUGIN* rdpei = (RDPEI_PLUGIN*) context->handle;
|
||||||
|
|
||||||
if (rdpei->frame.contactCount < MAX_CONTACTS)
|
if (rdpei->frame.contactCount < MAX_CONTACTS)
|
||||||
{
|
{
|
||||||
|
if (rdpei->frame.contactCount > 0)
|
||||||
|
{
|
||||||
|
previousContact = &(rdpei->contacts[rdpei->frame.contactCount - 1]);
|
||||||
|
|
||||||
|
if ((previousContact->x == contact->x) || (previousContact->y == contact->y) ||
|
||||||
|
(previousContact->contactId == contact->contactId))
|
||||||
|
{
|
||||||
|
return 1;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
|
||||||
|
if (rdpei->touchIdOffset < 0)
|
||||||
|
rdpei->touchIdOffset = contact->contactId;
|
||||||
|
|
||||||
|
contact->contactId -= rdpei->touchIdOffset;
|
||||||
|
|
||||||
CopyMemory(&(rdpei->contacts[rdpei->frame.contactCount]), contact, sizeof(RDPINPUT_CONTACT_DATA));
|
CopyMemory(&(rdpei->contacts[rdpei->frame.contactCount]), contact, sizeof(RDPINPUT_CONTACT_DATA));
|
||||||
rdpei->frame.contactCount++;
|
rdpei->frame.contactCount++;
|
||||||
}
|
}
|
||||||
@ -422,6 +459,7 @@ int DVCPluginEntry(IDRDYNVC_ENTRY_POINTS* pEntryPoints)
|
|||||||
rdpei->iface.Terminated = rdpei_plugin_terminated;
|
rdpei->iface.Terminated = rdpei_plugin_terminated;
|
||||||
|
|
||||||
rdpei->version = 1;
|
rdpei->version = 1;
|
||||||
|
rdpei->touchIdOffset = -1;
|
||||||
rdpei->currentFrameTime = 0;
|
rdpei->currentFrameTime = 0;
|
||||||
rdpei->previousFrameTime = 0;
|
rdpei->previousFrameTime = 0;
|
||||||
rdpei->frame.contacts = (RDPINPUT_CONTACT_DATA*) rdpei->contacts;
|
rdpei->frame.contacts = (RDPINPUT_CONTACT_DATA*) rdpei->contacts;
|
||||||
|
@ -328,20 +328,31 @@ 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))
|
//if ((x < 0) || (y < 0))
|
||||||
return 0;
|
// return 0;
|
||||||
|
|
||||||
printf("%s: id: %d x: %d y: %d\n",
|
contact.contactId = touchId;
|
||||||
xf_input_touch_state_string(flags),
|
|
||||||
touchId, x, y);
|
|
||||||
|
|
||||||
contact.contactId = touchId % 0xFF;
|
|
||||||
contact.fieldsPresent = 0;
|
contact.fieldsPresent = 0;
|
||||||
contact.x = x;
|
contact.x = x;
|
||||||
contact.y = y;
|
contact.y = y;
|
||||||
contact.contactFlags = flags;
|
contact.contactFlags = flags;
|
||||||
|
|
||||||
rdpei->BeginFrame(rdpei);
|
if (flags & CONTACT_FLAG_DOWN)
|
||||||
|
{
|
||||||
|
contact.contactFlags |= CONTACT_FLAG_INRANGE;
|
||||||
|
contact.contactFlags |= CONTACT_FLAG_INCONTACT;
|
||||||
|
}
|
||||||
|
else if (flags & CONTACT_FLAG_UPDATE)
|
||||||
|
{
|
||||||
|
contact.contactFlags |= CONTACT_FLAG_INRANGE;
|
||||||
|
contact.contactFlags |= CONTACT_FLAG_INCONTACT;
|
||||||
|
}
|
||||||
|
else if (flags & CONTACT_FLAG_UP)
|
||||||
|
{
|
||||||
|
//contact.contactFlags |= CONTACT_FLAG_INRANGE;
|
||||||
|
}
|
||||||
|
|
||||||
|
//rdpei->BeginFrame(rdpei);
|
||||||
rdpei->AddContact(rdpei, &contact);
|
rdpei->AddContact(rdpei, &contact);
|
||||||
rdpei->EndFrame(rdpei);
|
rdpei->EndFrame(rdpei);
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user