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
|
|
|
|
2020-09-15 11:34:41 +00:00
|
|
|
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
2014-02-17 10:18:15 +00:00
|
|
|
#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:
|
2010-04-27 07:33:33 +00:00
|
|
|
class Button : public Input
|
|
|
|
{
|
|
|
|
public:
|
2011-03-14 01:20:11 +00:00
|
|
|
Button(IOHIDElementRef element, IOHIDDeviceRef device) : m_element(element), m_device(device) {}
|
2015-09-17 19:13:41 +00:00
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-04-27 07:33:33 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const IOHIDElementRef m_element;
|
|
|
|
const IOHIDDeviceRef m_device;
|
2010-04-27 07:33:33 +00:00
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-04-27 07:33:33 +00:00
|
|
|
class Axis : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum direction
|
|
|
|
{
|
|
|
|
positive = 0,
|
|
|
|
negative
|
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2011-03-14 01:20:11 +00:00
|
|
|
Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction dir);
|
2015-09-17 19:13:41 +00:00
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-04-27 07:33:33 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const IOHIDElementRef m_element;
|
|
|
|
const IOHIDDeviceRef m_device;
|
2010-04-27 07:33:33 +00:00
|
|
|
std::string m_name;
|
2011-03-14 01:20:11 +00:00
|
|
|
const direction m_direction;
|
2011-01-14 05:06:08 +00:00
|
|
|
float m_neutral;
|
2011-01-15 21:16:13 +00:00
|
|
|
float m_scale;
|
2010-04-27 07:33:33 +00:00
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2011-01-16 17:00:17 +00:00
|
|
|
class Hat : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum direction
|
|
|
|
{
|
|
|
|
up = 0,
|
|
|
|
right,
|
|
|
|
down,
|
|
|
|
left
|
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2011-03-14 01:20:11 +00:00
|
|
|
Hat(IOHIDElementRef element, IOHIDDeviceRef device, direction dir);
|
2015-09-17 19:13:41 +00:00
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2011-01-16 17:00:17 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
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);
|
2014-01-28 23:11:51 +00:00
|
|
|
~Joystick();
|
2010-06-26 13:03:25 +00:00
|
|
|
|
2015-09-17 19:13:41 +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:
|
2011-03-14 01:20:11 +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);
|
|
|
|
|
2014-01-28 23:11:51 +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
|