Hard Light Productions Forums

Modding, Mission Design, and Coding => FS2 Open Coding - The Source Code Project (SCP) => Cross-Platform Development => Topic started by: membrana on November 03, 2007, 05:12:40 pm

Title: Does Force Feedback work under OS X?
Post by: membrana on November 03, 2007, 05:12:40 pm
well, this is a simple question really, but i just want to clarify the whole thing.
i  just downloaded FS2 Open and tested it a little and its great. graphics and sounds are greatly improved, and with Soulstrom's Launcher its really easy for me to play user-made campaigns and the like.
the problem is that i do not own a joystick, so i'm planning on buying one.
i want one with Force Feedback ( since i never had one with that feature  :( ), but i've been reading old posts stating that FF and HATs do not work in OS X...
also i read about GamePad Companion, but i won't be able to test it until i buy the joystick...
so...
i was planning on buying either the
Logitech Joystick Force™ 3D Pro (http://www.logitech.com/index.cfm/gaming/pc_gaming/joysticks/devices/297&cl=us,en) or the
Saitek Cyborg evo Force Feedback Joystick (http://saitek.com/uk/prod/evoforce.htm)
has anyone tested this joysticks under OS X?
has anyone tested another fully supported joystick under OS X?

thanks for all your help!!!
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on November 03, 2007, 07:03:48 pm
Force feedback isn't supported, at the moment.  I coded up FF support for Linux a few years ago but I was never able to get it working 100% (mostly due to my old hardware I'm sure) and so I never introduced it.  OS X FF support was to be next on my list but I never had, and still don't have, any way to actually test it.

One of these days I'm finally going to have enough time to write the code, but it's pretty low priority at the moment.
Title: Re: Does Force Feedback work under OS X?
Post by: membrana on November 03, 2007, 07:35:22 pm
well... i'm no coder at all, but if there's anything i can do to help bringing Force Feedback to FS2 on OS X, please let me know.

thanks for all your effort talyor!
Title: Re: Does Force Feedback work under OS X?
Post by: ni1s on November 06, 2007, 10:18:47 am
Force feedback isn't supported, at the moment.  I coded up FF support for Linux a few years ago but I was never able to get it working 100% (mostly due to my old hardware I'm sure) and so I never introduced it.  OS X FF support was to be next on my list but I never had, and still don't have, any way to actually test it.

One of these days I'm finally going to have enough time to write the code, but it's pretty low priority at the moment.
If it's way down on your list, maybe you could post the diff of the code you have. I would like to take a stab at it, and maybe by MS Sidewinder 2 FF won't just be an ugly block of plastic sitting on my desk...
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on November 06, 2007, 11:50:41 am
If it's way down on your list, maybe you could post the diff of the code you have. I would like to take a stab at it, and maybe by MS Sidewinder 2 FF won't just be an ugly block of plastic sitting on my desk...
You are welcome to it ... if you are willing to brave the horror.  ;)

http://icculus.org/~taylor/fso/misc/joy_ff-unix.cpp.gz

I don't have a diff for FSO, since the code was written against the icculus.org version, so this is just the single source file.  It should be simple enough to get into FSO though.  I think that the only change beyond this one file as for the joystick init code to pass the joystick name that SDL was using, so that the joystick SDL was going to use and the joystick that the FF was going to use would be the same.

Keep in mind several things though (before you think that this will actually work):

Title: Re: Does Force Feedback work under OS X?
Post by: iadesdragon on May 21, 2010, 10:02:30 am
Still hoping for Force Feedback with OSX...

maybe this helps?

http://www.apple.com/downloads/macosx/development_tools/iauxinpcinputdeviceapilibrary.html

Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on May 21, 2010, 12:39:21 pm
It may.  It may help SDL to access the devices on OSX, or it may help us access them directly, bypassing SDL.  Who knows?  :)
Title: Re: Does Force Feedback work under OS X?
Post by: iadesdragon on May 21, 2010, 03:56:17 pm
It seems to Be multiplatform and free for noncomercial use at least.

