Classes | Macros | Typedefs | Enumerations | Functions
uSynergy.h File Reference
#include <stdint.h>
Include dependency graph for uSynergy.h:
This graph shows which files directly or indirectly include this file:

Go to the source code of this file.

Classes

struct  uSynergyContext
 uSynergy context More...
 
struct  uSynergyCookie
 User context type. More...
 

Macros

#define USYNERGY_FALSE   0 /* False value */
 
#define USYNERGY_IDLE_TIMEOUT   2000 /* Timeout in milliseconds before reconnecting */
 
#define USYNERGY_LITTLE_ENDIAN
 Determine endianness. More...
 
#define USYNERGY_MODIFIER_ALT   0x0004 /* Alt key modifier */
 
#define USYNERGY_MODIFIER_ALT_GR   0x0020 /* AltGr key modifier */
 
#define USYNERGY_MODIFIER_CAPSLOCK   0x1000 /* CapsLock key modifier */
 
#define USYNERGY_MODIFIER_CTRL   0x0002 /* Ctrl key modifier */
 
#define USYNERGY_MODIFIER_LEVEL5LOCK   0x0040 /* Level5Lock key modifier */
 
#define USYNERGY_MODIFIER_META   0x0008 /* Meta key modifier */
 
#define USYNERGY_MODIFIER_NUMLOCK   0x2000 /* NumLock key modifier */
 
#define USYNERGY_MODIFIER_SCROLLOCK   0x4000 /* ScrollLock key modifier */
 
#define USYNERGY_MODIFIER_SHIFT   0x0001 /* Shift key modifier */
 Keyboard constants. More...
 
#define USYNERGY_MODIFIER_WIN   0x0010 /* Windows key modifier */
 
#define USYNERGY_NUM_JOYSTICKS   4 /* Maximum number of supported joysticks */
 Constants and limits. More...
 
#define USYNERGY_PROTOCOL_MAJOR   1 /* Major protocol version */
 
#define USYNERGY_PROTOCOL_MINOR   4 /* Minor protocol version */
 
#define USYNERGY_RECEIVE_BUFFER_SIZE   4096 /* Maximum size of an incoming packet */
 
#define USYNERGY_REPLY_BUFFER_SIZE   1024 /* Maximum size of a reply packet */
 
#define USYNERGY_TRACE_BUFFER_SIZE   1024 /* Maximum length of traced message */
 
#define USYNERGY_TRUE   1 /* True value */
 

Typedefs

typedef int uSynergyBool
 Boolean type. More...
 
typedef void(* uSynergyClipboardCallback) (uSynergyCookie cookie, enum uSynergyClipboardFormat format, const uint8_t *data, uint32_t size)
 Clipboard event callback. More...
 
typedef uSynergyBool(* uSynergyConnectFunc) (uSynergyCookie cookie)
 Connect function. More...
 
typedef uint32_t(* uSynergyGetTimeFunc) ()
 Get time function. More...
 
typedef void(* uSynergyJoystickCallback) (uSynergyCookie cookie, uint8_t joyNum, uint16_t buttons, int8_t leftStickX, int8_t leftStickY, int8_t rightStickX, int8_t rightStickY)
 Joystick event callback. More...
 
typedef void(* uSynergyKeyboardCallback) (uSynergyCookie cookie, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat)
 Key event callback. More...
 
typedef void(* uSynergyMouseCallback) (uSynergyCookie cookie, uint16_t x, uint16_t y, int16_t wheelX, int16_t wheelY, uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle)
 Mouse callback. More...
 
typedef uSynergyBool(* uSynergyReceiveFunc) (uSynergyCookie cookie, uint8_t *buffer, int maxLength, int *outLength)
 Receive function. More...
 
typedef void(* uSynergyScreenActiveCallback) (uSynergyCookie cookie, uSynergyBool active)
 Screen active callback. More...
 
typedef uSynergyBool(* uSynergySendFunc) (uSynergyCookie cookie, const uint8_t *buffer, int length)
 Send function. More...
 
typedef void(* uSynergySleepFunc) (uSynergyCookie cookie, int timeMs)
 Thread sleep function. More...
 
typedef void(* uSynergyTraceFunc) (uSynergyCookie cookie, const char *text)
 Trace function. More...
 

Enumerations

enum  uSynergyClipboardFormat { USYNERGY_CLIPBOARD_FORMAT_TEXT = 0, USYNERGY_CLIPBOARD_FORMAT_BITMAP = 1, USYNERGY_CLIPBOARD_FORMAT_HTML = 2 }
 Clipboard types. More...
 

