2015-05-23 22:55:12 -06:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 17:08:10 -06:00
|
|
|
// Licensed under GPLv2+
|
2014-02-10 11:54:46 -07:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2020-09-15 05:34:41 -06:00
|
|
|
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
2014-02-17 03:18:15 -07:00
|
|
|
#include "InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h"
|
2011-03-14 22:04:27 -06:00
|
|
|
|
2019-06-17 14:39:24 -06:00
|
|
|
namespace ciface::DInput
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2016-06-12 09:08:04 -06:00
|
|
|
void InitJoystick(IDirectInput8* const idi8, HWND hwnd);
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-02-05 03:28:32 -07:00
|
|
|
class Joystick : public ForceFeedback::ForceFeedbackDevice
|
2010-04-01 20:48:24 -06:00
|
|
|
{
|
2011-03-13 19:20:11 -06:00
|
|
|
private:
|
2010-04-01 20:48:24 -06:00
|
|
|
class Button : public Input
|
|
|
|
{
|
|
|
|
public:
|
2015-09-05 20:32:05 -06:00
|
|
|
Button(u8 index, const BYTE& button) : m_button(button), m_index(index) {}
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
private:
|
2011-03-13 19:20:11 -06:00
|
|
|
const BYTE& m_button;
|
|
|
|
const u8 m_index;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
class Axis : public Input
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
public:
|
2015-09-05 20:32:05 -06:00
|
|
|
Axis(u8 index, const LONG& axis, LONG base, LONG range)
|
|
|
|
: m_axis(axis), m_base(base), m_range(range), m_index(index)
|
2016-06-24 02:43:46 -06:00
|
|
|
{
|
|
|
|
}
|
2015-09-05 20:32:05 -06:00
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
|
|
|
private:
|
2011-03-13 19:20:11 -06:00
|
|
|
const LONG& m_axis;
|
|
|
|
const LONG m_base, m_range;
|
|
|
|
const u8 m_index;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
|
|
|
class Hat : public Input
|
|
|
|
{
|
|
|
|
public:
|
2015-09-05 20:32:05 -06:00
|
|
|
Hat(u8 index, const DWORD& hat, u8 direction)
|
|
|
|
: m_hat(hat), m_direction(direction), m_index(index)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2016-06-24 02:43:46 -06:00
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
private:
|
2011-03-13 19:20:11 -06:00
|
|
|
const DWORD& m_hat;
|
|
|
|
const u8 m_index, m_direction;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
|
|
|
|
2011-03-13 19:20:11 -06:00
|
|
|
public:
|
2014-11-13 01:55:14 -07:00
|
|
|
void UpdateInput() override;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2016-07-14 02:25:52 -06:00
|
|
|
Joystick(const LPDIRECTINPUTDEVICE8 device);
|
2010-04-01 20:48:24 -06:00
|
|
|
~Joystick();
|
2013-10-28 23:23:17 -06:00
|
|
|
|
2015-09-05 20:32:05 -06:00
|
|
|
std::string GetName() const override;
|
|
|
|
std::string GetSource() const override;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2019-03-09 08:57:37 -07:00
|
|
|
bool IsValid() const final override;
|
|
|
|
|
2010-04-01 20:48:24 -06:00
|
|
|
private:
|
2014-01-30 17:51:21 -07:00
|
|
|
const LPDIRECTINPUTDEVICE8 m_device;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-01-30 17:51:21 -07:00
|
|
|
DIJOYSTATE m_state_in;
|
2010-04-01 20:48:24 -06:00
|
|
|
|
2014-01-30 17:51:21 -07:00
|
|
|
bool m_buffered;
|
2010-04-01 20:48:24 -06:00
|
|
|
};
|
2019-06-17 14:39:24 -06:00
|
|
|
} // namespace ciface::DInput
|