Skip to content

Commit

Permalink
Add some error messages
Browse files Browse the repository at this point in the history
  • Loading branch information
verberktstan committed Apr 30, 2020
1 parent fed4aef commit 926050d
Show file tree
Hide file tree
Showing 2 changed files with 25 additions and 6 deletions.
Binary file modified FreeTheWheel
Binary file not shown.
31 changes: 25 additions & 6 deletions WheelSupports.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -7,6 +7,7 @@
//

#include <CoreFoundation/CFString.h>
#include <string>
#include "WheelSupports.h"

//=============================================================================
Expand Down Expand Up @@ -116,12 +117,30 @@ bool ConfigDevice(IOHIDDeviceRef hidDevice, DeviceID deviceID, const DeviceMode
IOReturn OpenDevice(IOHIDDeviceRef hidDevice)
{
IOReturn result = IOHIDDeviceOpen(hidDevice, kIOHIDOptionsTypeSeizeDevice);
if(result == kIOReturnError)
{
printf("ERROR: OpenDevice failed with result: %x\n", result);
return result;
}
return kIOReturnSuccess;
std::string msg = "";

switch(result) {
case kIOReturnError: msg = "general error"; break;
case kIOReturnNoMemory: msg = "can't allocate memory"; break;
case kIOReturnNoResources: msg = "resource shortage"; break;
case kIOReturnIPCError: msg = "error during IPC"; break;
case kIOReturnNoDevice: msg = "no such device"; break;
case kIOReturnNotPrivileged: msg = "privilege violation"; break;
case kIOReturnBadArgument: msg = "invalid argument"; break;
case kIOReturnLockedRead: msg = "device read locked"; break;
case kIOReturnLockedWrite: msg = "device write locked"; break;
//case kIOReturnExclusiveAccess: msg = "exclusive access and device already open"; break; // Common error on macOS Catalina with DFGT
case kIOReturnBadMessageID: msg = "sent/received messages had different msg_id"; break;
case kIOReturnUnsupported: msg = "unsupported function"; break;
case kIOReturnVMError: msg = "misc. VM failure"; break;
}

if(msg != "") {
printf("Error: OpenDevice failed - %s - (%x)\n", msg.c_str(), result);
return result;

}
return kIOReturnSuccess;
}


Expand Down

0 comments on commit 926050d

Please sign in to comment.