mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-07-23 06:09:50 -06:00
Commited my new wiimote plugin work so far. Some code was copied from the current wiimote plugin. I have cleaned up most of the functions, but there are still a bunch of unused structs and stuff that I need to clean up.
Moved ControllerInterface to InputCommon. Moved GCPadNew GUI/Config code to a new project, InputPluginCommon. It is used by both GCPadNew and WiimoteNew. I hope that I included everyone's fixes to GCPadNew and ControllerInterface. git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5355 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
110
Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp
Normal file
110
Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.cpp
Normal file
@ -0,0 +1,110 @@
|
||||
#include "Xlib.h"
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace Xlib
|
||||
{
|
||||
|
||||
void Init(std::vector<ControllerInterface::Device*>& devices, void* const hwnd)
|
||||
{
|
||||
// mouse will be added to this, Keyboard class will be turned into KeyboardMouse
|
||||
// single device for combined keyboard/mouse, this will allow combinations like shift+click more easily
|
||||
devices.push_back(new Keyboard((Display*)hwnd));
|
||||
}
|
||||
|
||||
Keyboard::Keyboard(Display* display) : m_display(display)
|
||||
{
|
||||
memset(&m_state, 0, sizeof(m_state));
|
||||
|
||||
int min_keycode, max_keycode;
|
||||
XDisplayKeycodes(m_display, &min_keycode, &max_keycode);
|
||||
|
||||
for (int i = min_keycode; i <= max_keycode; ++i)
|
||||
{
|
||||
Key *temp_key = new Key(m_display, i);
|
||||
if (temp_key->m_keyname.length())
|
||||
inputs.push_back(temp_key);
|
||||
else
|
||||
delete temp_key;
|
||||
}
|
||||
}
|
||||
|
||||
Keyboard::~Keyboard()
|
||||
{
|
||||
}
|
||||
|
||||
|
||||
ControlState Keyboard::GetInputState(const ControllerInterface::Device::Input* const input)
|
||||
{
|
||||
return ((Input*)input)->GetState(&m_state);
|
||||
}
|
||||
|
||||
void Keyboard::SetOutputState(const ControllerInterface::Device::Output* const output, const ControlState state)
|
||||
{
|
||||
|
||||
}
|
||||
|
||||
bool Keyboard::UpdateInput()
|
||||
{
|
||||
XQueryKeymap(m_display, m_state.keyboard);
|
||||
|
||||
// mouse stuff in here too
|
||||
|
||||
return true;
|
||||
}
|
||||
|
||||
bool Keyboard::UpdateOutput()
|
||||
{
|
||||
return true;
|
||||
}
|
||||
|
||||
|
||||
std::string Keyboard::GetName() const
|
||||
{
|
||||
return "Keyboard";
|
||||
//return "Keyboard Mouse"; // change to this later
|
||||
}
|
||||
|
||||
std::string Keyboard::GetSource() const
|
||||
{
|
||||
return "Xlib";
|
||||
}
|
||||
|
||||
int Keyboard::GetId() const
|
||||
{
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
||||
Keyboard::Key::Key(Display* const display, KeyCode keycode)
|
||||
: m_display(display), m_keycode(keycode)
|
||||
{
|
||||
int i = 0;
|
||||
KeySym keysym = 0;
|
||||
do
|
||||
{
|
||||
keysym = XKeycodeToKeysym(m_display, keycode, i);
|
||||
i++;
|
||||
}
|
||||
while (keysym == NoSymbol && i < 8);
|
||||
|
||||
// 0x0110ffff is the top of the unicode character range according to keysymdef.h
|
||||
// although it is probably more than we need.
|
||||
if (keysym == NoSymbol || keysym > 0x0110ffff)
|
||||
m_keyname = std::string();
|
||||
else
|
||||
m_keyname = std::string(XKeysymToString(keysym));
|
||||
}
|
||||
|
||||
ControlState Keyboard::Key::GetState(const State* const state)
|
||||
{
|
||||
return (state->keyboard[m_keycode/8] & (1 << (m_keycode%8))) != 0;
|
||||
}
|
||||
|
||||
std::string Keyboard::Key::GetName() const
|
||||
{
|
||||
return m_keyname;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
76
Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.h
Normal file
76
Source/Core/InputCommon/Src/ControllerInterface/Xlib/Xlib.h
Normal file
@ -0,0 +1,76 @@
|
||||
#ifndef _CIFACE_XLIB_H_
|
||||
#define _CIFACE_XLIB_H_
|
||||
|
||||
#include "../ControllerInterface.h"
|
||||
|
||||
#include <X11/Xlib.h>
|
||||
|
||||
namespace ciface
|
||||
{
|
||||
namespace Xlib
|
||||
{
|
||||
|
||||
void Init(std::vector<ControllerInterface::Device*>& devices, void* const hwnd);
|
||||
|
||||
class Keyboard : public ControllerInterface::Device
|
||||
{
|
||||
friend class ControllerInterface;
|
||||
friend class ControllerInterface::ControlReference;
|
||||
|
||||
protected:
|
||||
|
||||
struct State
|
||||
{
|
||||
char keyboard[32];
|
||||
// mouse crap will go here
|
||||
};
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
{
|
||||
friend class Keyboard;
|
||||
|
||||
protected:
|
||||
virtual ControlState GetState(const State* const state) = 0;
|
||||
};
|
||||
|
||||
class Key : public Input
|
||||
{
|
||||
friend class Keyboard;
|
||||
|
||||
public:
|
||||
std::string GetName() const;
|
||||
|
||||
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;
|
||||
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
ControlState GetInputState(const ControllerInterface::Device::Input* const input);
|
||||
void SetOutputState(const ControllerInterface::Device::Output* const output, const ControlState state);
|
||||
|
||||
public:
|
||||
Keyboard(Display* display);
|
||||
~Keyboard();
|
||||
|
||||
std::string GetName() const;
|
||||
std::string GetSource() const;
|
||||
int GetId() const;
|
||||
|
||||
private:
|
||||
Display* m_display;
|
||||
State m_state;
|
||||
};
|
||||
|
||||
}
|
||||
}
|
||||
|
||||
#endif
|
Reference in New Issue
Block a user