2014-02-10 18:54:46 +00:00
|
|
|
#pragma once
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-12-21 23:58:25 +00:00
|
|
|
#include <X11/keysym.h>
|
2014-02-17 10:18:15 +00:00
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
|
|
#include "InputCommon/ControllerInterface/Device.h"
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
namespace ciface
|
|
|
|
{
|
2010-04-10 20:44:56 +00:00
|
|
|
namespace Xlib
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
|
2013-06-17 00:07:10 +00:00
|
|
|
void Init(std::vector<Core::Device*>& devices, void* const hwnd);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2013-06-17 00:07:10 +00:00
|
|
|
class KeyboardMouse : public Core::Device
|
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
|
|
|
struct State
|
|
|
|
{
|
|
|
|
char keyboard[32];
|
2010-04-23 04:46:42 +00:00
|
|
|
unsigned int buttons;
|
2010-07-16 03:43:11 +00:00
|
|
|
struct
|
|
|
|
{
|
|
|
|
float x, y;
|
|
|
|
} cursor;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
class Key : public Input
|
|
|
|
{
|
2010-07-16 03:43:11 +00:00
|
|
|
friend class KeyboardMouse;
|
2010-04-25 18:04:55 +00:00
|
|
|
public:
|
2010-04-02 02:48:24 +00:00
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Key(Display* display, KeyCode keycode, const char* keyboard);
|
|
|
|
ControlState GetState() const;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2010-04-25 18:04:55 +00:00
|
|
|
private:
|
2014-02-16 20:30:18 +00:00
|
|
|
std::string m_keyname;
|
|
|
|
Display* const m_display;
|
2011-03-14 01:20:11 +00:00
|
|
|
const char* const m_keyboard;
|
2014-02-16 20:30:18 +00:00
|
|
|
const KeyCode m_keycode;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2010-04-23 04:46:42 +00:00
|
|
|
class Button : public Input
|
|
|
|
{
|
2010-04-25 18:04:55 +00:00
|
|
|
public:
|
2010-04-23 04:46:42 +00:00
|
|
|
std::string GetName() const;
|
2011-03-14 01:20:11 +00:00
|
|
|
Button(unsigned int index, unsigned int& buttons)
|
|
|
|
: m_buttons(buttons), m_index(index) {}
|
|
|
|
ControlState GetState() const;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2010-04-25 18:04:55 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const unsigned int& m_buttons;
|
2010-04-23 04:46:42 +00:00
|
|
|
const unsigned int m_index;
|
|
|
|
};
|
2010-07-16 03:43:11 +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, bool positive, const float& cursor)
|
|
|
|
: m_cursor(cursor), m_index(index), m_positive(positive) {}
|
|
|
|
ControlState GetState() const;
|
|
|
|
|
2010-07-16 03:43:11 +00:00
|
|
|
private:
|
2011-03-14 01:20:11 +00:00
|
|
|
const float& m_cursor;
|
2014-02-16 20:30:18 +00:00
|
|
|
const u8 m_index;
|
|
|
|
const bool m_positive;
|
2010-07-16 03:43:11 +00:00
|
|
|
};
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2011-03-14 01:20:11 +00:00
|
|
|
public:
|
2010-04-02 02:48:24 +00:00
|
|
|
bool UpdateInput();
|
|
|
|
bool UpdateOutput();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2010-07-16 03:43:11 +00:00
|
|
|
KeyboardMouse(Window window);
|
|
|
|
~KeyboardMouse();
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
std::string GetName() const;
|
|
|
|
std::string GetSource() const;
|
|
|
|
int GetId() const;
|
2013-10-29 05:23:17 +00:00
|
|
|
|
2010-04-25 18:04:55 +00:00
|
|
|
private:
|
2014-02-16 20:30:18 +00:00
|
|
|
Window m_window;
|
2011-03-14 01:20:11 +00:00
|
|
|
Display* m_display;
|
2014-02-16 20:30:18 +00:00
|
|
|
State m_state;
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|