Page 1 of 2

Gamepad support, building with SDK 10.5

Posted: Sun Mar 28, 2010 10:04 am
by maik
I'm trying to hack gamepad support into Oolite using the HIDManager classes that are available as of OS X 10.5. For that I set the base SDK to 10.5 but now I receive a lot of errors complaining about
- conflicting types for uint64
- static declarations of class_getInstanceSize follow non-static declarations
- instance_size being deprecated

Does someone have experience with targeting 10.5 and already solved these issues?

Cheers,
-Maik

Posted: Sun Mar 28, 2010 10:11 am
by Cmdr James
I had similar problems, and so I always target an earlier version. I suspect that the problem is that snow leopard has 64bit ints, but I am not certain.

Posted: Sun Mar 28, 2010 10:31 am
by maik
Only Snow Leopard (10.6) or Leopard (10.5) as well? I'm targeting the latter.

Posted: Sun Mar 28, 2010 5:43 pm
by maik
OK, I solved the build problems targeting 10.5.

I also fleshed out the JoystickHandler class in the Mac-specific folder to the point where I can play using my XBOX360 gamepad--great fun :)

My modifications are against the current trunk revision. Current button and axis mappings are hard coded, unfortunately I didn't manage to bring up the joystick mapping configuration view.

What is the preferred way of submitting a patch set so that others can play around with it? As I have no experience in multi-platform development there might be compile problems somewhere else now although I have been careful, so I'd very much like feedback on this.

Cheers,
-Maik

Posted: Mon Mar 29, 2010 8:30 am
by another_commander
maik wrote:
What is the preferred way of submitting a patch set so that others can play around with it? As I have no experience in multi-platform development there might be compile problems somewhere else now although I have been careful, so I'd very much like feedback on this.
You can email it to me (check email button below for details) and I can forward it as required. You can also put it up on pastebin and give us the link. There is no preferred way, just whatever suits you best. If it is a short patch, you could even consider posting it here.

Posted: Mon Mar 29, 2010 9:40 am
by maik
OK, here are the pastebin links:

The new JoystickHandler replaces the existing skeleton in Source/Mac-specific in the XCode project. It depends on the HIDManager that has been introduced with OS X 10.5 Leopard:

JoystcikHandler.h: http://pastebin.com/8pX7AmKu
JoystickHandler.m: http://pastebin.com/9tBhepCS

To allow targeting the Leopard SDK, three definitions have to be changed. Anyone with non-Leopard systems please report if they break anything:

In Universe.m (around line 198), and in Entity.m (around line 49) add the highlighted lines from http://pastebin.com/5CVs8RKB (line numbers based on SVN revision 3083).

In deps/Cross-platform-deps/SpiderMonkey/js/src/jsotypes.h (around line 69) add the highlighted lines from http://pastebin.com/CW6jjDBW (line number based on SVN revision 3083).

In the build configuration for Oolite, change all occurrences of SDK 10.4 to SDK 10.5 and add the IOKit framework as a linked library.

These modifications allow you to compile for OS X 10.5.

What do you get:
- A Joystick handler that has hardcoded values for using an Xbox 360 gamepad with Oolite.

Additional software you need if you want to use this particular gamepad:
- the Xbox 360 Controller Driver from http://tattiebogle.net/index.php/Projec ... Controller

Bugs:
- When I run Oolite by starting it from within Xcode, everything works fine. When I run it directly from the Finder, the first gamepad action crashes Oolite. Am investigating but happy for any help.

Irks/Annoyances:
- I have not been able to make the joystick configuration option appear in the game options so far. Does someone else know what I have to do here?
- I created a rather large dead zone for the gamepad (using 0.15 instead of 0.05) which works well, but I have not found a good setting (for sensitivity? somewhere else?) yet which allows me to make very small adjustments to perfectly target these pixel-sized pirates. It's not bad as it stands but improvement would be nice.

Comments, questions, suggestions, and further bug reports are highly welcome.

Cheers,
-Maik

Posted: Wed Mar 31, 2010 11:03 am
by maik
A Joystick handler that has hardcoded values for using an Xbox 360 gamepad with Oolite.
Note that other gamepads should work fine as well and won't require the Xbox360 driver, maybe the button mappings will be messed up as I only tested with the Xbox360 gamepad.
I have not been able to make the joystick configuration option appear in the game options so far. Does someone else know what I have to do here?
The config option does show up now, I missed one #ifdef and had to include the mapper entity files in the Oolite target. However, the config screen is very tightly linked to SDL joystick handling. It registers callbacks using methods that aren't even defined in JoystickHandler.h. I hope I will be able to keep the changes somewhat contained and in the end really get a config screen...

