2010-04-02 02:48:24 +00:00
|
|
|
#ifndef _CIFACE_XLIB_H_
|
|
|
|
#define _CIFACE_XLIB_H_
|
|
|
|
|
|
|
|
#include "../ControllerInterface.h"
|
|
|
|
|
|
|
|
#include <X11/Xlib.h>
|
|
|
|
|
|
|
|
namespace ciface
|
|
|
|
{
|
2010-04-10 20:44:56 +00:00
|
|
|
namespace Xlib
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
|
2010-04-10 20:44:56 +00:00
|
|
|
void Init(std::vector<ControllerInterface::Device*>& devices, void* const hwnd);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
class Keyboard : public ControllerInterface::Device
|
|
|
|
{
|
|
|
|
friend class ControllerInterface;
|
|
|
|
friend class ControllerInterface::ControlReference;
|
|
|
|
|
2010-04-10 20:44:56 +00:00
|
|
|
protected:
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
struct State
|
|
|
|
{
|
|
|
|
char keyboard[32];
|
|
|
|
// mouse crap will go here
|
|
|
|
};
|
|
|
|
|
2010-04-10 20:44:56 +00:00
|
|
|
class Input : public ControllerInterface::Device::Input
|
2010-04-02 02:48:24 +00:00
|
|
|
{
|
|
|
|
friend class Keyboard;
|
2010-04-10 20:44:56 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
virtual ControlState GetState(const State* const state) = 0;
|
|
|
|
};
|
2010-04-02 02:48:24 +00:00
|
|
|
|
|
|
|
class Key : public Input
|
|
|
|
{
|
|
|
|
friend class Keyboard;
|
2010-04-10 20:44:56 +00:00
|
|
|
|
|
|
|
public:
|
2010-04-02 02:48:24 +00:00
|
|
|
std::string GetName() const;
|
2010-04-10 20:44:56 +00:00
|
|
|
|
|
|
|
protected:
|
|
|
|
Key(Display* const display, KeyCode keycode);
|
|
|
|
ControlState GetState(const State* const state);
|
|
|
|
|
|
|
|
private:
|
|
|
|
Display* const m_display;
|
|
|
|
const KeyCode m_keycode;
|
|
|
|
std::string m_keyname;
|
|
|
|
|
2010-04-02 02:48:24 +00:00
|
|
|
};
|
|
|
|
|
|
|
|
bool UpdateInput();
|
|
|
|
bool UpdateOutput();
|
|
|
|
|
2010-04-10 20:44:56 +00:00
|
|
|
ControlState GetInputState(const ControllerInterface::Device::Input* const input);
|
|
|
|
void SetOutputState(const ControllerInterface::Device::Output* const output, const ControlState state);
|
2010-04-02 02:48:24 +00:00
|
|
|
|
2010-04-10 20:44:56 +00:00
|
|
|
public:
|
|
|
|
Keyboard(Display* display);
|
2010-04-02 02:48:24 +00:00
|
|
|
~Keyboard();
|
|
|
|
|
|
|
|
std::string GetName() const;
|
|
|
|
std::string GetSource() const;
|
|
|
|
int GetId() const;
|
|
|
|
|
2010-04-10 20:44:56 +00:00
|
|
|
private:
|
|
|
|
Display* m_display;
|
2010-04-02 02:48:24 +00:00
|
|
|
State m_state;
|
|
|
|
};
|
|
|
|
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
|
|
|
#endif
|