From 2709ae48db3b25188dd1ee78b6526ed3234aa1ba Mon Sep 17 00:00:00 2001 From: Alistair Buxton Date: Thu, 7 Feb 2013 00:42:08 +0000 Subject: [PATCH] Implement DMRM message for relative mouse movement. --- src/micro/uSynergy.c | 22 +++++++++++++++++++++- src/micro/uSynergy.h | 14 ++++++++++++++ 2 files changed, 35 insertions(+), 1 deletion(-) diff --git a/src/micro/uSynergy.c b/src/micro/uSynergy.c index ffdf504c..dda97bc3 100644 --- a/src/micro/uSynergy.c +++ b/src/micro/uSynergy.c @@ -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 **/ @@ -319,6 +334,12 @@ static void sProcessMessage(uSynergyContext *context, const uint8_t *message) context->m_mouseY = sNetToNative16(message+10); 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")) { // Mouse wheel @@ -437,7 +458,6 @@ static void sProcessMessage(uSynergyContext *context, const uint8_t *message) // kMsgCScreenSaver = "CSEC%1i" // kMsgDKeyRepeat = "DKRP%2i%2i%2i%2i" // kMsgDKeyRepeat1_0 = "DKRP%2i%2i%2i" - // kMsgDMouseRelMove = "DMRM%2i%2i" // kMsgEIncompatible = "EICV%2i%2i" // kMsgEBusy = "EBSY" // kMsgEUnknown = "EUNK" diff --git a/src/micro/uSynergy.h b/src/micro/uSynergy.h index ef1efaa6..2de72bf6 100644 --- a/src/micro/uSynergy.h +++ b/src/micro/uSynergy.h @@ -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 @@ -332,6 +345,7 @@ typedef struct uSynergyTraceFunc m_traceFunc; /* Function for tracing status (can be NULL) */ uSynergyScreenActiveCallback m_screenActiveCallback; /* Callback for entering and leaving screen */ uSynergyMouseCallback m_mouseCallback; /* Callback for mouse events */ + uSynergyMouseRelativeCallback m_mouseRelativeCallback; /* Callback for mouse relative events */ uSynergyKeyboardCallback m_keyboardCallback; /* Callback for keyboard events */ uSynergyJoystickCallback m_joystickCallback; /* Callback for joystick events */ uSynergyClipboardCallback m_clipboardCallback; /* Callback for clipboard events */