(2014-12-16, 04:17)techmunk Wrote: Not exactly what you want, but it might help... http://www.signal11.us/oss/udev. I'm not sure if the hidraw part is correct for what is desired here.
(2014-12-16, 16:13)OmniBlade Wrote: Retroarch has code in it for enumerating devices from udev and as a fall back udev should probably be preferred as the old joystick api is deprecated and isn't guaranteed to be available whereas udev almost certainly is. SDL defaults to using udev anyhow as I believe it gives slightly better latency.
(2014-12-17, 12:32)Wintermute0110 Wrote: for udev Linux joystick code SDL2 itself is a very good reference. Have a look at, http://hg.libsdl.org/SDL/file/704a0bfecf...joystick.c
Also, I've doing a SDL/SDL2 joystick/gamepad implementation for RBDoom3-BFG. I created some small joystick testing programs with hot-plug and gamepad support. I think implementing SDL2 gamepad support it is a very important feature that Kodi should include ASAP. It allows any user to create a universal mapping from his/her joystick to a know gamepad layout that every SDL2 aplication can use. Please have a look here and hope it helps,
https://github.com/Wintermute0110/RBDOOM...ster/utils
These are great resources, thank you guys.
Now I have a little present for you
As I mentioned before, I decided to move the platform-specific joystick code to binary add-ons. I created a new kind of add-on, "peripheral add-on", that can offer one or more types of peripherals. Currently, only joysticks can be offered. Next on my list, media readers like the Retrode will let you download ROMs from cartridges, launch games instantly by plugging them in, upload save games, etc. OFC we must "change one thing at a time". Media readers should only come after we've finished the API for joysticks.
The central repo for peripheral add-ons is now available at
https://github.com/garbear/xbmc-peripheral-addons
The initial version supports 4 APIs: DirectInput, XInput (for windows), SDL v1 and the Linux Joystick API. The Joystick add-on is based on my work for RetroPlayer, so there's some SDL fixes between Gotham and Helix that need to be incorporated. Full list here:
https://github.com/xbmc/xbmc/commits/Hel...ystick.cpp . The important change, SDLv1 -> SDLv2, is
PR:5364
Windows and Linux build right now. I haven't finished implementing peripheral add-ons in Kodi yet. I'll try to finish by the weekend so that we can load the add-on and test it out.
The code is meant to be run both as an add-on and a standalone app, so until then, someone could easily test by replacing the addon.cpp entry point with a main.cpp and compiling as an executable. Logging will intelligently switch between stdout and Kodi's log system, depending on if the code is loaded as an add-on or run as an executable.
Feel free to play around with the joystick code so far. Joystick APIs and logging is included, the Key Mapper and persistent storage are still empty folders. Persistent storage for keymaps could include a local XML dump, frontend-provided storage like a central MySQL database, cloud storage, read-only remote databases (like the
SDL Game Controller DB) and read-write remote DBs (to allow for "voting" on keymaps and data curation).