Functions

void uSynergyInit (uSynergyContext *context)
 Initialize uSynergy context. More...
 
void uSynergySendClipboard (uSynergyContext *context, const char *text)
 Send clipboard data. More...
 
void uSynergyUpdate (uSynergyContext *context)
 Update uSynergy. More...
 

Macro Definition Documentation

◆ USYNERGY_FALSE

#define USYNERGY_FALSE   0 /* False value */

Definition at line 72 of file uSynergy.h.

◆ USYNERGY_IDLE_TIMEOUT

#define USYNERGY_IDLE_TIMEOUT   2000 /* Timeout in milliseconds before reconnecting */

Definition at line 106 of file uSynergy.h.

◆ USYNERGY_LITTLE_ENDIAN

#define USYNERGY_LITTLE_ENDIAN

Determine endianness.

Definition at line 50 of file uSynergy.h.

◆ USYNERGY_MODIFIER_ALT

#define USYNERGY_MODIFIER_ALT   0x0004 /* Alt key modifier */

Definition at line 119 of file uSynergy.h.

◆ USYNERGY_MODIFIER_ALT_GR

#define USYNERGY_MODIFIER_ALT_GR   0x0020 /* AltGr key modifier */

Definition at line 122 of file uSynergy.h.

◆ USYNERGY_MODIFIER_CAPSLOCK

#define USYNERGY_MODIFIER_CAPSLOCK   0x1000 /* CapsLock key modifier */

Definition at line 124 of file uSynergy.h.

◆ USYNERGY_MODIFIER_CTRL

#define USYNERGY_MODIFIER_CTRL   0x0002 /* Ctrl key modifier */

Definition at line 118 of file uSynergy.h.

◆ USYNERGY_MODIFIER_LEVEL5LOCK

#define USYNERGY_MODIFIER_LEVEL5LOCK   0x0040 /* Level5Lock key modifier */

Definition at line 123 of file uSynergy.h.

◆ USYNERGY_MODIFIER_META

#define USYNERGY_MODIFIER_META   0x0008 /* Meta key modifier */

Definition at line 120 of file uSynergy.h.

◆ USYNERGY_MODIFIER_NUMLOCK

#define USYNERGY_MODIFIER_NUMLOCK   0x2000 /* NumLock key modifier */

Definition at line 125 of file uSynergy.h.

◆ USYNERGY_MODIFIER_SCROLLOCK

#define USYNERGY_MODIFIER_SCROLLOCK   0x4000 /* ScrollLock key modifier */

Definition at line 126 of file uSynergy.h.

◆ USYNERGY_MODIFIER_SHIFT

#define USYNERGY_MODIFIER_SHIFT   0x0001 /* Shift key modifier */

Keyboard constants.

Definition at line 117 of file uSynergy.h.

◆ USYNERGY_MODIFIER_WIN

#define USYNERGY_MODIFIER_WIN   0x0010 /* Windows key modifier */

Definition at line 121 of file uSynergy.h.

◆ USYNERGY_NUM_JOYSTICKS

#define USYNERGY_NUM_JOYSTICKS   4 /* Maximum number of supported joysticks */

Constants and limits.

Definition at line 101 of file uSynergy.h.

◆ USYNERGY_PROTOCOL_MAJOR

#define USYNERGY_PROTOCOL_MAJOR   1 /* Major protocol version */

Definition at line 103 of file uSynergy.h.

◆ USYNERGY_PROTOCOL_MINOR

#define USYNERGY_PROTOCOL_MINOR   4 /* Minor protocol version */

Definition at line 104 of file uSynergy.h.

◆ USYNERGY_RECEIVE_BUFFER_SIZE

#define USYNERGY_RECEIVE_BUFFER_SIZE   4096 /* Maximum size of an incoming packet */

Definition at line 110 of file uSynergy.h.

◆ USYNERGY_REPLY_BUFFER_SIZE

#define USYNERGY_REPLY_BUFFER_SIZE   1024 /* Maximum size of a reply packet */

Definition at line 109 of file uSynergy.h.

◆ USYNERGY_TRACE_BUFFER_SIZE

#define USYNERGY_TRACE_BUFFER_SIZE   1024 /* Maximum length of traced message */

Definition at line 108 of file uSynergy.h.

◆ USYNERGY_TRUE

#define USYNERGY_TRUE   1 /* True value */

Definition at line 73 of file uSynergy.h.

