2014-02-10 18:54:46 +00:00
|
|
|
// Copyright 2013 Dolphin Emulator Project
|
|
|
|
// Licensed under GPLv2
|
|
|
|
// 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>
|
|
|
|
|
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
2014-08-23 00:17:49 +00:00
|
|
|
#include "InputCommon/ControllerInterface/DInput/DInput8.h"
|
2010-07-03 08:04:10 +00:00
|
|
|
|
|
|
|
namespace ciface
|
|
|
|
{
|
|
|
|
namespace DInput
|
|
|
|
{
|
|
|
|
|
2013-06-17 00:07:10 +00:00
|
|
|
void InitKeyboardMouse(IDirectInput8* const idi8, std::vector<Core::Device*>& devices, 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;
|
2010-07-10 06:48:24 +00:00
|
|
|
struct
|
|
|
|
{
|
2014-11-09 20:02:18 +00:00
|
|
|
ControlState x, y;
|
2010-07-10 06:48:24 +00:00
|
|
|
} cursor;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
class Key : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Key(u8 index, const BYTE& key) : m_index(index), m_key(key) {}
|
|
|
|
ControlState GetState() const;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
class Button : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Button(u8 index, const BYTE& button) : m_index(index), m_button(button) {}
|
|
|
|
ControlState GetState() const;
|
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
|
|
|
};
|
|
|
|
|
|
|
|
class Axis : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Axis(u8 index, const LONG& axis, LONG range) : m_index(index), m_axis(axis), m_range(range) {}
|
|
|
|
ControlState GetState() const;
|
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
|
|
|
};
|
|
|
|
|
2010-07-10 06:48:24 +00:00
|
|
|
class Cursor : public Input
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string GetName() const;
|
|
|
|
bool IsDetectable() { return false; }
|
2014-11-09 20:02:18 +00:00
|
|
|
Cursor(u8 index, const ControlState& axis, const bool positive) : m_index(index), m_axis(axis), m_positive(positive) {}
|
2011-03-14 01:20:11 +00:00
|
|
|
ControlState GetState() const;
|
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
|
|
|
|
|
|
|
KeyboardMouse(const LPDIRECTINPUTDEVICE8 kb_device, const LPDIRECTINPUTDEVICE8 mo_device);
|
|
|
|
~KeyboardMouse();
|
|
|
|
|
|
|
|
std::string GetName() const;
|
|
|
|
int GetId() const;
|
|
|
|
std::string GetSource() const;
|
|
|
|
|
|
|
|
private:
|
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
|
|
|
|
2014-01-31 00:51:21 +00:00
|
|
|
DWORD m_last_update;
|
|
|
|
State m_state_in;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|