Makefile.dc
author Sam Lantinga <slouken@libsdl.org>
Mon, 02 Jun 2003 14:50:22 +0000
changeset 632 85e104fe14c2
parent 509 dad72daf44b3
child 1461 11134dc42da8
permissions -rw-r--r--
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.
     1 #GL=1
     2 
     3 CC = sh-elf-gcc -ml -m4-single-only
     4 AR = sh-elf-ar
     5 KOS_BASE=/prog/kos-1.1.7
     6 INCS = -I$(KOS_BASE)/libc/include -I$(KOS_BASE)/include -I$(KOS_BASE)/kernel/arch/dreamcast/include
     7 DEFS =-DNO_SIGNAL_H -DENABLE_DC
     8 
     9 ifdef GL
    10 DEFS += -DHAVE_OPENGL
    11 TARGET = libSDL_gl.a
    12 else
    13 TARGET = libSDL.a
    14 endif
    15 
    16 OPTFLAGS=-O2 -fomit-frame-pointer
    17 CFLAGS=-D_arch_dreamcast $(DEFS) $(INCS) -Iinclude -Isrc -Isrc/audio -Isrc/cdrom -Isrc/endian -Isrc/events -Isrc/joystick -Isrc/thread/dc -Isrc/thread -Isrc/timer -Isrc/video $(OPTFLAGS)
    18 
    19 SRCS = \
    20 	src/audio/dc/SDL_dcaudio.c \
    21 	src/audio/dc/aica.c \
    22 	src/audio/SDL_audio.c \
    23 	src/audio/SDL_audiocvt.c \
    24 	src/audio/SDL_audiodev.c \
    25 	src/audio/SDL_audiomem.c \
    26 	src/audio/SDL_mixer.c \
    27 	src/audio/SDL_wave.c \
    28 	src/cdrom/dc/SDL_syscdrom.c \
    29 	src/cdrom/SDL_cdrom.c \
    30 	src/endian/SDL_endian.c \
    31 	src/events/SDL_active.c \
    32 	src/events/SDL_events.c \
    33 	src/events/SDL_expose.c \
    34 	src/events/SDL_keyboard.c \
    35 	src/events/SDL_mouse.c \
    36 	src/events/SDL_quit.c \
    37 	src/events/SDL_resize.c \
    38 	src/file/SDL_rwops.c \
    39 	src/joystick/dc/SDL_sysjoystick.c \
    40 	src/joystick/SDL_joystick.c \
    41 	src/SDL.c \
    42 	src/SDL_error.c \
    43 	src/SDL_fatal.c \
    44 	src/SDL_getenv.c \
    45 	src/SDL_loadso.c \
    46 	src/thread/dc/SDL_syscond.c \
    47 	src/thread/dc/SDL_sysmutex.c \
    48 	src/thread/dc/SDL_syssem.c \
    49 	src/thread/dc/SDL_systhread.c \
    50 	src/thread/SDL_thread.c \
    51 	src/timer/dc/SDL_systimer.c \
    52 	src/timer/SDL_timer.c \
    53 	src/video/dc/SDL_dcevents.c \
    54 	src/video/dc/SDL_dcvideo.c \
    55 	src/video/SDL_blit.c \
    56 	src/video/SDL_blit_0.c \
    57 	src/video/SDL_blit_1.c \
    58 	src/video/SDL_blit_A.c \
    59 	src/video/SDL_blit_N.c \
    60 	src/video/SDL_bmp.c \
    61 	src/video/SDL_cursor.c \
    62 	src/video/SDL_gamma.c \
    63 	src/video/SDL_pixels.c \
    64 	src/video/SDL_RLEaccel.c \
    65 	src/video/SDL_stretch.c \
    66 	src/video/SDL_surface.c \
    67 	src/video/SDL_video.c \
    68 	src/video/SDL_yuv.c \
    69 	src/video/SDL_yuv_sw.c \
    70 
    71 OBJS = $(SRCS:.c=.o)
    72 
    73 TEST = \
    74 	test/checkkeys.c \
    75 	test/graywin.c \
    76 	test/loopwave.c \
    77 	test/testalpha.c \
    78 	test/testbitmap.c \
    79 	test/testcdrom.c \
    80 	test/testerror.c \
    81 	test/testgamma.c \
    82 	test/testgl.c \
    83 	test/testhread.c \
    84 	test/testjoystick.c \
    85 	test/testkeys.c \
    86 	test/testlock.c \
    87 	test/testoverlay.c \
    88 	test/testpalette.c \
    89 	test/testsem.c \
    90 	test/testsprite.c \
    91 	test/testtimer.c \
    92 	test/testtypes.c \
    93 	test/testver.c \
    94 	test/testvidinfo.c \
    95 	test/testwin.c \
    96 	test/testwm.c \
    97 	test/threadwin.c \
    98 	test/torturethread.c \
    99 
   100 clean:
   101 	rm $(OBJS)
   102 
   103 $(TARGET) : $(OBJS)
   104 	$(AR) rcs $(TARGET) $(OBJS)
   105