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