2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2014-02-10 18:54:46 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
|
|
|
|
2019-03-21 15:57:17 +00:00
|
|
|
#include <set>
|
|
|
|
|
2010-06-26 13:03:25 +00:00
|
|
|
#include <IOKit/hid/IOHIDLib.h>
|
2010-04-27 07:33:33 +00:00
|
|
|
|
2014-02-17 10:18:15 +00:00
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
|
|
|
#include "InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h"
|
2010-04-27 07:33:33 +00:00
|
|
|
|
2019-06-17 20:39:24 +00:00
|
|
|
namespace ciface::OSX
|
2010-04-27 07:33:33 +00:00
|
|
|
{
|
2014-01-28 23:11:51 +00:00
|
|
|
class Joystick : public ForceFeedback::ForceFeedbackDevice
|
2010-04-27 07:33:33 +00:00
|
|
|
{
|
2011-03-14 01:20:11 +00:00
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
class Button : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Button(IOHIDElementRef element, IOHIDDeviceRef device) : m_element(element), m_device(device) {}
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const IOHIDElementRef m_element;
|
|
|
|
const IOHIDDeviceRef m_device;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Axis : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum direction
|
|
|
|
{
|
|
|
|
positive = 0,
|
|
|
|
negative
|
|
|
|
};
|
|
|
|
|
|
|
|
Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction dir);
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const IOHIDElementRef m_element;
|
|
|
|
const IOHIDDeviceRef m_device;
|
|
|
|
std::string m_name;
|
|
|
|
const direction m_direction;
|
|
|
|
float m_neutral;
|
|
|
|
float m_scale;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Hat : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum direction
|
|
|
|
{
|
|
|
|
up = 0,
|
|
|
|
right,
|
|
|
|
down,
|
|
|
|
left
|
|
|
|
};
|
|
|
|
|
|
|
|
Hat(IOHIDElementRef element, IOHIDDeviceRef device, direction dir);
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const IOHIDElementRef m_element;
|
|
|
|
const IOHIDDeviceRef m_device;
|
|
|
|
const char* m_name;
|
|
|
|
const direction m_direction;
|
|
|
|
};
|
2011-01-16 17:00:17 +00:00
|
|
|
|
2011-03-14 01:20:11 +00:00
|
|
|
public:
|
2016-07-14 08:25:52 +00:00
|
|
|
Joystick(IOHIDDeviceRef device, std::string name);
|
2016-06-24 08:43:46 +00:00
|
|
|
~Joystick();
|
2010-06-26 13:03:25 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string GetName() const override;
|
|
|
|
std::string GetSource() const override;
|
2016-10-18 06:00:11 +00:00
|
|
|
bool IsSameDevice(const IOHIDDeviceRef) const;
|
2010-06-26 13:03:25 +00:00
|
|
|
|
2010-04-27 07:33:33 +00:00
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
const IOHIDDeviceRef m_device;
|
|
|
|
const std::string m_device_name;
|
2014-01-28 23:11:51 +00:00
|
|
|
|
2019-03-21 15:57:17 +00:00
|
|
|
void AddElements(CFArrayRef elements, std::set<IOHIDElementCookie>& cookies);
|
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
ForceFeedback::FFDeviceAdapterReference m_ff_device;
|
2010-04-27 07:33:33 +00:00
|
|
|
};
|
2019-06-17 20:39:24 +00:00
|
|
|
} // namespace ciface::OSX
|