Gamepad support, building with SDK 10.5

Discussion and announcements regarding the Mac port… er, original version of Oolite.

Moderators: winston, another_commander

What OS X version are you running Oolite on?

Poll ended at Sun Apr 11, 2010 10:04 am

OS X 10.4
2
29%
OS X 10.5
5
71%
 
Total votes: 7

User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Gamepad support, building with SDK 10.5

Post 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
User avatar
Cmdr James
Commodore
Commodore
Posts: 1357
Joined: Tue Jun 05, 2007 10:43 pm
Location: Berlin

Post 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.
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post by maik »

Only Snow Leopard (10.6) or Leopard (10.5) as well? I'm targeting the latter.
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post 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
another_commander
Quite Grand Sub-Admiral
Quite Grand Sub-Admiral
Posts: 6683
Joined: Wed Feb 28, 2007 7:54 am

Post 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.
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post 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
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post 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...
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post 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.
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post by maik »

Cool, thanks. I just created an account on Berlios: maikschulz
User avatar
JensAyton
Grand Admiral Emeritus
Grand Admiral Emeritus
Posts: 6657
Joined: Sat Apr 02, 2005 2:43 pm
Location: Sweden
Contact:

Post 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.
mark_au
Poor
Poor
Posts: 7
Joined: Thu Oct 25, 2007 6:02 am

Post 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
Mark W
Unix - where commands look like line noise
RobFord75
Harmless
Harmless
Posts: 1
Joined: Wed Jul 28, 2010 3:56 pm

Post 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
User avatar
maik
Wiki Wizard
Wiki Wizard
Posts: 2028
Joined: Wed Mar 10, 2010 12:30 pm
Location: Ljubljana, Slovenia (mainly industrial, feudal, TL12)

Post 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!
User avatar
webbasan
Average
Average
Posts: 8
Joined: Sat Aug 07, 2010 2:39 pm
Location: Mundito Rosinante - a small world at the border of the city.

Post 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? ;-)
User avatar
Commander McLane
---- E L I T E ----
---- E L I T E ----
Posts: 9520
Joined: Thu Dec 14, 2006 9:08 am
Location: a Hacker Outpost in a moderately remote area
Contact:

Post 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.
Post Reply