2010-06-26 13:03:25 +00:00
|
|
|
#include <IOKit/hid/IOHIDLib.h>
|
2010-04-27 07:33:33 +00:00
|
|
|
|
2013-06-17 00:07:10 +00:00
|
|
|
#include "../Device.h"
|
2010-04-27 07:33:33 +00:00
|
|
|
|
|
|
|
namespace ciface
|
|
|
|
{
|
|
|
|
namespace OSX
|
|
|
|
{
|
|
|
|
|
2013-06-17 00:07:10 +00:00
|
|
|
class Joystick : public Core::Device
|
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:
|
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Button(IOHIDElementRef element, IOHIDDeviceRef device)
|
|
|
|
: m_element(element), m_device(device) {}
|
|
|
|
ControlState GetState() const;
|
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
|
|
|
};
|
2010-06-26 13:03:25 +00:00
|
|
|
|
2010-04-27 07:33:33 +00:00
|
|
|
class Axis : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum direction {
|
|
|
|
positive = 0,
|
|
|
|
negative
|
|
|
|
};
|
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Axis(IOHIDElementRef element, IOHIDDeviceRef device, direction dir);
|
|
|
|
ControlState GetState() const;
|
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
|
|
|
};
|
2010-06-26 13:03:25 +00:00
|
|
|
|
2011-01-16 17:00:17 +00:00
|
|
|
class Hat : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
enum direction {
|
|
|
|
up = 0,
|
|
|
|
right,
|
|
|
|
down,
|
|
|
|
left
|
|
|
|
};
|
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Hat(IOHIDElementRef element, IOHIDDeviceRef device, direction dir);
|
|
|
|
ControlState GetState() const;
|
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:
|
2010-04-27 07:33:33 +00:00
|
|
|
bool UpdateInput();
|
|
|
|
bool UpdateOutput();
|
2010-06-26 13:03:25 +00:00
|
|
|
|
2011-01-30 05:46:19 +00:00
|
|
|
Joystick(IOHIDDeviceRef device, std::string name, int index);
|
2010-06-26 13:03:25 +00:00
|
|
|
|
2010-04-27 07:33:33 +00:00
|
|
|
std::string GetName() const;
|
|
|
|
std::string GetSource() const;
|
|
|
|
int GetId() 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;
|
|
|
|
const int m_index;
|
2010-04-27 07:33:33 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|