From 841052f7731c05e0f03d58284bfe8d249f91c109 Mon Sep 17 00:00:00 2001 From: Tom Harley Date: Thu, 4 Nov 2021 10:22:52 +0000 Subject: Initial commit --- SDL2_vnc.h | 81 ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ 1 file changed, 81 insertions(+) create mode 100644 SDL2_vnc.h (limited to 'SDL2_vnc.h') diff --git a/SDL2_vnc.h b/SDL2_vnc.h new file mode 100644 index 0000000..c6d4234 --- /dev/null +++ b/SDL2_vnc.h @@ -0,0 +1,81 @@ +#ifndef _SDL2_VNC_H +#define _SDL2_VNC_H + +#include +#include +#include + +#include + +typedef struct { + size_t size; + void *data; +} vnc_buf; + +typedef struct { + uint8_t bpp; + uint8_t depth; + uint8_t is_big_endian; + uint8_t is_true_colour; + + uint16_t red_max; + uint16_t green_max; + uint16_t blue_max; + + uint8_t red_shift; + uint8_t green_shift; + uint8_t blue_shift; +} vnc_pixel_format; + +typedef struct { + uint16_t w; + uint16_t h; + vnc_pixel_format fmt; + uint32_t name_length; + char *name; +} vnc_server_details; + +typedef struct { + uint16_t r; + uint16_t g; + uint16_t b; +} colour_map_entry; + +typedef struct { + colour_map_entry *data; + size_t size; +} vnc_colour_map; + +typedef struct { + int socket; + vnc_buf buffer; + SDL_Surface *scratch_buffer; + vnc_server_details server_details; + SDL_Surface *surface; + SDL_Thread *thread; + unsigned int fps; + vnc_colour_map colour_map; +} SDL_vnc; + +typedef enum { + SDL_VNC_ERROR_OOM, + SDL_VNC_ERROR_COULD_NOT_CREATE_SOCKET, + SDL_VNC_ERROR_COULD_NOT_CONNECT, + SDL_VNC_ERROR_SERVER_DISCONNECT, + SDL_VNC_ERROR_UNSUPPORTED_SECURITY_PROTOCOLS, + SDL_VNC_ERROR_SECURITY_HANDSHAKE_FAILED, + SDL_VNC_ERROR_UNIMPLEMENTED, + + OK = 0 +} SDL_vnc_result; + +SDL_vnc_result init_vnc_connection(SDL_vnc *vnc, char *host, unsigned int port, + unsigned int fps); + +int wait_on_vnc_connection(SDL_vnc *vnc); + +int key_event(SDL_vnc *vnc, bool pressed, SDL_Keysym key); +int pointer_event(SDL_vnc *vnc, uint32_t button_mask, uint16_t x, uint16_t y, + int32_t mw_x, int32_t mw_y); + +#endif /* _SDL2_VNC_H */ -- cgit v1.2.1