mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-21 05:09:34 -06:00
ForceFeedback: Add OSX rumble support
This commit is contained in:
@ -1,13 +1,14 @@
|
||||
#include <IOKit/hid/IOHIDLib.h>
|
||||
|
||||
#include "../Device.h"
|
||||
#include "../ForceFeedback/ForceFeedbackDevice.h"
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace OSX
|
||||
{
|
||||
|
||||
class Joystick : public Core::Device
|
||||
class Joystick : public ForceFeedback::ForceFeedbackDevice
|
||||
{
|
||||
private:
|
||||
class Button : public Input
|
||||
@ -62,9 +63,9 @@ private:
|
||||
|
||||
public:
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
Joystick(IOHIDDeviceRef device, std::string name, int index);
|
||||
~Joystick();
|
||||
|
||||
std::string GetName() const;
|
||||
std::string GetSource() const;
|
||||
@ -74,6 +75,8 @@ private:
|
||||
const IOHIDDeviceRef m_device;
|
||||
const std::string m_device_name;
|
||||
const int m_index;
|
||||
|
||||
ForceFeedback::FFDeviceAdapterReference m_ff_device;
|
||||
};
|
||||
|
||||
}
|
||||
|
@ -15,6 +15,7 @@ Joystick::Joystick(IOHIDDeviceRef device, std::string name, int index)
|
||||
: m_device(device)
|
||||
, m_device_name(name)
|
||||
, m_index(index)
|
||||
, m_ff_device(nullptr)
|
||||
{
|
||||
// Buttons
|
||||
NSDictionary *buttonDict =
|
||||
@ -71,6 +72,20 @@ Joystick::Joystick(IOHIDDeviceRef device, std::string name, int index)
|
||||
}
|
||||
CFRelease(axes);
|
||||
}
|
||||
|
||||
// Force Feedback
|
||||
FFCAPABILITIES ff_caps;
|
||||
if (SUCCEEDED(ForceFeedback::FFDeviceAdapter::Create(IOHIDDeviceGetService(m_device), &m_ff_device)) &&
|
||||
SUCCEEDED(FFDeviceGetForceFeedbackCapabilities(m_ff_device->m_device, &ff_caps)))
|
||||
{
|
||||
InitForceFeedback(m_ff_device, ff_caps.numFfAxes);
|
||||
}
|
||||
}
|
||||
|
||||
Joystick::~Joystick()
|
||||
{
|
||||
if (m_ff_device)
|
||||
m_ff_device->Release();
|
||||
}
|
||||
|
||||
bool Joystick::UpdateInput()
|
||||
@ -78,11 +93,6 @@ bool Joystick::UpdateInput()
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Joystick::UpdateOutput()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
std::string Joystick::GetName() const
|
||||
{
|
||||
return m_device_name;
|
||||
|
Reference in New Issue
Block a user