summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface/OSX/OSXKeyboard.h
blob: 84ab9ae810ce46101388274e8024dd8e7ce4a9ab (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
#pragma once

#include "../ControllerInterface.h"
#include <IOKit/hid/IOHIDLib.h>

namespace ciface
{
namespace OSX
{

class Keyboard : public ControllerInterface::Device
{
	friend class ControllerInterface;
	friend class ControllerInterface::ControlReference;
	
protected:
	
	class Input : public ControllerInterface::Device::Input
	{
		friend class Keyboard;
	protected:
		virtual ControlState GetState(IOHIDDeviceRef device) = 0;
	};
	
	class Key : public Input
	{
		friend class Keyboard;
	public:
		std::string GetName() const;
	protected:
		Key( IOHIDElementRef element );
		ControlState GetState(IOHIDDeviceRef device);
	private:
		IOHIDElementRef	m_element;
		std::string		m_name;
	};
	
	bool UpdateInput();
	bool UpdateOutput();
	
	ControlState GetInputState( const ControllerInterface::Device::Input* const input );
	void SetOutputState( const ControllerInterface::Device::Output* const output, const ControlState state );
	
public:
	Keyboard(IOHIDDeviceRef device);
	
	std::string GetName() const;
	std::string GetSource() const;
	int GetId() const;
	
private:
	IOHIDDeviceRef	m_device;
	std::string		m_device_name;
};

}
}