So this could serve as Common Solution
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on May 21, 2010, 08:48:34 pm
Holy crap, it IS cross platform.  I didn't notice, what with that being on Apple's website, and the name starting with 'i', just assumed it was an Apple only thing.  There's a very good chance we could replace our joystick handling with that then, possibly all input sources.
Title: Re: Does Force Feedback work under OS X?
Post by: iadesdragon on May 23, 2010, 08:51:23 am
Yes, same to me, idn´t realize it is multi platform until i followed the link.

To bad i'm not into PC/OSX/Linux programing, no chance to imlement this myself...
Title: Re: Does Force Feedback work under OS X?
Post by: Iss Mneur on May 23, 2010, 10:53:07 am
Holy crap, it IS cross platform.  I didn't notice, what with that being on Apple's website, and the name starting with 'i', just assumed it was an Apple only thing.  There's a very good chance we could replace our joystick handling with that then, possibly all input sources.

Yes, but it is shareware.  According the vendors website it is free for non-commercial and educational uses, but I was unable to find the actual verbiage of the license. So whether we are allowed to use this as part of FSO I can't tell.  Also, because it would be released to us as a binary blob like TrackIR, it would have to be yet another external dependency.

Though, I have to say, the feature list looks nice.
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on May 23, 2010, 02:10:28 pm
External dependencies shouldn't be much of an issue down the line.  And we are non-commercial so I don't really see an issue with that.
Title: Re: Does Force Feedback work under OS X?
Post by: iadesdragon on May 23, 2010, 05:23:01 pm
It states however in the licensing ruls thatone needs to Show the Logo and the credits someplace reveringt to the use of the Lib.

Maybe we should simply ask this Guy about it. I believe he can Sport some Press.

Seems to be a rather Small russian Company.


Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on May 23, 2010, 10:13:06 pm
Sporting the logo would be difficult since the existing retail content can't be modified.  We could only do that in the MediaVPs and future total conversions.  Credits we can do I think.
Title: Re: Does Force Feedback work under OS X?
Post by: iadesdragon on May 24, 2010, 12:22:10 pm
Maybe it's good enough to show the Label next to the force feedback setup in launcher. Or even have a specific page in launcher that allows for changes to the Force Feedback behavior (since never any changes where made to the original game interface this should be the only place for such a thing ).