Posted: Fri Apr 02, 2010 3:22 pm
by JensAyton
I’ve started a branch for this:

Code: Select all

svn checkout svn://svn.berlios.de/oolite-linux/branches/mac-joystick
It puts the joystick code in a loadable bundle, so the game continues to work with 10.4 (without joystick support). It also matches joysticks as well as game pads.

Todo:
  • Obviously, it needs to be configurable, and able to match saved configurations to the right device.
  • Currently it’s possible to freeze the game completely by wiggling the stick fast. This is because the input events are dispatched on the main event loop and swamp it, so timers don’t fire. This can be fixed by using a separate thread.
If you want to work on this, and have a BerliOS account, I’ll give you checkin access.

Edit: Redefining OOLITE_HAVE_JOYSTICK to 1 in OOCocoa.h in the branch will now attempt to compile in stick config screen support, but generate a bunch missing method errors. It’s likely the interface between PlayerEntityStickMapping and JoystickHandler needs to be made more abstract to deal with conceptual differences between SDL and IOKit.

Posted: Tue Apr 06, 2010 9:23 am
by maik
Cool, thanks. I just created an account on Berlios: maikschulz

Posted: Wed Apr 07, 2010 7:57 pm
by JensAyton
OK, you should now be able to commit if you check out over svn+ssh as per http://developer.berlios.de/svn/?group_id=3577.

Posted: Thu Apr 22, 2010 10:08 am
by mark_au
Awesome news on a much needed feature. I have been hanging out to play oolite again. I haven't bothered since i migrated to mac due to the lack of configurable joystick support. Ive tried controller mate but with little success
good work guys

Posted: Wed Jul 28, 2010 10:20 pm
by RobFord75
Hello All

First post here, I did play Oolite for a little a couple of years ago, but being a console gamer at heart, using a joypad would be fantastic.

I have recently found out that the playstation 3 controller is natively supported by Snow Leopard, and was really hoping it would be possible to use this over bluetooth.

Is there anymore recent news on the progression of the joypad support for mac?

I am a bit illiterate when it comes to any sort of coding or building from source.

I look forward to some good news from this.

Cheers


Rob

Posted: Thu Jul 29, 2010 6:12 am
by maik
Not for the moment, I'm afraid.

I have included the missing bits and pieces in the OS X part of the source to make everything compile but then real life in the form of a new job got in the way. It's not forgotten though!

Posted: Sat Aug 07, 2010 9:49 pm
by webbasan
Hello,

I'm just wondering: I was also searching for the current state of joystick support in Oolite on the Mac and how it might be done.

I found an old posting of Aegidian, which suggests that he did came to some resolution (www_idevgames_com/forum/showthread.php?s=&threadid=5373) -- what happened with that stuff? Did it ever make it into any release version?

I found other pointers, which suggested to use DDHidLib www_dribin_org/dave/blog/archives/2007/03/19/ddhidlib_10/ (Download here: code_google_com/p/ddribin/downloads/list, the link in the blog points to an older version).

I compiled that stuff and successfully tried the provided test application with my Logitech Rumblepad 2 (no "rumble" though, i'm looking for information on that. It seems that there is some Linux code available which could be harvested...)

It would be nice to know if the test application is also able to read the Xbox pad -- the author of the Xbox contoller driver mentions something on his page (tattiebogle_net/index.php/ProjectRoot/Xbox360Controller/UsbInfo) which I don't quite understand: Does he suggest that this device does not send proper HID-device codes and so a generic driver can't be used with this device?

I would prefer a more generic approach for the joystick support, if possible. As far as I understand, it's quite complicated to use that HID API directly and the newer API is only available since 10.5. If I got it right this DDHidLib is supposed to make it easier and does support 10.4.

P.S.: Ok, I tried to override the "SPAM"-protection, but I suppose that everybody is able to recreate the original URLs? ;-)

Posted: Sun Aug 08, 2010 12:00 pm
by Commander McLane
Hi, webbasan, and welcome to the boards, and of course to this great game! :D

Although I'm a Mac user, I have always played Elite in all its incarnations only with keyboard, so I'm afraid I can't help you, as far as joystick support is concerned. Just wanted to be the first to say hello.

But I am sure that somebody on these boards, which have the reputation of being the friendliest this side of Riedquat, will be able to help you.