DefOS - Extra native OS functions

Pretty sure FFI isn’t available on Linux. I think I tested a few months ago and it wasn’t supported. It doesn’t work on Mac either.

FFI and LuaJIT are available on all platforms except html 5 and arm64. But there’s some kind of problem when building (not bundling) from editor 2.

2 Likes

Hi all.

I try bundling DefOS with Native Extension(for use on macOS) and receieve build error. Anyone can help?

Or maybe I can make FFI variant for macOS?

Yes, but you need to share the build error.

I can probably do this during next week. It would be great to get rid of the FFI stuff and only ship it as a native extension.

3 Likes

Ok. I show error later.

And thank you for make Native Extension for Windows. Or say what need to do for Windows. I try make it.

Bundle error

Temporary make FFI disable cursors function for macOS.

If anyone need it add to defos.lua next code:

if ffi.os == "OSX" then
	ffi.cdef([[
			int CGDisplayHideCursor();
			int CGDisplayShowCursor();
		]])
	function M.disable_mouse_cursor()
		C.CGDisplayHideCursor()
	end
	function M.enable_mouse_cursor()
		C.CGDisplayShowCursor()
	end
end

You can make for HTML5 disable cursors function too?

It can be done, best way will be to use Pointer Lock API.

I’ve pushed a version for windows using native extensions instead of FFI. Tested on Windows 10. It would be great if someone could try it on Win 7 or 8:

https://github.com/subsoap/defos/tree/dev/removeffi

7 Likes

I try on Win 7 some later. Today say.

What about error in bundle process?

Awesome!! I tried it on Windows 7. It builds and works fine, but when I bundle it the extension doesn’t seem to be included. I just get “attempt to index global ‘defos’ (a nil value)”. I’m using Editor 2, is that a problem, or am I missing something else?

A separate issue, I still have a weird issue with maximizing. I think I’ve narrowed it down—if, before toggling maximized or fullscreen from DefOS, I use the windows command (windows-button + up) to maximize the window, then toggle maximize from DefOS, the window vanishes completely. It doesn’t show up in the task bar or the task manager, but it’s still running and sending stuff to the editor console. The only way to stop it is to kill the dmengine.exe process from the task manager (or build from the editor again).

If I do Win+Up to maximize, then toggle fullscreen from DefOS, then toggle maximized or fullscreen back again from DefOS, it crashes.

So, if you feel like looking into it, that’s that. Now that I’ve figured out when it happens I can sort of get rid of the issue by disabling the maximize button from DefOS, though of course that’s not ideal.

1 Like

I repeat DefOS not bundle error in macos build.

1 Like

Yes, that should be an NSRect and not a CGRect. I’ve changed this. Could you please try building again?

2 Likes

Yes. Try now.

I build it, but please add fix for full version(I mean branch with Windows Native Extension).

Thank you.

Oh, sorry, I thought I had already fixed that on the branch as well as on master. Try again!

2 Likes

Thank you. All ok.

1 Like

Does this happen when you are using the extension from the master branch as well (ie with the Windows version running using LuaJIT FFI)?

1 Like