DefOS - Extra native OS functions

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

4 Likes

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?

2 Likes

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 =)

1 Like

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

4 Likes

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.

4 Likes

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.

https://github.com/subsoap/defos/archive/v1.0.0.zip

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

6 Likes

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

6 Likes

hardware cursor!!! :tada::tada:

4 Likes

Is Linux support planned?

https://github.com/subsoap/defos/issues/37 :slight_smile:

1 Like

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.

4 Likes

v2.0.0

Dependency URL:

Add this to your game.project:

https://github.com/subsoap/defos/archive/v2.0.0.zip

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.
8 Likes

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

v2.1.0

Dependency URL:

Add this to your game.project:

https://github.com/subsoap/defos/archive/v2.1.0.zip

Deprecations:

  • 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.
16 Likes

New release:

v2.2.0

Dependency URL:

Add this to your game.project:

https://github.com/subsoap/defos/archive/v2.2.0.zip

New features:

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

Retina cursors on Linux:

v2.2.1

Dependency URL:

Add this to your game.project:

https://github.com/subsoap/defos/archive/v2.2.1.zip

Bug fixes:

  • High-DPI cursors are loaded correctly on Linux
8 Likes

I added an issue on the github repo regarding support for 1.2.170 and Emscripten 1.39.16.

3 Likes

Is there a reason why NSTrackingEnabledDuringMouseDrag not included as option for NSTrackingArea creation (defos_mac.mm, line 679)?

I need to take screenshots for my mobile game, and I’m using defos to set the view width and height.

When the values are larger than my monitor dimensions then the view width or height is clamped to fit my monitor.

Is there a way to show all the pixels, even if it goes well off-screen, so I can take my screengrabs at the size I need?

You can render stuff to a render target of any size you want and then save that.

2 Likes