~ubuntu-branches/ubuntu/karmic/libsdl1.2/karmic

« back to all changes in this revision

Viewing changes to src/joystick/darwin/SDL_sysjoystick.c

  • Committer: Bazaar Package Importer
  • Author(s): Steve Kowalik
  • Date: 2008-01-05 14:10:45 UTC
  • mto: (2.1.3 lenny)
  • mto: This revision was merged to the branch mainline in revision 16.
  • Revision ID: james.westby@ubuntu.com-20080105141045-mjdg2rp09mamme4a
Tags: upstream-1.2.13
ImportĀ upstreamĀ versionĀ 1.2.13

Show diffs side-by-side

added added

removed removed

Lines of Context:
39
39
/* The header was moved here in Mac OS X 10.1 */
40
40
#include <Kernel/IOKit/hidsystem/IOHIDUsageTables.h>
41
41
#endif
 
42
#if MAC_OS_X_VERSION_MIN_REQUIRED == 1030
 
43
#include "10.3.9-FIX/IOHIDLib.h"
 
44
#else
42
45
#include <IOKit/hid/IOHIDLib.h>
 
46
#endif
43
47
#include <IOKit/hid/IOHIDKeys.h>
44
48
#include <CoreFoundation/CoreFoundation.h>
45
49
#include <Carbon/Carbon.h> /* for NewPtrClear, DisposePtr */
723
727
{
724
728
        recDevice *device = joystick->hwdata;
725
729
        recElement *element;
726
 
        SInt32 value;
 
730
        SInt32 value, range;
727
731
        int i;
728
732
 
729
733
        if (device->removed)  /* device was unplugged; ignore it. */
776
780
        {
777
781
                Uint8 pos = 0;
778
782
 
779
 
                value = HIDGetElementValue(device, element);
780
 
                if (element->max == 3) /* 4 position hatswitch - scale up value */
 
783
                range = (element->max - element->min + 1);
 
784
                value = HIDGetElementValue(device, element) - element->min;
 
785
                if (range == 4) /* 4 position hatswitch - scale up value */
781
786
                        value *= 2;
782
 
                else if (element->max != 7) /* Neither a 4 nor 8 positions - fall back to default position (centered) */
 
787
                else if (range != 8) /* Neither a 4 nor 8 positions - fall back to default position (centered) */
783
788
                        value = -1;
784
789
                switch(value)
785
790
                {