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>
|
|
|
|
|
2014-08-23 00:17:49 +00:00
|
|
|
#include "InputCommon/ControllerInterface/DInput/DInput8.h"
|
2016-06-24 08:43:46 +00:00
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
2010-07-03 08:04:10 +00:00
|
|
|
|
|
|
|
namespace ciface
|
|
|
|
{
|
|
|
|
namespace DInput
|
|
|
|
{
|
2019-03-09 15:57:37 +00:00
|
|
|
void InitKeyboardMouse(IDirectInput8* const idi8);
|
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:
|
2016-06-24 08:43:46 +00:00
|
|
|
struct State
|
|
|
|
{
|
|
|
|
BYTE keyboard[256];
|
|
|
|
DIMOUSESTATE2 mouse;
|
|
|
|
struct
|
|
|
|
{
|
|
|
|
ControlState x, y;
|
|
|
|
} cursor;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Key : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Key(u8 index, const BYTE& key) : m_key(key), m_index(index) {}
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const BYTE& m_key;
|
|
|
|
const u8 m_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Button : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Button(u8 index, const BYTE& button) : m_button(button), m_index(index) {}
|
|
|
|
std::string GetName() const override;
|
|
|
|
ControlState GetState() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const BYTE& m_button;
|
|
|
|
const u8 m_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Axis : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
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;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const LONG& m_axis;
|
|
|
|
const LONG m_range;
|
|
|
|
const u8 m_index;
|
|
|
|
};
|
|
|
|
|
|
|
|
class Cursor : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
Cursor(u8 index, const ControlState& axis, const bool positive)
|
|
|
|
: m_axis(axis), m_index(index), m_positive(positive)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
std::string GetName() const override;
|
|
|
|
bool IsDetectable() override { return false; }
|
|
|
|
ControlState GetState() const override;
|
|
|
|
|
|
|
|
private:
|
|
|
|
const ControlState& m_axis;
|
|
|
|
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:
|
2016-06-24 08:43:46 +00:00
|
|
|
void UpdateInput() override;
|
2010-07-03 08:04:10 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
KeyboardMouse(const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRECTINPUTDEVICE8 mo_device);
|
|
|
|
~KeyboardMouse();
|
2010-07-03 08:04:10 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
std::string GetName() const override;
|
|
|
|
std::string GetSource() const override;
|
2010-07-03 08:04:10 +00:00
|
|
|
|
|
|
|
private:
|
2016-06-24 08:43:46 +00:00
|
|
|
const LPDIRECTINPUTDEVICE8 m_kb_device;
|
|
|
|
const LPDIRECTINPUTDEVICE8 m_mo_device;
|
2010-07-03 08:04:10 +00:00
|
|
|
|
2016-06-24 08:43:46 +00:00
|
|
|
DWORD m_last_update;
|
|
|
|
State m_state_in;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
2019-03-09 15:57:37 +00:00
|
|
|
} // namespace DInput
|
|
|
|
} // namespace ciface
|