Merge branch 'master' of https://github.com/ali1234/synergy into ali1234-master

This commit is contained in:
Nick Bolton 2014-10-22 15:52:06 +01:00
commit cfa10d68ca
2 changed files with 39 additions and 1 deletions

View File

@ -166,6 +166,21 @@ static void sSendMouseCallback(uSynergyContext *context)
/**
@brief Call mouse relative callback after a mouse event
**/
static void sSendMouseRelativeCallback(uSynergyContext *context, int16_t x, int16_t y)
{
// Skip if no callback is installed
if (context->m_mouseRelativeCallback == 0L)
return;
// Send callback
context->m_mouseRelativeCallback(context->m_cookie, x, y);
}
/** /**
@brief Send keyboard callback when a key has been pressed or released @brief Send keyboard callback when a key has been pressed or released
**/ **/
@ -319,6 +334,12 @@ static void sProcessMessage(uSynergyContext *context, const uint8_t *message)
context->m_mouseY = sNetToNative16(message+10); context->m_mouseY = sNetToNative16(message+10);
sSendMouseCallback(context); sSendMouseCallback(context);
} }
else if (USYNERGY_IS_PACKET("DMRM"))
{
// Mouse relative. Reply with CNOP
// kMsgDMouseRelMove = "DMRM%2i%2i"
sSendMouseRelativeCallback(context, sNetToNative16(message+8), sNetToNative16(message+10));
}
else if (USYNERGY_IS_PACKET("DMWM")) else if (USYNERGY_IS_PACKET("DMWM"))
{ {
// Mouse wheel // Mouse wheel
@ -437,7 +458,6 @@ static void sProcessMessage(uSynergyContext *context, const uint8_t *message)
// kMsgCScreenSaver = "CSEC%1i" // kMsgCScreenSaver = "CSEC%1i"
// kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i" // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i"
// kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i" // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i"
// kMsgDMouseRelMove = "DMRM%2i%2i"
// kMsgEIncompatible = "EICV%2i%2i" // kMsgEIncompatible = "EICV%2i%2i"
// kMsgEBusy = "EBSY" // kMsgEBusy = "EBSY"
// kMsgEUnknown = "EUNK" // kMsgEUnknown = "EUNK"
@ -514,6 +534,10 @@ static void sUpdateContext(uSynergyContext *context)
/* Eat packets */ /* Eat packets */
for (;;) for (;;)
{ {
/* If less than 4 bytes left in buffer, we can't even get the next packet length yet */
if(context->m_receiveOfs < 4)
return;
/* Grab packet length and bail out if the packet goes beyond the end of the buffer */ /* Grab packet length and bail out if the packet goes beyond the end of the buffer */
packlen = sNetToNative32(context->m_receiveBuffer); packlen = sNetToNative32(context->m_receiveBuffer);
if (packlen+4 > context->m_receiveOfs) if (packlen+4 > context->m_receiveOfs)

View File

@ -255,6 +255,19 @@ typedef void (*uSynergyMouseCallback)(uSynergyCookie cookie, uint16_t x, uint16
/**
@brief Mouse relative callback
This callback is called when a mouse relative event happens.
@param cookie Cookie supplied in the Synergy context
@param x Mouse X motion
@param y Mouse Y motion
**/
typedef void (*uSynergyMouseRelativeCallback)(uSynergyCookie cookie, int16_t x, int16_t y);
/** /**
@brief Key event callback @brief Key event callback
@ -332,6 +345,7 @@ typedef struct
uSynergyTraceFunc m_traceFunc; /* Function for tracing status (can be NULL) */ uSynergyTraceFunc m_traceFunc; /* Function for tracing status (can be NULL) */
uSynergyScreenActiveCallback m_screenActiveCallback; /* Callback for entering and leaving screen */ uSynergyScreenActiveCallback m_screenActiveCallback; /* Callback for entering and leaving screen */
uSynergyMouseCallback m_mouseCallback; /* Callback for mouse events */ uSynergyMouseCallback m_mouseCallback; /* Callback for mouse events */
uSynergyMouseRelativeCallback m_mouseRelativeCallback; /* Callback for mouse relative events */
uSynergyKeyboardCallback m_keyboardCallback; /* Callback for keyboard events */ uSynergyKeyboardCallback m_keyboardCallback; /* Callback for keyboard events */
uSynergyJoystickCallback m_joystickCallback; /* Callback for joystick events */ uSynergyJoystickCallback m_joystickCallback; /* Callback for joystick events */
uSynergyClipboardCallback m_clipboardCallback; /* Callback for clipboard events */ uSynergyClipboardCallback m_clipboardCallback; /* Callback for clipboard events */