Skip to content

Instantly share code, notes, and snippets.

@codeman38
Created October 9, 2011 19:43
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save codeman38/1274066 to your computer and use it in GitHub Desktop.
Save codeman38/1274066 to your computer and use it in GitHub Desktop.
Mac Xbox 360 Controller driver: Patches for various bugs
diff -ru 360ControllerSource.orig/360Controller/xbox360hid.h 360ControllerSource/360Controller/xbox360hid.h
--- 360ControllerSource.orig/360Controller/xbox360hid.h 2007-04-21 14:37:27.000000000 -0400
+++ 360ControllerSource/360Controller/xbox360hid.h 2011-10-09 15:41:16.000000000 -0400
@@ -58,10 +58,10 @@
0x45, 0x01, // PHYSICAL_MAXIMUM (1)
0x95, 0x04, // REPORT_COUNT (4)
0x05, 0x09, // USAGE_PAGE (Button)
+ 0x09, 0x08, // USAGE (Button 8)
+ 0x09, 0x07, // USAGE (Button 7)
0x09, 0x09, // USAGE (Button 9)
0x09, 0x0a, // USAGE (Button 10)
- 0x09, 0x07, // USAGE (Button 7)
- 0x09, 0x08, // USAGE (Button 8)
0x81, 0x02, // INPUT (Data,Var,Abs)
0x75, 0x01, // REPORT_SIZE (1)
0x15, 0x00, // LOGICAL_MINIMUM (0)
diff -ru 360ControllerSource.orig/Pref360Control/Pref360ControlPref.m 360ControllerSource/Pref360Control/Pref360ControlPref.m
--- 360ControllerSource.orig/Pref360Control/Pref360ControlPref.m 2011-05-08 17:37:07.000000000 -0400
+++ 360ControllerSource/Pref360Control/Pref360ControlPref.m 2011-10-09 15:59:38.000000000 -0400
@@ -165,16 +165,16 @@
[rightShoulder setPressed:b];
break;
case 6:
- [leftStick setPressed:b];
+ [centreButtons setBack:b];
break;
case 7:
- [rightStick setPressed:b];
+ [centreButtons setStart:b];
break;
case 8:
- [centreButtons setStart:b];
+ [leftStick setPressed:b];
break;
case 9:
- [centreButtons setBack:b];
+ [rightStick setPressed:b];
break;
case 10:
[centreButtons setSpecific:b];
diff -ru 360ControllerSource.0.10/360Controller/_60Controller.cpp 360ControllerSource.0.10a/360Controller/_60Controller.cpp
--- 360ControllerSource.0.10/360Controller/_60Controller.cpp 2011-06-16 13:21:00.000000000 -0400
+++ 360ControllerSource.0.10a/360Controller/_60Controller.cpp 2011-10-09 00:18:14.000000000 -0400
@@ -1,6 +1,7 @@
/*
MICE Xbox 360 Controller driver for Mac OS X
Copyright (C) 2006-2007 Colin Munro
+ Bug fixes contributed by Cody "codeman38" Boisclair
_60Controller.cpp - main source of the driver
@@ -665,69 +666,75 @@
// This handles a completed asynchronous read
void Xbox360Peripheral::ReadComplete(void *parameter,IOReturn status,UInt32 bufferSizeRemaining)
{
- LockRequired locker(mainLock);
- IOReturn err;
- bool reread=!isInactive();
-
- switch(status) {
- case kIOReturnOverrun:
- IOLog("read - kIOReturnOverrun, clearing stall\n");
- if (inPipe != NULL)
- inPipe->ClearStall();
- // Fall through
- case kIOReturnSuccess:
- if (inBuffer != NULL)
- {
- const XBOX360_IN_REPORT *report=(const XBOX360_IN_REPORT*)inBuffer->getBytesNoCopy();
- if((report->header.command==inReport)&&(report->header.size==sizeof(XBOX360_IN_REPORT))) {
- fiddleReport(inBuffer);
- err = padHandler->handleReport(inBuffer, kIOHIDReportTypeInput);
- if(err!=kIOReturnSuccess) {
- IOLog("read - failed to handle report: 0x%.8x\n",err);
- }
- }
- }
- break;
- case kIOReturnNotResponding:
- IOLog("read - kIOReturnNotResponding\n");
- reread=false;
- break;
- default:
- reread=false;
- break;
+ if (padHandler != NULL) // avoid deadlock with release
+ {
+ LockRequired locker(mainLock);
+ IOReturn err;
+ bool reread=!isInactive();
+
+ switch(status) {
+ case kIOReturnOverrun:
+ IOLog("read - kIOReturnOverrun, clearing stall\n");
+ if (inPipe != NULL)
+ inPipe->ClearStall();
+ // Fall through
+ case kIOReturnSuccess:
+ if (inBuffer != NULL)
+ {
+ const XBOX360_IN_REPORT *report=(const XBOX360_IN_REPORT*)inBuffer->getBytesNoCopy();
+ if((report->header.command==inReport)&&(report->header.size==sizeof(XBOX360_IN_REPORT))) {
+ fiddleReport(inBuffer);
+ err = padHandler->handleReport(inBuffer, kIOHIDReportTypeInput);
+ if(err!=kIOReturnSuccess) {
+ IOLog("read - failed to handle report: 0x%.8x\n",err);
+ }
+ }
+ }
+ break;
+ case kIOReturnNotResponding:
+ IOLog("read - kIOReturnNotResponding\n");
+ reread=false;
+ break;
+ default:
+ reread=false;
+ break;
+ }
+ if(reread) QueueRead();
}
- if(reread) QueueRead();
}
void Xbox360Peripheral::SerialReadComplete(void *parameter, IOReturn status, UInt32 bufferSizeRemaining)
{
- LockRequired locker(mainLock);
- bool reread = !isInactive();
-
- switch (status)
+ if (padHandler != NULL) // avoid deadlock with release
{
- case kIOReturnOverrun:
- IOLog("read (serial) - kIOReturnOverrun, clearing stall\n");
- if (serialInPipe != NULL)
- serialInPipe->ClearStall();
- // Fall through
- case kIOReturnSuccess:
- serialHeard = true;
- if (serialInBuffer != NULL)
- SerialMessage(serialInBuffer, serialInBuffer->getCapacity() - bufferSizeRemaining);
- break;
-
- case kIOReturnNotResponding:
- IOLog("read (serial) - kIOReturnNotResponding\n");
- reread = false;
- break;
-
- default:
- reread = false;
- break;
+ LockRequired locker(mainLock);
+ bool reread = !isInactive();
+
+ switch (status)
+ {
+ case kIOReturnOverrun:
+ IOLog("read (serial) - kIOReturnOverrun, clearing stall\n");
+ if (serialInPipe != NULL)
+ serialInPipe->ClearStall();
+ // Fall through
+ case kIOReturnSuccess:
+ serialHeard = true;
+ if (serialInBuffer != NULL)
+ SerialMessage(serialInBuffer, serialInBuffer->getCapacity() - bufferSizeRemaining);
+ break;
+
+ case kIOReturnNotResponding:
+ IOLog("read (serial) - kIOReturnNotResponding\n");
+ reread = false;
+ break;
+
+ default:
+ reread = false;
+ break;
+ }
+ if (reread)
+ QueueSerialRead();
}
- if (reread)
- QueueSerialRead();
}
// Handle a completed asynchronous write
diff -ru 360ControllerSource.orig/360Controller/360Controller.xcodeproj/project.pbxproj 360ControllerSource/360Controller/360Controller.xcodeproj/project.pbxproj
--- 360ControllerSource.orig/360Controller/360Controller.xcodeproj/project.pbxproj 2011-06-16 13:21:00.000000000 -0400
+++ 360ControllerSource/360Controller/360Controller.xcodeproj/project.pbxproj 2011-10-09 11:42:15.000000000 -0400
@@ -296,6 +296,7 @@
GCC_ENABLE_FIX_AND_CONTINUE = NO;
GCC_GENERATE_DEBUGGING_SYMBOLS = NO;
GCC_MODEL_TUNING = G5;
+ GCC_VERSION = "";
GCC_WARN_ABOUT_RETURN_TYPE = YES;
GCC_WARN_UNUSED_VARIABLE = YES;
INFOPLIST_FILE = Info.plist;
@@ -305,6 +306,8 @@
MODULE_VERSION = 1.0.0d1;
PREBINDING = NO;
PRODUCT_NAME = 360Controller;
+ SDKROOT = macosx10.6;
+ "SDKROOT[arch=x86_64]" = macosx10.6;
WRAPPER_EXTENSION = kext;
ZERO_LINK = NO;
};
@@ -342,8 +345,8 @@
ARCHS = "$(ARCHS_STANDARD_32_64_BIT)";
GCC_VERSION = 4.0;
MACOSX_DEPLOYMENT_TARGET = 10.2;
- SDKROOT = macosx10.5;
- "SDKROOT[arch=x86_64]" = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
+ SDKROOT = macosx10.6;
+ "SDKROOT[arch=x86_64]" = macosx10.6;
};
name = Deployment;
};
diff -ru 360ControllerSource.orig/360Daemon/360Daemon.xcodeproj/project.pbxproj 360ControllerSource/360Daemon/360Daemon.xcodeproj/project.pbxproj
--- 360ControllerSource.orig/360Daemon/360Daemon.xcodeproj/project.pbxproj 2011-05-08 18:50:26.000000000 -0400
+++ 360ControllerSource/360Daemon/360Daemon.xcodeproj/project.pbxproj 2011-10-09 11:45:36.000000000 -0400
@@ -180,7 +180,7 @@
GCC_PREFIX_HEADER = 360Daemon_Prefix.pch;
INSTALL_PATH = "$(HOME)/bin";
PRODUCT_NAME = 360Daemon;
- SDKROOT = /Developer/SDKs/MacOSX10.5.sdk;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
ZERO_LINK = YES;
};
name = Debug;
@@ -194,6 +194,7 @@
GCC_PREFIX_HEADER = 360Daemon_Prefix.pch;
INSTALL_PATH = "$(HOME)/bin";
PRODUCT_NAME = 360Daemon;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
};
name = Release;
};
diff -ru 360ControllerSource.orig/DriverTool/DriverTool.xcodeproj/project.pbxproj 360ControllerSource/DriverTool/DriverTool.xcodeproj/project.pbxproj
--- 360ControllerSource.orig/DriverTool/DriverTool.xcodeproj/project.pbxproj 2011-05-08 14:43:08.000000000 -0400
+++ 360ControllerSource/DriverTool/DriverTool.xcodeproj/project.pbxproj 2011-10-09 16:01:26.000000000 -0400
@@ -172,7 +172,7 @@
GCC_PREFIX_HEADER = DriverTool_Prefix.pch;
INSTALL_PATH = /usr/local/bin;
PRODUCT_NAME = DriverTool;
- SDKROOT = macosx10.5;
+ SDKROOT = macosx10.6;
};
name = Release;
};
diff -ru 360ControllerSource.orig/Feedback360/Feedback360.xcodeproj/project.pbxproj 360ControllerSource/Feedback360/Feedback360.xcodeproj/project.pbxproj
--- 360ControllerSource.orig/Feedback360/Feedback360.xcodeproj/project.pbxproj 2011-05-08 13:46:59.000000000 -0400
+++ 360ControllerSource/Feedback360/Feedback360.xcodeproj/project.pbxproj 2011-10-09 00:21:11.000000000 -0400
@@ -209,6 +209,7 @@
INFOPLIST_FILE = Info.plist;
INSTALL_PATH = "$(HOME)/Library/Bundles";
PRODUCT_NAME = Feedback360;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
WRAPPER_EXTENSION = bundle;
ZERO_LINK = NO;
};
diff -ru 360ControllerSource.orig/Pref360Control/Pref360Control.xcodeproj/project.pbxproj 360ControllerSource/Pref360Control/Pref360Control.xcodeproj/project.pbxproj
--- 360ControllerSource.orig/Pref360Control/Pref360Control.xcodeproj/project.pbxproj 2011-05-08 13:46:59.000000000 -0400
+++ 360ControllerSource/Pref360Control/Pref360Control.xcodeproj/project.pbxproj 2011-10-09 16:02:28.000000000 -0400
@@ -396,6 +396,7 @@
INSTALL_PATH = "$(HOME)/Library/PreferencePanes";
LIBRARY_SEARCH_PATHS = "";
LIBRARY_STYLE = Bundle;
+ MACOSX_DEPLOYMENT_TARGET = 10.6;
OTHER_CFLAGS = "";
OTHER_LDFLAGS = (
"-bundle",
@@ -403,6 +404,7 @@
);
OTHER_REZFLAGS = "";
PRODUCT_NAME = Pref360Control;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
SECTORDER_FLAGS = "";
WARNING_CFLAGS = (
"-Wmost",
@@ -438,6 +440,7 @@
);
OTHER_REZFLAGS = "";
PRODUCT_NAME = Pref360Control;
+ SDKROOT = "$(DEVELOPER_SDK_DIR)/MacOSX10.6.sdk";
SECTORDER_FLAGS = "";
WARNING_CFLAGS = (
"-Wmost",
diff -ru 360ControllerSource.orig/Wireless360Controller/Wireless360Controller.xcodeproj/project.pbxproj 360ControllerSource/Wireless360Controller/Wireless360Controller.xcodeproj/project.pbxproj
--- 360ControllerSource.orig/Wireless360Controller/Wireless360Controller.xcodeproj/project.pbxproj 2011-05-08 13:46:59.000000000 -0400
+++ 360ControllerSource/Wireless360Controller/Wireless360Controller.xcodeproj/project.pbxproj 2011-10-09 18:50:21.000000000 -0400
@@ -201,6 +201,8 @@
MODULE_NAME = com.yourcompany.driver.Wireless360Controller;
MODULE_VERSION = 1.0.0d1;
PRODUCT_NAME = Wireless360Controller;
+ SDKROOT = macosx10.6;
+ "SDKROOT[arch=x86_64]" = macosx10.6;
WRAPPER_EXTENSION = kext;
};
name = Release;
diff -ru 360ControllerSource.orig/WirelessGamingReceiver/WirelessGamingReceiver.xcodeproj/project.pbxproj 360ControllerSource/WirelessGamingReceiver/WirelessGamingReceiver.xcodeproj/project.pbxproj
--- 360ControllerSource.orig/WirelessGamingReceiver/WirelessGamingReceiver.xcodeproj/project.pbxproj 2011-05-07 21:33:39.000000000 -0400
+++ 360ControllerSource/WirelessGamingReceiver/WirelessGamingReceiver.xcodeproj/project.pbxproj 2011-10-09 18:49:45.000000000 -0400
@@ -221,6 +221,8 @@
MODULE_NAME = com.yourcompany.driver.WirelessGamingReceiver;
MODULE_VERSION = 1.0.0d1;
PRODUCT_NAME = WirelessGamingReceiver;
+ SDKROOT = macosx10.6;
+ "SDKROOT[arch=x86_64]" = macosx10.6;
WRAPPER_EXTENSION = kext;
};
name = Release;
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment