Free hardware cursor plugin for windows

Every good game engine supporting desktop systems should have a mechanism for easily setting custom cursors. This functionality is not freely available in solar2D so I made a plugin to enable it.

I do not own a mac or have any knowledge of apple development so I could only target windows.

Unfortunately there is a bug where the game crashes on exit if the plugin is not “freed” a few moments before exiting.
I do not know how to fix this problem and hope one of the forum members here has an idea what might be causing this and how it can be fixed. @vlads perhaps?

I suspect it has something to do with how the engine frees up memory when exiting.

The plugin is open source (but very bare bones as of now) if anyone would like to take a look.
https://github.com/ANSH3LL/plugin_hwcursor

2 Likes

Updated the github page. Also the plugin is now usable.

Hi.

On the shutdown side of things, you might have some luck making a userdata (possibly just a singleton) and registering the appropriate cleanup behavior as its __gc metamethod.

There are also separate issues as far as hardening against the simulator itself crashing, since some cursor calls operate at more of an OS granularity. I don’t know what the proper procedure is there.

Also, there were a couple of guys playing with this sort of thing a while back. Maybe I can dig up some links later. That said, there is also something of a cursor wishlist on desktop platforms. :slight_smile:

1 Like

Thank you for the suggestion. It seems like it might help even though I don’t really know how to implement it as I have little knowledge of the lua C API. I will look into it though.

The crashing only occurs if the window subclass procedure is not yet removed when the engine is shutting down. Oddly, even attempting to remove the subclassing at the WM_CLOSE and WM_DESTROY window messages does not help. Maybe it’s too late by then and the engine crashes with an access violation error.

Integrating this functionality directly into the engine would be a good idea… Anyone is free to use my code as a springboard should they decide to do this.

Update: the __gc metamethod did not stop the crashing, but I’ve found a workaround with only a minor inconvenience. The user will have to click the close button twice instead of just once, but there will be no more crashes whatsoever. The programmatic way is still available and preferred, but no longer necessary.

I’ve updated the plugin to v0.2 as well, so if anyone was already using it, please update the URL in your build.settings.

1 Like

I’ve updated the plugin to v0.3, with support for windows-provided cursors such as the pointing hand cursor and more. Check out the README on github as well as the example project to find out how to make use of this feature.

Don’t forget to also update the URL in your build.settings to https://github.com/ANSH3LL/plugin_hwcursor/releases/download/v0.3/win32-sim.tgz

1 Like

I’ve updated the plugin to v0.4, the error where the application would crash on exit as well as the inconvenient workaround have both been fixed.

Everything should now be working perfectly smoothly and the end user should experience no inconveniences whatsoever. Clicking the close button once should now close the application as expected.

Should there be any issues, feel free to open an issue on github or reply to this thread.

Don’t forget to update the URL in your build.settings to https://github.com/ANSH3LL/plugin_hwcursor/releases/download/v0.4/win32-sim.tgz

3 Likes