mirror of
https://github.com/dolphin-emu/dolphin.git
synced 2025-04-20 11:35:54 +00:00
Add linux fixes to GCPadNew from trunk.
git-svn-id: https://dolphin-emu.googlecode.com/svn/branches/stable@5323 8ced0084-cf51-0410-be5f-012b33b47a6e
This commit is contained in:
parent
45db281360
commit
449e28f9a6
8 changed files with 265 additions and 63 deletions
|
@ -792,38 +792,36 @@ void CFrame::OnGameListCtrl_ItemActivated(wxListEvent& WXUNUSED (event))
|
|||
|
||||
void CFrame::OnKeyDown(wxKeyEvent& event)
|
||||
{
|
||||
// Toggle fullscreen
|
||||
if (event.GetKeyCode() == WXK_RETURN && event.GetModifiers() == wxMOD_ALT)
|
||||
{
|
||||
DoFullscreen(!IsFullScreen());
|
||||
|
||||
// We do that to avoid the event to be double processed (which would cause the window to be stuck in fullscreen)
|
||||
event.StopPropagation();
|
||||
}
|
||||
else if(event.GetKeyCode() == WXK_ESCAPE)
|
||||
{
|
||||
main_frame->DoPause();
|
||||
}
|
||||
// event.Skip() allows the event to propagate to the gamelist for example
|
||||
else if (! (Core::GetState() == Core::CORE_RUN && bRenderToMain && event.GetEventObject() == this))
|
||||
event.Skip();
|
||||
|
||||
#ifdef _WIN32
|
||||
if(event.GetKeyCode() == 'M', '3', '4', '5', '6', '7') // Send this to the video plugin WndProc
|
||||
{
|
||||
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
|
||||
}
|
||||
#elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
|
||||
if (event.GetKeyCode() >= '3' && event.GetKeyCode() <= '7') // Send this to the video plugin
|
||||
{
|
||||
X11_SendKeyEvent(event.GetKeyCode());
|
||||
}
|
||||
#endif
|
||||
|
||||
|
||||
// Send the keyboard status to the Input plugin
|
||||
if(Core::GetState() != Core::CORE_UNINITIALIZED)
|
||||
CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down
|
||||
{
|
||||
// Toggle fullscreen
|
||||
if (event.GetKeyCode() == WXK_RETURN && event.GetModifiers() == wxMOD_ALT)
|
||||
{
|
||||
DoFullscreen(!IsFullScreen());
|
||||
|
||||
// We do that to avoid the event to be double processed (which would cause the window to be stuck in fullscreen)
|
||||
event.StopPropagation();
|
||||
}
|
||||
else if(event.GetKeyCode() == WXK_ESCAPE)
|
||||
{
|
||||
main_frame->DoPause();
|
||||
}
|
||||
// event.Skip() allows the event to propagate to the gamelist for example
|
||||
else if (! (Core::GetState() == Core::CORE_RUN && bRenderToMain && event.GetEventObject() == this))
|
||||
event.Skip();
|
||||
|
||||
if (event.GetKeyCode() >= '3' && event.GetKeyCode() <= '7') // Send this to the video plugin
|
||||
{
|
||||
#ifdef _WIN32
|
||||
PostMessage((HWND)Core::GetWindowHandle(), WM_USER, WM_USER_KEYDOWN, event.GetKeyCode());
|
||||
#elif defined(HAVE_X11) && HAVE_X11 && defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
|
||||
X11_SendKeyEvent(event.GetKeyCode());
|
||||
#endif
|
||||
}
|
||||
|
||||
// Send the keyboard status to the Input plugin
|
||||
CPluginManager::GetInstance().GetPad(0)->PAD_Input(event.GetKeyCode(), 1); // 1 = Down
|
||||
}
|
||||
}
|
||||
|
||||
void CFrame::OnKeyUp(wxKeyEvent& event)
|
||||
|
|
|
@ -2,8 +2,8 @@
|
|||
#include "ConfigDiag.h"
|
||||
|
||||
PadSettingCheckBox::PadSettingCheckBox( wxWindow* const parent, ControlState& _value, const char* const label )
|
||||
: wxCheckBox( parent, -1, wxString::FromAscii( label ), wxDefaultPosition )
|
||||
, PadSetting(_value)
|
||||
: PadSetting(_value)
|
||||
, wxCheckBox( parent, -1, wxString::FromAscii( label ), wxDefaultPosition )
|
||||
{
|
||||
UpdateGUI();
|
||||
}
|
||||
|
@ -20,8 +20,8 @@ void PadSettingCheckBox::UpdateValue()
|
|||
}
|
||||
|
||||
PadSettingChoice::PadSettingChoice( wxWindow* const parent, ControlState& _value, int min, int max )
|
||||
: wxChoice( parent, -1, wxDefaultPosition, wxSize( 48, -1 ) )
|
||||
, PadSetting(_value)
|
||||
: PadSetting(_value)
|
||||
, wxChoice( parent, -1, wxDefaultPosition, wxSize( 48, -1 ) )
|
||||
{
|
||||
Append( wxT("0") );
|
||||
for ( ; min<=max; ++min )
|
||||
|
@ -362,17 +362,19 @@ void ControlDialog::SelectControl( wxCommandEvent& event )
|
|||
// final_label = "||";
|
||||
else
|
||||
{
|
||||
final_label = wxT('|');
|
||||
for ( unsigned int i=0; i<sels.size(); ++i )
|
||||
final_label += names[ sels[i] ] + wxT('|');
|
||||
final_label = wxT('|');
|
||||
for ( unsigned int i=0; i<sels.size(); ++i )
|
||||
final_label += names[ sels[i] ] + wxT('|');
|
||||
}
|
||||
if (!final_label.CompareTo(wxT("|")))
|
||||
final_label.Empty();
|
||||
|
||||
control_chooser->textctrl->SetLabel( final_label );
|
||||
|
||||
// kinda dumb
|
||||
wxCommandEvent nullevent;
|
||||
((GamepadPage*)m_parent)->SetControl( nullevent );
|
||||
|
||||
|
||||
}
|
||||
|
||||
ControlChooser::ControlChooser( wxWindow* const parent, ControllerInterface::ControlReference* const ref, wxWindow* const eventsink )
|
||||
|
@ -422,7 +424,7 @@ ControlChooser::ControlChooser( wxWindow* const parent, ControllerInterface::Con
|
|||
|
||||
txtbox_szr->Add( textctrl, 1, wxEXPAND, 0 );
|
||||
|
||||
wxBoxSizer* mode_szr;
|
||||
wxBoxSizer* mode_szr = NULL;
|
||||
if ( control_reference->is_input )
|
||||
{
|
||||
mode_cbox = new wxChoice( parent, -1 );
|
||||
|
|
|
@ -40,7 +40,7 @@ void ControllerInterface::Init()
|
|||
ciface::DirectInput::Init( m_devices/*, (HWND)m_hwnd*/ );
|
||||
#endif
|
||||
#ifdef CIFACE_USE_XLIB
|
||||
ciface::XLIB::Init( m_devices, m_hwnd );
|
||||
ciface::Xlib::Init( m_devices, m_hwnd );
|
||||
#endif
|
||||
#ifdef CIFACE_USE_OSX
|
||||
ciface::OSX::Init( m_devices, m_hwnd );
|
||||
|
@ -238,7 +238,7 @@ ControlState ControllerInterface::InputReference::State( const ControlState igno
|
|||
if ( NULL == device )
|
||||
return 0;
|
||||
|
||||
ControlState state;
|
||||
ControlState state = 0;
|
||||
// this mode thing will be turned into a switch statement
|
||||
switch ( mode )
|
||||
{
|
||||
|
@ -360,11 +360,7 @@ void ControllerInterface::DeviceQualifier::FromDevice(const ControllerInterface:
|
|||
//
|
||||
bool ControllerInterface::DeviceQualifier::operator==(const ControllerInterface::Device* const dev) const
|
||||
{
|
||||
if ( dev->GetName() == name )
|
||||
if ( dev->GetId() == cid )
|
||||
if ( dev->GetSource() == source )
|
||||
return true;
|
||||
return false;
|
||||
return (dev->GetName() == name) && (dev->GetId() == cid) && (dev->GetSource() == source);
|
||||
}
|
||||
|
||||
//
|
||||
|
|
|
@ -6,6 +6,7 @@
|
|||
#include <sstream>
|
||||
#include <map>
|
||||
#include <algorithm>
|
||||
#include "Common.h"
|
||||
|
||||
// enable disable sources
|
||||
#ifdef _WIN32
|
||||
|
@ -16,7 +17,7 @@
|
|||
#endif
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
// Xlib is not tested at all currently, it is like 80% complete at least though
|
||||
//#define CIFACE_USE_XLIB
|
||||
#define CIFACE_USE_XLIB
|
||||
#endif
|
||||
#ifndef CIFACE_USE_DIRECTINPUT_JOYSTICK
|
||||
#define CIFACE_USE_SDL
|
||||
|
|
|
@ -0,0 +1,108 @@
|
|||
#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);
|
||||
|
||||
if (keysym == NoSymbol)
|
||||
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));
|
||||
}
|
||||
|
||||
std::string Keyboard::Key::GetName() const
|
||||
{
|
||||
return m_keyname;
|
||||
}
|
||||
|
||||
}
|
||||
}
|
|
@ -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
|
|
@ -55,12 +55,14 @@ bool IsFocus()
|
|||
#elif defined HAVE_X11 && HAVE_X11
|
||||
Display* GCdisplay = (Display*)g_PADInitialize->hWnd;
|
||||
Window GLWin = *(Window *)g_PADInitialize->pXWindow;
|
||||
bool bFocus = False;
|
||||
#if defined(HAVE_GTK2) && HAVE_GTK2 && defined(wxGTK)
|
||||
bFocus = (wxPanel *)g_PADInitialize->pPanel == wxWindow::FindFocus();
|
||||
#endif
|
||||
Window FocusWin;
|
||||
int Revert;
|
||||
XGetInputFocus(GCdisplay, &FocusWin, &Revert);
|
||||
XWindowAttributes WinAttribs;
|
||||
XGetWindowAttributes (GCdisplay, GLWin, &WinAttribs);
|
||||
return (GLWin != 0 && (GLWin == FocusWin || WinAttribs.override_redirect));
|
||||
return (GLWin == FocusWin || bFocus);
|
||||
#else
|
||||
return true;
|
||||
#endif
|
||||
|
@ -177,8 +179,10 @@ void PAD_GetStatus(u8 _numPAD, SPADStatus* _pPADStatus)
|
|||
|
||||
// if we want background input or have focus
|
||||
if ( g_plugin.controllers[_numPAD]->options[0].settings[0]->value || IsFocus() )
|
||||
{
|
||||
// get input
|
||||
((GCPad*)g_plugin.controllers[ _numPAD ])->GetInput( _pPADStatus );
|
||||
}
|
||||
else
|
||||
{
|
||||
// center sticks
|
||||
|
@ -252,10 +256,20 @@ void GetDllInfo(PLUGIN_INFO* _pPluginInfo)
|
|||
void DllConfig(HWND _hParent)
|
||||
{
|
||||
bool was_init = false;
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
Display *dpy = NULL;
|
||||
#endif
|
||||
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
|
||||
dpy = XOpenDisplay(0);
|
||||
InitPlugin(dpy);
|
||||
#else
|
||||
InitPlugin(_hParent);
|
||||
#endif
|
||||
}
|
||||
|
||||
// copied from GCPad
|
||||
#if defined(HAVE_WX) && HAVE_WX
|
||||
|
@ -282,8 +296,13 @@ void DllConfig(HWND _hParent)
|
|||
#endif
|
||||
// /
|
||||
|
||||
if ( false == was_init ) // hack for showing dialog when game isnt running
|
||||
if ( !was_init ) // hack for showing dialog when game isnt running
|
||||
{
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
XCloseDisplay(dpy);
|
||||
#endif
|
||||
g_plugin.controller_interface.DeInit();
|
||||
}
|
||||
}
|
||||
|
||||
// ___________________________________________________________________________
|
||||
|
|
|
@ -9,26 +9,28 @@ padenv = env.Clone()
|
|||
files = [
|
||||
'Config.cpp',
|
||||
'ControllerEmu.cpp',
|
||||
'ControllerEmu/GCPad/GCPad.cpp',
|
||||
'ControllerEmu/GCPad/GCPad.cpp',
|
||||
'GCPadNew.cpp',
|
||||
'ControllerInterface/ControllerInterface.cpp',
|
||||
'IniFile.cpp',
|
||||
]
|
||||
'IniFile.cpp'
|
||||
]
|
||||
|
||||
if padenv['HAVE_SDL']:
|
||||
files += [ 'ControllerInterface/SDL/SDL.cpp' ]
|
||||
files += [ 'ControllerInterface/SDL/SDL.cpp' ]
|
||||
if sys.platform == 'linux2':
|
||||
files += [ 'ControllerInterface/Xlib/Xlib.cpp' ]
|
||||
|
||||
if padenv['HAVE_WX']:
|
||||
files += [
|
||||
'ConfigDiag.cpp',
|
||||
'ConfigDiagBitmaps.cpp',
|
||||
]
|
||||
files += [
|
||||
'ConfigDiag.cpp',
|
||||
'ConfigDiagBitmaps.cpp',
|
||||
]
|
||||
|
||||
padenv.Append(
|
||||
LIBS = [ 'inputcommon', 'common', ],
|
||||
LIBS = [ 'inputcommon', 'common' ],
|
||||
)
|
||||
|
||||
if sys.platform == 'darwin':
|
||||
padenv['FRAMEWORKS'] = ['CoreFoundation', 'System', 'Cocoa', ]
|
||||
padenv['FRAMEWORKS'] = ['CoreFoundation', 'System', 'Cocoa' ]
|
||||
|
||||
padenv.SharedLibrary(env['plugin_dir']+name, files)
|
||||
|
|
Loading…
Add table
Reference in a new issue