summaryrefslogtreecommitdiff
path: root/Source/Core/InputCommon/Src/ControllerInterface/DirectInput/DirectInputMouse.h
blob: c645d027274d161c276b905880bf83fb50e3a860 (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
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
#ifndef _CIFACE_DIRECTINPUT_MOUSE_H_
#define _CIFACE_DIRECTINPUT_MOUSE_H_

#include "../ControllerInterface.h"

#define DIRECTINPUT_VERSION 0x0800
#define WIN32_LEAN_AND_MEAN
#define NOMINMAX
#include <Windows.h>
#include <dinput.h>

namespace ciface
{
namespace DirectInput
{

void InitMouse(IDirectInput8* const idi8, std::vector<ControllerInterface::Device*>& devices);

class Mouse : public ControllerInterface::Device
{
	friend class ControllerInterface;
	friend class ControllerInterface::ControlReference;

protected:

	class Input : public ControllerInterface::Device::Input
	{
		friend class Mouse;
	protected:
		virtual ControlState GetState(const DIMOUSESTATE2* const boardstate) const = 0;
	};

	class Button : public Input
	{
		friend class Mouse;
	public:
		std::string GetName() const;
	protected:
		Button(const unsigned int index) : m_index(index) {}
		ControlState GetState(const DIMOUSESTATE2* const state) const;
	private:
		const unsigned int	m_index;
	};

	class Axis : public Input
	{
		friend class Mouse;
	public:
		std::string GetName() const;
	protected:
		Axis(const unsigned int index, const LONG range) : m_index(index), m_range(range) {}
		ControlState GetState(const DIMOUSESTATE2* const state) const;
	private:
		const unsigned int	m_index;
		const LONG			m_range;
	};
	
	bool UpdateInput();
	bool UpdateOutput();

	ControlState GetInputState( const ControllerInterface::Device::Input* const input ) const;
	void SetOutputState( const ControllerInterface::Device::Output* const input, const ControlState state );

public:
	Mouse(const LPDIRECTINPUTDEVICE8 mo_device, const int index);
	~Mouse();

	std::string GetName() const;
	int GetId() const;
	std::string GetSource() const;

private:
	const LPDIRECTINPUTDEVICE8	m_mo_device;
	const int			m_index;

	DWORD			m_last_update;
	DIMOUSESTATE2		m_state_in;
};

}
}

#endif