diff --git a/KompleteSynthesia/USBController.h b/KompleteSynthesia/USBController.h index ed817ab..6a496cb 100644 --- a/KompleteSynthesia/USBController.h +++ b/KompleteSynthesia/USBController.h @@ -37,12 +37,13 @@ extern const uint32_t kPID_S88MK3; @property (nonatomic, assign) CGSize screenSize; @property (nonatomic, assign) unsigned int screenCount; @property (nonatomic, assign) BOOL connected; +@property (nonatomic, assign) uint32_t deviceInterfaceEndpoint; + (NSString*)descriptionWithIOReturn:(IOReturn)code; - (id)initWithError:(NSError**)error; -- (BOOL)bulkWriteData:(NSData*)data endpoint:(int)endpointNumber error:(NSError**)error; +- (BOOL)bulkWriteData:(NSData*)data error:(NSError**)error; - (void)teardown; diff --git a/KompleteSynthesia/USBController.m b/KompleteSynthesia/USBController.m index 5efdac5..44f551a 100644 --- a/KompleteSynthesia/USBController.m +++ b/KompleteSynthesia/USBController.m @@ -34,6 +34,9 @@ const uint32_t kPID_S61MK3 = 0x1720; // FIXME: NO IDEA - THESE ARE PLACEHOLDERS SO FAR const uint32_t kPID_S88MK3 = 0x1730; // FIXME: NO IDEA - THESE ARE PLACEHOLDERS SO FAR +const uint32_t kUSBDeviceInterface = 0x03; // FIXME: Possibly MK2 specific. +const uint32_t kUSBDeviceInterfaceEndpoint = 0x03; // FIXME: Possibly MK2 specific. + @implementation USBController { IOUSBDeviceInterface942** device; IOUSBInterfaceInterface942** interface; @@ -53,6 +56,7 @@ - (id)initWithError:(NSError**)error self = [super init]; if (self) { _connected = NO; + _deviceInterfaceEndpoint = kUSBDeviceInterfaceEndpoint; //transferActive = 0; if ([self detectDevice:error] == NULL) { return nil; @@ -267,11 +271,11 @@ - (BOOL)endpoint:(uint8_t)ep pipeRef:(uint8_t*)pipep return NO; } -- (BOOL)bulkWriteData:(NSData*)data endpoint:(int)endpointNumber error:(NSError**)error +- (BOOL)bulkWriteData:(NSData*)data error:(NSError**)error { assert(data.length > 0); uint8_t pipeRef; - if ([self endpoint:endpointNumber pipeRef:&pipeRef] == NO) { + if ([self endpoint:_deviceInterfaceEndpoint pipeRef:&pipeRef] == NO) { NSLog(@"endpoint doesnt exist"); if (error) { NSDictionary *userInfo = @{ @@ -355,7 +359,7 @@ - (IOUSBDeviceInterface942**)detectDevice:(NSError**)error io_registry_entry_t entry = 0; - entry = IORegistryGetRootEntry(kIOMasterPortDefault); + entry = IORegistryGetRootEntry(kIOMainPortDefault); if (entry == 0) { return nil; } @@ -480,7 +484,7 @@ - (BOOL)openDevice:(NSError**)error return NO; } - ret = [self openDeviceInterface:3]; + ret = [self openDeviceInterface:kUSBDeviceInterface]; if (ret != kIOReturnSuccess) { if (error) { NSDictionary *userInfo = @{ diff --git a/KompleteSynthesia/VideoController.m b/KompleteSynthesia/VideoController.m index 09ecc9b..c45efb3 100644 --- a/KompleteSynthesia/VideoController.m +++ b/KompleteSynthesia/VideoController.m @@ -287,7 +287,7 @@ - (BOOL)drawNIImage:(NIImage*)image screen:(uint8_t)screen x:(unsigned int)x y:( const unsigned char commandBlob3[] = { 0x02, 0x00, 0x00, 0x00, 0x03, 0x00, 0x00, 0x00, 0x40, 0x00, 0x00, 0x00 }; [stream appendBytes:commandBlob3 length:sizeof(commandBlob3)]; - BOOL ret = [usb bulkWriteData:stream endpoint:3 error:error]; + BOOL ret = [usb bulkWriteData:stream error:error]; stream.length = 0;