Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
0 parents
commit e1f77b3
Showing
96 changed files
with
19,175 additions
and
0 deletions.
There are no files selected for viewing
Large diffs are not rendered by default.
Oops, something went wrong.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,150 @@ | ||
/* | ||
MICE Xbox 360 Controller driver for Mac OS X | ||
Copyright (C) 2006-2013 Colin Munro | ||
ChatPad.cpp - Implementation of the ChatPad Accessory driver | ||
This file is part of Xbox360Controller. | ||
Xbox360Controller is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
Xbox360Controller is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Foobar; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <IOKit/IOLib.h> | ||
#include "ChatPad.h" | ||
namespace HID_ChatPad { | ||
#include "chatpadhid.h" | ||
} | ||
#include "chatpadkeys.h" | ||
#include "_60Controller.h" | ||
|
||
OSDefineMetaClassAndStructors(ChatPadKeyboardClass, IOHIDDevice) | ||
|
||
IOReturn ChatPadKeyboardClass::newReportDescriptor(IOMemoryDescriptor **descriptor) const | ||
{ | ||
IOBufferMemoryDescriptor *buffer; | ||
|
||
buffer = IOBufferMemoryDescriptor::inTaskWithOptions(kernel_task, 0, sizeof(HID_ChatPad::ReportDescriptor)); | ||
if (buffer == NULL) | ||
return kIOReturnNoResources; | ||
buffer->writeBytes(0, HID_ChatPad::ReportDescriptor, sizeof(HID_ChatPad::ReportDescriptor)); | ||
*descriptor = buffer; | ||
return kIOReturnSuccess; | ||
} | ||
|
||
IOReturn ChatPadKeyboardClass::setReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) | ||
{ | ||
// Maybe add LED support later? | ||
return kIOReturnUnsupported; | ||
} | ||
|
||
IOReturn ChatPadKeyboardClass::getReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) | ||
{ | ||
return kIOReturnUnsupported; | ||
} | ||
|
||
IOReturn ChatPadKeyboardClass::handleReport(IOMemoryDescriptor *report, IOHIDReportType reportType, IOOptionBits options) | ||
{ | ||
IOBufferMemoryDescriptor *realReport = OSDynamicCast(IOBufferMemoryDescriptor, report); | ||
if (realReport != NULL) | ||
{ | ||
unsigned char *data = (unsigned char*)realReport->getBytesNoCopy(); | ||
if (data[0] == 0x00) | ||
{ | ||
for (int i = 2; i < 5; i++) | ||
{ | ||
data[i] = ChatPad2USB(data[i]); | ||
} | ||
} | ||
} | ||
return IOHIDDevice::handleReport(report, reportType, options); | ||
} | ||
|
||
OSNumber* ChatPadKeyboardClass::newPrimaryUsageNumber() const | ||
{ | ||
return OSNumber::withNumber(HID_ChatPad::ReportDescriptor[3], 8); | ||
} | ||
|
||
OSNumber* ChatPadKeyboardClass::newPrimaryUsagePageNumber() const | ||
{ | ||
return OSNumber::withNumber(HID_ChatPad::ReportDescriptor[1], 8); | ||
} | ||
|
||
OSString* ChatPadKeyboardClass::newProductString() const | ||
{ | ||
return OSString::withCString("ChatPad"); | ||
} | ||
|
||
OSString* ChatPadKeyboardClass::newTransportString() const | ||
{ | ||
return OSString::withCString("Serial"); | ||
} | ||
|
||
OSNumber* ChatPadKeyboardClass::newVendorIDNumber() const | ||
{ | ||
// Same as USB | ||
return OSNumber::withNumber(100, 32); | ||
} | ||
|
||
OSNumber* ChatPadKeyboardClass::newProductIDNumber() const | ||
{ | ||
// Same as USB, plus one | ||
return OSNumber::withNumber(100, 32); | ||
} | ||
|
||
static IOHIDDevice* GetParent(const IOService *current) | ||
{ | ||
Xbox360Peripheral *owner; | ||
|
||
owner = OSDynamicCast(Xbox360Peripheral, current->getProvider()); | ||
if (owner == NULL) | ||
return NULL; | ||
return owner->getController(0); | ||
} | ||
|
||
bool ChatPadKeyboardClass::start(IOService *provider) | ||
{ | ||
if (!IOHIDDevice::start(provider)) | ||
return false; | ||
return OSDynamicCast(Xbox360Peripheral, provider) != NULL; | ||
} | ||
|
||
OSString* ChatPadKeyboardClass::newManufacturerString() const | ||
{ | ||
IOHIDDevice *device = GetParent(this); | ||
if (device == NULL) | ||
return NULL; | ||
return device->newManufacturerString(); | ||
} | ||
|
||
OSString* ChatPadKeyboardClass::newSerialNumberString() const | ||
{ | ||
IOHIDDevice *device = GetParent(this); | ||
if (device == NULL) | ||
return NULL; | ||
return device->newSerialNumberString(); | ||
} | ||
|
||
OSNumber* ChatPadKeyboardClass::newLocationIDNumber() const | ||
{ | ||
IOHIDDevice *device = GetParent(this); | ||
if (device == NULL) | ||
return NULL; | ||
OSNumber *number = device->newLocationIDNumber(); | ||
if (number == NULL) | ||
return NULL; | ||
UInt32 value = number->unsigned32BitValue(); | ||
number->release(); | ||
return OSNumber::withNumber(value + 1, 32); | ||
} |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,53 @@ | ||
/* | ||
MICE Xbox 360 Controller driver for Mac OS X | ||
Copyright (C) 2006-2013 Colin Munro | ||
ChatPad.h - Driver class for the ChatPad accessory | ||
This file is part of Xbox360Controller. | ||
Xbox360Controller is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
Xbox360Controller is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Foobar; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
|
||
#include <IOKit/hid/IOHIDDevice.h> | ||
|
||
class ChatPadKeyboardClass : public IOHIDDevice | ||
{ | ||
OSDeclareDefaultStructors(ChatPadKeyboardClass) | ||
|
||
private: | ||
|
||
public: | ||
virtual bool start(IOService *provider); | ||
|
||
// IOHidDevice methods | ||
virtual IOReturn newReportDescriptor(IOMemoryDescriptor **descriptor) const; | ||
|
||
virtual IOReturn setReport(IOMemoryDescriptor *report,IOHIDReportType reportType,IOOptionBits options=0); | ||
virtual IOReturn getReport(IOMemoryDescriptor *report,IOHIDReportType reportType,IOOptionBits options); | ||
|
||
virtual IOReturn handleReport(IOMemoryDescriptor *report, IOHIDReportType reportType = kIOHIDReportTypeInput, IOOptionBits options = 0); | ||
|
||
virtual OSString* newManufacturerString() const; | ||
virtual OSNumber* newPrimaryUsageNumber() const; | ||
virtual OSNumber* newPrimaryUsagePageNumber() const; | ||
virtual OSNumber* newProductIDNumber() const; | ||
virtual OSString* newProductString() const; | ||
virtual OSString* newSerialNumberString() const; | ||
virtual OSString* newTransportString() const; | ||
virtual OSNumber* newVendorIDNumber() const; | ||
|
||
virtual OSNumber* newLocationIDNumber() const; | ||
}; |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,115 @@ | ||
/* | ||
MICE Xbox 360 Controller driver for Mac OS X | ||
Copyright (C) 2006-2013 Colin Munro | ||
ControlStruct.h - Structures used by the device | ||
This file is part of Xbox360Controller. | ||
Xbox360Controller is free software; you can redistribute it and/or modify | ||
it under the terms of the GNU General Public License as published by | ||
the Free Software Foundation; either version 2 of the License, or | ||
(at your option) any later version. | ||
Xbox360Controller is distributed in the hope that it will be useful, | ||
but WITHOUT ANY WARRANTY; without even the implied warranty of | ||
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | ||
GNU General Public License for more details. | ||
You should have received a copy of the GNU General Public License | ||
along with Foobar; if not, write to the Free Software | ||
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA | ||
*/ | ||
#ifndef __CONTROLSTRUCT_H__ | ||
#define __CONTROLSTRUCT_H__ | ||
|
||
typedef UInt8 XBox360_Byte; | ||
typedef UInt16 XBox360_Short; | ||
typedef SInt16 XBox360_SShort; | ||
|
||
#define Xbox360_Prepare(x,t) {memset(&x,0,sizeof(x));x.header.command=t;x.header.size=sizeof(x);} | ||
|
||
#define PACKED __attribute__((__packed__)) | ||
|
||
// Common structure format | ||
typedef struct { | ||
XBox360_Byte command; | ||
XBox360_Byte size; | ||
} PACKED XBOX360_PACKET; | ||
|
||
// Analog stick format | ||
typedef struct { | ||
XBox360_SShort x,y; | ||
} PACKED XBOX360_HAT; | ||
|
||
// Structure describing the report had back from the controller | ||
typedef struct { | ||
XBOX360_PACKET header; | ||
XBox360_Short buttons; | ||
XBox360_Byte trigL,trigR; | ||
XBOX360_HAT left,right; | ||
XBox360_Byte reserved[6]; | ||
} PACKED XBOX360_IN_REPORT; | ||
|
||
// Structure describing the command to change LED status | ||
typedef struct { | ||
XBOX360_PACKET header; | ||
XBox360_Byte pattern; | ||
} PACKED XBOX360_OUT_LED; | ||
|
||
// Structure describing the command to change rumble motor status | ||
typedef struct { | ||
XBOX360_PACKET header; | ||
XBox360_Byte reserved1; | ||
XBox360_Byte big,little; | ||
XBox360_Byte reserved[3]; | ||
} PACKED XBOX360_OUT_RUMBLE; | ||
|
||
// Enumeration of command types | ||
enum { | ||
// In | ||
inReport = 0, | ||
// Out | ||
outRumble = 0, | ||
outLed = 1 | ||
}; | ||
|
||
// Button bits | ||
enum { | ||
btnHatRight = 0x8000, | ||
btnHatLeft = 0x4000, | ||
btnBack = 0x2000, | ||
btnStart = 0x1000, | ||
btnDigiRight = 0x0800, | ||
btnDigiLeft = 0x0400, | ||
btnDigiDown = 0x0200, | ||
btnDigiUp = 0x0100, | ||
btnY = 0x0080, | ||
btnX = 0x0040, | ||
btnB = 0x0020, | ||
btnA = 0x0010, | ||
btnReserved1 = 0x0008, // Unused? | ||
btnXbox = 0x0004, | ||
btnShoulderRight = 0x0002, | ||
btnShoulderLeft = 0x0001 | ||
}; | ||
|
||
// LED values | ||
enum { | ||
ledOff = 0x00, | ||
ledBlinkingAll = 0x01, | ||
ledFlashOn1 = 0x02, | ||
ledFlashOn2 = 0x03, | ||
ledFlashOn3 = 0x04, | ||
ledFlashOn4 = 0x05, | ||
ledOn1 = 0x06, | ||
ledOn2 = 0x07, | ||
ledOn3 = 0x08, | ||
ledOn4 = 0x09, | ||
ledRotating = 0x0a, | ||
ledBlinking = 0x0b, // Blinking of previously enabled LED (e.g. from 0x01-0x09) | ||
ledBlinkingSlow = 0x0c, // As above | ||
ldAlternating = 0x0d // 1+4, 2+3, then back to previous after a short time | ||
}; | ||
|
||
#endif // __CONTROLSTRUCT_H__ |
Oops, something went wrong.