Macros | Functions
uSynergy.c File Reference
#include "uSynergy.h"
#include <stdio.h>
#include <string.h>
Include dependency graph for uSynergy.c:

Go to the source code of this file.

Macros

#define USYNERGY_IS_PACKET(pkt_id)   memcmp(message+4, pkt_id, 4)==0
 Parse a single client message, update state, send callbacks and send replies. More...
 

Functions

static void sAddString (uSynergyContext *context, const char *string)
 Add string to reply packet. More...
 
static void sAddUInt16 (uSynergyContext *context, uint16_t value)
 Add uint16 to reply packet. More...
 
static void sAddUInt32 (uSynergyContext *context, uint32_t value)
 Add uint32 to reply packet. More...
 
static void sAddUInt8 (uSynergyContext *context, uint8_t value)
 Add uint8 to reply packet. More...
 
static int16_t sNetToNative16 (const unsigned char *value)
 Read 16 bit integer in network byte order and convert to native byte order. More...
 
static int32_t sNetToNative32 (const unsigned char *value)
 Read 32 bit integer in network byte order and convert to native byte order. More...
 
static void sProcessMessage (uSynergyContext *context, const uint8_t *message)
 
static void sSendJoystickCallback (uSynergyContext *context, uint8_t joyNum)
 Send joystick callback. More...
 
static void sSendKeyboardCallback (uSynergyContext *context, uint16_t key, uint16_t modifiers, uSynergyBool down, uSynergyBool repeat)
 Send keyboard callback when a key has been pressed or released. More...
 
static void sSendMouseCallback (uSynergyContext *context)
 Call mouse callback after a mouse event. More...
 
static uSynergyBool sSendReply (uSynergyContext *context)
 Send reply packet. More...
 
static void sSetDisconnected (uSynergyContext *context)
 Mark context as being disconnected. More...
 
static void sTrace (uSynergyContext *context, const char *text)
 Trace text to client. More...
 
static void sUpdateContext (uSynergyContext *context)
 Update a connected context. More...
 
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_IS_PACKET

#define USYNERGY_IS_PACKET (   pkt_id)    memcmp(message+4, pkt_id, 4)==0

Parse a single client message, update state, send callbacks and send replies.

Definition at line 205 of file uSynergy.c.

Function Documentation

◆ sAddString()

static void sAddString ( uSynergyContext context,
const char *  string 
)
static

Add string to reply packet.

Definition at line 81 of file uSynergy.c.

◆ sAddUInt16()

static void sAddUInt16 ( uSynergyContext context,
uint16_t  value 
)
static

Add uint16 to reply packet.

Definition at line 103 of file uSynergy.c.

◆ sAddUInt32()

static void sAddUInt32 ( uSynergyContext context,
uint32_t  value 
)
static

Add uint32 to reply packet.

Definition at line 116 of file uSynergy.c.

◆ sAddUInt8()

static void sAddUInt8 ( uSynergyContext context,
uint8_t  value 
)
static

Add uint8 to reply packet.

Definition at line 93 of file uSynergy.c.

◆ sNetToNative16()

static int16_t sNetToNative16 ( const unsigned char *  value)
static

Read 16 bit integer in network byte order and convert to native byte order.

Definition at line 41 of file uSynergy.c.

◆ sNetToNative32()

static int32_t sNetToNative32 ( const unsigned char *  value)
static

Read 32 bit integer in network byte order and convert to native byte order.

Definition at line 55 of file uSynergy.c.

◆ sProcessMessage()

static void sProcessMessage ( uSynergyContext context,
const uint8_t *  message 
)
static

Definition at line 206 of file uSynergy.c.

◆ sSendJoystickCallback()

static void sSendJoystickCallback ( uSynergyContext context,
uint8_t  joyNum 
)
static

Send joystick callback.

Definition at line 187 of file uSynergy.c.

◆ sSendKeyboardCallback()

static void sSendKeyboardCallback ( uSynergyContext context,
uint16_t  key,
uint16_t  modifiers,
uSynergyBool  down,
uSynergyBool  repeat 
)
static

Send keyboard callback when a key has been pressed or released.

Definition at line 172 of file uSynergy.c.

◆ sSendMouseCallback()

static void sSendMouseCallback ( uSynergyContext context)
static

Call mouse callback after a mouse event.

Definition at line 156 of file uSynergy.c.

◆ sSendReply()

static uSynergyBool sSendReply ( uSynergyContext context)
static

Send reply packet.

Definition at line 131 of file uSynergy.c.

◆ sSetDisconnected()

static void sSetDisconnected ( uSynergyContext context)
static

Mark context as being disconnected.

Definition at line 462 of file uSynergy.c.

◆ sTrace()

static void sTrace ( uSynergyContext context,
const char *  text 
)
static

Trace text to client.

Definition at line 69 of file uSynergy.c.

◆ sUpdateContext()

static void sUpdateContext ( uSynergyContext context)
static

Update a connected context.

Definition at line 476 of file uSynergy.c.

◆ 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