mirror of
https://github.com/fhgwright/SCSI2SD.git
synced 2024-10-19 17:23:50 +00:00
Ugly workaround for lack of multiple HID device support on OSX.
This commit is contained in:
parent
70a3b594c2
commit
8721b36467
@ -28,10 +28,10 @@ ifeq ($(TARGET),Linux)
|
||||
endif
|
||||
ifeq ($(TARGET),Darwin)
|
||||
# Should match OSX
|
||||
VPATH += hidapi/mac
|
||||
VPATH += hidapi-mac
|
||||
LDFLAGS += -framework IOKit -framework CoreFoundation
|
||||
CFLAGS += -mmacosx-version-min=10.7
|
||||
CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7
|
||||
CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7 -std=c++0x
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
BUILD=build/mac
|
||||
|
@ -32,18 +32,57 @@ HID::HID(hid_device_info* hidInfo) :
|
||||
myFirmwareVersion(0),
|
||||
mySDCapacity(0)
|
||||
{
|
||||
while (hidInfo)
|
||||
// hidInfo->interface_number not supported on mac, and interfaces
|
||||
// are enumerated in a random order. :-(
|
||||
// We rely on the watchdog value of the debug interface changing on each
|
||||
// read to differentiate the interfaces.
|
||||
while (hidInfo && !(myConfigHandle && myDebugHandle))
|
||||
{
|
||||
if (hidInfo->interface_number == CONFIG_INTERFACE)
|
||||
{
|
||||
myConfigHandle = hid_open_path(hidInfo->path);
|
||||
hidInfo = hidInfo->next;
|
||||
}
|
||||
else if (hidInfo->interface_number == DEBUG_INTERFACE)
|
||||
{
|
||||
myDebugHandle = hid_open_path(hidInfo->path);
|
||||
readDebugData();
|
||||
hidInfo = hidInfo->next;
|
||||
}
|
||||
else if (hidInfo->interface_number == -1)
|
||||
{
|
||||
// hidInfo->interface_number not supported on mac, and
|
||||
// interfaces are enumerated in a random order. :-(
|
||||
// We rely on the watchdog value of the debug interface
|
||||
// changing on each read to differentiate the interfaces.
|
||||
hid_device* dev = hid_open_path(hidInfo->path);
|
||||
if (!dev)
|
||||
{
|
||||
hidInfo = hidInfo->next;
|
||||
continue;
|
||||
}
|
||||
|
||||
uint8_t buf[HID_PACKET_SIZE];
|
||||
int watchVal = -1;
|
||||
int configIntFound = 1;
|
||||
for (int i = 0; i < 4; ++i)
|
||||
{
|
||||
buf[0] = 0; // report id
|
||||
hid_read(dev, buf, HID_PACKET_SIZE);
|
||||
if (watchVal == -1) watchVal = buf[25];
|
||||
configIntFound = configIntFound && (buf[25] == watchVal);
|
||||
}
|
||||
|
||||
if (configIntFound)
|
||||
{
|
||||
myConfigHandle = dev;
|
||||
}
|
||||
else
|
||||
{
|
||||
myDebugHandle = dev;
|
||||
readDebugData();
|
||||
}
|
||||
}
|
||||
hidInfo = hidInfo->next;
|
||||
}
|
||||
}
|
||||
|
||||
|
1119
software/bootloaderhost/hidapi-mac/hid.c
Normal file
1119
software/bootloaderhost/hidapi-mac/hid.c
Normal file
File diff suppressed because it is too large
Load Diff
@ -28,10 +28,10 @@ ifeq ($(TARGET),Linux)
|
||||
endif
|
||||
ifeq ($(TARGET),Darwin)
|
||||
# Should match OSX
|
||||
VPATH += ../bootloaderhost/hidapi/mac
|
||||
VPATH += ../bootloaderhost/hidapi-mac
|
||||
LDFLAGS += -framework IOKit -framework CoreFoundation
|
||||
CFLAGS += -mmacosx-version-min=10.7
|
||||
CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7
|
||||
CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7 -std=c++0x
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
BUILD=build/mac
|
||||
|
@ -113,14 +113,18 @@ struct __attribute__((packed)) ConfigPacket
|
||||
|
||||
static void printConfig(ConfigPacket* packet)
|
||||
{
|
||||
printf("SCSI ID:\t\t\t%d\n", packet->scsiId);
|
||||
printf("Vendor:\t\t\t\t\"%.*s\"\n", 8, packet->vendor);
|
||||
printf("Product ID:\t\t\t\"%.*s\"\n", 16, packet->prodId);
|
||||
printf("Revision:\t\t\t\"%.*s\"\n", 4, packet->revision);
|
||||
printf("\n");
|
||||
printf("Parity Checking:\t\t%s\n", packet->enableParity ? "enabled" : "disabled");
|
||||
printf("Unit Attention Condition:\t%s\n", packet->enableUnitAttention ? "enabled" : "disabled");
|
||||
printf("Bytes per sector:\t\t%d\n", packet->bytesPerSector);
|
||||
std::cout <<
|
||||
"SCSI ID:\t\t\t" << packet->scsiId << "\n" <<
|
||||
"Vendor:\t\t\t\t\"" << std::string(packet->vendor, 8) << "\"\n" <<
|
||||
"Product ID:\t\t\t\"" << std::string(packet->prodId, 16) << "\"\n" <<
|
||||
"Revision:\t\t\t\"" << std::string(packet->revision, 4) << "\"\n" <<
|
||||
"\n" <<
|
||||
"Parity Checking:\t\t" <<
|
||||
(packet->enableParity ? "enabled" : "disabled") << "\n" <<
|
||||
"Unit Attention Condition:\t" <<
|
||||
(packet->enableUnitAttention ? "enabled" : "disabled") << "\n" <<
|
||||
"Bytes per sector:\t\t" << packet->bytesPerSector << std::endl;
|
||||
|
||||
if (packet->maxSectors)
|
||||
{
|
||||
char sizeBuf[64];
|
||||
@ -142,11 +146,12 @@ static void printConfig(ConfigPacket* packet)
|
||||
sprintf(sizeBuf, "%" PRIu64 " bytes", maxBytes);
|
||||
}
|
||||
|
||||
printf("Maximum Size:\t\t\t%s (%d sectors)\n", sizeBuf, packet->maxSectors);
|
||||
std::cout <<"Maximum Size:\t\t\t" << sizeBuf <<
|
||||
" (" << packet->maxSectors << " sectors)" << std::endl;
|
||||
}
|
||||
else
|
||||
{
|
||||
printf("Maximum Size:\t\t\tUnlimited\n");
|
||||
std::cout << "Maximum Size:\t\t\tUnlimited" << std::endl;
|
||||
}
|
||||
}
|
||||
|
||||
@ -311,7 +316,7 @@ int main(int argc, char* argv[])
|
||||
{
|
||||
int64_t maxSectors = -1;
|
||||
if (sscanf(optarg, "%" PRId64, &maxSectors) == 1 &&
|
||||
maxSectors >= 0 && maxSectors <= UINT32_MAX)
|
||||
maxSectors >= 0 && maxSectors <= 0xffffffff)
|
||||
{
|
||||
packet.maxSectors = maxSectors;
|
||||
}
|
||||
@ -362,6 +367,7 @@ int main(int argc, char* argv[])
|
||||
break;
|
||||
|
||||
case '?':
|
||||
doWrite = 0;
|
||||
usage();
|
||||
}
|
||||
}
|
||||
|
@ -28,10 +28,10 @@ ifeq ($(TARGET),Linux)
|
||||
endif
|
||||
ifeq ($(TARGET),Darwin)
|
||||
# Should match OSX
|
||||
VPATH += ../bootloaderhost/hidapi/mac
|
||||
VPATH += ../bootloaderhost/hidapi-mac
|
||||
LDFLAGS += -framework IOKit -framework CoreFoundation
|
||||
CFLAGS += -mmacosx-version-min=10.7
|
||||
CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7
|
||||
CXXFLAGS += -stdlib=libc++ -mmacosx-version-min=10.7 -std=c++0x
|
||||
CC=clang
|
||||
CXX=clang++
|
||||
BUILD=build/mac
|
||||
|
Loading…
Reference in New Issue
Block a user