Mercurial > sdl-ios-xcode
view README.MacOSX @ 632:85e104fe14c2
Date: Sun, 1 Jun 2003 15:38:45 -0700 (PDT)
From: Jeff Brown <jabrown@caida.org>
Subject: [patch] SDL-1.2.5 + FreeBSD joystick axes, hat fixes
Hello again! When I sent in some SDL fixes last December, I found out
they'd already been fixed in the CVS version. This time, I checked the
repository before bugging you. =)
I'm using SDL-1.2.5 on a FreeBSD 4.6.2-RELEASE system, and in the course
of getting my multi-analog-axis USB controller (with a hat switch!)
working with d2x-sdl -- the SDL port of the Descent 2 engine -- I came
across a few problems:
1) The second analog stick is reported as a slider in one direction, and
"Rz" in the other. SDL was ignoring the Rz axis, so I added Rx/Ry/Rz to
the set of things SDL considers to be axes.
2) After the above change, the set of JOYAXE_* axes for my gamepad was
{0,1,3,7}; however, d2x-sdl expects the axes to be contiguously numbered
from 0, which seems like a pretty reasonable expectation, rather than
having to scan the entire space of axes that SDL may or may not have.
So, I added a table lookup which maps the JOYAXE_* axis numbers to 0,1,...
in the order they're detected by SDL_SYS_JoystickOpen(), when reporting
them to the application. I also added a function "usage_to_joyaxe()"
which maps the USB HUG_* usage values to JOYAXE_values, since the repeated
case statements testing for HUG_* were getting out of hand.
3) The BSD joystick driver had no hat support, so I added it. It looks
like our USB library can only support one hat switch per device, which
makes life easy.
The patch against SDL-1.2.5 which implements these changes is at:
http://www.caida.org/~jabrown/patches/sdl-1.2.5-bsdhat.diff
After applying, SDL's "testjoystick" reports all activity from my gamepad
correctly, and d2x works too (though it needed some other fixes).
Moving on...
There is also a problem with slightly different USBHID library interfaces
on different versions of FreeBSD. I wasn't going to mention this since the
FreeBSD port for SDL-1.2.5 (and not SDL itself) was doing the FreeBSD
version-specific patching, so I e-mailed the port maintainer with this
change. However, I see that you've incorporated the FreeBSD
version-checking stuff into the CVS version of SDL, so now it's relevant
for you too.
The problem is, the FreeBSD #if tests don't work right for FreeBSD
4.6.2-RELEASE. There may be other versions with this problem, but I've
only tested 4.6.2-R. The following patch against your latest CVS version
fixes this:
--- SDL_sysjoystick.c-1.16 Tue Apr 15 09:02:08 2003
+++ SDL_sysjoystick.c Sun Jun 1 15:10:28 2003
@@ -420,6 +420,8 @@
# else
len = hid_report_size(rd, repinfo[repind].kind, r->rid);
# endif
+# elif (__FreeBSD_version == 460002)
+ len = hid_report_size(rd, r->rid, repinfo[repind].kind);
# else
len = hid_report_size(rd, repinfo[repind].kind, &r->rid);
#endif
I hope this is all useful to you. I've been getting myself dizzy playing
Descent 2 with it, all morning!
-Jeff Brown
P.S. My USB controller is a Thrustmaster Firestorm Dual Analog 2. That's
probably irrelevant, but I threw it in for completeness.
author | Sam Lantinga <slouken@libsdl.org> |
---|---|
date | Mon, 02 Jun 2003 14:50:22 +0000 |
parents | 50620ec9c86a |
children | ae4ab3ac89a9 |
line wrap: on
line source
============================================================================== Using the Simple DirectMedia Layer with Mac OS X ============================================================================== These instructions are for people using Apple's Mac OS X (pronounced "ten"). From the developer's point of view, OS X is a sort of hybrid Mac and Unix system, and you have the option of using either traditional command line tools or Apple's IDE ProjectBuilder (PB). To build using the command line, use the standard configure and make process: ./configure make make install (You may need to create the subdirs of /usr/local manually.) To use the library once it's built, you essential have two possibilities: use the traditional autoconf/automake/make method, or use Apple's Project Builder. ============================================================================== Using the Simple DirectMedia Layer with a traditional Makefile ============================================================================== An existing autoconf/automake build system for your SDL app has good chances to work almost unchanged on OS X. However, to produce a "real" MacOS X binary that you can distribute to users, you need to put the generated binary into a so called "bundle", which basically is a fancy folder with a name like "MyCoolGame.app". To get this build automatically, add something like the following rule to your Makefile.am: bundle_contents = APP_NAME.app/Contents APP_NAME_bundle: EXE_NAME mkdir -p $(bundle_contents)/MacOS mkdir -p $(bundle_contents)/Resources echo "APPL????" > $(bundle_contents)/PkgInfo $(INSTALL_PROGRAM) $< $(bundle_contents)/MacOS/ You should replace EXE_NAME with the name of the executable. APP_NAME is what will be visible to the user in the Finder. Usually it will be the same as EXE_NAME but capitalized. E.g. if EXE_NAME is "testgame" then APP_NAME usually is "TestGame". You might also want to use @PACKAGE@ to use the package name as specified in your configure.in file. If your project builds more than one application, you will have to do a bit more. For each of your target applications, you need a seperate rule. If you want the created bundles to be installed, you may want to add this rule to your Makefile.am: install-exec-hook: APP_NAME_bundle rm -rf $(DESTDIR)$(prefix)/Applications/APP_NAME.app mkdir -p $(DESTDIR)$(prefix)/Applications/ cp -r $< /$(DESTDIR)$(prefix)Applications/ This rule takes the Bundle created by the rule from step 3 and installs them into $(DESTDIR)$(prefix)/Applications/. Again, if you want to install multiple applications, you will have to augment the make rule accordingly. ============================================================================== Using the Simple DirectMedia Layer with Project Builder ============================================================================== These instructions are for using Apple's Project Builder IDE to build SDL applications. - First steps The first thing to do is to unpack the PBProjects.tar.gz archive in the top level SDL directory (where the PBProjects.tar.gz archive resides). Because Stuffit Expander will unpack the archive into a subdirectory, you should unpack the archive manually from the command line: cd [path_to_SDL_source] tar zxf PBProjects.tar.gz This will create a new folder called PBProjects, which you can browse normally from the Finder. - Building the Framework The SDL Library is packaged as a framework bundle, an organized relocatable folder heirarchy of executible code, interface headers, and additional resources. For practical purposes, you can think of a framework as a more user and system-friendly shared library, whose library file behaves more or less like a standard UNIX shared library. To build the framework, simply open the framework project and build it. By default, the framework bundle "SDL.framework" is installed in ~/Library/Frameworks. Therefore, the testers and project stationary expect it to be located there. However, it will function the same in any of the following locations: ~/Library/Frameworks /Local/Library/Frameworks /System/Library/Frameworks - Build Options There are two "Build Styles" (See the "Targets" tab) for SDL. "Deployment" should be used if you aren't tweaking the SDL library. "Development" should be used to debug SDL apps or the library itself. - Building the Testers Open the SDLTest project and build away! - Using the Project Stationary Copy the stationary to the indicated folders to access it from the "New Project" and "Add target" menus. What could be easier? - Setting up a new project by hand Some of you won't want to use the Stationary so I'll give some tips: * Create a new "Cocoa Application" * Add src/main/macosx/SDLMain.m , .h and .nib to your project * Remove "main.c" from your project * Remove "MainMenu.nib" from your project * Add "$(HOME)/Library/Frameworks/SDL.framework/Headers" to include path * Add "$(HOME)/Library/Frameworks" to the frameworks search path * Add "-framework SDL -framework Foundation -framework AppKit" to "OTHER_LDFLAGS" * Set the "Main Nib File" under "Application Settings" to "SDLMain.nib" * Add your files * Clean and build - Building from command line Use pbxbuild in the same directory as your .pbproj file - Running your app You can send command line args to your app by either invoking it from the command line (in *.app/Contents/MacOS) or by entering them in the "Executibles" panel of the target settings. - Implementation Notes Some things that may be of interest about how it all works... * Working directory As defined in the SDL_main.m file, the working directory of your SDL app is by default set to its parent. You may wish to change this to better suit your needs. * You have a Cocoa App! Your SDL app is essentially a Cocoa application. When your app starts up and the libraries finish loading, a Cocoa procedure is called, which sets up the working directory and calls your main() method. You are free to modify your Cocoa app with generally no consequence to SDL. You cannot, however, easily change the SDL window itself. Functionality may be added in the future to help this. Known bugs are listed in the file "BUGS"