2015-05-24 04:55:12 +00:00
|
|
|
// Copyright 2010 Dolphin Emulator Project
|
2015-05-17 23:08:10 +00:00
|
|
|
// Licensed under GPLv2+
|
2014-02-10 18:54:46 +00:00
|
|
|
// Refer to the license.txt file included.
|
|
|
|
|
|
|
|
#pragma once
|
2010-07-03 08:04:10 +00:00
|
|
|
|
2014-02-19 01:17:31 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
2020-01-24 06:06:39 +00:00
|
|
|
#include "Common/Matrix.h"
|
2014-08-23 00:17:49 +00:00
|
|
|
#include "InputCommon/ControllerInterface/DInput/DInput8.h"
|
2014-02-19 01:17:31 +00:00
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
2010-07-03 08:04:10 +00:00
|
|
|
|
2019-06-17 20:39:24 +00:00
|
|
|
namespace ciface::DInput
|
2010-07-03 08:04:10 +00:00
|
|
|
{
|
2019-04-20 14:25:11 +00:00
|
|
|
void InitKeyboardMouse(IDirectInput8* const idi8, HWND hwnd);
|
2010-07-03 08:04:10 +00:00
|
|
|
|
2013-06-17 00:07:10 +00:00
|
|
|
class KeyboardMouse : public Core::Device
|
2010-07-03 08:04:10 +00:00
|
|
|
{
|
2011-03-14 01:20:11 +00:00
|
|
|
private:
|
2010-07-03 08:04:10 +00:00
|
|
|
struct State
|
|
|
|
{
|
2014-01-31 00:51:21 +00:00
|
|
|
BYTE keyboard[256];
|
|
|
|
DIMOUSESTATE2 mouse;
|
2020-01-24 06:06:39 +00:00
|
|
|
Common::TVec2<ControlState> cursor;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
class Key : public Input
|
|
|
|
{
|
|
|
|
public:
|
2015-09-06 02:32:05 +00:00
|
|
|
Key(u8 index, const BYTE& key) : m_key(key), m_index(index) {}
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const BYTE& m_key;
|
|
|
|
const u8 m_index;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
class Button : public Input
|
|
|
|
{
|
|
|
|
public:
|
2015-09-06 02:32:05 +00: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 08:43:46 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const BYTE& m_button;
|
|
|
|
const u8 m_index;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
class Axis : public Input
|
|
|
|
{
|
|
|
|
public:
|
2015-09-06 02:32:05 +00:00
|
|
|
Axis(u8 index, const LONG& axis, LONG range) : m_axis(axis), m_range(range), m_index(index) {}
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const LONG& m_axis;
|
|
|
|
const LONG m_range;
|
|
|
|
const u8 m_index;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
class Cursor : public Input
|
|
|
|
{
|
|
|
|
public:
|
2015-09-06 02:32:05 +00:00
|
|
|
Cursor(u8 index, const ControlState& axis, const bool positive)
|
|
|
|
: m_axis(axis), m_index(index), m_positive(positive)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
std::string GetName() const override;
|
2020-02-22 16:27:43 +00:00
|
|
|
bool IsDetectable() const override { return false; }
|
2015-09-06 02:32:05 +00:00
|
|
|
ControlState GetState() const override;
|
2016-06-24 08:43:46 +00:00
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
private:
|
2014-11-09 20:02:18 +00:00
|
|
|
const ControlState& m_axis;
|
2011-03-14 01:20:11 +00:00
|
|
|
const u8 m_index;
|
|
|
|
const bool m_positive;
|
2010-07-10 06:48:24 +00:00
|
|
|
};
|
|
|
|
|
2011-03-14 01:20:11 +00:00
|
|
|
public:
|
2014-11-13 08:55:14 +00:00
|
|
|
void UpdateInput() override;
|
2010-07-03 08:04:10 +00:00
|
|
|
|
2019-04-20 14:25:11 +00:00
|
|
|
KeyboardMouse(const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRECTINPUTDEVICE8 mo_device,
|
|
|
|
HWND hwnd);
|
2010-07-03 08:04:10 +00:00
|
|
|
~KeyboardMouse();
|
|
|
|
|
2015-09-06 02:32:05 +00:00
|
|
|
std::string GetName() const override;
|
|
|
|
std::string GetSource() const override;
|
2010-07-03 08:04:10 +00:00
|
|
|
|
|
|
|
private:
|
2019-04-20 14:25:11 +00:00
|
|
|
void UpdateCursorInput();
|
|
|
|
|
2014-01-31 00:51:21 +00:00
|
|
|
const LPDIRECTINPUTDEVICE8 m_kb_device;
|
|
|
|
const LPDIRECTINPUTDEVICE8 m_mo_device;
|
2010-07-03 08:04:10 +00:00
|
|
|
|
2019-04-20 14:25:11 +00:00
|
|
|
const HWND m_hwnd;
|
|
|
|
|
2014-01-31 00:51:21 +00:00
|
|
|
DWORD m_last_update;
|
|
|
|
State m_state_in;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
2019-06-17 20:39:24 +00:00
|
|
|
} // namespace ciface::DInput
|