mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-03-12 06:39:14 +01:00
Get the wiimote new plugin working in linux. Wiimote emulation works at least. Real wiimotes don't.
git-svn-id: https://dolphin-emu.googlecode.com/svn/trunk@5399 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
219e8beb6d
commit
05e3808beb
@ -16,9 +16,12 @@ Keyboard::Keyboard(Display* display) : m_display(display)
|
||||
{
|
||||
memset(&m_state, 0, sizeof(m_state));
|
||||
|
||||
m_window = DefaultRootWindow(m_display);
|
||||
|
||||
int min_keycode, max_keycode;
|
||||
XDisplayKeycodes(m_display, &min_keycode, &max_keycode);
|
||||
|
||||
// Keyboard Keys
|
||||
for (int i = min_keycode; i <= max_keycode; ++i)
|
||||
{
|
||||
Key *temp_key = new Key(m_display, i);
|
||||
@ -27,6 +30,13 @@ Keyboard::Keyboard(Display* display) : m_display(display)
|
||||
else
|
||||
delete temp_key;
|
||||
}
|
||||
|
||||
// Mouse Buttons
|
||||
inputs.push_back(new Button(Button1Mask));
|
||||
inputs.push_back(new Button(Button2Mask));
|
||||
inputs.push_back(new Button(Button3Mask));
|
||||
inputs.push_back(new Button(Button4Mask));
|
||||
inputs.push_back(new Button(Button5Mask));
|
||||
}
|
||||
|
||||
Keyboard::~Keyboard()
|
||||
@ -48,7 +58,9 @@ bool Keyboard::UpdateInput()
|
||||
{
|
||||
XQueryKeymap(m_display, m_state.keyboard);
|
||||
|
||||
// mouse stuff in here too
|
||||
int root_x, root_y, win_x, win_y;
|
||||
Window root, child;
|
||||
XQueryPointer(m_display, m_window, &root, &child, &root_x, &root_y, &win_x, &win_y, &m_state.buttons);
|
||||
|
||||
return true;
|
||||
}
|
||||
@ -101,10 +113,30 @@ ControlState Keyboard::Key::GetState(const State* const state)
|
||||
return (state->keyboard[m_keycode/8] & (1 << (m_keycode%8))) != 0;
|
||||
}
|
||||
|
||||
ControlState Keyboard::Button::GetState(const State* const state)
|
||||
{
|
||||
return ((state->buttons & m_index) > 0);
|
||||
}
|
||||
|
||||
std::string Keyboard::Key::GetName() const
|
||||
{
|
||||
return m_keyname;
|
||||
}
|
||||
|
||||
std::string Keyboard::Button::GetName() const
|
||||
{
|
||||
char button = '0';
|
||||
switch (m_index)
|
||||
{
|
||||
case Button1Mask: button = '1'; break;
|
||||
case Button2Mask: button = '2'; break;
|
||||
case Button3Mask: button = '3'; break;
|
||||
case Button4Mask: button = '4'; break;
|
||||
case Button5Mask: button = '5'; break;
|
||||
}
|
||||
|
||||
return std::string("Button ") + button;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
||||
|
@ -22,7 +22,7 @@ class Keyboard : public ControllerInterface::Device
|
||||
struct State
|
||||
{
|
||||
char keyboard[32];
|
||||
// mouse crap will go here
|
||||
unsigned int buttons;
|
||||
};
|
||||
|
||||
class Input : public ControllerInterface::Device::Input
|
||||
@ -46,11 +46,26 @@ class Keyboard : public ControllerInterface::Device
|
||||
|
||||
private:
|
||||
Display* const m_display;
|
||||
const KeyCode m_keycode;
|
||||
std::string m_keyname;
|
||||
const KeyCode m_keycode;
|
||||
std::string m_keyname;
|
||||
|
||||
};
|
||||
|
||||
class Button : public Input
|
||||
{
|
||||
friend class Keyboard;
|
||||
|
||||
public:
|
||||
std::string GetName() const;
|
||||
|
||||
protected:
|
||||
Button(const unsigned int index) : m_index(index) {}
|
||||
ControlState GetState(const State* const state);
|
||||
|
||||
private:
|
||||
const unsigned int m_index;
|
||||
};
|
||||
|
||||
bool UpdateInput();
|
||||
bool UpdateOutput();
|
||||
|
||||
@ -66,6 +81,7 @@ class Keyboard : public ControllerInterface::Device
|
||||
int GetId() const;
|
||||
|
||||
private:
|
||||
Window m_window;
|
||||
Display* m_display;
|
||||
State m_state;
|
||||
};
|
||||
|
@ -321,7 +321,7 @@ void Initialize(void *init)
|
||||
{
|
||||
g_PADInitialize = (SPADInitialize*)init;
|
||||
if ( false == g_plugin.controller_interface.IsInit() )
|
||||
InitPlugin( ((SPADInitialize*)init)->hWnd );
|
||||
InitPlugin( g_PADInitialize->hWnd );
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
|
@ -12,6 +12,10 @@
|
||||
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
#include <X11/Xlib.h>
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
#include <gtk/gtk.h>
|
||||
#include <gdk/gdkx.h>
|
||||
#endif
|
||||
#endif
|
||||
|
||||
#define PLUGIN_VERSION 0x0100
|
||||
@ -232,14 +236,24 @@ void GetDllInfo(PLUGIN_INFO* _pPluginInfo)
|
||||
//
|
||||
void DllConfig(HWND _hParent)
|
||||
{
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
bool was_init = false;
|
||||
|
||||
if ( g_plugin.controller_interface.IsInit() ) // hack for showing dialog when game isnt running
|
||||
was_init = true;
|
||||
else
|
||||
InitPlugin( _hParent );
|
||||
{
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
Window win = GDK_WINDOW_XID(GTK_WIDGET(_hParent)->window);
|
||||
g_WiimoteInitialize.hWnd = GDK_WINDOW_XDISPLAY(GTK_WIDGET(_hParent)->window);
|
||||
g_WiimoteInitialize.pXWindow = &win;
|
||||
InitPlugin(g_WiimoteInitialize.hWnd);
|
||||
#else
|
||||
InitPlugin(_hParent);
|
||||
#endif
|
||||
}
|
||||
|
||||
// copied from GCPad
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
wxWindow *frame = GetParentedWxWindow(_hParent);
|
||||
ConfigDialog* m_ConfigFrame = new ConfigDialog( frame, g_plugin, PLUGIN_FULL_NAME, was_init );
|
||||
|
||||
@ -260,11 +274,11 @@ void DllConfig(HWND _hParent)
|
||||
m_ConfigFrame->Destroy();
|
||||
m_ConfigFrame = NULL;
|
||||
frame->Destroy();
|
||||
#endif
|
||||
// /
|
||||
|
||||
if ( false == was_init ) // hack for showing dialog when game isnt running
|
||||
DeInitPlugin();
|
||||
#endif
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
@ -299,7 +313,7 @@ void Initialize(void *init)
|
||||
{
|
||||
g_WiimoteInitialize = *(SWiimoteInitialize*)init;
|
||||
if ( false == g_plugin.controller_interface.IsInit() )
|
||||
InitPlugin( ((SPADInitialize*)init)->hWnd );
|
||||
InitPlugin( g_WiimoteInitialize.hWnd );
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
|
Loading…
x
Reference in New Issue
Block a user