cleanup, but I may have messed up line endings... I hope not.
This commit is contained in:
@@ -11,7 +11,7 @@ HIDDevice::~HIDDevice()
|
||||
if( m_Queue )
|
||||
{
|
||||
CFRunLoopSourceRef runLoopSource;
|
||||
|
||||
|
||||
if( m_bRunning )
|
||||
{
|
||||
CALL( m_Queue, stop );
|
||||
@@ -19,7 +19,7 @@ HIDDevice::~HIDDevice()
|
||||
CFRunLoopSourceInvalidate( runLoopSource );
|
||||
CFRelease( runLoopSource );
|
||||
}
|
||||
|
||||
|
||||
CALL( m_Queue, dispose );
|
||||
CALL( m_Queue, Release );
|
||||
}
|
||||
@@ -36,20 +36,20 @@ bool HIDDevice::Open( io_object_t device )
|
||||
CFMutableDictionaryRef properties;
|
||||
kern_return_t result;
|
||||
CFTypeRef object;
|
||||
|
||||
|
||||
result = IORegistryEntryCreateCFProperties( device, &properties, kCFAllocatorDefault, kNilOptions );
|
||||
if( result != KERN_SUCCESS || !properties )
|
||||
{
|
||||
LOG->Warn( "Couldn't get properties." );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDProductKey) );
|
||||
|
||||
|
||||
CFTypeRef vidRef = CFDictionaryGetValue( properties, CFSTR(kIOHIDVendorIDKey) );
|
||||
CFTypeRef pidRef = CFDictionaryGetValue( properties, CFSTR(kIOHIDProductIDKey) );
|
||||
int vid, pid;
|
||||
|
||||
|
||||
if( !IntValue(vidRef, vid) )
|
||||
vid = 0;
|
||||
if( !IntValue(pidRef, pid) )
|
||||
@@ -60,7 +60,7 @@ bool HIDDevice::Open( io_object_t device )
|
||||
CFRelease( properties );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( object && CFGetTypeID(object) == CFStringGetTypeID() )
|
||||
{
|
||||
const char *str = CFStringGetCStringPtr( CFStringRef(object), CFStringGetSystemEncoding() );
|
||||
@@ -69,7 +69,7 @@ bool HIDDevice::Open( io_object_t device )
|
||||
if( m_sDescription == "" )
|
||||
m_sDescription = ssprintf( "%04x:%04x", vid, pid );
|
||||
LOG->Trace( "\t\tDevice description: %s", m_sDescription.c_str() );
|
||||
|
||||
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDElementKey) );
|
||||
if ( !object || CFGetTypeID(object) != CFArrayGetTypeID() )
|
||||
{
|
||||
@@ -77,19 +77,19 @@ bool HIDDevice::Open( io_object_t device )
|
||||
CFRelease( properties );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
CFArrayRef logicalDevices = CFArrayRef( object );
|
||||
CFRange r = { 0, CFArrayGetCount(logicalDevices) };
|
||||
|
||||
|
||||
CFArrayApplyFunction( logicalDevices, r, HIDDevice::AddLogicalDevice, this );
|
||||
|
||||
|
||||
CFRelease( properties );
|
||||
|
||||
|
||||
// Create the interface
|
||||
IOCFPlugInInterface **plugInInterface;
|
||||
HRESULT hresult;
|
||||
SInt32 score;
|
||||
|
||||
|
||||
ret = IOCreatePlugInInterfaceForService( device, kIOHIDDeviceUserClientTypeID,
|
||||
kIOCFPlugInInterfaceID, &plugInInterface, &score );
|
||||
if( ret != kIOReturnSuccess )
|
||||
@@ -97,21 +97,21 @@ bool HIDDevice::Open( io_object_t device )
|
||||
PrintIOErr( ret, "Failed to create plugin interface." );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// Call a method of the plugin to create the device interface
|
||||
CFUUIDBytes bytes = CFUUIDGetUUIDBytes( kIOHIDDeviceInterfaceID );
|
||||
|
||||
|
||||
hresult = CALL( plugInInterface, QueryInterface, bytes, (void **)&m_Interface );
|
||||
|
||||
|
||||
CALL( plugInInterface, Release );
|
||||
|
||||
|
||||
if( hresult != S_OK )
|
||||
{
|
||||
LOG->Warn( "Couldn't get device interface from plugin interface." );
|
||||
m_Interface = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// open the interface
|
||||
if( (ret = CALL(m_Interface, open, 0)) != kIOReturnSuccess )
|
||||
{
|
||||
@@ -120,7 +120,7 @@ bool HIDDevice::Open( io_object_t device )
|
||||
m_Interface = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
// alloc/create queue
|
||||
m_Queue = CALL( m_Interface, allocQueue );
|
||||
if( !m_Queue )
|
||||
@@ -128,7 +128,7 @@ bool HIDDevice::Open( io_object_t device )
|
||||
LOG->Warn( "Couldn't allocate a queue." );
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
if( (ret = CALL(m_Queue, create, 0, 32)) != kIOReturnSuccess )
|
||||
{
|
||||
PrintIOErr( ret, "Failed to create the queue." );
|
||||
@@ -138,7 +138,7 @@ bool HIDDevice::Open( io_object_t device )
|
||||
m_Interface = NULL;
|
||||
return false;
|
||||
}
|
||||
|
||||
|
||||
Open();
|
||||
LOG->Trace( "\t\tDevice open" );
|
||||
return true;
|
||||
@@ -149,32 +149,32 @@ void HIDDevice::StartQueue( CFRunLoopRef loopRef, IOHIDCallbackFunction callback
|
||||
CFRunLoopSourceRef runLoopSource;
|
||||
// This creates a run loop source. It is released in the dtor.
|
||||
IOReturn ret = CALL( m_Queue, createAsyncEventSource, &runLoopSource );
|
||||
|
||||
|
||||
if( ret != kIOReturnSuccess )
|
||||
{
|
||||
PrintIOErr( ret, "Failed to create async event source." );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
if( !CFRunLoopContainsSource(loopRef, runLoopSource, kCFRunLoopDefaultMode) )
|
||||
CFRunLoopAddSource( loopRef, runLoopSource, kCFRunLoopDefaultMode );
|
||||
|
||||
|
||||
ret = CALL( m_Queue, setEventCallout, callback, target, (void *)refCon );
|
||||
|
||||
|
||||
if( ret != kIOReturnSuccess )
|
||||
{
|
||||
PrintIOErr( ret, "Failed to set the call back." );
|
||||
return;
|
||||
}
|
||||
|
||||
|
||||
// start the queue
|
||||
ret = CALL( m_Queue, start );
|
||||
|
||||
|
||||
if( ret != kIOReturnSuccess )
|
||||
{
|
||||
CFRunLoopSourceInvalidate( runLoopSource );
|
||||
CFRelease( runLoopSource );
|
||||
|
||||
|
||||
PrintIOErr( ret, "Failed to start the queue." );
|
||||
return;
|
||||
}
|
||||
@@ -185,32 +185,32 @@ void HIDDevice::AddLogicalDevice( const void *value, void *context )
|
||||
{
|
||||
if( CFGetTypeID(CFTypeRef(value)) != CFDictionaryGetTypeID() )
|
||||
return;
|
||||
|
||||
|
||||
CFDictionaryRef properties = CFDictionaryRef( value );
|
||||
HIDDevice *This = (HIDDevice *)context;
|
||||
CFTypeRef object;
|
||||
int usage, usagePage;
|
||||
|
||||
|
||||
// Get usage page
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDElementUsagePageKey) );
|
||||
if( !IntValue(object, usagePage) )
|
||||
return;
|
||||
|
||||
|
||||
// Get usage
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDElementUsageKey) );
|
||||
if( !IntValue(object, usage) )
|
||||
return;
|
||||
|
||||
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDElementKey) );
|
||||
if( !object || CFGetTypeID(object) != CFArrayGetTypeID() )
|
||||
return;
|
||||
|
||||
|
||||
if( !This->AddLogicalDevice(usagePage, usage) )
|
||||
return;
|
||||
|
||||
|
||||
CFArrayRef elements = CFArrayRef( object );
|
||||
CFRange r = { 0, CFArrayGetCount(elements) };
|
||||
|
||||
|
||||
CFArrayApplyFunction( elements, r, HIDDevice::AddElement, This );
|
||||
}
|
||||
|
||||
@@ -218,34 +218,33 @@ void HIDDevice::AddElement( const void *value, void *context )
|
||||
{
|
||||
if( CFGetTypeID(CFTypeRef(value)) != CFDictionaryGetTypeID() )
|
||||
return;
|
||||
|
||||
|
||||
CFDictionaryRef properties = CFDictionaryRef( value );
|
||||
HIDDevice *This = (HIDDevice *)context;
|
||||
CFTypeRef object;
|
||||
int usage, usagePage;
|
||||
long cookie;
|
||||
|
||||
|
||||
// Recursively add elements
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDElementKey) );
|
||||
if( object && CFGetTypeID(object) == CFArrayGetTypeID() )
|
||||
{
|
||||
CFArrayRef elements = CFArrayRef( object );
|
||||
CFRange r = { 0, CFArrayGetCount(elements) };
|
||||
|
||||
|
||||
CFArrayApplyFunction( elements, r, AddElement, context );
|
||||
}
|
||||
|
||||
|
||||
// Get usage page
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDElementUsagePageKey) );
|
||||
if( !IntValue(object, usagePage) )
|
||||
return;
|
||||
|
||||
|
||||
// Get usage
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDElementUsageKey) );
|
||||
if( !IntValue(object, usage) )
|
||||
return;
|
||||
|
||||
|
||||
|
||||
// Get cookie
|
||||
object = CFDictionaryGetValue( properties, CFSTR(kIOHIDElementCookieKey) );
|
||||
if( !LongValue(object, cookie) )
|
||||
|
||||
@@ -55,9 +55,8 @@ namespace __gnu_cxx
|
||||
};
|
||||
}
|
||||
|
||||
/*
|
||||
* This is just awful, these aren't objects, treating them as such leads
|
||||
* to: (*object)->function(object [, argument]...)
|
||||
/* This is just awful, these aren't objects, treating them as such
|
||||
* leads to: (*object)->function(object [, argument]...)
|
||||
* Instead, do: CALL(object, function [, argument]...)
|
||||
*/
|
||||
#define CALL(o,f,...) (*(o))->f((o), ## __VA_ARGS__)
|
||||
@@ -69,34 +68,26 @@ private:
|
||||
IOHIDQueueInterface **m_Queue;
|
||||
bool m_bRunning;
|
||||
RString m_sDescription;
|
||||
|
||||
|
||||
static void AddLogicalDevice( const void *value, void *context );
|
||||
static void AddElement( const void *value, void *context );
|
||||
|
||||
|
||||
protected:
|
||||
/*
|
||||
* Each physical device has zero or more logical devices. If this device allows
|
||||
* a logical device of type (usagePage, usage), then allocate storage as necessary
|
||||
* and return true, otherwise, return false.
|
||||
*/
|
||||
/* Each physical device has zero or more logical devices. If this device
|
||||
* allows a logical device of type (usagePage, usage), then allocate storage
|
||||
* as necessary and return true, otherwise, return false. */
|
||||
virtual bool AddLogicalDevice( int usagePage, int usage ) = 0;
|
||||
|
||||
/*
|
||||
* If the most recently added logical device cares about the state of an element of type
|
||||
* (usagePage, usage), store the cookie.
|
||||
*/
|
||||
|
||||
/* If the most recently added logical device cares about the state of an
|
||||
* element of type (usagePage, usage), store the cookie. */
|
||||
virtual void AddElement( int usagePage, int usage, IOHIDElementCookie cookie, const CFDictionaryRef properties ) = 0;
|
||||
|
||||
/*
|
||||
* Add any elements to the queue by calling AddElementToQueue() with the stored cookies.
|
||||
*/
|
||||
|
||||
// Add any elements to the queue by calling AddElementToQueue() with the stored cookies.
|
||||
virtual void Open() = 0;
|
||||
|
||||
/*
|
||||
* Optional. Subclasses can initialize the device, if required.
|
||||
*/
|
||||
|
||||
// Optional. Subclasses can initialize the device, if required.
|
||||
virtual bool InitDevice( int vid, int pid ) { return true; }
|
||||
|
||||
|
||||
// This adds the element with the given cookie to the queue to be notified of state changes.
|
||||
inline void AddElementToQueue( IOHIDElementCookie cookie )
|
||||
{
|
||||
@@ -104,7 +95,7 @@ protected:
|
||||
if( ret != KERN_SUCCESS )
|
||||
LOG->Warn( "Failed to add HID element with cookie %p to queue: %u", cookie, ret );
|
||||
}
|
||||
|
||||
|
||||
// Perform a synchronous set report on the HID interface.
|
||||
inline IOReturn SetReport( IOHIDReportType type, UInt32 reportID, void *buffer, UInt32 size, UInt32 timeoutMS )
|
||||
{
|
||||
@@ -113,31 +104,27 @@ protected:
|
||||
public:
|
||||
HIDDevice();
|
||||
virtual ~HIDDevice();
|
||||
|
||||
|
||||
bool Open( io_object_t device );
|
||||
void StartQueue( CFRunLoopRef loopRef, IOHIDCallbackFunction callback, void *target, int refCon );
|
||||
inline const RString& GetDescription() const { return m_sDescription; }
|
||||
|
||||
|
||||
/*
|
||||
* Add button presses (or releases) to vPresses for the given cookie. More than one DeviceInput
|
||||
* can be added at a time. For example, Two axes presses may be generated by a single element.
|
||||
* The value of the element is passed to determine if this is a push or a release. The time
|
||||
* is provided as an optimization.
|
||||
*/
|
||||
|
||||
/* Add button presses (or releases) to vPresses for the given cookie. More
|
||||
* than one DeviceInput can be added at a time. For example, Two axes
|
||||
* presses may be generated by a single element. The value of the element is
|
||||
* passed to determine if this is a push or a release. The time is provided
|
||||
* as an optimization. */
|
||||
virtual void GetButtonPresses( vector<DeviceInput>& vPresses, IOHIDElementCookie cookie, int value, const RageTimer& now ) const = 0;
|
||||
|
||||
/*
|
||||
* Returns the number of IDs assigned starting from startID. This is not meaningful for devices like
|
||||
* keyboards that all share the same InputDevice id. If a particular device has multiple logical
|
||||
* devices, then it must ensure that AssignIDs does not assign an ID outside of its range. Return
|
||||
* -1 to indicate that the device does not share the same InputDevice and none could be assigned.
|
||||
*/
|
||||
|
||||
/* Returns the number of IDs assigned starting from startID. This is not
|
||||
* meaningful for devices like keyboards that all share the same InputDevice
|
||||
* id. If a particular device has multiple logical devices, then it must
|
||||
* ensure that AssignIDs does not assign an ID outside of its range.
|
||||
* Return -1 to indicate that the device does not share the same InputDevice
|
||||
* and none could be assigned. */
|
||||
virtual int AssignIDs( InputDevice startID ) { return 0; }
|
||||
|
||||
/*
|
||||
* Add a device and a description for each logical device.
|
||||
*/
|
||||
|
||||
//Add a device and a description for each logical device.
|
||||
virtual void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const = 0;
|
||||
};
|
||||
|
||||
|
||||
@@ -11,75 +11,75 @@ bool KeyboardDevice::AddLogicalDevice( int usagePage, int usage )
|
||||
static bool UsbKeyToDeviceButton( UInt8 iUsbKey, DeviceButton &buttonOut )
|
||||
{
|
||||
UInt8 usage = iUsbKey;
|
||||
|
||||
|
||||
if( usage < kHIDUsage_KeyboardA )
|
||||
return false;
|
||||
|
||||
|
||||
if( usage <= kHIDUsage_KeyboardZ )
|
||||
{
|
||||
buttonOut = enum_add2( KEY_Ca, usage - kHIDUsage_KeyboardA );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// KEY_C0 = KEY_C1 - 1, kHIDUsage_Keyboard0 = kHIDUsage_Keyboard9 + 1
|
||||
if( usage <= kHIDUsage_Keyboard9 )
|
||||
{
|
||||
buttonOut = enum_add2( KEY_C1, usage - kHIDUsage_Keyboard1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if( usage >= kHIDUsage_KeyboardF1 && usage <= kHIDUsage_KeyboardF12 )
|
||||
{
|
||||
buttonOut = enum_add2( KEY_F1, usage - kHIDUsage_KeyboardF1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
if( usage >= kHIDUsage_KeyboardF13 && usage <= kHIDUsage_KeyboardF16 )
|
||||
{
|
||||
buttonOut = enum_add2( KEY_F13, usage - kHIDUsage_KeyboardF13 );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// keypad 0 is again backward
|
||||
if( usage >= kHIDUsage_Keypad1 && usage <= kHIDUsage_Keypad9 )
|
||||
{
|
||||
buttonOut = enum_add2( KEY_KP_C1, usage - kHIDUsage_Keypad1 );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#define OTHER(n) (enum_add2(KEY_OTHER_0, (n)))
|
||||
|
||||
|
||||
// [0, 8]
|
||||
if( usage >= kHIDUsage_KeyboardF17 && usage <= kHIDUsage_KeyboardExecute )
|
||||
{
|
||||
buttonOut = OTHER( 0 + usage - kHIDUsage_KeyboardF17 );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// [9, 19]
|
||||
if( usage >= kHIDUsage_KeyboardSelect && usage <= kHIDUsage_KeyboardVolumeDown )
|
||||
{
|
||||
buttonOut = OTHER( 9 + usage - kHIDUsage_KeyboardSelect );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
// [20, 41]
|
||||
if( usage >= kHIDUsage_KeypadEqualSignAS400 && usage <= kHIDUsage_KeyboardCancel )
|
||||
{
|
||||
buttonOut = OTHER( 20 + usage - kHIDUsage_KeypadEqualSignAS400 );
|
||||
return true;
|
||||
}
|
||||
|
||||
// [42, 47]
|
||||
|
||||
// [42, 47]
|
||||
// XXX kHIDUsage_KeyboardClearOrAgain
|
||||
if( usage >= kHIDUsage_KeyboardSeparator && usage <= kHIDUsage_KeyboardExSel )
|
||||
{
|
||||
buttonOut = OTHER( 32 + usage - kHIDUsage_KeyboardSeparator );
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
#define X(x,y) case x: buttonOut = y; return true
|
||||
|
||||
|
||||
// Time for the special cases
|
||||
switch( usage )
|
||||
{
|
||||
@@ -146,7 +146,7 @@ static bool UsbKeyToDeviceButton( UInt8 iUsbKey, DeviceButton &buttonOut )
|
||||
}
|
||||
#undef X
|
||||
#undef OTHER
|
||||
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
@@ -154,7 +154,7 @@ void KeyboardDevice::AddElement( int usagePage, int usage, IOHIDElementCookie co
|
||||
{
|
||||
if( usagePage != kHIDPage_KeyboardOrKeypad )
|
||||
return;
|
||||
|
||||
|
||||
DeviceButton button;
|
||||
if( UsbKeyToDeviceButton(usage,button) )
|
||||
m_Mapping[cookie] = button;
|
||||
@@ -172,14 +172,14 @@ void KeyboardDevice::Open()
|
||||
void KeyboardDevice::GetButtonPresses( vector<DeviceInput>& vPresses, IOHIDElementCookie cookie, int value, const RageTimer& now ) const
|
||||
{
|
||||
hash_map<IOHIDElementCookie, DeviceButton>::const_iterator iter = m_Mapping.find( cookie );
|
||||
|
||||
|
||||
if( iter != m_Mapping.end() )
|
||||
{
|
||||
//LOG->Trace( "Pushed %s", DeviceButtonToString(iter->second).c_str() );
|
||||
vPresses.push_back( DeviceInput(DEVICE_KEYBOARD, iter->second, value, now) );
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
void KeyboardDevice::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const
|
||||
{
|
||||
if( vDevices.size() && vDevices[0].id == DEVICE_KEYBOARD )
|
||||
@@ -187,283 +187,282 @@ void KeyboardDevice::GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevice
|
||||
vDevices.insert( vDevices.begin(), InputDeviceInfo(DEVICE_KEYBOARD, "Keyboard") );
|
||||
}
|
||||
|
||||
|
||||
// http://lists.apple.com/archives/carbon-dev/2005/Feb/msg00071.html
|
||||
// index represents USB keyboard usage value, content is Mac virtual keycode
|
||||
static UInt8 g_iUsbKeyToMacVirtualKey[256] =
|
||||
{
|
||||
0xFF, /* 00 no event */
|
||||
0xFF, /* 01 ErrorRollOver */
|
||||
0xFF, /* 02 POSTFail */
|
||||
0xFF, /* 03 ErrorUndefined */
|
||||
0x00, /* 04 A */
|
||||
0x0B, /* 05 B */
|
||||
0x08, /* 06 C */
|
||||
0x02, /* 07 D */
|
||||
0x0E, /* 08 E */
|
||||
0x03, /* 09 F */
|
||||
0x05, /* 0A G */
|
||||
0x04, /* 0B H */
|
||||
0x22, /* 0C I */
|
||||
0x26, /* 0D J */
|
||||
0x28, /* 0E K */
|
||||
0x25, /* 0F L */
|
||||
static UInt8 g_iUsbKeyToMacVirtualKey[256] =
|
||||
{
|
||||
0xFF, // 00 no event
|
||||
0xFF, // 01 ErrorRollOver
|
||||
0xFF, // 02 POSTFail
|
||||
0xFF, // 03 ErrorUndefined
|
||||
0x00, // 04 A
|
||||
0x0B, // 05 B
|
||||
0x08, // 06 C
|
||||
0x02, // 07 D
|
||||
0x0E, // 08 E
|
||||
0x03, // 09 F
|
||||
0x05, // 0A G
|
||||
0x04, // 0B H
|
||||
0x22, // 0C I
|
||||
0x26, // 0D J
|
||||
0x28, // 0E K
|
||||
0x25, // 0F L
|
||||
|
||||
0x2E, /* 10 M */
|
||||
0x2D, /* 11 N */
|
||||
0x1F, /* 12 O */
|
||||
0x23, /* 13 P */
|
||||
0x0C, /* 14 Q */
|
||||
0x0F, /* 15 R */
|
||||
0x01, /* 16 S */
|
||||
0x11, /* 17 T */
|
||||
0x20, /* 18 U */
|
||||
0x09, /* 19 V */
|
||||
0x0D, /* 1A W */
|
||||
0x07, /* 1B X */
|
||||
0x10, /* 1C Y */
|
||||
0x06, /* 1D Z */
|
||||
0x12, /* 1E 1/! */
|
||||
0x13, /* 1F 2/@ */
|
||||
0x2E, // 10 M
|
||||
0x2D, // 11 N
|
||||
0x1F, // 12 O
|
||||
0x23, // 13 P
|
||||
0x0C, // 14 Q
|
||||
0x0F, // 15 R
|
||||
0x01, // 16 S
|
||||
0x11, // 17 T
|
||||
0x20, // 18 U
|
||||
0x09, // 19 V
|
||||
0x0D, // 1A W
|
||||
0x07, // 1B X
|
||||
0x10, // 1C Y
|
||||
0x06, // 1D Z
|
||||
0x12, // 1E 1/!
|
||||
0x13, // 1F 2/@
|
||||
|
||||
0x14, /* 20 3 # */
|
||||
0x15, /* 21 4 $ */
|
||||
0x17, /* 22 5 % */
|
||||
0x16, /* 23 6 ^ */
|
||||
0x1A, /* 24 7 & */
|
||||
0x1C, /* 25 8 * */
|
||||
0x19, /* 26 9 ( */
|
||||
0x1D, /* 27 0 ) */
|
||||
0x24, /* 28 Return (Enter) */
|
||||
0x35, /* 29 ESC */
|
||||
0x33, /* 2A Delete (Backspace) */
|
||||
0x30, /* 2B Tab */
|
||||
0x31, /* 2C Spacebar */
|
||||
0x1B, /* 2D - _ */
|
||||
0x18, /* 2E = + */
|
||||
0x21, /* 2F [ { */
|
||||
0x14, // 20 3 #
|
||||
0x15, // 21 4 $
|
||||
0x17, // 22 5 %
|
||||
0x16, // 23 6 ^
|
||||
0x1A, // 24 7 &
|
||||
0x1C, // 25 8 *
|
||||
0x19, // 26 9 (
|
||||
0x1D, // 27 0 )
|
||||
0x24, // 28 Return (Enter)
|
||||
0x35, // 29 ESC
|
||||
0x33, // 2A Delete (Backspace)
|
||||
0x30, // 2B Tab
|
||||
0x31, // 2C Spacebar
|
||||
0x1B, // 2D - _
|
||||
0x18, // 2E = +
|
||||
0x21, // 2F [ {
|
||||
|
||||
0x1E, /* 30 ] } */
|
||||
0x2A, /* 31 \ | */
|
||||
0xFF, /* 32 Non-US # and ~ (what?!!!) */
|
||||
0x29, /* 33 ; : */
|
||||
0x27, /* 34 ' " */
|
||||
0x32, /* 35 ` ~ */
|
||||
0x2B, /* 36 , < */
|
||||
0x2F, /* 37 . > */
|
||||
0x2C, /* 38 / ? */
|
||||
0x39, /* 39 Caps Lock */
|
||||
0x7A, /* 3A F1 */
|
||||
0x78, /* 3B F2 */
|
||||
0x63, /* 3C F3 */
|
||||
0x76, /* 3D F4 */
|
||||
0x60, /* 3E F5 */
|
||||
0x61, /* 3F F6 */
|
||||
0x1E, // 30 ] }
|
||||
0x2A, // 31 \ |
|
||||
0xFF, // 32 Non-US # and ~ (what?!!!)
|
||||
0x29, // 33 ; :
|
||||
0x27, // 34 ' "
|
||||
0x32, // 35 ` ~
|
||||
0x2B, // 36 , <
|
||||
0x2F, // 37 . >
|
||||
0x2C, // 38 / ?
|
||||
0x39, // 39 Caps Lock
|
||||
0x7A, // 3A F1
|
||||
0x78, // 3B F2
|
||||
0x63, // 3C F3
|
||||
0x76, // 3D F4
|
||||
0x60, // 3E F5
|
||||
0x61, // 3F F6
|
||||
|
||||
0x62, /* 40 F7 */
|
||||
0x64, /* 41 F8 */
|
||||
0x65, /* 42 F9 */
|
||||
0x6D, /* 43 F10 */
|
||||
0x67, /* 44 F11 */
|
||||
0x6F, /* 45 F12 */
|
||||
0x69, /* 46 F13/PrintScreen */
|
||||
0x6B, /* 47 F14/ScrollLock */
|
||||
0x71, /* 48 F15/Pause */
|
||||
0x72, /* 49 Insert */
|
||||
0x73, /* 4A Home */
|
||||
0x74, /* 4B PageUp */
|
||||
0x75, /* 4C Delete Forward */
|
||||
0x77, /* 4D End */
|
||||
0x79, /* 4E PageDown */
|
||||
0x7C, /* 4F RightArrow */
|
||||
0x62, // 40 F7
|
||||
0x64, // 41 F8
|
||||
0x65, // 42 F9
|
||||
0x6D, // 43 F10
|
||||
0x67, // 44 F11
|
||||
0x6F, // 45 F12
|
||||
0x69, // 46 F13/PrintScreen
|
||||
0x6B, // 47 F14/ScrollLock
|
||||
0x71, // 48 F15/Pause
|
||||
0x72, // 49 Insert
|
||||
0x73, // 4A Home
|
||||
0x74, // 4B PageUp
|
||||
0x75, // 4C Delete Forward
|
||||
0x77, // 4D End
|
||||
0x79, // 4E PageDown
|
||||
0x7C, // 4F RightArrow
|
||||
|
||||
0x7B, /* 50 LeftArrow */
|
||||
0x7D, /* 51 DownArrow */
|
||||
0x7E, /* 52 UpArrow */
|
||||
0x47, /* 53 NumLock/Clear */
|
||||
0x4B, /* 54 Keypad / */
|
||||
0x43, /* 55 Keypad * */
|
||||
0x4E, /* 56 Keypad - */
|
||||
0x45, /* 57 Keypad + */
|
||||
0x4C, /* 58 Keypad Enter */
|
||||
0x53, /* 59 Keypad 1 */
|
||||
0x54, /* 5A Keypad 2 */
|
||||
0x55, /* 5B Keypad 3 */
|
||||
0x56, /* 5C Keypad 4 */
|
||||
0x57, /* 5D Keypad 5 */
|
||||
0x58, /* 5E Keypad 6 */
|
||||
0x59, /* 5F Keypad 7 */
|
||||
0x7B, // 50 LeftArrow
|
||||
0x7D, // 51 DownArrow
|
||||
0x7E, // 52 UpArrow
|
||||
0x47, // 53 NumLock/Clear
|
||||
0x4B, // 54 Keypad /
|
||||
0x43, // 55 Keypad *
|
||||
0x4E, // 56 Keypad -
|
||||
0x45, // 57 Keypad +
|
||||
0x4C, // 58 Keypad Enter
|
||||
0x53, // 59 Keypad 1
|
||||
0x54, // 5A Keypad 2
|
||||
0x55, // 5B Keypad 3
|
||||
0x56, // 5C Keypad 4
|
||||
0x57, // 5D Keypad 5
|
||||
0x58, // 5E Keypad 6
|
||||
0x59, // 5F Keypad 7
|
||||
|
||||
0x5B, /* 60 Keypad 8 */
|
||||
0x5C, /* 61 Keypad 9 */
|
||||
0x52, /* 62 Keypad 0 */
|
||||
0x41, /* 63 Keypad . */
|
||||
0xFF, /* 64 Non-US \ and | (what ??!!) */
|
||||
0x6E, /* 65 ApplicationKey (not on a mac!)*/
|
||||
0x7F, /* 66 PowerKey */
|
||||
0x51, /* 67 Keypad = */
|
||||
0x69, /* 68 F13 */
|
||||
0x6B, /* 69 F14 */
|
||||
0x71, /* 6A F15 */
|
||||
0xFF, /* 6B F16 */
|
||||
0xFF, /* 6C F17 */
|
||||
0xFF, /* 6D F18 */
|
||||
0xFF, /* 6E F19 */
|
||||
0xFF, /* 6F F20 */
|
||||
0x5B, // 60 Keypad 8
|
||||
0x5C, // 61 Keypad 9
|
||||
0x52, // 62 Keypad 0
|
||||
0x41, // 63 Keypad .
|
||||
0xFF, // 64 Non-US \ and | (what ??!!)
|
||||
0x6E, // 65 ApplicationKey (not on Apple keyboards)
|
||||
0x7F, // 66 PowerKey
|
||||
0x51, // 67 Keypad =
|
||||
0x69, // 68 F13
|
||||
0x6B, // 69 F14
|
||||
0x71, // 6A F15
|
||||
0xFF, // 6B F16
|
||||
0xFF, // 6C F17
|
||||
0xFF, // 6D F18
|
||||
0xFF, // 6E F19
|
||||
0xFF, // 6F F20
|
||||
|
||||
0x5B, /* 70 F21 */
|
||||
0x5C, /* 71 F22 */
|
||||
0x52, /* 72 F23 */
|
||||
0x41, /* 73 F24 */
|
||||
0xFF, /* 74 Execute */
|
||||
0xFF, /* 75 Help */
|
||||
0x7F, /* 76 Menu */
|
||||
0x4C, /* 77 Select */
|
||||
0x69, /* 78 Stop */
|
||||
0x6B, /* 79 Again */
|
||||
0x71, /* 7A Undo */
|
||||
0xFF, /* 7B Cut */
|
||||
0xFF, /* 7C Copy */
|
||||
0xFF, /* 7D Paste */
|
||||
0xFF, /* 7E Find */
|
||||
0xFF, /* 7F Mute */
|
||||
|
||||
0xFF, /* 80 no event */
|
||||
0xFF, /* 81 no event */
|
||||
0xFF, /* 82 no event */
|
||||
0xFF, /* 83 no event */
|
||||
0xFF, /* 84 no event */
|
||||
0xFF, /* 85 no event */
|
||||
0xFF, /* 86 no event */
|
||||
0xFF, /* 87 no event */
|
||||
0xFF, /* 88 no event */
|
||||
0xFF, /* 89 no event */
|
||||
0xFF, /* 8A no event */
|
||||
0xFF, /* 8B no event */
|
||||
0xFF, /* 8C no event */
|
||||
0xFF, /* 8D no event */
|
||||
0xFF, /* 8E no event */
|
||||
0xFF, /* 8F no event */
|
||||
0x5B, // 70 F21
|
||||
0x5C, // 71 F22
|
||||
0x52, // 72 F23
|
||||
0x41, // 73 F24
|
||||
0xFF, // 74 Execute
|
||||
0xFF, // 75 Help
|
||||
0x7F, // 76 Menu
|
||||
0x4C, // 77 Select
|
||||
0x69, // 78 Stop
|
||||
0x6B, // 79 Again
|
||||
0x71, // 7A Undo
|
||||
0xFF, // 7B Cut
|
||||
0xFF, // 7C Copy
|
||||
0xFF, // 7D Paste
|
||||
0xFF, // 7E Find
|
||||
0xFF, // 7F Mute
|
||||
|
||||
0xFF, /* 90 no event */
|
||||
0xFF, /* 91 no event */
|
||||
0xFF, /* 92 no event */
|
||||
0xFF, /* 93 no event */
|
||||
0xFF, /* 94 no event */
|
||||
0xFF, /* 95 no event */
|
||||
0xFF, /* 96 no event */
|
||||
0xFF, /* 97 no event */
|
||||
0xFF, /* 98 no event */
|
||||
0xFF, /* 99 no event */
|
||||
0xFF, /* 9A no event */
|
||||
0xFF, /* 9B no event */
|
||||
0xFF, /* 9C no event */
|
||||
0xFF, /* 9D no event */
|
||||
0xFF, /* 9E no event */
|
||||
0xFF, /* 9F no event */
|
||||
0xFF, // 80 no event
|
||||
0xFF, // 81 no event
|
||||
0xFF, // 82 no event
|
||||
0xFF, // 83 no event
|
||||
0xFF, // 84 no event
|
||||
0xFF, // 85 no event
|
||||
0xFF, // 86 no event
|
||||
0xFF, // 87 no event
|
||||
0xFF, // 88 no event
|
||||
0xFF, // 89 no event
|
||||
0xFF, // 8A no event
|
||||
0xFF, // 8B no event
|
||||
0xFF, // 8C no event
|
||||
0xFF, // 8D no event
|
||||
0xFF, // 8E no event
|
||||
0xFF, // 8F no event
|
||||
|
||||
0xFF, /* A0 no event */
|
||||
0xFF, /* A1 no event */
|
||||
0xFF, /* A2 no event */
|
||||
0xFF, /* A3 no event */
|
||||
0xFF, /* A4 no event */
|
||||
0xFF, /* A5 no event */
|
||||
0xFF, /* A6 no event */
|
||||
0xFF, /* A7 no event */
|
||||
0xFF, /* A8 no event */
|
||||
0xFF, /* A9 no event */
|
||||
0xFF, /* AA no event */
|
||||
0xFF, /* AB no event */
|
||||
0xFF, /* AC no event */
|
||||
0xFF, /* AD no event */
|
||||
0xFF, /* AE no event */
|
||||
0xFF, /* AF no event */
|
||||
0xFF, // 90 no event
|
||||
0xFF, // 91 no event
|
||||
0xFF, // 92 no event
|
||||
0xFF, // 93 no event
|
||||
0xFF, // 94 no event
|
||||
0xFF, // 95 no event
|
||||
0xFF, // 96 no event
|
||||
0xFF, // 97 no event
|
||||
0xFF, // 98 no event
|
||||
0xFF, // 99 no event
|
||||
0xFF, // 9A no event
|
||||
0xFF, // 9B no event
|
||||
0xFF, // 9C no event
|
||||
0xFF, // 9D no event
|
||||
0xFF, // 9E no event
|
||||
0xFF, // 9F no event
|
||||
|
||||
0xFF, /* B0 no event */
|
||||
0xFF, /* B1 no event */
|
||||
0xFF, /* B2 no event */
|
||||
0xFF, /* B3 no event */
|
||||
0xFF, /* B4 no event */
|
||||
0xFF, /* B5 no event */
|
||||
0xFF, /* B6 no event */
|
||||
0xFF, /* B7 no event */
|
||||
0xFF, /* B8 no event */
|
||||
0xFF, /* B9 no event */
|
||||
0xFF, /* BA no event */
|
||||
0xFF, /* BB no event */
|
||||
0xFF, /* BC no event */
|
||||
0xFF, /* BD no event */
|
||||
0xFF, /* BE no event */
|
||||
0xFF, /* BF no event */
|
||||
0xFF, // A0 no event
|
||||
0xFF, // A1 no event
|
||||
0xFF, // A2 no event
|
||||
0xFF, // A3 no event
|
||||
0xFF, // A4 no event
|
||||
0xFF, // A5 no event
|
||||
0xFF, // A6 no event
|
||||
0xFF, // A7 no event
|
||||
0xFF, // A8 no event
|
||||
0xFF, // A9 no event
|
||||
0xFF, // AA no event
|
||||
0xFF, // AB no event
|
||||
0xFF, // AC no event
|
||||
0xFF, // AD no event
|
||||
0xFF, // AE no event
|
||||
0xFF, // AF no event
|
||||
|
||||
0xFF, /* C0 no event */
|
||||
0xFF, /* C1 no event */
|
||||
0xFF, /* C2 no event */
|
||||
0xFF, /* C3 no event */
|
||||
0xFF, /* C4 no event */
|
||||
0xFF, /* C5 no event */
|
||||
0xFF, /* C6 no event */
|
||||
0xFF, /* C7 no event */
|
||||
0xFF, /* C8 no event */
|
||||
0xFF, /* C9 no event */
|
||||
0xFF, /* CA no event */
|
||||
0xFF, /* CB no event */
|
||||
0xFF, /* CC no event */
|
||||
0xFF, /* CD no event */
|
||||
0xFF, /* CE no event */
|
||||
0xFF, /* CF no event */
|
||||
0xFF, // B0 no event
|
||||
0xFF, // B1 no event
|
||||
0xFF, // B2 no event
|
||||
0xFF, // B3 no event
|
||||
0xFF, // B4 no event
|
||||
0xFF, // B5 no event
|
||||
0xFF, // B6 no event
|
||||
0xFF, // B7 no event
|
||||
0xFF, // B8 no event
|
||||
0xFF, // B9 no event
|
||||
0xFF, // BA no event
|
||||
0xFF, // BB no event
|
||||
0xFF, // BC no event
|
||||
0xFF, // BD no event
|
||||
0xFF, // BE no event
|
||||
0xFF, // BF no event
|
||||
|
||||
0xFF, /* D0 no event */
|
||||
0xFF, /* D1 no event */
|
||||
0xFF, /* D2 no event */
|
||||
0xFF, /* D3 no event */
|
||||
0xFF, /* D4 no event */
|
||||
0xFF, /* D5 no event */
|
||||
0xFF, /* D6 no event */
|
||||
0xFF, /* D7 no event */
|
||||
0xFF, /* D8 no event */
|
||||
0xFF, /* D9 no event */
|
||||
0xFF, /* DA no event */
|
||||
0xFF, /* DB no event */
|
||||
0xFF, /* DC no event */
|
||||
0xFF, /* DD no event */
|
||||
0xFF, /* DE no event */
|
||||
0xFF, /* DF no event */
|
||||
0xFF, // C0 no event
|
||||
0xFF, // C1 no event
|
||||
0xFF, // C2 no event
|
||||
0xFF, // C3 no event
|
||||
0xFF, // C4 no event
|
||||
0xFF, // C5 no event
|
||||
0xFF, // C6 no event
|
||||
0xFF, // C7 no event
|
||||
0xFF, // C8 no event
|
||||
0xFF, // C9 no event
|
||||
0xFF, // CA no event
|
||||
0xFF, // CB no event
|
||||
0xFF, // CC no event
|
||||
0xFF, // CD no event
|
||||
0xFF, // CE no event
|
||||
0xFF, // CF no event
|
||||
|
||||
0x3B, /* E0 left control key */
|
||||
0x38, /* E1 left shift key key */
|
||||
0x3A, /* E2 left alt/option key */
|
||||
0x37, /* E3 left GUI (windows/cmd) key */
|
||||
|
||||
0x3B, /* E4 right control key */
|
||||
0x38, /* E5 right shift key key */
|
||||
0x3A, /* E6 right alt/option key */
|
||||
0x37, /* E7 right GUI (windows/cmd) key */
|
||||
0xFF, /* E8 no event */
|
||||
0xFF, /* E9 no event */
|
||||
0xFF, /* EA no event */
|
||||
0xFF, /* EB no event */
|
||||
0xFF, /* EC no event */
|
||||
0xFF, /* ED no event */
|
||||
0xFF, /* EE no event */
|
||||
0xFF, /* EF no event */
|
||||
|
||||
0xFF, /* F0 no event */
|
||||
0xFF, /* F1 no event */
|
||||
0xFF, /* F2 no event */
|
||||
0xFF, /* F3 no event */
|
||||
0xFF, /* F4 no event */
|
||||
0xFF, /* F5 no event */
|
||||
0xFF, /* F6 no event */
|
||||
0xFF, /* F7 no event */
|
||||
0xFF, /* F8 no event */
|
||||
0xFF, /* F9 no event */
|
||||
0xFF, /* FA no event */
|
||||
0xFF, /* FB no event */
|
||||
0xFF, /* FC no event */
|
||||
0xFF, /* FD no event */
|
||||
0xFF, /* FE no event */
|
||||
0xFF, /* FF no event */
|
||||
0xFF, // D0 no event
|
||||
0xFF, // D1 no event
|
||||
0xFF, // D2 no event
|
||||
0xFF, // D3 no event
|
||||
0xFF, // D4 no event
|
||||
0xFF, // D5 no event
|
||||
0xFF, // D6 no event
|
||||
0xFF, // D7 no event
|
||||
0xFF, // D8 no event
|
||||
0xFF, // D9 no event
|
||||
0xFF, // DA no event
|
||||
0xFF, // DB no event
|
||||
0xFF, // DC no event
|
||||
0xFF, // DD no event
|
||||
0xFF, // DE no event
|
||||
0xFF, // DF no event
|
||||
|
||||
0x3B, // E0 left control key
|
||||
0x38, // E1 left shift key key
|
||||
0x3A, // E2 left alt/option key
|
||||
0x37, // E3 left GUI (windows/cmd) key
|
||||
|
||||
0x3B, // E4 right control key
|
||||
0x38, // E5 right shift key key
|
||||
0x3A, // E6 right alt/option key
|
||||
0x37, // E7 right GUI (windows/cmd) key
|
||||
0xFF, // E8 no event
|
||||
0xFF, // E9 no event
|
||||
0xFF, // EA no event
|
||||
0xFF, // EB no event
|
||||
0xFF, // EC no event
|
||||
0xFF, // ED no event
|
||||
0xFF, // EE no event
|
||||
0xFF, // EF no event
|
||||
|
||||
0xFF, // F0 no event
|
||||
0xFF, // F1 no event
|
||||
0xFF, // F2 no event
|
||||
0xFF, // F3 no event
|
||||
0xFF, // F4 no event
|
||||
0xFF, // F5 no event
|
||||
0xFF, // F6 no event
|
||||
0xFF, // F7 no event
|
||||
0xFF, // F8 no event
|
||||
0xFF, // F9 no event
|
||||
0xFF, // FA no event
|
||||
0xFF, // FB no event
|
||||
0xFF, // FC no event
|
||||
0xFF, // FD no event
|
||||
0xFF, // FE no event
|
||||
0xFF, // FF no event
|
||||
};
|
||||
|
||||
static UInt8 g_iDeviceButtonToMacVirtualKey[KEY_OTHER_0];
|
||||
@@ -471,7 +470,7 @@ static UInt8 g_iDeviceButtonToMacVirtualKey[KEY_OTHER_0];
|
||||
bool KeyboardDevice::DeviceButtonToMacVirtualKey( DeviceButton button, UInt8 &iMacVKOut )
|
||||
{
|
||||
static bool bInited = false;
|
||||
|
||||
|
||||
if( !bInited )
|
||||
{
|
||||
memset( g_iDeviceButtonToMacVirtualKey, 0xFF, sizeof(g_iDeviceButtonToMacVirtualKey) );
|
||||
@@ -487,11 +486,11 @@ bool KeyboardDevice::DeviceButtonToMacVirtualKey( DeviceButton button, UInt8 &iM
|
||||
return iMacVKOut != 0xFF;
|
||||
}
|
||||
|
||||
|
||||
|
||||
/*
|
||||
* (c) 2005-2006 Steve Checkoway
|
||||
* All rights reserved.
|
||||
*
|
||||
*
|
||||
* Permission is hereby granted, free of charge, to any person obtaining a
|
||||
* copy of this software and associated documentation files (the
|
||||
* "Software"), to deal in the Software without restriction, including
|
||||
@@ -501,7 +500,7 @@ bool KeyboardDevice::DeviceButtonToMacVirtualKey( DeviceButton button, UInt8 &iM
|
||||
* copyright notice(s) and this permission notice appear in all copies of
|
||||
* the Software and that both the above copyright notice(s) and this
|
||||
* permission notice appear in supporting documentation.
|
||||
*
|
||||
*
|
||||
* THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS
|
||||
* OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF
|
||||
* MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT OF
|
||||
|
||||
@@ -7,7 +7,7 @@ class KeyboardDevice : public HIDDevice
|
||||
{
|
||||
private:
|
||||
__gnu_cxx::hash_map<IOHIDElementCookie, DeviceButton> m_Mapping;
|
||||
|
||||
|
||||
protected:
|
||||
bool AddLogicalDevice( int usagePage, int usage );
|
||||
void AddElement( int usagePage, int usage, IOHIDElementCookie cookie, const CFDictionaryRef properties );
|
||||
@@ -16,11 +16,10 @@ protected:
|
||||
public:
|
||||
void GetButtonPresses( vector<DeviceInput>& vPresses, IOHIDElementCookie cookie, int value, const RageTimer& now ) const;
|
||||
void GetDevicesAndDescriptions( vector<InputDeviceInfo>& vDevices ) const;
|
||||
|
||||
|
||||
static bool DeviceButtonToMacVirtualKey( DeviceButton button, UInt8 &iMacVKOut );
|
||||
};
|
||||
|
||||
|
||||
#endif
|
||||
|
||||
/*
|
||||
|
||||
Reference in New Issue
Block a user