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
|
|
|
|
|
|
|
#define DIRECTINPUT_VERSION 0x0800
|
|
|
|
#define WIN32_LEAN_AND_MEAN
|
|
|
|
#define NOMINMAX
|
|
|
|
#include <dinput.h>
|
2014-02-19 01:17:31 +00:00
|
|
|
#include <windows.h>
|
|
|
|
|
|
|
|
#include "InputCommon/ControllerInterface/Device.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
|
|
|
|
{
|
|
|
|
float x, y;
|
|
|
|
} 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; }
|
2011-03-14 01:20:11 +00:00
|
|
|
Cursor(u8 index, const float& axis, const bool positive) : m_index(index), m_axis(axis), m_positive(positive) {}
|
|
|
|
ControlState GetState() const;
|
2010-07-10 06:48:24 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const float& m_axis;
|
|
|
|
const u8 m_index;
|
|
|
|
const bool m_positive;
|
2010-07-10 06:48:24 +00:00
|
|
|
};
|
|
|
|
|
2010-07-03 08:04:10 +00:00
|
|
|
class Light : public Output
|
|
|
|
{
|
|
|
|
public:
|
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Light(u8 index) : m_index(index) {}
|
|
|
|
void SetState(ControlState state);
|
2010-07-03 08:04:10 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const u8 m_index;
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
2011-03-14 01:20:11 +00:00
|
|
|
|
|
|
|
public:
|
2010-07-03 08:04:10 +00:00
|
|
|
bool UpdateInput();
|
|
|
|
bool UpdateOutput();
|
|
|
|
|
|
|
|
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;
|
|
|
|
unsigned char m_state_out[3]; // NUM CAPS SCROLL
|
|
|
|
bool m_current_state_out[3]; // NUM CAPS SCROLL
|
2010-07-03 08:04:10 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|