I've Made a SDL-VNC Client Library

Hullo!

TL;DR: SDL2_vnc: A companion library to SDL for working with VNC servers

For a bit of fun recently, I’ve been working on a library that provides access to an RFB via SDL surfaces. Originally, I started writing this so I could manipulate output from QEMU guest machines (as QEMU has a VNC server built-in), but I realised that the code was getting close to something that might be useful to other people, so I’ve spent a little time cleaning it up in the hopes someone else finds it useful!

As a library, this project provides functionality for initialising a VNC connection, and creating a thread that continually requests framebuffer updates from the server. Users can access a surface that’s continually updated by the server-watching thread to be an up-to-date representation of the RFB. An SDL_Event entry is registered for when the server closes the connection. Users can also send pointer and key events to the VNC server using straightforward functions.

I’ve also included a simple VNC client that acts as an example usage of the library.

I’ve tried to mirror the core SDL projects (SDL, SDL_ttf etc.) in how the library looks and functions from the perspective of a user. If you look at the commit log, you’ll see I renamed a lot of identifiers to match the naming style of those projects. I also plan on adding doxygen documentation for the user-facing functions. My library is licensed under the zlib licence, same as SDL2, for ease of use.

Before writing this, I was getting by by adapting a different SDL-VNC library I came across, that had been written for SDL1. I ended up changing the code enough that I figured a re-write would be useful, but thanks to A. Schiffler for the prior art! Unfortunately, the email address mentioned in that library’s source code is hosted at a domain that seems to have expired; if anyone knows how I could contact the creator, I’d appreciate it.

The working title for the library has been SDL2_vnc, though I understand that’s a generic enough name that it might conflict with someone else’s project; I’d be happy to change the name in this case.

SDL2_vnc can be found at the link at the top of this topic. Code review/suggestions are more than welcome, as are issues and contributions. If issues/contributions are difficult to do on that platform (I barely use it usually), I’d be happy to move the project to a different home.

I have a lot of ideas on how to improve/add to this project (for example adding any testing at all), but I’d love to hear suggestions from any interested parties! In particular, I’d really appreciate comments on my use of SDL in this project: I’ve done some small projects using SDL in the past but I’m sure there are still SDL features/quirks/best-practices I’m sleeping on. I would also really appreciate suggestions on VNC servers to test with: the QEMU implementation only uses a portion of the standard, and in particular the VMs I have been using (mostly SerenityOS) don’t support hardware pointers in QEMU so I get laggy pointers.

So yeah, I’d be happy to answer any questions anyone has, and hope that someone can find a use for this lil library of mine (:

I ended up changing the code enough that I figured a re-write would be useful, but thanks to A. Schiffler for the prior art! Unfortunately, the email address mentioned in that library’s source code is hosted at a domain that seems to have expired; if anyone knows how I could contact the creator, I’d appreciate it.

SDL2_gfx: SDL2_gfx - Graphics primitives and surface functions for SDL2 mentions an e-mail address which is at ferzkopp.net (so it probably still works)

1 Like