I am quite happy with the Joystick driver for Linux GitHub - ufechner7/Joysticks.jl: Joystick interface for Julia , but now people also want to have it on Windows.
That seams to be difficult. As far as I understand there are two options
Use a Windows API, e.g. DirectX
Using a cross-platform intermediate library like SFML , SDL , ClanLib oder Allegro
As far as I know option one will not work because this is a C++ interface with a lot of proprietary extensions and Julia can only access C libraries directly.
For option two I looked at SDL for which Julia bindings exist, but they are more or less unmaintained and at least one serious bug is in the binding. See: GitHub - JuliaMultimedia/SimpleDirectMediaLayer.jl: SDL2
I did not look at SFML, ClanLib or Allegro yet.
Any suggestions how to proceed?
Update: There are bindings for SFML GitHub - zyedidia/SFML.jl: A binding of the game and multimedia library SFML for Julia , but they look unmaintained and cannot be installed on a current Julia version.
Perhaps one more option: GitHub - chengchingwen/Raylib.jl: Julia wrapper for the raylib videogames programming library
1 Like
First finding: The mouse driver example for Raylib works. Next question: Does the joystick support work?
https://github-wiki-see.page/m/raysan5/raylib/wiki/raylib-input-system
Palli
May 22, 2022, 10:06pm
3
Note this one installs:
and startup is fast:
julia> @time using CSFML
0.592167 seconds (1.17 M allocations: 55.937 MiB, 1.58% gc time, 19.78% compilation time)
I’m on Linux so I didn’t test Windows, nor further than this. I believe it’s a replacement.
I did see some PR for the other, and tried to see how far I would get (maybe not a lot of work to fix the rest, if at all needed):
(v0.7) pkg> add https://github.com/zyedidia/SFML.jl#69d9d1a
I could install it but then get some warnings plus:
julia> @time using SFML
[..]
Something has gone wrong with the SFML installation.
ErrorException("could not load library \"libsfml-graphics\"\nlibGLEW.so.1.10: cannot open shared object file: No such file or directory")
1.817890 seconds (3.01 M allocations: 151.960 MiB, 1.92% gc time)
1 Like
On Debian you can install the package libsfml-dev
which will also install all dependencies.
Palli
May 22, 2022, 10:26pm
6
Hope the other option CSFML.jl just works for you, because:
Despite (on Ubuntu):
$ sudo apt-get install libsfml-dev
and rm SFML.jl just in case, then again, for me at least:
(v0.7) pkg> add https://github.com/zyedidia/SFML.jl#69d9d1a
[..]
Building SFML → `~/.julia/packages/SFML/O6kxz/deps/build.log`
┌ Error: Error building `SFML`:
[..]
ERROR: LoadError: UndefVarError: JULIA_HOME not defined
│ Stacktrace:
[..]
│ in expression starting at /home/pharaldsson_sym/.julia/packages/SFML/O6kxz/deps/build.jl:148
│ Downloading SFML...
│ Downloading CSFML...
â”” @ Pkg.Operations /buildworker/worker/package_linux64/build/usr/share/julia/stdlib/v0.7/Pkg/src/Operations.jl:1068
add GitHub - zyedidia/SFML.jl: A binding of the game and multimedia library SFML for Julia
Something has gone wrong with the SFML installation.
ErrorException(“could not load library "libsfml-graphics"\nlibGLEW.so.1.10: cannot open shared object file: No such file or directory”)
5.380880 seconds (3.73 M allocations: 188.123 MiB, 1.73% gc time)
Thanks for investigating!
First success:
using GLFW
present = GLFW.JoystickPresent(GLFW.JOYSTICK_1)
returns true
And this also works:
while true
axis = GLFW.GetJoystickAxes(GLFW.JOYSTICK_1)
buttons = GLFW.GetJoystickButtons(GLFW.JOYSTICK_1)
println(axis, " ", buttons)
sleep(0.1)
end
2 Likes