Merge pull request #1893 from skidau/GCKeyboard
Added GameCube Keyboard support.
This commit is contained in:
@@ -25,6 +25,7 @@
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Movie.h"
|
||||
#include "Core/NetPlayProto.h"
|
||||
#include "Core/HW/GCKeyboard.h"
|
||||
#include "Core/HW/GCPad.h"
|
||||
#include "Core/HW/SI.h"
|
||||
#if defined(__LIBUSB__) || defined (_WIN32)
|
||||
@@ -39,13 +40,14 @@
|
||||
#include "DolphinWX/X11Utils.h"
|
||||
#endif
|
||||
|
||||
const std::array<wxString, 7> ControllerConfigDiag::m_gc_pad_type_strs = {{
|
||||
const std::array<wxString, 8> ControllerConfigDiag::m_gc_pad_type_strs = {{
|
||||
_("None"),
|
||||
_("Standard Controller"),
|
||||
_("Steering Wheel"),
|
||||
_("Dance Mat"),
|
||||
_("TaruKonga (Bongos)"),
|
||||
_("GBA"),
|
||||
_("Keyboard"),
|
||||
_("AM-Baseboard")
|
||||
}};
|
||||
|
||||
@@ -123,9 +125,12 @@ wxStaticBoxSizer* ControllerConfigDiag::CreateGamecubeSizer()
|
||||
pad_type_choices[i]->SetStringSelection(m_gc_pad_type_strs[5]);
|
||||
gamecube_configure_bt[i]->Disable();
|
||||
break;
|
||||
case SIDEVICE_AM_BASEBOARD:
|
||||
case SIDEVICE_GC_KEYBOARD:
|
||||
pad_type_choices[i]->SetStringSelection(m_gc_pad_type_strs[6]);
|
||||
break;
|
||||
case SIDEVICE_AM_BASEBOARD:
|
||||
pad_type_choices[i]->SetStringSelection(m_gc_pad_type_strs[7]);
|
||||
break;
|
||||
default:
|
||||
pad_type_choices[i]->SetStringSelection(m_gc_pad_type_strs[0]);
|
||||
gamecube_configure_bt[i]->Disable();
|
||||
@@ -514,6 +519,11 @@ void ControllerConfigDiag::OnGameCubePortChanged(wxCommandEvent& event)
|
||||
gamecube_configure_bt[device_num]->Disable();
|
||||
}
|
||||
else if (device_name == m_gc_pad_type_strs[6])
|
||||
{
|
||||
tempType = SIDEVICE_GC_KEYBOARD;
|
||||
gamecube_configure_bt[device_num]->Enable();
|
||||
}
|
||||
else if (device_name == m_gc_pad_type_strs[7])
|
||||
{
|
||||
tempType = SIDEVICE_AM_BASEBOARD;
|
||||
gamecube_configure_bt[device_num]->Enable();
|
||||
@@ -533,6 +543,7 @@ void ControllerConfigDiag::OnGameCubePortChanged(wxCommandEvent& event)
|
||||
void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event)
|
||||
{
|
||||
InputConfig* const pad_plugin = Pad::GetConfig();
|
||||
InputConfig* const key_plugin = Keyboard::GetConfig();
|
||||
const int port_num = m_gc_port_config_ids[event.GetId()];
|
||||
|
||||
bool was_init = false;
|
||||
@@ -547,16 +558,30 @@ void ControllerConfigDiag::OnGameCubeConfigButton(wxCommandEvent& event)
|
||||
#if defined(HAVE_X11) && HAVE_X11
|
||||
Window win = X11Utils::XWindowFromHandle(GetHandle());
|
||||
Pad::Initialize(reinterpret_cast<void*>(win));
|
||||
Keyboard::Initialize(reinterpret_cast<void*>(win));
|
||||
#else
|
||||
Pad::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||
Keyboard::Initialize(reinterpret_cast<void*>(GetHandle()));
|
||||
#endif
|
||||
}
|
||||
|
||||
InputConfigDialog m_ConfigFrame(this, *pad_plugin, _("Dolphin GCPad Configuration"), port_num);
|
||||
m_ConfigFrame.ShowModal();
|
||||
m_ConfigFrame.Destroy();
|
||||
if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_GC_KEYBOARD)
|
||||
{
|
||||
InputConfigDialog m_ConfigFrame(this, *key_plugin, _("GameCube Controller Configuration"), port_num);
|
||||
m_ConfigFrame.ShowModal();
|
||||
m_ConfigFrame.Destroy();
|
||||
}
|
||||
else
|
||||
{
|
||||
InputConfigDialog m_ConfigFrame(this, *pad_plugin, _("GameCube Controller Configuration"), port_num);
|
||||
m_ConfigFrame.ShowModal();
|
||||
m_ConfigFrame.Destroy();
|
||||
}
|
||||
|
||||
// if game isn't running
|
||||
if (!was_init)
|
||||
{
|
||||
Keyboard::Shutdown();
|
||||
Pad::Shutdown();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -83,7 +83,7 @@ private:
|
||||
|
||||
std::map<wxWindowID, unsigned int> m_gc_port_choice_ids;
|
||||
std::map<wxWindowID, unsigned int> m_gc_port_config_ids;
|
||||
static const std::array<wxString, 7> m_gc_pad_type_strs;
|
||||
static const std::array<wxString, 8> m_gc_pad_type_strs;
|
||||
|
||||
std::map<wxWindowID, unsigned int> m_wiimote_index_from_ctrl_id;
|
||||
unsigned int m_orig_wiimote_sources[MAX_BBMOTES];
|
||||
|
||||
@@ -836,7 +836,11 @@ ControlGroupBox::ControlGroupBox(ControllerEmu::ControlGroup* const group, wxWin
|
||||
break;
|
||||
case GROUP_TYPE_BUTTONS:
|
||||
{
|
||||
wxBitmap bitmap(int(12*group->controls.size()+1), 12);
|
||||
// Draw buttons in rows of 8
|
||||
unsigned int button_cols = group->controls.size() > 8 ? 8 : group->controls.size();
|
||||
unsigned int button_rows = ceil((float)group->controls.size() / 8.0f);
|
||||
wxBitmap bitmap(int(12 * button_cols + 1), (12 * button_rows) - (button_rows - 1));
|
||||
|
||||
dc.SelectObject(bitmap);
|
||||
dc.Clear();
|
||||
static_bitmap = new wxStaticBitmap(parent, wxID_ANY, bitmap, wxDefaultPosition, wxDefaultSize, wxBITMAP_TYPE_BMP);
|
||||
@@ -1055,14 +1059,11 @@ InputConfigDialog::InputConfigDialog(wxWindow* const parent, InputConfig& config
|
||||
, m_config(config)
|
||||
{
|
||||
m_pad_notebook = new wxNotebook(this, wxID_ANY, wxDefaultPosition, wxDefaultSize, wxNB_DEFAULT);
|
||||
for (unsigned int i = 0; i < std::min(config.controllers.size(), (size_t)MAX_WIIMOTES); ++i)
|
||||
{
|
||||
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_config, i, this);
|
||||
m_padpages.push_back(gp);
|
||||
m_pad_notebook->AddPage(gp, wxString::Format("%s %u", wxGetTranslation(StrToWxStr(m_config.gui_name)), 1+i));
|
||||
}
|
||||
GamepadPage* gp = new GamepadPage(m_pad_notebook, m_config, tab_num, this);
|
||||
m_padpages.push_back(gp);
|
||||
m_pad_notebook->AddPage(gp, wxString::Format("%s [%u]", wxGetTranslation(StrToWxStr(m_config.gui_name)), 1 + tab_num));
|
||||
|
||||
m_pad_notebook->SetSelection(tab_num);
|
||||
m_pad_notebook->SetSelection(0);
|
||||
|
||||
UpdateDeviceComboBox();
|
||||
UpdateProfileComboBox();
|
||||
|
||||
@@ -108,6 +108,25 @@ static void DrawCoordinate(wxDC &dc, ControlState x, ControlState y)
|
||||
DrawCenteredRectangle(dc, xc, yc, COORD_VIS_SIZE, COORD_VIS_SIZE);
|
||||
}
|
||||
|
||||
void DrawButton(unsigned int* const bitmasks, unsigned int buttons, unsigned int n, wxDC& dc, ControlGroupBox* g, unsigned int row)
|
||||
{
|
||||
if (buttons & bitmasks[(row * 8) + n])
|
||||
{
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char amt = 255 - g->control_group->controls[(row * 8) + n]->control_ref->State() * 128;
|
||||
dc.SetBrush(wxBrush(wxColour(amt, amt, amt)));
|
||||
}
|
||||
dc.DrawRectangle(n * 12, (row == 0) ? 0 : (row * 12 - 1), 14, 12);
|
||||
|
||||
// text
|
||||
const std::string name = g->control_group->controls[(row * 8) + n]->name;
|
||||
// bit of hax so ZL, ZR show up as L, R
|
||||
dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n * 12 + 2, 1 + ((row == 0) ? 0 : (row * 12 - 1)));
|
||||
}
|
||||
|
||||
static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
{
|
||||
switch (g->control_group->type)
|
||||
@@ -295,35 +314,29 @@ static void DrawControlGroupBox(wxDC &dc, ControlGroupBox *g)
|
||||
break;
|
||||
case GROUP_TYPE_BUTTONS :
|
||||
{
|
||||
const unsigned int button_count = ((unsigned int)g->control_group->controls.size());
|
||||
unsigned int button_count = ((unsigned int)g->control_group->controls.size());
|
||||
|
||||
// draw the shit
|
||||
dc.SetPen(*wxGREY_PEN);
|
||||
|
||||
unsigned int * const bitmasks = new unsigned int[ button_count ];
|
||||
unsigned int* const bitmasks = new unsigned int[button_count];
|
||||
for (unsigned int n = 0; n<button_count; ++n)
|
||||
bitmasks[n] = (1 << n);
|
||||
|
||||
unsigned int buttons = 0;
|
||||
((ControllerEmu::Buttons*)g->control_group)->GetState(&buttons, bitmasks);
|
||||
|
||||
for (unsigned int n = 0; n<button_count; ++n)
|
||||
// Draw buttons in rows of 8
|
||||
for (unsigned int row = 0; row < ceil((float)button_count / 8.0f); row++)
|
||||
{
|
||||
if (buttons & bitmasks[n])
|
||||
{
|
||||
dc.SetBrush(*wxRED_BRUSH);
|
||||
}
|
||||
else
|
||||
{
|
||||
unsigned char amt = 255 - g->control_group->controls[n]->control_ref->State() * 128;
|
||||
dc.SetBrush(wxBrush(wxColour(amt, amt, amt)));
|
||||
}
|
||||
dc.DrawRectangle(n * 12, 0, 14, 12);
|
||||
unsigned int buttons_to_draw = 8;
|
||||
if ((button_count - row * 8) <= 8)
|
||||
buttons_to_draw = button_count - row * 8;
|
||||
|
||||
// text
|
||||
const std::string name = g->control_group->controls[n]->name;
|
||||
// bit of hax so ZL, ZR show up as L, R
|
||||
dc.DrawText(StrToWxStr(std::string(1, (name[1] && name[1] < 'a') ? name[1] : name[0])), n*12 + 2, 1);
|
||||
for (unsigned int n = 0; n < buttons_to_draw; ++n)
|
||||
{
|
||||
DrawButton(bitmasks, buttons, n, dc, g, row);
|
||||
}
|
||||
}
|
||||
|
||||
delete[] bitmasks;
|
||||
|
||||
Reference in New Issue
Block a user