Typedef Documentation

◆ uSynergyBool

typedef int uSynergyBool

Boolean type.

Definition at line 71 of file uSynergy.h.

◆ uSynergyClipboardCallback

typedef void(* uSynergyClipboardCallback) (uSynergyCookie cookie, enum uSynergyClipboardFormat format, const uint8_t *data, uint32_t size)

Clipboard event callback.

This callback is called when something is placed on the clipboard. Multiple callbacks may be fired for multiple clipboard formats if they are supported. The data provided is read-only and may not be modified by the application.

Parameters
cookieCookie supplied in the Synergy context
formatClipboard format
dataMemory area containing the clipboard raw data
sizeSize of clipboard data

Definition at line 305 of file uSynergy.h.

◆ uSynergyConnectFunc

typedef uSynergyBool(* uSynergyConnectFunc) (uSynergyCookie cookie)

Connect function.

This function is called when uSynergy needs to connect to the host. It doesn't imply a network implementation or destination address, that must all be handled on the user side. The function should return USYNERGY_TRUE if a connection was established or USYNERGY_FALSE if it could not connect.

When network errors occur (e.g. uSynergySend or uSynergyReceive fail) then the connect call will be called again so the implementation of the function must close any old connections and clean up resources before retrying.

Parameters
cookieCookie supplied in the Synergy context

Definition at line 149 of file uSynergy.h.

◆ uSynergyGetTimeFunc

typedef uint32_t(* uSynergyGetTimeFunc) ()

Get time function.

This function is called when uSynergy needs to know the current time. This is used to determine when timeouts have occured. The time base should be a cyclic millisecond time value.

Returns
Time value in milliseconds

Definition at line 207 of file uSynergy.h.

◆ uSynergyJoystickCallback

typedef void(* uSynergyJoystickCallback) (uSynergyCookie cookie, uint8_t joyNum, uint16_t buttons, int8_t leftStickX, int8_t leftStickY, int8_t rightStickX, int8_t rightStickY)

Joystick event callback.

This callback is called when a joystick stick or button changes. It is possible that multiple callbacks are fired when different sticks or buttons change as these are individual messages in the packet stream. Each callback will contain all the valid state for the different axes and buttons. The last callback received will represent the most current joystick state.