I`m quit willing to do debug testing on Windows and OSX since i run an iMAC using boot camp.

As said before i am an experienced embedded control guy an am fluent with C (as well as a little bite Objective C and C++ )

but i have no clue of the OS Based programming like Windows or OSX....
Title: Re: Does Force Feedback work under OS X?
Post by: iadesdragon on May 24, 2010, 12:22:56 pm
oh and just forgot to mention i've got an Logitech Force 3D at hand...

Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on May 24, 2010, 01:50:39 pm
I've got a Saitek Cyborg 3d Rumble still.  I have a Force Feeback Pro but it's gameport only, and even with a 3dpvert the FF doesn't work.
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on May 27, 2010, 06:46:25 pm
It states however in the licensing ruls thatone needs to Show the Logo and the credits someplace reveringt to the use of the Lib.
I didn't see anything about having to show a logo or anything.  A credit/copyright, yes, but we already have that for several other libs we use in the credits screen in-game so that wouldn't be an issue.


But, I really don't like the idea of using iAuxINP.  I duplicates a lot of functionality that SDL already provides, but not nearly enough to replace it, and I really have to worry about negative effects due to the interaction of the two.  It would probably just be better in the long run for us for somebody to simply backport the Haptic API from SDL 1.3 to SDL 1.2 and then provide a custom lib for the people that really want FF support.  And I seem to remember a backport already existing somewhere, for WebOS I think, so it should be possible to do.  And then we would be one step closer to being ready for the next major SDL version as well.
Title: Re: Does Force Feedback work under OS X?
Post by: Echelon9 on May 28, 2010, 05:32:47 am
And then we would be one step closer to being ready for the next major SDL version as well.
taylor, do you have a list of what might be blocking us moving to the next SDL? I've never followed the SDL releases closely, so I'm not across the possible issues, and not sure what I should be working on.
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on May 28, 2010, 07:31:55 am
taylor, do you have a list of what might be blocking us moving to the next SDL? I've never followed the SDL releases closely, so I'm not across the possible issues, and not sure what I should be working on.
About the only thing blocking us from using the next SDL is: the next SDL. ;)

Seriously, it's a moving target.  I'm using it for another project and have had to rewrite some things several times because the API likes to change.  And recently the multi-input API (multiple keyboards/mice/joysticks/etc.) was ripped out, they went back to a simple API, and are going to redesign the multi-input API from scratch before adding it back.  So now I've got to rewrite all of my input for this other project to keep up with SDL 1.3 development, temporarily losing the multi-input support that I require, and then rewrite it all again to add multi-input back.  :(

But really, when it stabilizes I will be the first (and possibly only :sigh:) person to volunteer to port FSO over to the new SDL.  I just really like it a lot better than SDL 1.2.  And it would only take a single weekend to port FSO over as well, and that's if you try to take advantage of some of the new features.  We don't use that much of SDL (no sound, no threads, no graphics) that it would be at all difficult for us to move over to the new SDL when the time comes.
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on May 28, 2010, 09:30:40 am
On top of that, a lot of Linux platforms don't even have 1.3 in their package managers yet.  It'd be an install from source situation in those cases and likely cause people a lot of headache, just to try to get FF working.
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on May 28, 2010, 11:14:59 am
SDL 1.3 is a highly unstable API which isn't remotely ready for any type of release, so it shouldn't be in distros at all in the first place.  There isn't any point in worrying about it at this time, or even this year for that matter.

The haptic support in 1.3 is pretty stable and can be backported to 1.2 though, so if we want FF with the least amount of fuss then that's how we should do it.  It will be the same or less amount of work than getting iAuxINP in there, and users would have to install a lib by hand either way so that isn't an hit on either option (although in the SDL case they would have source as well).  The 1.2 backport means that the code will automatically be ready for 1.3 when the time eventually comes though and that means far less long term work than messing with iAuxINP.
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on May 28, 2010, 12:32:11 pm
Just curious, do you mean essentially doing this for an internal SDL lib, or going through SDL and providing them with the fruits of our labor?
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on May 28, 2010, 12:46:14 pm
Just an internal lib.  SDL 1.2 is frozen and I don't think there will be any more releases from it unless there is a major bug or something.  I seem to remember the conversation of putting haptic support in 1.2 as well but they didn't want to add to the API at this point.

I do believe that the work has mostly been done already though, since I'm pretty sure that Palm (or someone just working on the port) did all of the work for the WebOS version of SDL.  I remember seeing a diff for it against official 1.2, or something to that effect, which contained the haptic code.  SDL is LGPL of course, so the changes have to be released.

And it should be possible to set it up in the FSO code so that it will dynamically load the functions out of the SDL lib, so the special SDL lib wouldn't be required for existing functionality.  People that want FF could then just drop a single lib in the game directory and things should just work.


I think I might try and look into this over the weekend and see if I can find out exactly what it would take to do.
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on May 31, 2010, 06:08:18 pm
So as it turns out the haptic code was originally developed based on SDL 1.2.11 for GSoC.  I have now gotten current SDL 1.2 patched with this code, it compiles, and the haptic test binary works too!  I still need to track down any possible bug fixes that were made later, after it was merged into SDL 1.3, but that shouldn't be much of an issue.  After that it's just a matter of writing the FSO code.  :D

I'll see if I can find some time to whip up the necessary code for FSO later this week.  I'm not going to be able to produce any builds, but I can provide the necessary diffs for others to make some builds (both SDL and FSO).  Stay tuned...
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on June 02, 2010, 10:28:44 am
FSO code support pretty much done now.  The effects need to be tweaked a bit (damn near broke my hand when firing a missile for the first time, wasn't quite ready for that ;)) and it still needs to be made to not require the modified lib, but it is working in-game on Linux at least.  Should work even better under OS X too, since it has better OS level haptic support than Linux does.

This stuff really came together a lot faster and easier than I could have guessed.  Total time on both things (SDL and FSO) was probably about 6 hours.  I'll try and find an hour or two to finish up the code tomorrow and test it better, and then get the diffs out by the weekend. :)
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on June 02, 2010, 10:34:13 am
/me is happy.

And I don't even have a working FF joystick around!
Title: Re: Does Force Feedback work under OS X?
Post by: iadesdragon on June 02, 2010, 01:06:48 pm
but i have ;-) keep it rolling in i'll be testing :-)
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on June 02, 2010, 01:39:20 pm
This does mean we'll have to build against a custom SDL on Linux then I suppose?
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on June 02, 2010, 01:52:04 pm
Nope, it will be totally optional.  I'm going to include the necessary header info in there, so nothing new external will be required.  It should build just fine against normal SDL libs/headers.  When loading it will try to dynamically load the function ptrs out of the SDL lib, and if they are found then it will allow for use of haptic.  If the ptrs aren't found then FF will just be disabled and it will function like it always has.
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on June 03, 2010, 02:38:01 am
Dynamic usage code implemented and tested.  This is only tested under Linux so far, but the code should work the same on OS X builds.  It builds fine against default system SDL 1.2, runs fine with haptic disabled using default lib, and runs fine with haptic enabled using modified lib.  :D


Also, here is the haptic patch (http://icculus.org/~taylor/misc/sdl_1.2-haptic.diff.gz) for SDL 1.2.  I'm posting it now to give a couple days head start on getting a new framework built before the game patch is released this weekend.  Hopefully somebody will be able to take care of getting it built and ready for use.  Do note that the Xcode project hasn't been updated in the patch, so please send me those changes so that I can include them in an updated patch later on.

New files to add to project:
include/SDL_haptic.h
src/haptic/*
src/joystick/darwin/SDL_sysjoystick_c.h
src/joystick/linux/SDL_sysjoystick_c.h
src/joystick/win32/SDL_dxjoystick_c.h
test/testhaptic.c

And be sure to add the ForceFeedback framework to the project as well.
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on June 03, 2010, 10:39:23 am
And although it probably still needs a bit of work and testing, I'm going to go ahead and post the FSO patch as well in case I end up too busy this weekend to do it.

http://icculus.org/~taylor/fso/misc/fso_haptic.diff.gz

Remove from project file(s):
src/io/joy-unix.cpp

Add to project file(s):
src/io/joy-sdl.cpp
src/io/joy_ff-sdl.cpp
src/io/SDL_haptic.h

And with any luck, applied to trunk and built with nothing special, it should work just fine.  That should probably be the first test too.  If that works out then testing with the modified SDL framework would come next to see how well haptic actually works in-game for everyone other than me.

Do be warned that some of the effects might be a little strong though, so be prepared.  This is something that I'm definitely going to need feedback on from everyone to make sure all of the effects are set up properly.  We'll also probably have to work out some additional support for game pads (rumble) in the future.  Right now it will most likely only work with regular force joysticks.


Enjoy.  :)
Title: Re: Does Force Feedback work under OS X?
Post by: iadesdragon on June 14, 2010, 03:50:35 pm
i would really love testing but, sorrily i'm not set up for compiling the stuff myself...

is there a stupid guys guide to compiling FSO on Mac?

Title: Re: Does Force Feedback work under OS X?
Post by: Echelon9 on June 20, 2010, 12:25:17 am
i would really love testing but, sorrily i'm not set up for compiling the stuff myself...

is there a stupid guys guide to compiling FSO on Mac?
Ask, and you shall be rewarded. Here's a guide I've just written up (http://www.hard-light.net/wiki/index.php/Mac_Development_Guide), please let me know if it's clear enough or if any sections should be further detailed.
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on June 20, 2010, 02:54:25 pm
3.1.x on 10.5.x was working last I used it, can't check any more though.

And, even longer ago when I first started making Mac builds, it was on a Blue and White G3 running 10.4 and 2.5.x, and it worked then too.  But I believe there's been recent reports that we broke that since then.
Title: Re: Does Force Feedback work under OS X?
Post by: Echelon9 on June 21, 2010, 09:24:46 am
Yes, I remember 3.1.x on 10.5.x was working for me too, a fair few revisions ago now.

I'd like to keep it as 'Unknown' until we get a recent confirmation. Having said this, Xcode has improved so much over the last 2 years that developers should be using the most recent version available for their platform to get the most out of it.
Title: Re: Does Force Feedback work under OS X?
Post by: SiriusGrey on September 11, 2010, 10:29:45 am
Linux user here - it works (patched 3.6.12)!

Thanks taylor - this is the proper way to implement it :)

A quick note to Linux users: the device /dev/input/eventX must be _writable_ by the user you run fs2 as. There should probably be an automatic UDEV rule for this; but there is none currently in my distribution (Debian sid).

For me the effects were quite weak (Saitek Cyborg EVO Force) - I myself implemented a rather hackish linux-specific version of FF here: http://www.hard-light.net/forums/index.php?topic=67253.0 (http://www.hard-light.net/forums/index.php?topic=67253.0) and the effects were stronger there. Maybe the strength multiplier could be turned into a configuration option?

I'll be available for testing this further.

Cheers,
Sirius

My Procedure:

* download SDL-1.2.14 source; patch with taylors patch;
* sh autogen.sh; ./configure --prefix=/home/me/software/sdl-1.2; make -j3; make install
* checkout fs2_open_3_6_12 from svn; patch with taylors patch;
* sh autogen.sh --with-sdl-prefix=/home/me/software/sdl-1.2 --enable-inferno; make -j3
* LD_LIBRARY_PATH=/home/me/software/sdl-1.2 dev/fs2_open_3_6_12/code/fs2_open_INF_r -mod fs2,mediavps_3612
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on September 15, 2010, 10:34:46 am
Good to hear that it works for someone else. :)

The effects were rather strong for me so I was worried about it.  Not sure how we should handle it if there is a lot of variation among different joysticks.  I don't know if a strength multiplier is the best option overall, but I can't claim to know of any better options either.


Oh, and you really don't need to build FSO against the patched SDL either.  Just using your default system one should work fine.  There is only one additional header for SDL and it is included with the FSO patch so that nothing external would be required to build.
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on September 15, 2010, 10:54:20 am
So to use this on Mac/Linux, we need to:

Patch FSO in SVN
Update the Mac's Frameworks.tgz with a new SDL framework built with the patch
Have users compile their own SDL on Linux or include a custom lib for linux users

Is that about right?  I'm not really sure what to do to make it easy on the linux users, but it seems like we should be able to pull this off for Mac users with the way things are currently set up.  We need to update the Ogg framework still anyway, which we had a user looking at.
Title: Re: Does Force Feedback work under OS X?
Post by: taylor on September 15, 2010, 12:37:10 pm
Yeah, that's pretty much it.

For Linux users we can have a pre-compiled .so available, and they can have script actually set LD_LIBARARY_PATH properly to use the custom version in the game directory instead of the system version.  Still a bit more complicated than the OS X version of course, but not terribly difficult.
Title: Re: Does Force Feedback work under OS X?
Post by: chief1983 on September 15, 2010, 01:29:24 pm
So we can distribute the .so that they could just drop in their folder with a nightly build?  Sounds nice.