examples/vtouchpad/vtouchpad.c file

Main file.

Contents

Functions

auto parse_event(const char* ev, int* error) -> struct mouse_event
Given a string ev containing a single event, parses it as expected.
void onopen(ws_cli_conn_t* client)
On open event, just signals that a new client has been connected.
void onclose(ws_cli_conn_t* client)
On close event, just signals that a client has been disconnected.
void onmessage(ws_cli_conn_t* client, const unsigned char* msg, uint64_t size, int type)
For each new event, parses the string as expected all call the appropriate routines.

Function documentation

struct mouse_event parse_event(const char* ev, int* error)

Given a string ev containing a single event, parses it as expected.

Parameters
ev String representing the event.
error Set to 1 if an error was found, 0 otherwise.
Returns Returns a mouse_event structure.

The event can be (D stands to 'delimiter', currently ';'): (Mouse Movement): mouse_move D off_X D off_Y, where the offset is an integer type that represents the amount of pixels the mouse have to move. Example: mouse_move;10;-20.

Negative offsets represents movement to the left and to the top. Positive offsets are the opposite.

(Mouse Button Press): Represents if a mouse button has been pressed or released.

Valid events are: a) mouse_btn_left_down (left button press) b) mouse_btn_left_up (left button release) c) mouse_btn_right_down d) mouse_btn_right_up

void onopen(ws_cli_conn_t* client)

On open event, just signals that a new client has been connected.

Parameters
client Client connection.

void onclose(ws_cli_conn_t* client)

On close event, just signals that a client has been disconnected.

Parameters
client Client connection.

void onmessage(ws_cli_conn_t* client, const unsigned char* msg, uint64_t size, int type)

For each new event, parses the string as expected all call the appropriate routines.

Parameters
client Client connection. (ignored)
msg Received message/event.
size Message size (in bytes). (ignored)
type Message type. (ignored)