#include <stdint.h>
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... | |
#define USYNERGY_FALSE 0 /* False value */ |
Definition at line 72 of file uSynergy.h.
#define USYNERGY_IDLE_TIMEOUT 2000 /* Timeout in milliseconds before reconnecting */ |
Definition at line 106 of file uSynergy.h.
#define USYNERGY_LITTLE_ENDIAN |
Determine endianness.
Definition at line 50 of file uSynergy.h.
#define USYNERGY_MODIFIER_ALT 0x0004 /* Alt key modifier */ |
Definition at line 119 of file uSynergy.h.
#define USYNERGY_MODIFIER_ALT_GR 0x0020 /* AltGr key modifier */ |
Definition at line 122 of file uSynergy.h.
#define USYNERGY_MODIFIER_CAPSLOCK 0x1000 /* CapsLock key modifier */ |
Definition at line 124 of file uSynergy.h.
#define USYNERGY_MODIFIER_CTRL 0x0002 /* Ctrl key modifier */ |
Definition at line 118 of file uSynergy.h.
#define USYNERGY_MODIFIER_LEVEL5LOCK 0x0040 /* Level5Lock key modifier */ |
Definition at line 123 of file uSynergy.h.
#define USYNERGY_MODIFIER_META 0x0008 /* Meta key modifier */ |
Definition at line 120 of file uSynergy.h.
#define USYNERGY_MODIFIER_NUMLOCK 0x2000 /* NumLock key modifier */ |
Definition at line 125 of file uSynergy.h.
#define USYNERGY_MODIFIER_SCROLLOCK 0x4000 /* ScrollLock key modifier */ |
Definition at line 126 of file uSynergy.h.
#define USYNERGY_MODIFIER_SHIFT 0x0001 /* Shift key modifier */ |
Keyboard constants.
Definition at line 117 of file uSynergy.h.
#define USYNERGY_MODIFIER_WIN 0x0010 /* Windows key modifier */ |
Definition at line 121 of file uSynergy.h.
#define USYNERGY_NUM_JOYSTICKS 4 /* Maximum number of supported joysticks */ |
Constants and limits.
Definition at line 101 of file uSynergy.h.
#define USYNERGY_PROTOCOL_MAJOR 1 /* Major protocol version */ |
Definition at line 103 of file uSynergy.h.
#define USYNERGY_PROTOCOL_MINOR 4 /* Minor protocol version */ |
Definition at line 104 of file uSynergy.h.
#define USYNERGY_RECEIVE_BUFFER_SIZE 4096 /* Maximum size of an incoming packet */ |
Definition at line 110 of file uSynergy.h.
Definition at line 109 of file uSynergy.h.
Definition at line 108 of file uSynergy.h.
#define USYNERGY_TRUE 1 /* True value */ |
Definition at line 73 of file uSynergy.h.
typedef int uSynergyBool |
Boolean type.
Definition at line 71 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
format | Clipboard format |
data | Memory area containing the clipboard raw data |
size | Size of clipboard data |
Definition at line 305 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
Definition at line 149 of file uSynergy.h.
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.
Definition at line 207 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
joyNum | Joystick number, always in the range [0 ... USYNERGY_NUM_JOYSTICKS> |
buttons | Button pressed mask |
leftStickX | Left stick X position, in range [-127 ... 127] |
leftStickY | Left stick Y position, in range [-127 ... 127] |
rightStickX | Right stick X position, in range [-127 ... 127] |
rightStickY | Right stick Y position, in range [-127 ... 127] |
Definition at line 289 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
key | Key code of key that was pressed or released |
modifiers | Status of modifier keys (alt, shift, etc.) |
down | Down or up status, 1 is key is pressed down, 0 if key is released (up) |
repeat | Repeat 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.
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.
cookie | Cookie supplied in the Synergy context |
x | Mouse X position |
y | Mouse Y position |
wheelX | Mouse wheel X position |
wheelY | Mouse wheel Y position |
buttonLeft | Left button pressed status, 0 for released, 1 for pressed |
buttonMiddle | Middle button pressed status, 0 for released, 1 for pressed |
buttonRight | Right button pressed status, 0 for released, 1 for pressed |
Definition at line 254 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
buffer | Address of buffer to receive data into |
maxLength | Maximum amount of bytes to write into the receive buffer |
outLength | Address of integer that receives the actual amount of bytes written into buffer |
Definition at line 181 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
active | Activation flag, 1 if the screen has become active, 0 if the screen has become inactive |
Definition at line 234 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
buffer | Address of buffer to send |
length | Length of buffer to send |
Definition at line 164 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
timeMs | Time to sleep the current thread (in milliseconds) |
Definition at line 195 of file uSynergy.h.
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.
cookie | Cookie supplied in the Synergy context |
text | Text to be traced |
Definition at line 221 of file uSynergy.h.
Clipboard types.
Enumerator | |
---|---|
USYNERGY_CLIPBOARD_FORMAT_TEXT | |
USYNERGY_CLIPBOARD_FORMAT_BITMAP | |
USYNERGY_CLIPBOARD_FORMAT_HTML |
Definition at line 89 of file uSynergy.h.
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.
context | Context to be initialized |
Definition at line 570 of file uSynergy.c.
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.
context | Context to send clipboard data to |
text | Text to set to the clipboard |
Definition at line 603 of file uSynergy.c.
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.
context | Context to be updated |
Definition at line 583 of file uSynergy.c.