Implement DMRM message for relative mouse movement.

This commit is contained in:
Alistair Buxton 2013-02-07 00:42:08 +00:00
parent b52f2e0ca7
commit 2709ae48db
2 changed files with 35 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"

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 */