mirror of
https://github.com/moonlight-stream/moonlight-common-c.git
synced 2026-06-17 14:21:30 +00:00
Add workaround for keyboard and UTF-8 events interfering with each other
This commit is contained in:
@@ -1116,6 +1116,20 @@ int sendInputPacketOnControlStream(unsigned char* data, int length) {
|
|||||||
return 0;
|
return 0;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
bool isControlDataInTransit(void) {
|
||||||
|
bool ret = false;
|
||||||
|
|
||||||
|
PltLockMutex(&enetMutex);
|
||||||
|
if (peer != NULL && peer->state == ENET_PEER_STATE_CONNECTED) {
|
||||||
|
if (peer->reliableDataInTransit != 0) {
|
||||||
|
ret = true;
|
||||||
|
}
|
||||||
|
}
|
||||||
|
PltUnlockMutex(&enetMutex);
|
||||||
|
|
||||||
|
return ret;
|
||||||
|
}
|
||||||
|
|
||||||
bool LiGetEstimatedRttInfo(uint32_t* estimatedRtt, uint32_t* estimatedRttVariance) {
|
bool LiGetEstimatedRttInfo(uint32_t* estimatedRtt, uint32_t* estimatedRttVariance) {
|
||||||
bool ret = false;
|
bool ret = false;
|
||||||
|
|
||||||
|
|||||||
@@ -386,6 +386,17 @@ static void inputSendThreadProc(void* context) {
|
|||||||
uint32_t totalLength = PAYLOAD_SIZE(holder) - sizeof(uint32_t);
|
uint32_t totalLength = PAYLOAD_SIZE(holder) - sizeof(uint32_t);
|
||||||
uint32_t i = 0;
|
uint32_t i = 0;
|
||||||
|
|
||||||
|
// HACK: This is a workaround for the fact that GFE doesn't appear to synchronize keyboard
|
||||||
|
// and UTF-8 text events with each other. We need to make sure any previous keyboard events
|
||||||
|
// have been processed prior to sending these UTF-8 events to avoid interference between
|
||||||
|
// the two (especially with modifier keys).
|
||||||
|
while (!PltIsThreadInterrupted(&inputSendThread) && isControlDataInTransit()) {
|
||||||
|
PltSleepMs(10);
|
||||||
|
}
|
||||||
|
|
||||||
|
// Finally, sleep an additional 50 ms to allow the events to be processed by Windows
|
||||||
|
PltSleepMs(50);
|
||||||
|
|
||||||
// We send each Unicode code point individually. This way we can always ensure they will
|
// We send each Unicode code point individually. This way we can always ensure they will
|
||||||
// never straddle a packet boundary (which will cause a parsing error on the host).
|
// never straddle a packet boundary (which will cause a parsing error on the host).
|
||||||
while (i < totalLength) {
|
while (i < totalLength) {
|
||||||
|
|||||||
@@ -89,6 +89,7 @@ void connectionReceivedCompleteFrame(int frameIndex);
|
|||||||
void connectionSawFrame(int frameIndex);
|
void connectionSawFrame(int frameIndex);
|
||||||
void connectionLostPackets(int lastReceivedPacket, int nextReceivedPacket);
|
void connectionLostPackets(int lastReceivedPacket, int nextReceivedPacket);
|
||||||
int sendInputPacketOnControlStream(unsigned char* data, int length);
|
int sendInputPacketOnControlStream(unsigned char* data, int length);
|
||||||
|
bool isControlDataInTransit(void);
|
||||||
|
|
||||||
int performRtspHandshake(void);
|
int performRtspHandshake(void);
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user