diff options
| author | Soren Jorvang <soren.jorvang@gmail.com> | 2011-01-16 17:00:17 +0000 |
|---|---|---|
| committer | Soren Jorvang <soren.jorvang@gmail.com> | 2011-01-16 17:00:17 +0000 |
| commit | 4a7d3ee1c8f959558fabb0a014bed7b8d3105854 (patch) | |
| tree | 44f4851fc2526962364666456f2c200d999c75af /Source/Core | |
| parent | 7e612a613a2c99501c4304562c5af698193231e3 (diff) | |
Deal with "hat" switches.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@6863 8ced0084-cf51-0410-be5f-012b33b47a6e
Diffstat (limited to 'Source/Core')
3 files changed, 112 insertions, 13 deletions
diff --git a/Source/Core/DolphinWX/Src/SConscript b/Source/Core/DolphinWX/Src/SConscript index 0534b1fdb0..04643361dc 100644 --- a/Source/Core/DolphinWX/Src/SConscript +++ b/Source/Core/DolphinWX/Src/SConscript @@ -60,11 +60,14 @@ else: if sys.platform == 'win32': files += [ "stdafx.cpp" ] elif sys.platform == 'darwin': - if env['HAVE_WX']: - wxlibs += env['wxconfiglibs'] ldflags += [ '-Wl,-pagezero_size,0x1000' ] exe = '#' + env['prefix'] + '/Dolphin.app/Contents/MacOS/Dolphin' + if env['HAVE_WX']: + wxlibs += env['wxconfiglibs'] + else: + exe += 'NoGUI' + env.Install('#' + env['prefix'] + '/Dolphin.app/Contents/' + 'Library/Frameworks/Cg.framework', source = [ '#Externals/Cg/Cg.framework/Cg', diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h index c9bb7bdfaf..c26df5e579 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h +++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.h @@ -53,6 +53,26 @@ protected: float m_scale; }; + class Hat : public Input + { + friend class Joystick; + public: + enum direction { + up = 0, + right, + down, + left + }; + std::string GetName() const; + protected: + Hat(IOHIDElementRef element, direction dir); + ControlState GetState(IOHIDDeviceRef device) const; + private: + IOHIDElementRef m_element; + std::string m_name; + direction m_direction; + }; + bool UpdateInput(); bool UpdateOutput(); diff --git a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm index b3012b6c87..223e363cce 100644 --- a/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm +++ b/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXJoystick.mm @@ -60,8 +60,15 @@ Joystick::Joystick(IOHIDDeviceRef device) (IOHIDElementRef)CFArrayGetValueAtIndex(axes, i); //DeviceElementDebugPrint(e, NULL); - AddInput(new Axis(e, Axis::negative)); - AddInput(new Axis(e, Axis::positive)); + if (IOHIDElementGetUsage(e) == kHIDUsage_GD_Hatswitch) { + AddInput(new Hat(e, Hat::up)); + AddInput(new Hat(e, Hat::right)); + AddInput(new Hat(e, Hat::down)); + AddInput(new Hat(e, Hat::left)); + } else { + AddInput(new Axis(e, Axis::negative)); + AddInput(new Axis(e, Axis::positive)); + } } CFRelease(axes); } @@ -159,15 +166,9 @@ Joystick::Axis::Axis(IOHIDElementRef element, direction dir) case kHIDUsage_GD_Wheel: description = "Wheel"; break; - case kHIDUsage_GD_Hatswitch: - description = "Hat"; - break; case kHIDUsage_Csmr_ACPan: description = "Pan"; break; - default: - WARN_LOG(PAD, "Unknown axis type 0x%x, using it anyway...", - IOHIDElementGetUsage(m_element)); } m_name = std::string("Axis ") + description; @@ -190,9 +191,9 @@ ControlState Joystick::Axis::GetState(IOHIDDeviceRef device) const return (position - m_neutral) * m_scale; if (m_direction == negative && position < m_neutral) return (m_neutral - position) * m_scale; - } - - return 0; + } + + return 0; } std::string Joystick::Axis::GetName() const @@ -200,6 +201,81 @@ std::string Joystick::Axis::GetName() const return m_name; } +Joystick::Hat::Hat(IOHIDElementRef element, direction dir) + : m_element(element) + , m_direction(dir) +{ + switch (dir) { + case up: + m_name = "Up"; + break; + case right: + m_name = "Right"; + break; + case down: + m_name = "Down"; + break; + case left: + m_name = "Left"; + break; + default: + m_name = "unk"; + } +} + +ControlState Joystick::Hat::GetState(IOHIDDeviceRef device) const +{ + IOHIDValueRef value; + int position; + + if (IOHIDDeviceGetValue(device, m_element, &value) == kIOReturnSuccess) + { + position = IOHIDValueGetIntegerValue(value); + + switch (position) { + case 0: + if (m_direction == up) + return 1; + break; + case 1: + if (m_direction == up || m_direction == right) + return 1; + break; + case 2: + if (m_direction == right) + return 1; + break; + case 3: + if (m_direction == right || m_direction == down) + return 1; + break; + case 4: + if (m_direction == down) + return 1; + break; + case 5: + if (m_direction == down || m_direction == left) + return 1; + break; + case 6: + if (m_direction == left) + return 1; + break; + case 7: + if (m_direction == left || m_direction == up) + return 1; + break; + }; + } + + return 0; +} + +std::string Joystick::Hat::GetName() const +{ + return m_name; +} + } } |
