libgdx/libgdx — pull request #881 by 3xp0n3nt (2013-10-28 22:35:23+00:00)
Title: Add support for custom cursors on desktop.

Added support for setting a custom mouse cursor on the desktop. I added the setCursorImage method to the Input interface, since it seemed like the best place to put it - right underneath setCursorPosition.

Only LwjglInput has a non-empty implementation for now; I don't know if this is viable on any other platform - it's intended for desktop-only right now.

The method takes a Pixmap and hotspot params; a Pixmap works well for handling all of the byte juggling required by LWJGL's finicky Cursor class, since the final cursor image data must be an IntBuffer in ARGB8888 format, vertically flipped to allow for a lower-left origin, and only single-bit alpha transparency is supported (i.e., 0x00 or 0xFF).

The method works flawlessly on OSX 10.6.8 (Snow Leopard); it hasn't been tested on Windows or Linux. It works fine by loading the cursor image file via an AssetManager, and then passing the loaded Pixmap straight into the method. I'm sure there are other ways to load a Pixmap, but that's the only way I tested it with.

Please forgive the faux changes in IOSInput.java - there were nasty ^M characters floating around in there, and my git settings remove them automatically. I don't think they should be there anyway, so hope that's not a problem. ;)