Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Add joystick support for OS X #195

Closed
scdwyer opened this issue May 22, 2012 · 7 comments
Closed

Add joystick support for OS X #195

scdwyer opened this issue May 22, 2012 · 7 comments
Labels
Enhancement Improve upon exiting functionality MacOS X Portability

Comments

@scdwyer
Copy link
Contributor

scdwyer commented May 22, 2012

Joystick support is needed for the nps sim (and old booz simulator) as well as input2ivy for manual control over a datalink.

Currently, joysticks are implemented using the built-in linux interface (#include <linux/joystick.h>).

As far as I know, there is no equivalent in OS X.

What are some options for joystick support in OS X?

With SDL, could possibly port the linux stuff over to that as well, and make everything consistent/cross platform. There are also Ocaml SDL bindings. It appears that FlightGear uses plib.

I don't know what would be easier to port existing linux code to.

@lamestllama
Copy link
Member

Hi Steven

I was going to use SLD as it is supported in windows too. I just haven't had any time to devote to it yet. SDL uses a polled idea wheres the current linux stuff uses a callback mechanism that I didn't have time to work out.

Eric

On 22/05/2012, at 1:38 PM, scdwyer wrote:

Joystick support is needed for the nps sim (and old booz simulator) as well as input2ivy for manual control over a datalink.

Currently, joysticks are implemented using the built-in linux interface (#include <linux/joystick.h>).

As far as I know, there is no equivalent in OS X.

What are some options for joystick support in OS X?

With SDL, could possibly port the linux stuff over to that as well, and make everything consistent/cross platform. There are also Ocaml SDL bindings. It appears that FlightGear uses plib.

I don't know what would be easier to port existing linux code to.


Reply to this email directly or view it on GitHub:
#195

@scdwyer
Copy link
Contributor Author

scdwyer commented May 22, 2012

Hi Eric

I was thinking SDL would be convenient and easy as well (and thought about the windows compatibility). In looking at the code that uses joysticks (input2ivy and nps), it looks like it would be rather easy to use SDL (I suspect far less code than current implementations) because it appears that the programs looking for joystick input both essentially use a polled method anyways. In input2ivy, the ocaml program calls a joystick init function and then repeatedly calls a joystick update function (both external c functions) which could easily be rewritten to used SDL (I think). The same goes for nps, it copies in the new joystick values at a periodic rate. Currently values seem updated by events with some Gtk help, but there doesn't seem to be a reason not to be able to call an update function just prior to copying values.

Thoughts?

-Stephen

@scdwyer
Copy link
Contributor Author

scdwyer commented May 27, 2012

I started experimenting with SDL, very easy to use.

One thing, I haven't found a way to specify the joystick by device (i.e. js0) like you would normally do in the joystick programs on linux. Should everything be moved to SDL-based support? Basically right now you select a joystick by number of which each one is assigned an index by SDL (0, 1, 2,...). There is also the option of somehow specifying by joystick name. For one joystick attached I don't think it will matter much, should always be the only one, linux or OS X.

Should there be some sort of central joystick handler/SDL framework? Or just initialize SDL and select joystick in the current init functions and then read joystick state in the update function (make one if currently not used, like in nps)?

@lamestllama
Copy link
Member

Steven

On 27/05/2012, at 4:15 PM, scdwyer wrote:

I started experimenting with SDL, very easy to use.

Cool

One thing, I haven't found a way to specify the joystick by device (i.e. js0) like you would normally do in the joystick programs on linux. Should everything be moved to SDL-based support? Basically right now you select a joystick by number of which each one is assigned an index by SDL (0, 1, 2,...). There is also the option of somehow specifying by joystick name. For one joystick attached I don't think it will matter much, should always be the only one, linux or OS X.

Should there be some sort of central joystick handler/SDL framework? Or just initialize SDL and select joystick in the current init functions and then read joystick state in the update function (make one if currently not used, like in nps)?
A centralized handler makes a lot of sense because it means we wrap any difficulties in implementation and make sure all the applications that make up paparazzi use the joystick in a consistent fashion.

Eric

@scdwyer
Copy link
Contributor Author

scdwyer commented Jun 13, 2012

Another option for this would be to update input2ivy to use SDL for joystick support. Then input2ivy could be used in current applications, and a small ivy listener written in C could be added to NPS in place of nps_radio_control_joystick.[c][h] instead of reimplementing the joystick support twice. This also allows all of the configuration handling of input2ivy to be used for NPS (right now extremely minimal/hardcoded). Might need a bit of extra configuration for NPS, but the feature set would be considerably enhanced.

In converting input2ivy to use SDL, either ocamlsdl could be used (libsdl-ocaml-dev on debian, ocamlsdl on macports) which would mean input2ivy doesn't need the c-ocaml bindings any more, or just modify the existing usb_stick.[c][h] to use SDL instead of linux/joystick.h.

Thoughts on this? I don't know how up to date the ocamlsdl stuff is.

@flixr
Copy link
Member

flixr commented Jun 13, 2012

I haven't looked at plib, but SDL sounds good :-)
Having a centralized handler/wrapper than can be used by different programs might be nice, but I'm not sure how much there actually needs to be still wrapped...

Updating input2ivy to use SDL sounds good, but I would rather make a new input option for this in nps (radio_control_ivy or so).

@flixr
Copy link
Member

flixr commented Jun 30, 2012

merged into master...

@flixr flixr closed this as completed Jun 30, 2012
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Enhancement Improve upon exiting functionality MacOS X Portability
Projects
None yet
Development

No branches or pull requests

3 participants