2015-05-24 06:55:12 +02:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2021-07-05 03:22:19 +02:00
|
|
|
// SPDX-License-Identifier: GPL-2.0-or-later
|
2014-02-10 13:54:46 -05:00
|
|
|
|
|
|
|
#pragma once
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2020-09-15 04:34:41 -07:00
|
|
|
#include "InputCommon/ControllerInterface/CoreDevice.h"
|
2014-02-17 05:18:15 -05:00
|
|
|
#include "InputCommon/ControllerInterface/ForceFeedback/ForceFeedbackDevice.h"
|
2011-03-15 04:04:27 +00:00
|
|
|
|
2019-06-17 16:39:24 -04:00
|
|
|
namespace ciface::DInput
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2016-06-12 17:08:04 +02:00
|
|
|
void InitJoystick(IDirectInput8* const idi8, HWND hwnd);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2014-02-05 19:28:32 +09:00
|
|
|
class Joystick : public ForceFeedback::ForceFeedbackDevice
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
2011-03-14 01:20:11 +00:00
|
|
|
private:
|
2010-04-02 02:48:24 +00:00
|
|
|
class Button : public Input
|
|
|
|
{
|
|
|
|
public:
|
2015-09-05 22:32:05 -04: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 10:43:46 +02:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const BYTE& m_button;
|
|
|
|
const u8 m_index;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
2016-06-24 10:43:46 +02:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
class Axis : public Input
|
2016-06-24 10:43:46 +02:00
|
|
|
{
|
|
|
|
public:
|
2015-09-05 22:32:05 -04: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 10:43:46 +02:00
|
|
|
{
|
|
|
|
}
|
2015-09-05 22:32:05 -04:00
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const LONG& m_axis;
|
|
|
|
const LONG m_base, m_range;
|
|
|
|
const u8 m_index;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Hat : public Input
|
|
|
|
{
|
|
|
|
public:
|
2015-09-05 22:32:05 -04: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 10:43:46 +02:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const DWORD& m_hat;
|
|
|
|
const u8 m_index, m_direction;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
2011-03-14 01:20:11 +00:00
|
|
|
public:
|
2014-11-13 00:55:14 -08:00
|
|
|
void UpdateInput() override;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2016-07-14 10:25:52 +02:00
|
|
|
Joystick(const LPDIRECTINPUTDEVICE8 device);
|
2010-04-02 02:48:24 +00:00
|
|
|
~Joystick();
|
2013-10-29 01:23:17 -04:00
|
|
|
|
2015-09-05 22:32:05 -04:00
|
|
|
std::string GetName() const override;
|
|
|
|
std::string GetSource() const override;
|
2022-03-02 15:40:20 -06:00
|
|
|
int GetSortPriority() const override { return -3; }
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2019-03-09 09:57:37 -06:00
|
|
|
bool IsValid() const final override;
|
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
private:
|
2014-01-30 19:51:21 -05:00
|
|
|
const LPDIRECTINPUTDEVICE8 m_device;
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2021-09-03 21:43:19 -07:00
|
|
|
DIJOYSTATE m_state_in{};
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2014-01-30 19:51:21 -05:00
|
|
|
bool m_buffered;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
2019-06-17 16:39:24 -04:00
|
|
|
} // namespace ciface::DInput
|