mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2024-11-15 05:47:56 -07:00
osx input: now supports mice(buttons + axes). also less crashes :p
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5416 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
199ebe5c9c
commit
ac8bc6b350
@ -1,7 +1,6 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
@ -11,51 +10,5 @@ namespace OSX
|
||||
void Init( std::vector<ControllerInterface::Device*>& devices );
|
||||
void DeInit();
|
||||
|
||||
class Keyboard : public ControllerInterface::Device
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
friend class ControllerInterface::ControlReference;
|
||||
|
||||
protected:
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
{
|
||||
friend class Keyboard;
|
||||
protected:
|
||||
virtual ControlState GetState() = 0;
|
||||
};
|
||||
|
||||
class Key : public Input
|
||||
{
|
||||
friend class Keyboard;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Key( IOHIDElementRef key_element );
|
||||
ControlState GetState();
|
||||
private:
|
||||
IOHIDElementRef m_key_element;
|
||||
std::string m_key_name;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
ControlState GetInputState( const ControllerInterface::Device::Input* const input );
|
||||
void SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state );
|
||||
|
||||
public:
|
||||
Keyboard(IOHIDDeviceRef device, int index);
|
||||
|
||||
std::string GetName() const;
|
||||
std::string GetSource() const;
|
||||
int GetId() const;
|
||||
|
||||
private:
|
||||
IOHIDDeviceRef m_device;
|
||||
int m_device_index;
|
||||
std::string m_device_name;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -3,6 +3,8 @@
|
||||
#ifdef CIFACE_USE_OSX
|
||||
|
||||
#include "OSX.h"
|
||||
#include "OSXKeyboard.h"
|
||||
#include "OSXMouse.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
@ -15,38 +17,38 @@ namespace OSX
|
||||
static IOHIDManagerRef HIDManager = NULL;
|
||||
static CFStringRef OurRunLoop = CFSTR("DolphinOSXInput");
|
||||
|
||||
unsigned int KeyboardIndex = 0;
|
||||
|
||||
|
||||
static void DeviceMatching_callback(void* inContext,
|
||||
IOReturn inResult,
|
||||
void* inSender,
|
||||
IOHIDDeviceRef inIOHIDDeviceRef)
|
||||
{
|
||||
NSLog(@"-------------------------");
|
||||
NSLog(@"Got Device: %@", IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDProductKey)));
|
||||
//NSLog(@"-------------------------");
|
||||
//NSLog(@"Got Device: %@", IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(kIOHIDProductKey)));
|
||||
|
||||
// Add to the devices vector if it's of a type we want
|
||||
if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Keyboard) ||
|
||||
IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Keypad))
|
||||
{
|
||||
std::vector<ControllerInterface::Device*> *devices = (std::vector<ControllerInterface::Device*> *)inContext;
|
||||
devices->push_back(new Keyboard(inIOHIDDeviceRef, KeyboardIndex++));
|
||||
devices->push_back(new Keyboard(inIOHIDDeviceRef));
|
||||
}
|
||||
if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse))
|
||||
{
|
||||
std::vector<ControllerInterface::Device*> *devices = (std::vector<ControllerInterface::Device*> *)inContext;
|
||||
devices->push_back(new Mouse(inIOHIDDeviceRef));
|
||||
}
|
||||
/*
|
||||
// One of the built-in mice devices insta-crash :(
|
||||
else if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse))
|
||||
{
|
||||
}
|
||||
// Probably just a lot of fiddling...but then we can kill SDL dependency (?)
|
||||
else if (IOHIDDeviceConformsTo(inIOHIDDeviceRef, kHIDPage_GenericDesktop, kHIDUsage_GD_GamePad))
|
||||
{
|
||||
std::vector<ControllerInterface::Device*> *devices = (std::vector<ControllerInterface::Device*> *)inContext;
|
||||
devices->push_back();
|
||||
}
|
||||
*/
|
||||
else
|
||||
{
|
||||
// Actually, we don't want it
|
||||
NSLog(@"Throwing away...");
|
||||
#define shortlog(x)
|
||||
//#define shortlog(x) NSLog(@"%s: %@", x, IOHIDDeviceGetProperty(inIOHIDDeviceRef, CFSTR(x)));
|
||||
shortlog(kIOHIDTransportKey)
|
||||
@ -75,13 +77,16 @@ static void DeviceMatching_callback(void* inContext,
|
||||
|
||||
void Init( std::vector<ControllerInterface::Device*>& devices )
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
HIDManager = IOHIDManagerCreate(kCFAllocatorDefault, kIOHIDOptionsTypeNone);
|
||||
if (!HIDManager)
|
||||
NSLog(@"Failed to create HID Manager reference");
|
||||
|
||||
// HID Manager will give us the following devices:
|
||||
// Keyboard, Keypad, Mouse, GamePad
|
||||
NSArray *matchingDevices = [NSArray arrayWithObjects:
|
||||
NSArray *matchingDevices =
|
||||
[NSArray arrayWithObjects:
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInteger:kHIDPage_GenericDesktop], @ kIOHIDDeviceUsagePageKey,
|
||||
[NSNumber numberWithInteger:kHIDUsage_GD_Keyboard], @ kIOHIDDeviceUsageKey, nil],
|
||||
@ -112,6 +117,8 @@ void Init( std::vector<ControllerInterface::Device*>& devices )
|
||||
// Things should be configured now. Disable hotplugging and other scheduling
|
||||
IOHIDManagerRegisterDeviceMatchingCallback(HIDManager, NULL, NULL);
|
||||
IOHIDManagerUnscheduleFromRunLoop(HIDManager, CFRunLoopGetCurrent(), OurRunLoop);
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
void DeInit()
|
||||
@ -154,7 +161,7 @@ void DeviceElementDebugPrint(const void *value, void *context)
|
||||
}
|
||||
|
||||
c_type.append(" ");
|
||||
NSLog(@"%s%s%spage: 0x%x usage: 0x%x name: %s lmin: %u lmax: %u",
|
||||
NSLog(@"%s%s%spage: 0x%x usage: 0x%x name: %s lmin: %i lmax: %i pmin: %i pmax: %i",
|
||||
type.c_str(),
|
||||
type == "collection" ? ":" : "",
|
||||
type == "collection" ? c_type.c_str() : " ",
|
||||
@ -162,7 +169,9 @@ void DeviceElementDebugPrint(const void *value, void *context)
|
||||
IOHIDElementGetUsage(e),
|
||||
IOHIDElementGetName(e), // TOO BAD IT"S FUCKING USELESS
|
||||
IOHIDElementGetLogicalMin(e),
|
||||
IOHIDElementGetLogicalMax(e));
|
||||
IOHIDElementGetLogicalMax(e),
|
||||
IOHIDElementGetPhysicalMin(e),
|
||||
IOHIDElementGetPhysicalMax(e));
|
||||
|
||||
if (type == "collection")
|
||||
{
|
||||
|
@ -0,0 +1,58 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace OSX
|
||||
{
|
||||
|
||||
class Keyboard : public ControllerInterface::Device
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
friend class ControllerInterface::ControlReference;
|
||||
|
||||
protected:
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
{
|
||||
friend class Keyboard;
|
||||
protected:
|
||||
virtual ControlState GetState() = 0;
|
||||
};
|
||||
|
||||
class Key : public Input
|
||||
{
|
||||
friend class Keyboard;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Key( IOHIDElementRef element );
|
||||
ControlState GetState();
|
||||
private:
|
||||
IOHIDDeviceRef m_device;
|
||||
IOHIDElementRef m_element;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
ControlState GetInputState( const ControllerInterface::Device::Input* const input );
|
||||
void SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state );
|
||||
|
||||
public:
|
||||
Keyboard(IOHIDDeviceRef device);
|
||||
|
||||
std::string GetName() const;
|
||||
std::string GetSource() const;
|
||||
int GetId() const;
|
||||
|
||||
private:
|
||||
IOHIDDeviceRef m_device;
|
||||
std::string m_device_name;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
@ -2,7 +2,7 @@
|
||||
|
||||
#ifdef CIFACE_USE_OSX
|
||||
|
||||
#include "OSX.h"
|
||||
#include "OSXKeyboard.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
@ -24,36 +24,39 @@ struct PrettyKeys
|
||||
extern void DeviceElementDebugPrint(const void*, void*);
|
||||
|
||||
|
||||
Keyboard::Keyboard(IOHIDDeviceRef device, int index)
|
||||
Keyboard::Keyboard(IOHIDDeviceRef device)
|
||||
: m_device(device)
|
||||
, m_device_index(index)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
m_device_name = [(NSString *)IOHIDDeviceGetProperty(m_device, CFSTR(kIOHIDProductKey)) UTF8String];
|
||||
|
||||
// Go through all the elements of the device we've been given and try to make something out of them
|
||||
CFArrayRef elements = IOHIDDeviceCopyMatchingElements(m_device, NULL, kIOHIDOptionsTypeNone);
|
||||
CFIndex idx = 0;
|
||||
for (IOHIDElementRef e = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, idx);
|
||||
e;
|
||||
e = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, ++idx))
|
||||
// This class should only recieve Keyboard or Keypad devices
|
||||
// Now, filter on just the buttons we can handle sanely
|
||||
NSDictionary *matchingElements =
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInteger:kIOHIDElementTypeInput_Button], @ kIOHIDElementTypeKey,
|
||||
[NSNumber numberWithInteger:0], @ kIOHIDElementMinKey,
|
||||
[NSNumber numberWithInteger:1], @ kIOHIDElementMaxKey,
|
||||
nil];
|
||||
|
||||
CFArrayRef elements =
|
||||
IOHIDDeviceCopyMatchingElements(m_device, (CFDictionaryRef)matchingElements, kIOHIDOptionsTypeNone);
|
||||
|
||||
if (elements)
|
||||
{
|
||||
if ((IOHIDElementGetType(e) == kIOHIDElementTypeInput_Button) &&
|
||||
(IOHIDElementGetUsagePage(e) == kHIDPage_KeyboardOrKeypad) &&
|
||||
(IOHIDElementGetLogicalMin(e) == 0) &&
|
||||
(IOHIDElementGetLogicalMax(e) == 1))
|
||||
{
|
||||
try {
|
||||
inputs.push_back(new Key(e));
|
||||
}
|
||||
catch (std::bad_alloc&) {
|
||||
}
|
||||
}
|
||||
else
|
||||
for (int i = 0; i < CFArrayGetCount(elements); i++)
|
||||
{
|
||||
IOHIDElementRef e = (IOHIDElementRef)CFArrayGetValueAtIndex(elements, i);
|
||||
//DeviceElementDebugPrint(e, NULL);
|
||||
}
|
||||
|
||||
try { inputs.push_back(new Key(e)); }
|
||||
catch (std::bad_alloc&) { /*Thrown if the key is reserved*/ }
|
||||
}
|
||||
CFRelease(elements);
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
ControlState Keyboard::GetInputState( const ControllerInterface::Device::Input* const input )
|
||||
@ -87,20 +90,22 @@ std::string Keyboard::GetSource() const
|
||||
|
||||
int Keyboard::GetId() const
|
||||
{
|
||||
return m_device_index;
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Keyboard::Key::Key(IOHIDElementRef key_element)
|
||||
: m_key_element(key_element)
|
||||
, m_key_name("RESERVED") // for some reason HID Manager gives these to us. bad_alloc!
|
||||
Keyboard::Key::Key(IOHIDElementRef element)
|
||||
: m_element(element)
|
||||
, m_name("RESERVED") // for some reason HID Manager gives these to us. bad_alloc!
|
||||
{
|
||||
uint32_t keycode = IOHIDElementGetUsage(m_key_element);
|
||||
m_device = IOHIDElementGetDevice(m_element);
|
||||
|
||||
uint32_t keycode = IOHIDElementGetUsage(m_element);
|
||||
for (uint32_t i = 0; i < sizeof(named_keys)/sizeof(*named_keys); i++)
|
||||
{
|
||||
if (named_keys[i].code == keycode)
|
||||
{
|
||||
m_key_name = named_keys[i].name;
|
||||
m_name = named_keys[i].name;
|
||||
return;
|
||||
}
|
||||
}
|
||||
@ -110,19 +115,15 @@ Keyboard::Key::Key(IOHIDElementRef key_element)
|
||||
ControlState Keyboard::Key::GetState()
|
||||
{
|
||||
IOHIDValueRef value;
|
||||
if (IOHIDDeviceGetValue(IOHIDElementGetDevice(m_key_element), m_key_element, &value) == kIOReturnSuccess)
|
||||
{
|
||||
double scaled_value = IOHIDValueGetScaledValue(value, kIOHIDValueScaleTypePhysical);
|
||||
//NSLog(@"element %x value %x scaled %f", IOHIDElementGetUsage(m_key_element), value, scaled_value);
|
||||
return scaled_value > 0;
|
||||
}
|
||||
if (IOHIDDeviceGetValue(m_device, m_element, &value) == kIOReturnSuccess)
|
||||
return IOHIDValueGetScaledValue(value, kIOHIDValueScaleTypePhysical) > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Keyboard::Key::GetName() const
|
||||
{
|
||||
return m_key_name;
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
|
@ -0,0 +1,77 @@
|
||||
#pragma once
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace OSX
|
||||
{
|
||||
|
||||
class Mouse : public ControllerInterface::Device
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
friend class ControllerInterface::ControlReference;
|
||||
|
||||
protected:
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
{
|
||||
friend class Mouse;
|
||||
protected:
|
||||
virtual ControlState GetState() = 0;
|
||||
};
|
||||
|
||||
class Button : public Input
|
||||
{
|
||||
friend class Mouse;
|
||||
public:
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Button( IOHIDElementRef element );
|
||||
ControlState GetState();
|
||||
private:
|
||||
IOHIDDeviceRef m_device;
|
||||
IOHIDElementRef m_element;
|
||||
std::string m_name;
|
||||
};
|
||||
|
||||
class Axis : public Input
|
||||
{
|
||||
friend class Mouse;
|
||||
public:
|
||||
enum direction {
|
||||
positive = 0,
|
||||
negative
|
||||
};
|
||||
std::string GetName() const;
|
||||
protected:
|
||||
Axis( IOHIDElementRef element, direction dir );
|
||||
ControlState GetState();
|
||||
private:
|
||||
IOHIDDeviceRef m_device;
|
||||
IOHIDElementRef m_element;
|
||||
std::string m_name;
|
||||
direction m_direction;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
ControlState GetInputState( const ControllerInterface::Device::Input* const input );
|
||||
void SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state );
|
||||
|
||||
public:
|
||||
Mouse(IOHIDDeviceRef device);
|
||||
|
||||
std::string GetName() const;
|
||||
std::string GetSource() const;
|
||||
int GetId() const;
|
||||
|
||||
private:
|
||||
IOHIDDeviceRef m_device;
|
||||
std::string m_device_name;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
184
Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXMouse.mm
Normal file
184
Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXMouse.mm
Normal file
@ -0,0 +1,184 @@
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#ifdef CIFACE_USE_OSX
|
||||
|
||||
#include "OSXMouse.h"
|
||||
#include <Foundation/Foundation.h>
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace OSX
|
||||
{
|
||||
|
||||
extern void DeviceElementDebugPrint(const void*, void*);
|
||||
|
||||
|
||||
Mouse::Mouse(IOHIDDeviceRef device)
|
||||
: m_device(device)
|
||||
{
|
||||
NSAutoreleasePool *pool = [[NSAutoreleasePool alloc] init];
|
||||
|
||||
m_device_name = [(NSString *)IOHIDDeviceGetProperty(m_device, CFSTR(kIOHIDProductKey)) UTF8String];
|
||||
|
||||
// Buttons
|
||||
NSDictionary *buttonDict =
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInteger:kIOHIDElementTypeInput_Button], @ kIOHIDElementTypeKey,
|
||||
[NSNumber numberWithInteger:kHIDPage_Button], @ kIOHIDElementUsagePageKey,
|
||||
nil];
|
||||
|
||||
CFArrayRef buttons =
|
||||
IOHIDDeviceCopyMatchingElements(m_device, (CFDictionaryRef)buttonDict, kIOHIDOptionsTypeNone);
|
||||
|
||||
if (buttons)
|
||||
{
|
||||
for (int i = 0; i < CFArrayGetCount(buttons); i++)
|
||||
{
|
||||
IOHIDElementRef e = (IOHIDElementRef)CFArrayGetValueAtIndex(buttons, i);
|
||||
//DeviceElementDebugPrint(e, NULL);
|
||||
|
||||
inputs.push_back(new Button(e));
|
||||
}
|
||||
CFRelease(buttons);
|
||||
}
|
||||
|
||||
// Axes
|
||||
NSDictionary *axisDict =
|
||||
[NSDictionary dictionaryWithObjectsAndKeys:
|
||||
[NSNumber numberWithInteger:kIOHIDElementTypeInput_Misc], @ kIOHIDElementTypeKey,
|
||||
nil];
|
||||
|
||||
CFArrayRef axes =
|
||||
IOHIDDeviceCopyMatchingElements(m_device, (CFDictionaryRef)axisDict, kIOHIDOptionsTypeNone);
|
||||
|
||||
if (axes)
|
||||
{
|
||||
for (int i = 0; i < CFArrayGetCount(axes); i++)
|
||||
{
|
||||
IOHIDElementRef e = (IOHIDElementRef)CFArrayGetValueAtIndex(axes, i);
|
||||
//DeviceElementDebugPrint(e, NULL);
|
||||
|
||||
inputs.push_back(new Axis(e, Axis::negative));
|
||||
inputs.push_back(new Axis(e, Axis::positive));
|
||||
}
|
||||
CFRelease(axes);
|
||||
}
|
||||
|
||||
[pool release];
|
||||
}
|
||||
|
||||
ControlState Mouse::GetInputState( const ControllerInterface::Device::Input* const input )
|
||||
{
|
||||
return ((Input*)input)->GetState();
|
||||
}
|
||||
|
||||
void Mouse::SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state )
|
||||
{
|
||||
}
|
||||
|
||||
bool Mouse::UpdateInput()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Mouse::UpdateOutput()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Mouse::GetName() const
|
||||
{
|
||||
return m_device_name;
|
||||
}
|
||||
|
||||
std::string Mouse::GetSource() const
|
||||
{
|
||||
return "OSX";
|
||||
}
|
||||
|
||||
int Mouse::GetId() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Mouse::Button::Button(IOHIDElementRef element)
|
||||
: m_element(element)
|
||||
{
|
||||
m_device = IOHIDElementGetDevice(m_element);
|
||||
|
||||
std::ostringstream s;
|
||||
s << IOHIDElementGetUsage(m_element);
|
||||
m_name = std::string("Button ") + s.str();
|
||||
}
|
||||
|
||||
ControlState Mouse::Button::GetState()
|
||||
{
|
||||
IOHIDValueRef value;
|
||||
if (IOHIDDeviceGetValue(m_device, m_element, &value) == kIOReturnSuccess)
|
||||
return IOHIDValueGetScaledValue(value, kIOHIDValueScaleTypePhysical) > 0;
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Mouse::Button::GetName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
Mouse::Axis::Axis(IOHIDElementRef element, direction dir)
|
||||
: m_element(element)
|
||||
, m_direction(dir)
|
||||
{
|
||||
m_device = IOHIDElementGetDevice(m_element);
|
||||
|
||||
// Need to parse the element a bit first
|
||||
std::string description("unk");
|
||||
|
||||
switch (IOHIDElementGetUsage(m_element))
|
||||
{
|
||||
default:
|
||||
NSLog(@"Unknown axis type 0x%x, using anyways...", IOHIDElementGetUsage(m_element));
|
||||
break;
|
||||
case kHIDUsage_GD_X: description = "X"; break;
|
||||
case kHIDUsage_GD_Y: description = "Y"; break;
|
||||
case kHIDUsage_GD_Wheel: description = "Wheel"; break;
|
||||
case kHIDUsage_Csmr_ACPan: description = "Pan"; break;
|
||||
}
|
||||
|
||||
m_name = std::string("Axis ") + description;
|
||||
m_name.append((m_direction == positive) ? std::string("+") : std::string("-"));
|
||||
}
|
||||
|
||||
ControlState Mouse::Axis::GetState()
|
||||
{
|
||||
IOHIDValueRef value;
|
||||
if (IOHIDDeviceGetValue(m_device, m_element, &value) == kIOReturnSuccess)
|
||||
{
|
||||
double scaled_value = IOHIDValueGetScaledValue(value, kIOHIDValueScaleTypePhysical);
|
||||
double actual_value = 0;
|
||||
|
||||
if ((scaled_value < 0) && (m_direction == negative))
|
||||
actual_value = fabs(scaled_value);
|
||||
else if ((scaled_value > 0) && (m_direction == positive))
|
||||
actual_value = scaled_value;
|
||||
|
||||
//NSLog(@"%s %f %f", m_name.c_str(), scaled_value, actual_value);
|
||||
return actual_value;
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
std::string Mouse::Axis::GetName() const
|
||||
{
|
||||
return m_name;
|
||||
}
|
||||
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
@ -29,7 +29,8 @@ if icenv['HAVE_SDL']:
|
||||
if sys.platform == 'darwin':
|
||||
files += [
|
||||
'ControllerInterface/OSX/OSX.mm',
|
||||
'ControllerInterface/OSX/OSXKeyboard.mm'
|
||||
'ControllerInterface/OSX/OSXKeyboard.mm',
|
||||
'ControllerInterface/OSX/OSXMouse.mm'
|
||||
]
|
||||
icenv['FRAMEWORKS'] = ['IOKit']
|
||||
|
||||
|
@ -955,6 +955,9 @@
|
||||
292AC59211838FD700B8790B /* pluginspecs_pad.h in Headers */ = {isa = PBXBuildFile; fileRef = 292AC1DC11838FD700B8790B /* pluginspecs_pad.h */; };
|
||||
292AC59311838FD700B8790B /* pluginspecs_video.h in Headers */ = {isa = PBXBuildFile; fileRef = 292AC1DD11838FD700B8790B /* pluginspecs_video.h */; };
|
||||
292AC59411838FD700B8790B /* pluginspecs_wiimote.h in Headers */ = {isa = PBXBuildFile; fileRef = 292AC1DE11838FD700B8790B /* pluginspecs_wiimote.h */; };
|
||||
298D72BB11867D970096937B /* OSXKeyboard.h in Headers */ = {isa = PBXBuildFile; fileRef = 298D72BA11867D970096937B /* OSXKeyboard.h */; };
|
||||
298D731E118699AD0096937B /* OSXMouse.mm in Sources */ = {isa = PBXBuildFile; fileRef = 298D731C118699AD0096937B /* OSXMouse.mm */; };
|
||||
298D731F118699AD0096937B /* OSXMouse.h in Headers */ = {isa = PBXBuildFile; fileRef = 298D731D118699AD0096937B /* OSXMouse.h */; };
|
||||
29D1528F118634B400CC2741 /* OSXKeyboard.mm in Sources */ = {isa = PBXBuildFile; fileRef = 29D1528E118634B400CC2741 /* OSXKeyboard.mm */; };
|
||||
29D152AC1186461800CC2741 /* NamedKeys.h in Headers */ = {isa = PBXBuildFile; fileRef = 29D152AB1186461800CC2741 /* NamedKeys.h */; };
|
||||
5232B1F10EEB634D0093A7B1 /* Cocoa.framework in Frameworks */ = {isa = PBXBuildFile; fileRef = 5232B1F00EEB634D0093A7B1 /* Cocoa.framework */; };
|
||||
@ -2316,6 +2319,9 @@
|
||||
292AC1DC11838FD700B8790B /* pluginspecs_pad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pluginspecs_pad.h; sourceTree = "<group>"; };
|
||||
292AC1DD11838FD700B8790B /* pluginspecs_video.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pluginspecs_video.h; sourceTree = "<group>"; };
|
||||
292AC1DE11838FD700B8790B /* pluginspecs_wiimote.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = pluginspecs_wiimote.h; sourceTree = "<group>"; };
|
||||
298D72BA11867D970096937B /* OSXKeyboard.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSXKeyboard.h; sourceTree = "<group>"; };
|
||||
298D731C118699AD0096937B /* OSXMouse.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OSXMouse.mm; sourceTree = "<group>"; };
|
||||
298D731D118699AD0096937B /* OSXMouse.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = OSXMouse.h; sourceTree = "<group>"; };
|
||||
29D1528E118634B400CC2741 /* OSXKeyboard.mm */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.cpp.objcpp; path = OSXKeyboard.mm; sourceTree = "<group>"; };
|
||||
29D152AB1186461800CC2741 /* NamedKeys.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = NamedKeys.h; sourceTree = "<group>"; };
|
||||
5048396D09E3307300765E4B /* DolphinProj.xcconfig */ = {isa = PBXFileReference; fileEncoding = 30; lastKnownFileType = text.xcconfig; path = DolphinProj.xcconfig; sourceTree = "<group>"; };
|
||||
@ -3581,9 +3587,12 @@
|
||||
isa = PBXGroup;
|
||||
children = (
|
||||
29D152AB1186461800CC2741 /* NamedKeys.h */,
|
||||
29D1528E118634B400CC2741 /* OSXKeyboard.mm */,
|
||||
292AC00211838FD600B8790B /* OSX.mm */,
|
||||
292AC00311838FD600B8790B /* OSX.h */,
|
||||
292AC00211838FD600B8790B /* OSX.mm */,
|
||||
298D72BA11867D970096937B /* OSXKeyboard.h */,
|
||||
29D1528E118634B400CC2741 /* OSXKeyboard.mm */,
|
||||
298D731D118699AD0096937B /* OSXMouse.h */,
|
||||
298D731C118699AD0096937B /* OSXMouse.mm */,
|
||||
);
|
||||
path = OSX;
|
||||
sourceTree = "<group>";
|
||||
@ -4850,6 +4859,8 @@
|
||||
292AC59311838FD700B8790B /* pluginspecs_video.h in Headers */,
|
||||
292AC59411838FD700B8790B /* pluginspecs_wiimote.h in Headers */,
|
||||
29D152AC1186461800CC2741 /* NamedKeys.h in Headers */,
|
||||
298D72BB11867D970096937B /* OSXKeyboard.h in Headers */,
|
||||
298D731F118699AD0096937B /* OSXMouse.h in Headers */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
@ -5903,6 +5914,7 @@
|
||||
292AC58A11838FD700B8790B /* WiimoteEmu.cpp in Sources */,
|
||||
292AC58D11838FD700B8790B /* WiimoteNew.cpp in Sources */,
|
||||
29D1528F118634B400CC2741 /* OSXKeyboard.mm in Sources */,
|
||||
298D731E118699AD0096937B /* OSXMouse.mm in Sources */,
|
||||
);
|
||||
runOnlyForDeploymentPostprocessing = 0;
|
||||
};
|
||||
|
Loading…
Reference in New Issue
Block a user