Parameters
cookieCookie supplied in the Synergy context
joyNumJoystick number, always in the range [0 ... USYNERGY_NUM_JOYSTICKS>
buttonsButton pressed mask
leftStickXLeft stick X position, in range [-127 ... 127]
leftStickYLeft stick Y position, in range [-127 ... 127]
rightStickXRight stick X position, in range [-127 ... 127]
rightStickYRight stick Y position, in range [-127 ... 127]

Definition at line 289 of file uSynergy.h.

◆ uSynergyKeyboardCallback

typedef void(* uSynergyKeyboardCallback) (uSynergyCookie cookie, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat)

Key event callback.

This callback is called when a key is pressed or released.

Parameters
cookieCookie supplied in the Synergy context
keyKey code of key that was pressed or released
modifiersStatus of modifier keys (alt, shift, etc.)
downDown or up status, 1 is key is pressed down, 0 if key is released (up)
repeatRepeat flag, 1 if the key is down because the key is repeating, 0 if the key is initially pressed by the user

Definition at line 269 of file uSynergy.h.

◆ uSynergyMouseCallback

typedef void(* uSynergyMouseCallback) (uSynergyCookie cookie, uint16_t x, uint16_t y, int16_t wheelX, int16_t wheelY, uSynergyBool buttonLeft, uSynergyBool buttonRight, uSynergyBool buttonMiddle)

Mouse callback.

This callback is called when a mouse events happens. The mouse X and Y position, wheel and button state is communicated in the message. It's up to the user to interpret if this is a mouse up, down, double-click or other message.

Parameters
cookieCookie supplied in the Synergy context
xMouse X position
yMouse Y position
wheelXMouse wheel X position
wheelYMouse wheel Y position
buttonLeftLeft button pressed status, 0 for released, 1 for pressed
buttonMiddleMiddle button pressed status, 0 for released, 1 for pressed
buttonRightRight button pressed status, 0 for released, 1 for pressed

Definition at line 254 of file uSynergy.h.

◆ uSynergyReceiveFunc

typedef uSynergyBool(* uSynergyReceiveFunc) (uSynergyCookie cookie, uint8_t *buffer, int maxLength, int *outLength)

Receive function.

This function is called when uSynergy needs to receive data from the default connection. It should return USYNERGY_TRUE if receiving data succeeded and USYNERGY_FALSE otherwise. This function should block until data has been received and wait for data to become available. If outLength is set to 0 upon completion it is assumed that the connection is alive, but still in a connecting state and needs time to settle.

Parameters
cookieCookie supplied in the Synergy context
bufferAddress of buffer to receive data into
maxLengthMaximum amount of bytes to write into the receive buffer
outLengthAddress of integer that receives the actual amount of bytes written into buffer

Definition at line 181 of file uSynergy.h.

◆ uSynergyScreenActiveCallback

typedef void(* uSynergyScreenActiveCallback) (uSynergyCookie cookie, uSynergyBool active)

Screen active callback.

This callback is called when Synergy makes the screen active or inactive. This callback is usually sent when the mouse enters or leaves the screen.

Parameters
cookieCookie supplied in the Synergy context
activeActivation flag, 1 if the screen has become active, 0 if the screen has become inactive

Definition at line 234 of file uSynergy.h.

◆ uSynergySendFunc

typedef uSynergyBool(* uSynergySendFunc) (uSynergyCookie cookie, const uint8_t *buffer, int length)

Send function.

This function is called when uSynergy needs to send something over the default connection. It should return USYNERGY_TRUE if sending succeeded and USYNERGY_FALSE otherwise. This function should block until the send operation is completed.

Parameters
cookieCookie supplied in the Synergy context
bufferAddress of buffer to send
lengthLength of buffer to send

Definition at line 164 of file uSynergy.h.

◆ uSynergySleepFunc

typedef void(* uSynergySleepFunc) (uSynergyCookie cookie, int timeMs)

Thread sleep function.

This function is called when uSynergy wants to suspend operation for a while before retrying an operation. It is mostly used when a socket times out or disconnect occurs to prevent uSynergy from continuously hammering a network connection in case the network is down.

Parameters
cookieCookie supplied in the Synergy context
timeMsTime to sleep the current thread (in milliseconds)

Definition at line 195 of file uSynergy.h.

◆ uSynergyTraceFunc

typedef void(* uSynergyTraceFunc) (uSynergyCookie cookie, const char *text)

Trace function.

This function is called when uSynergy wants to trace something. It is optional to show these messages, but they are often useful when debugging. uSynergy only traces major events like connecting and disconnecting. Usually only a single trace is shown when the connection is established and no more trace are called.

Parameters
cookieCookie supplied in the Synergy context
textText to be traced

Definition at line 221 of file uSynergy.h.

Enumeration Type Documentation

◆ uSynergyClipboardFormat

Clipboard types.

Enumerator
USYNERGY_CLIPBOARD_FORMAT_TEXT 
USYNERGY_CLIPBOARD_FORMAT_BITMAP 
USYNERGY_CLIPBOARD_FORMAT_HTML 

Definition at line 89 of file uSynergy.h.

Function Documentation

◆ uSynergyInit()

void uSynergyInit ( uSynergyContext context)

Initialize uSynergy context.

This function initializes context for use. Call this function directly after creating the context, before filling in any configuration data in it. Not calling this function will cause undefined behavior.

Parameters
contextContext to be initialized

Definition at line 570 of file uSynergy.c.

◆ uSynergySendClipboard()

void uSynergySendClipboard ( uSynergyContext context,
const char *  text 
)

Send clipboard data.

This function sets new clipboard data and sends it to the server. Use this function if your client cuts or copies data onto the clipboard that it needs to share with the server.

Currently there is only support for plaintext, but HTML and image data could be supported with some effort.

Parameters
contextContext to send clipboard data to
textText to set to the clipboard

Definition at line 603 of file uSynergy.c.

◆ uSynergyUpdate()

void uSynergyUpdate ( uSynergyContext context)

Update uSynergy.

This function updates uSynergy and does the bulk of the work. It does connection management, receiving data, reconnecting after errors or timeouts and so on. It assumes that networking operations are blocking and it can suspend the current thread if it needs to wait. It is best practice to call uSynergyUpdate from a background thread so it is responsive.

Because uSynergy relies mostly on blocking calls it will mostly stay in thread sleep state waiting for system mutexes and won't eat much memory.

uSynergyUpdate doesn't do any memory allocations or have any side effects beyond those of the callbacks it calls.

Parameters
contextContext to be updated

Definition at line 583 of file uSynergy.c.



libaditof
Author(s):
autogenerated on Wed May 21 2025 02:07:05