DefOS - Extra native OS functions


This would make a great addition to the Asset portal! Nudge, nudge


No, the FFI module doesn’t do any of that stuff.

I did have a slightly different issue with maximizing/full screen with the FFI module. Sometimes if I maximize the window, toggle fullscreen, and toggle fullscreen off again, the window would be oversized, so the top bar was outside of the screen. Sometimes it worked fine though, I never found out what exactly caused it. Toggling fullscreen from a non-maximized window worked perfectly.

Thanks a lot for your efforts on this!


Is there a generic “Defold Community” account label you could add it through?


It’s works fine on windows 7.
Can you replace master with updated NE version? (I can do this, if you want)
I want to add some new functionality to DefOS that I need for my game. But NE I like more than FFI =)


Merged. I also create an issue for the thing @ross.grams reported a while back.


I’d really like to send some thumbs up and big hugs to @dapetcu21, @pkeod, @AGulev and @ChaosYu for the great collaboration on this repo. It’s beautiful open source collaboration in the making! Well done guys.


You’ve contributed too so thank you!

There will likely be breaking API changes soon anyone using DefOS now can switch to using the v1.0.0 release to avoid having your game break unexpectedly - otherwise the changes won’t be too much trouble to adapt to.

Anyone experienced with Linux programming should consider helping to get support for the Linux target added.


There is now the ability with DefOS to change the hardware cursor thanks to @ChaosYu and @dapetcu21 who has also done good and thoughtful quality of life changes to the project. There is also the ability to clip the cursor to the window view area, lock the cursor to a position (while still getting dx,dy - useful with first person shooters for rotation), set the cursor position, and resize the actual window view area and not just the window itself so that you can get accurate scaling such as when making a pixel art game and wanting to give the user quick options to scale the game window to 1x,2x,4x scaling.

While software cursors are useful, they are tied to the FPS of the project, and if the project lags the cursor will lag too. With hardware cursors, your custom cursor in game will appear to move much more smoothly and also hide some of the situations where you can’t avoid lag in game such as inbetween screen transitions. Generally you should always use the hardware cursor option unless you have a good reason not to.

There is one problem still which is not solved and it is that with macOS cursor locking is not currently giving the dx,dy properly when the cursor is locked. We need assistance from Defold team to solve this if possible. @sven @Mathias_Westerdahl @britzl


hardware cursor!!! :tada::tada:


Is Linux support planned?

#53 :slight_smile:


I posted on a few Linux communities asking for an expert to contribute but didn’t get any luck.

If anyone out there wants to give it a shot that would be excellent! I was planning on using GLFW2/3 as references.



Dependency URL:

Add this to your game.project:

Breaking changes:

  • enable_mouse_cursor() and disable_mouse_cursor() have been renamed to set_cursor_visible().
  • toggle_maximize() has been renamed to toggle_maximized().
  • If you want to center the window in the center of the screen, use set_window_size(nil, nil, width, height) instead of set_window_size(-1, -1, width, height).

New features:

  • Precisely set/get the position and resolution of the game view only (without the containing window).
  • Change the mouse cursor type between a selection of system cursors and even set custom hardware cursors.
  • Programatically move the mouse cursor to an arbitrary position.
  • Lock the mouse cursor to a position while still receiving dx and dy (useful for FPS controls).
  • Clip the cursor within the screen bounds.
  • Additional getters and setters for existing features.
  • A callback for onclick on HTML5 to work around permission issues when using toggle_fullscreen() and the likes.


This release made possible thanks to @dapetcu21 @AGulev and @ChaosYu
Send them some thanks and love!


Dependency URL:

Add this to your game.project:


  • move_cursor_to() has been renamed to set_cursor_pos_view(). Old name still available.

New features:

  • Linux support.
  • Query attached displays, their placement on the desktop and supported resolution modes.
  • Get the current cursor position with get_cursor_pos()/get_cursor_pos_view().
  • Get the path to the game installation directory.
  • Get the command line arguments passed to the game’s executable.
  • Toggle “always on top” for the game window.
  • Minimize the window.
  • Set the window icon programatically.

Bug fixes:

  • Fix wrong reporting of window size and position on Windows when window was maximized.
  • Fix cursor locking and clipping handling when window is unfocused on Windows.
  • Fix passing nil for x and y in set_window_size() and set_view_size() centered the window in the middle of the primary display instead of the current display.


New release:


Dependency URL:

Add this to your game.project:

New features:

  • load_cursor() function to load a cursor once and reuse it many times without loading it each time