summaryrefslogtreecommitdiff
path: root/Source/Core
diff options
context:
space:
mode:
authorskidau <skidau@gmail.com>2015-01-17 09:36:05 +1100
committerskidau <skidau@gmail.com>2015-01-17 09:36:05 +1100
commit5e8ab05cc01d430fc0e4ccbf379369effd00485c (patch)
tree6d3eb8ab8f850017b6e919da51c2dc8c8d7ed37e /Source/Core
parent9d9ffa5b8321b371edd40547232852ff81d309bd (diff)
Added GameCube Keyboard support.
Diffstat (limited to 'Source/Core')
-rw-r--r--Source/Core/Core/CMakeLists.txt3
-rw-r--r--Source/Core/Core/Core.cpp18
-rw-r--r--Source/Core/Core/Core.vcxproj6
-rw-r--r--Source/Core/Core/Core.vcxproj.filters21
-rw-r--r--Source/Core/Core/HW/GCKeyboard.cpp71
-rw-r--r--Source/Core/Core/HW/GCKeyboard.h21
-rw-r--r--Source/Core/Core/HW/GCKeyboardEmu.cpp448
-rw-r--r--Source/Core/Core/HW/GCKeyboardEmu.h32
-rw-r--r--Source/Core/Core/HW/GCPad.cpp1
-rw-r--r--Source/Core/Core/HW/SI_Device.cpp6
-rw-r--r--Source/Core/Core/HW/SI_DeviceGCController.cpp1
-rw-r--r--Source/Core/Core/HW/SI_DeviceGCController.h1
-rw-r--r--Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp5
-rw-r--r--Source/Core/Core/HW/SI_DeviceGCSteeringWheel.h2
-rw-r--r--Source/Core/Core/HW/SI_DeviceKeyboard.cpp191
-rw-r--r--Source/Core/Core/HW/SI_DeviceKeyboard.h66
-rw-r--r--Source/Core/DolphinWX/ControllerConfigDiag.cpp35
-rw-r--r--Source/Core/DolphinWX/ControllerConfigDiag.h2
-rw-r--r--Source/Core/DolphinWX/InputConfigDiag.cpp11
-rw-r--r--Source/Core/InputCommon/KeyboardStatus.h198
20 files changed, 1117 insertions, 22 deletions
diff --git a/Source/Core/Core/CMakeLists.txt b/Source/Core/Core/CMakeLists.txt
index 7cbf4509f6..15a8b0e48d 100644
--- a/Source/Core/Core/CMakeLists.txt
+++ b/Source/Core/Core/CMakeLists.txt
@@ -97,6 +97,8 @@ set(SRCS ActionReplay.cpp
HW/EXI_DeviceIPL.cpp
HW/EXI_DeviceMemoryCard.cpp
HW/EXI_DeviceMic.cpp
+ HW/GCKeyboard.cpp
+ HW/GCKeyboardEmu.cpp
HW/GCMemcard.cpp
HW/GCMemcardDirectory.cpp
HW/GCMemcardRaw.cpp
@@ -116,6 +118,7 @@ set(SRCS ActionReplay.cpp
HW/SI_DeviceGBA.cpp
HW/SI_DeviceGCController.cpp
HW/SI_DeviceGCSteeringWheel.cpp
+ HW/SI_DeviceKeyboard.cpp
HW/Sram.cpp
HW/StreamADPCM.cpp
HW/SystemTimers.cpp
diff --git a/Source/Core/Core/Core.cpp b/Source/Core/Core/Core.cpp
index 4756659b36..9d5c2db2b2 100644
--- a/Source/Core/Core/Core.cpp
+++ b/Source/Core/Core/Core.cpp
@@ -39,6 +39,7 @@
#include "Core/HW/CPU.h"
#include "Core/HW/DSP.h"
#include "Core/HW/EXI.h"
+#include "Core/HW/GCKeyboard.h"
#include "Core/HW/GCPad.h"
#include "Core/HW/GPFifo.h"
#include "Core/HW/HW.h"
@@ -360,7 +361,14 @@ void EmuThread()
return;
}
- Pad::Initialize(s_window_handle);
+ for (unsigned int port_num = 0; port_num < 4; port_num++)
+ {
+ if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_GC_KEYBOARD)
+ Keyboard::Initialize(s_window_handle);
+ else
+ Pad::Initialize(s_window_handle);
+ }
+
// Load and Init Wiimotes - only if we are booting in Wii mode
if (core_parameter.bWii)
{
@@ -475,7 +483,13 @@ void EmuThread()
INFO_LOG(CONSOLE, "%s", StopMessage(false, "Shutting down HW").c_str());
HW::Shutdown();
INFO_LOG(CONSOLE, "%s", StopMessage(false, "HW shutdown").c_str());
- Pad::Shutdown();
+ for (unsigned int port_num = 0; port_num < 4; port_num++)
+ {
+ if (SConfig::GetInstance().m_SIDevice[port_num] == SIDEVICE_GC_KEYBOARD)
+ Keyboard::Shutdown();
+ else
+ Pad::Shutdown();
+ }
Wiimote::Shutdown();
g_video_backend->Shutdown();
AudioCommon::ShutdownSoundStream();
diff --git a/Source/Core/Core/Core.vcxproj b/Source/Core/Core/Core.vcxproj
index ae775bcc5a..bf34fbabbe 100644
--- a/Source/Core/Core/Core.vcxproj
+++ b/Source/Core/Core/Core.vcxproj
@@ -128,6 +128,8 @@
<ClCompile Include="HW\EXI_DeviceIPL.cpp" />
<ClCompile Include="HW\EXI_DeviceMemoryCard.cpp" />
<ClCompile Include="HW\EXI_DeviceMic.cpp" />
+ <ClCompile Include="HW\GCKeyboard.cpp" />
+ <ClCompile Include="HW\GCKeyboardEmu.cpp" />
<ClCompile Include="HW\GCMemcard.cpp" />
<ClCompile Include="HW\GCMemcardDirectory.cpp" />
<ClCompile Include="HW\GCMemcardRaw.cpp" />
@@ -147,6 +149,7 @@
<ClCompile Include="HW\SI_DeviceGBA.cpp" />
<ClCompile Include="HW\SI_DeviceGCController.cpp" />
<ClCompile Include="HW\SI_DeviceGCSteeringWheel.cpp" />
+ <ClCompile Include="HW\SI_DeviceKeyboard.cpp" />
<ClCompile Include="HW\SI_GCAdapter.cpp">
<!--
Disable "nonstandard extension used : zero-sized array in struct/union" warning,
@@ -333,6 +336,8 @@
<ClInclude Include="HW\EXI_DeviceIPL.h" />
<ClInclude Include="HW\EXI_DeviceMemoryCard.h" />
<ClInclude Include="HW\EXI_DeviceMic.h" />
+ <ClInclude Include="HW\GCKeyboard.h" />
+ <ClInclude Include="HW\GCKeyboardEmu.h" />
<ClInclude Include="HW\GCMemcard.h" />
<ClInclude Include="HW\GCMemcardDirectory.h" />
<ClInclude Include="HW\GCMemcardRaw.h" />
@@ -352,6 +357,7 @@
<ClInclude Include="HW\SI_DeviceGBA.h" />
<ClInclude Include="HW\SI_DeviceGCController.h" />
<ClInclude Include="HW\SI_DeviceGCSteeringWheel.h" />
+ <ClInclude Include="HW\SI_DeviceKeyboard.h" />
<ClInclude Include="HW\SI_GCAdapter.h" />
<ClInclude Include="HW\Sram.h" />
<ClInclude Include="HW\StreamADPCM.h" />
diff --git a/Source/Core/Core/Core.vcxproj.filters b/Source/Core/Core/Core.vcxproj.filters
index 4ddaee9aa4..6f1d44f1f6 100644
--- a/Source/Core/Core/Core.vcxproj.filters
+++ b/Source/Core/Core/Core.vcxproj.filters
@@ -82,6 +82,9 @@
<Filter Include="HW %28Flipper/Hollywood%29\EXI - Expansion Interface">
<UniqueIdentifier>{d19f1218-0e28-4f24-a4b3-33fac750a899}</UniqueIdentifier>
</Filter>
+ <Filter Include="HW %28Flipper/Hollywood%29\GCKeyboard">
+ <UniqueIdentifier>{15452851-6ca5-4520-bbf1-d4b810317be3}</UniqueIdentifier>
+ </Filter>
<Filter Include="HW %28Flipper/Hollywood%29\GCMemcard">
<UniqueIdentifier>{d7b3050d-3dd9-4284-969c-c5ad3b3662d9}</UniqueIdentifier>
</Filter>
@@ -406,6 +409,12 @@
<ClCompile Include="HW\Sram.cpp">
<Filter>HW %28Flipper/Hollywood%29\EXI - Expansion Interface</Filter>
</ClCompile>
+ <ClCompile Include="HW\GCKeyboard.cpp">
+ <Filter>HW %28Flipper/Hollywood%29\GCPad</Filter>
+ </ClCompile>
+ <ClCompile Include="HW\GCKeyboardEmu.cpp">
+ <Filter>HW %28Flipper/Hollywood%29\GCPad</Filter>
+ </ClCompile>
<ClCompile Include="HW\GCMemcard.cpp">
<Filter>HW %28Flipper/Hollywood%29\GCMemcard</Filter>
</ClCompile>
@@ -451,6 +460,9 @@
<ClCompile Include="HW\SI_DeviceGCSteeringWheel.cpp">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClCompile>
+ <ClCompile Include="HW\SI_DeviceKeyboard.cpp">
+ <Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
+ </ClCompile>
<ClCompile Include="HW\VideoInterface.cpp">
<Filter>HW %28Flipper/Hollywood%29\VI - Video Interface</Filter>
</ClCompile>
@@ -925,6 +937,12 @@
<ClInclude Include="HW\Sram.h">
<Filter>HW %28Flipper/Hollywood%29\EXI - Expansion Interface</Filter>
</ClInclude>
+ <ClInclude Include="HW\GCKeyboard.h">
+ <Filter>HW %28Flipper/Hollywood%29\GCPad</Filter>
+ </ClInclude>
+ <ClInclude Include="HW\GCKeyboardEmu.h">
+ <Filter>HW %28Flipper/Hollywood%29\GCPad</Filter>
+ </ClInclude>
<ClInclude Include="HW\GCMemcard.h">
<Filter>HW %28Flipper/Hollywood%29\GCMemcard</Filter>
</ClInclude>
@@ -970,6 +988,9 @@
<ClInclude Include="HW\SI_DeviceGCSteeringWheel.h">
<Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
</ClInclude>
+ <ClInclude Include="HW\SI_DeviceKeyboard.h">
+ <Filter>HW %28Flipper/Hollywood%29\SI - Serial Interface</Filter>
+ </ClInclude>
<ClInclude Include="HW\VideoInterface.h">
<Filter>HW %28Flipper/Hollywood%29\VI - Video Interface</Filter>
</ClInclude>
diff --git a/Source/Core/Core/HW/GCKeyboard.cpp b/Source/Core/Core/HW/GCKeyboard.cpp
new file mode 100644
index 0000000000..df08522887
--- /dev/null
+++ b/Source/Core/Core/HW/GCKeyboard.cpp
@@ -0,0 +1,71 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "Common/CommonTypes.h"
+
+#include "Core/ConfigManager.h"
+#include "Core/HW/GCKeyboard.h"
+#include "Core/HW/GCKeyboardEmu.h"
+#include "InputCommon/InputConfig.h"
+#include "InputCommon/KeyboardStatus.h"
+#include "InputCommon/ControllerInterface/ControllerInterface.h"
+
+namespace Keyboard
+{
+
+static InputConfig s_config("GCKeyNew", _trans("Keyboard"), "GCKey");
+InputConfig* GetConfig()
+{
+ return &s_config;
+}
+
+void Shutdown()
+{
+ std::vector<ControllerEmu*>::const_iterator
+ i = s_config.controllers.begin(),
+ e = s_config.controllers.end();
+ for ( ; i!=e; ++i )
+ delete *i;
+ s_config.controllers.clear();
+
+ g_controller_interface.Shutdown();
+}
+
+// if plugin isn't initialized, init and load config
+void Initialize(void* const hwnd)
+{
+ for (unsigned int i=0; i<4; ++i)
+ s_config.controllers.push_back(new GCKeyboard(i));
+
+ g_controller_interface.Initialize(hwnd);
+
+ // load the saved controller config
+ s_config.LoadConfig(true);
+}
+
+void GetStatus(u8 _port, KeyboardStatus* _pKeyboardStatus)
+{
+ memset(_pKeyboardStatus, 0, sizeof(*_pKeyboardStatus));
+ _pKeyboardStatus->err = PAD_ERR_NONE;
+
+ std::unique_lock<std::recursive_mutex> lk(s_config.controls_lock, std::try_to_lock);
+
+ if (!lk.owns_lock())
+ {
+ // if gui has lock (messing with controls), skip this input cycle
+ // center axes and return
+ _pKeyboardStatus->key0x = 0;
+ _pKeyboardStatus->key1x = 0;
+ _pKeyboardStatus->key2x = 0;
+ _pKeyboardStatus->key3x = 0;
+ _pKeyboardStatus->key4x = 0;
+ _pKeyboardStatus->key5x = 0;
+ return;
+ }
+
+ // get input
+ ((GCKeyboard*)s_config.controllers[_port])->GetInput(_pKeyboardStatus);
+}
+
+}
diff --git a/Source/Core/Core/HW/GCKeyboard.h b/Source/Core/Core/HW/GCKeyboard.h
new file mode 100644
index 0000000000..407b822db1
--- /dev/null
+++ b/Source/Core/Core/HW/GCKeyboard.h
@@ -0,0 +1,21 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "Common/CommonTypes.h"
+#include "InputCommon/InputConfig.h"
+#include "InputCommon/KeyboardStatus.h"
+
+#pragma once
+
+namespace Keyboard
+{
+
+void Shutdown();
+void Initialize(void* const hwnd);
+
+InputConfig* GetConfig();
+
+void GetStatus(u8 _port, KeyboardStatus* _pKeyboardStatus);
+
+}
diff --git a/Source/Core/Core/HW/GCKeyboardEmu.cpp b/Source/Core/Core/HW/GCKeyboardEmu.cpp
new file mode 100644
index 0000000000..91b0c9ebf8
--- /dev/null
+++ b/Source/Core/Core/HW/GCKeyboardEmu.cpp
@@ -0,0 +1,448 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "Core/Host.h"
+#include "Core/HW/GCKeyboardEmu.h"
+
+static const u16 keys0_bitmasks[] =
+{
+ KEYMASK_HOME,
+ KEYMASK_END,
+ KEYMASK_PGUP,
+ KEYMASK_PGDN,
+ KEYMASK_SCROLLLOCK,
+ KEYMASK_A,
+ KEYMASK_B,
+ KEYMASK_C,
+ KEYMASK_D,
+ KEYMASK_E,
+ KEYMASK_F,
+ KEYMASK_G,
+ KEYMASK_H,
+ KEYMASK_I,
+ KEYMASK_J,
+ KEYMASK_K
+};
+static const u16 keys1_bitmasks[] =
+{
+ KEYMASK_L,
+ KEYMASK_M,
+ KEYMASK_N,
+ KEYMASK_O,
+ KEYMASK_P,
+ KEYMASK_Q,
+ KEYMASK_R,
+ KEYMASK_S,
+ KEYMASK_T,
+ KEYMASK_U,
+ KEYMASK_V,
+ KEYMASK_W,
+ KEYMASK_X,
+ KEYMASK_Y,
+ KEYMASK_Z,
+ KEYMASK_1
+};
+static const u16 keys2_bitmasks[] =
+{
+ KEYMASK_2,
+ KEYMASK_3,
+ KEYMASK_4,
+ KEYMASK_5,
+ KEYMASK_6,
+ KEYMASK_7,
+ KEYMASK_8,
+ KEYMASK_9,
+ KEYMASK_0,
+ KEYMASK_MINUS,
+ KEYMASK_PLUS,
+ KEYMASK_PRINTSCR,
+ KEYMASK_BRACE_OPEN,
+ KEYMASK_BRACE_CLOSE,
+ KEYMASK_COLON,
+ KEYMASK_QUOTE
+};
+static const u16 keys3_bitmasks[] =
+{
+ KEYMASK_HASH,
+ KEYMASK_COMMA,
+ KEYMASK_PERIOD,
+ KEYMASK_QUESTIONMARK,
+ KEYMASK_INTERNATIONAL1,
+ KEYMASK_F1,
+ KEYMASK_F2,
+ KEYMASK_F3,
+ KEYMASK_F4,
+ KEYMASK_F5,
+ KEYMASK_F6,
+ KEYMASK_F7,
+ KEYMASK_F8,
+ KEYMASK_F9,
+ KEYMASK_F10,
+ KEYMASK_F11
+};
+static const u16 keys4_bitmasks[] =
+{
+ KEYMASK_F12,
+ KEYMASK_ESC,
+ KEYMASK_INSERT,
+ KEYMASK_DELETE,
+ KEYMASK_TILDE,
+ KEYMASK_BACKSPACE,
+ KEYMASK_TAB,
+ KEYMASK_CAPSLOCK,
+ KEYMASK_LEFTSHIFT,
+ KEYMASK_RIGHTSHIFT,
+ KEYMASK_LEFTCONTROL,
+ KEYMASK_RIGHTALT,
+ KEYMASK_LEFTWINDOWS,
+ KEYMASK_SPACE,
+ KEYMASK_RIGHTWINDOWS,
+ KEYMASK_MENU
+};
+static const u16 keys5_bitmasks[] =
+{
+ KEYMASK_LEFTARROW,
+ KEYMASK_DOWNARROW,
+ KEYMASK_UPARROW,
+ KEYMASK_RIGHTARROW,
+ KEYMASK_ENTER
+};
+
+static const char* const named_keys0[] =
+{
+ "HOME",
+ "END",
+ "PGUP",
+ "PGDN",
+ "SCR LK",
+ "A",
+ "B",
+ "C",
+ "D",
+ "E",
+ "F",
+ "G",
+ "H",
+ "I",
+ "J",
+ "K"
+};
+static const char* const named_keys1[] =
+{
+ "L",
+ "M",
+ "N",
+ "O",
+ "P",
+ "Q",
+ "R",
+ "S",
+ "T",
+ "U",
+ "V",
+ "W",
+ "X",
+ "Y",
+ "Z",
+ "1"
+};
+static const char* const named_keys2[] =
+{
+ "2",
+ "3",
+ "4",
+ "5",
+ "6",
+ "7",
+ "8",
+ "9",
+ "0",
+ "-",
+ "`",
+ "PRT SC",
+ "'",
+ "[",
+ "=",
+ "*"
+};
+static const char* const named_keys3[] =
+{
+ "]",
+ ",",
+ ".",
+ "/",
+ "\\",
+ "F1",
+ "F2",
+ "F3",
+ "F4",
+ "F5",
+ "F6",
+ "F7",
+ "F8",
+ "F9",
+ "F10",
+ "F11"
+};
+static const char* const named_keys4[] =
+{
+ "F12",
+ "ESC",
+ "INSERT",
+ "DELETE",
+ ";",
+ "BACKSPACE",
+ "TAB",
+ "CAPS LOCK",
+ "L SHIFT",
+ "R SHIFT",
+ "L CTRL",
+ "R ALT",
+ "L WIN",
+ "SPACE",
+ "R WIN",
+ "MENU"
+};
+static const char* const named_keys5[] =
+{
+ "LEFT",
+ "DOWN",
+ "UP",
+ "RIGHT",
+ "ENTER"
+};
+
+GCKeyboard::GCKeyboard(const unsigned int index) : m_index(index)
+{
+ // buttons
+ groups.emplace_back(m_keys0x = new Buttons(_trans("Keys")));
+ for (unsigned int i = 0; i < sizeof(named_keys0) / sizeof(*named_keys0); ++i)
+ m_keys0x->controls.emplace_back(new ControlGroup::Input(named_keys0[i]));
+
+ groups.emplace_back(m_keys1x = new Buttons(_trans("Keys")));
+ for (unsigned int i = 0; i < sizeof(named_keys1) / sizeof(*named_keys1); ++i)
+ m_keys1x->controls.emplace_back(new ControlGroup::Input(named_keys1[i]));
+
+ groups.emplace_back(m_keys2x = new Buttons(_trans("Keys")));
+ for (unsigned int i = 0; i < sizeof(named_keys2) / sizeof(*named_keys2); ++i)
+ m_keys2x->controls.emplace_back(new ControlGroup::Input(named_keys2[i]));
+
+ groups.emplace_back(m_keys3x = new Buttons(_trans("Keys")));
+ for (unsigned int i = 0; i < sizeof(named_keys3) / sizeof(*named_keys3); ++i)
+ m_keys3x->controls.emplace_back(new ControlGroup::Input(named_keys3[i]));
+
+ groups.emplace_back(m_keys4x = new Buttons(_trans("Keys")));
+ for (unsigned int i = 0; i < sizeof(named_keys4) / sizeof(*named_keys4); ++i)
+ m_keys4x->controls.emplace_back(new ControlGroup::Input(named_keys4[i]));
+
+ groups.emplace_back(m_keys5x = new Buttons(_trans("Keys")));
+ for (unsigned int i = 0; i < sizeof(named_keys5) / sizeof(*named_keys5); ++i)
+ m_keys5x->controls.emplace_back(new ControlGroup::Input(named_keys5[i]));
+
+
+ // options
+ groups.emplace_back(m_options = new ControlGroup(_trans("Options")));
+ m_options->settings.emplace_back(new ControlGroup::BackgroundInputSetting(_trans("Background Input")));
+ m_options->settings.emplace_back(new ControlGroup::IterateUI(_trans("Iterative Input")));
+}
+
+std::string GCKeyboard::GetName() const
+{
+ return std::string("GCKeyboard") + char('1'+m_index);
+}
+
+void GCKeyboard::GetInput(KeyboardStatus* const kb)
+{
+ m_keys0x->GetState(&kb->key0x, keys0_bitmasks);
+ m_keys1x->GetState(&kb->key1x, keys1_bitmasks);
+ m_keys2x->GetState(&kb->key2x, keys2_bitmasks);
+ m_keys3x->GetState(&kb->key3x, keys3_bitmasks);
+ m_keys4x->GetState(&kb->key4x, keys4_bitmasks);
+ m_keys5x->GetState(&kb->key5x, keys5_bitmasks);
+}
+
+void GCKeyboard::LoadDefaults(const ControllerInterface& ciface)
+{
+ #define set_control(group, num, str) (group)->controls[num]->control_ref->expression = (str)
+
+ ControllerEmu::LoadDefaults(ciface);
+
+ // Buttons
+ set_control(m_keys0x, 5, "A");
+ set_control(m_keys0x, 6, "B");
+ set_control(m_keys0x, 7, "C");
+ set_control(m_keys0x, 8, "D");
+ set_control(m_keys0x, 9, "E");
+ set_control(m_keys0x, 10, "F");
+ set_control(m_keys0x, 11, "G");
+ set_control(m_keys0x, 12, "H");
+ set_control(m_keys0x, 13, "I");
+ set_control(m_keys0x, 14, "J");
+ set_control(m_keys0x, 15, "K");
+ set_control(m_keys1x, 0, "L");
+ set_control(m_keys1x, 1, "M");
+ set_control(m_keys1x, 2, "N");
+ set_control(m_keys1x, 3, "O");
+ set_control(m_keys1x, 4, "P");
+ set_control(m_keys1x, 5, "Q");
+ set_control(m_keys1x, 6, "R");
+ set_control(m_keys1x, 7, "S");
+ set_control(m_keys1x, 8, "T");
+ set_control(m_keys1x, 9, "U");
+ set_control(m_keys1x, 10, "V");
+ set_control(m_keys1x, 11, "W");
+ set_control(m_keys1x, 12, "X");
+ set_control(m_keys1x, 13, "Y");
+ set_control(m_keys1x, 14, "Z");
+
+ set_control(m_keys1x, 15, "1");
+ set_control(m_keys2x, 0, "2");
+ set_control(m_keys2x, 1, "3");
+ set_control(m_keys2x, 2, "4");
+ set_control(m_keys2x, 3, "5");
+ set_control(m_keys2x, 4, "6");
+ set_control(m_keys2x, 5, "7");
+ set_control(m_keys2x, 6, "8");
+ set_control(m_keys2x, 7, "9");
+ set_control(m_keys2x, 8, "0");
+
+ set_control(m_keys3x, 5, "F1");
+ set_control(m_keys3x, 6, "F2");
+ set_control(m_keys3x, 7, "F3");
+ set_control(m_keys3x, 8, "F4");
+ set_control(m_keys3x, 9, "F5");
+ set_control(m_keys3x, 10, "F6");
+ set_control(m_keys3x, 11, "F7");
+ set_control(m_keys3x, 12, "F8");
+ set_control(m_keys3x, 13, "F9");
+ set_control(m_keys3x, 14, "F10");
+ set_control(m_keys3x, 15, "F11");
+ set_control(m_keys4x, 0, "F12");
+
+#ifdef _WIN32
+ set_control(m_keys0x, 0, "HOME");
+ set_control(m_keys0x, 1, "END");
+ set_control(m_keys0x, 2, "PRIOR");
+ set_control(m_keys0x, 3, "NEXT");
+ set_control(m_keys0x, 4, "SCROLL");
+
+ set_control(m_keys2x, 9, "MINUS");
+ set_control(m_keys2x, 10, "GRAVE");
+ set_control(m_keys2x, 11, "SYSRQ");
+ set_control(m_keys2x, 12, "APOSTROPHE");
+ set_control(m_keys2x, 13, "LBRACKET");
+ set_control(m_keys2x, 14, "EQUALS");
+ set_control(m_keys2x, 15, "MULTIPLY");
+ set_control(m_keys3x, 0, "RBRACKET");
+ set_control(m_keys3x, 1, "COMMA");
+ set_control(m_keys3x, 2, "PERIOD");
+ set_control(m_keys3x, 3, "SLASH");
+ set_control(m_keys3x, 4, "BACKSLASH");
+
+ set_control(m_keys4x, 1, "ESCAPE");
+ set_control(m_keys4x, 2, "INSERT");
+ set_control(m_keys4x, 3, "DELETE");
+ set_control(m_keys4x, 4, "SEMICOLON");
+ set_control(m_keys4x, 5, "BACK");
+ set_control(m_keys4x, 6, "TAB");
+ set_control(m_keys4x, 7, "CAPITAL");
+ set_control(m_keys4x, 8, "LSHIFT");
+ set_control(m_keys4x, 9, "RSHIFT");
+ set_control(m_keys4x, 10, "LCONTROL");
+ set_control(m_keys4x, 11, "RMENU");
+ set_control(m_keys4x, 12, "LWIN");
+ set_control(m_keys4x, 13, "SPACE");
+ set_control(m_keys4x, 14, "RWIN");
+ set_control(m_keys4x, 15, "MENU");
+
+ set_control(m_keys5x, 0, "LEFT");
+ set_control(m_keys5x, 1, "DOWN");
+ set_control(m_keys5x, 2, "UP");
+ set_control(m_keys5x, 3, "RIGHT");
+ set_control(m_keys5x, 4, "RETURN");
+#elif __APPLE__
+ set_control(m_keys0x, 0, "Home");
+ set_control(m_keys0x, 1, "End");
+ set_control(m_keys0x, 2, "Page Up");
+ set_control(m_keys0x, 3, "Page Down");
+ set_control(m_keys0x, 4, ""); // Scroll lock
+
+ set_control(m_keys2x, 9, "-");
+ set_control(m_keys2x, 10, "Paragraph");
+ set_control(m_keys2x, 11, ""); // Print Scr
+ set_control(m_keys2x, 12, "'");
+ set_control(m_keys2x, 13, "[");
+ set_control(m_keys2x, 14, "=");
+ set_control(m_keys2x, 15, "Keypad *");
+ set_control(m_keys3x, 0, "]");
+ set_control(m_keys3x, 1, ",");
+ set_control(m_keys3x, 2, ".");
+ set_control(m_keys3x, 3, "/");
+ set_control(m_keys3x, 4, "\");
+
+ set_control(m_keys4x, 1, "Escape");
+ set_control(m_keys4x, 2, "Insert");
+ set_control(m_keys4x, 3, "Delete");
+ set_control(m_keys4x, 4, ";");
+ set_control(m_keys4x, 5, "Backspace");
+ set_control(m_keys4x, 6, "Tab");
+ set_control(m_keys4x, 7, "Caps Lock");
+ set_control(m_keys4x, 8, "Left Shift");
+ set_control(m_keys4x, 9, "Right Shift");
+ set_control(m_keys4x, 10, "Left Control");
+ set_control(m_keys4x, 11, "Right Alt");
+ set_control(m_keys4x, 12, "Left Command");
+ set_control(m_keys4x, 13, "Space");
+ set_control(m_keys4x, 14, "Right Command");
+ set_control(m_keys4x, 15, ""); // Menu
+
+ set_control(m_keys5x, 0, "Left Arrow");
+ set_control(m_keys5x, 1, "Down Arrow");
+ set_control(m_keys5x, 2, "Up Arrow");
+ set_control(m_keys5x, 3, "Right Arrow");
+ set_control(m_keys5x, 4, "Return");
+#else // linux
+ set_control(m_keys0x, 0, "Home");
+ set_control(m_keys0x, 1, "End");
+ set_control(m_keys0x, 2, "Prior");
+ set_control(m_keys0x, 3, "Next");
+ set_control(m_keys0x, 4, "Scroll_Lock");
+
+ set_control(m_keys2x, 9, "minus");
+ set_control(m_keys2x, 10, "grave");
+ set_control(m_keys2x, 11, "Print");
+ set_control(m_keys2x, 12, "apostrophe");
+ set_control(m_keys2x, 13, "bracketleft");
+ set_control(m_keys2x, 14, "equal");
+ set_control(m_keys2x, 15, "KP_Multiply");
+ set_control(m_keys3x, 0, "bracketright");
+ set_control(m_keys3x, 1, "comma");
+ set_control(m_keys3x, 2, "period");
+ set_control(m_keys3x, 3, "slash");
+ set_control(m_keys3x, 4, "backslash");
+
+ set_control(m_keys4x, 1, "Escape");
+ set_control(m_keys4x, 2, "Insert");
+ set_control(m_keys4x, 3, "Delete");
+ set_control(m_keys4x, 4, "semicolon");
+ set_control(m_keys4x, 5, "BackSpace");
+ set_control(m_keys4x, 6, "Tab");
+ set_control(m_keys4x, 7, "Caps_Lock");
+ set_control(m_keys4x, 8, "Shift_L");
+ set_control(m_keys4x, 9, "Shift_R");
+ set_control(m_keys4x, 10, "Control_L");
+ set_control(m_keys4x, 11, "Alt_R");
+ set_control(m_keys4x, 12, "Super_L");
+ set_control(m_keys4x, 13, "space");
+ set_control(m_keys4x, 14, "Super_R");
+ set_control(m_keys4x, 15, "Menu");
+
+ set_control(m_keys5x, 0, "Left");
+ set_control(m_keys5x, 1, "Down");
+ set_control(m_keys5x, 2, "Up");
+ set_control(m_keys5x, 3, "Right");
+ set_control(m_keys5x, 4, "Return");
+#endif
+
+}
diff --git a/Source/Core/Core/HW/GCKeyboardEmu.h b/Source/Core/Core/HW/GCKeyboardEmu.h
new file mode 100644
index 0000000000..adbc14dd15
--- /dev/null
+++ b/Source/Core/Core/HW/GCKeyboardEmu.h
@@ -0,0 +1,32 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include <string>
+
+#include "InputCommon/ControllerEmu.h"
+#include "InputCommon/KeyboardStatus.h"
+
+class GCKeyboard : public ControllerEmu
+{
+public:
+
+ GCKeyboard(const unsigned int index);
+ void GetInput(KeyboardStatus* const pad);
+ std::string GetName() const override;
+ void LoadDefaults(const ControllerInterface& ciface) override;
+
+private:
+
+ Buttons* m_keys0x;
+ Buttons* m_keys1x;
+ Buttons* m_keys2x;
+ Buttons* m_keys3x;
+ Buttons* m_keys4x;
+ Buttons* m_keys5x;
+ ControlGroup* m_options;
+
+ const unsigned int m_index;
+};
diff --git a/Source/Core/Core/HW/GCPad.cpp b/Source/Core/Core/HW/GCPad.cpp
index 1c61e3dd7f..7b3802d268 100644
--- a/Source/Core/Core/HW/GCPad.cpp
+++ b/Source/Core/Core/HW/GCPad.cpp
@@ -11,7 +11,6 @@
#include "InputCommon/InputConfig.h"
#include "InputCommon/ControllerInterface/ControllerInterface.h"
-
namespace Pad
{
diff --git a/Source/Core/Core/HW/SI_Device.cpp b/Source/Core/Core/HW/SI_Device.cpp
index 42747686a6..cdc80574d5 100644
--- a/Source/Core/Core/HW/SI_Device.cpp
+++ b/Source/Core/Core/HW/SI_Device.cpp
@@ -11,7 +11,7 @@
#include "Core/HW/SI_DeviceGBA.h"
#include "Core/HW/SI_DeviceGCController.h"
#include "Core/HW/SI_DeviceGCSteeringWheel.h"
-
+#include "Core/HW/SI_DeviceKeyboard.h"
// --- interface ISIDevice ---
int ISIDevice::RunBuffer(u8* _pBuffer, int _iLength)
@@ -84,6 +84,10 @@ ISIDevice* SIDevice_Create(const SIDevices device, const int port_number)
return new CSIDevice_GBA(device, port_number);
break;
+ case SIDEVICE_GC_KEYBOARD:
+ return new CSIDevice_Keyboard(device, port_number);
+ break;
+
case SIDEVICE_AM_BASEBOARD:
return new CSIDevice_AMBaseboard(device, port_number);
break;
diff --git a/Source/Core/Core/HW/SI_DeviceGCController.cpp b/Source/Core/Core/HW/SI_DeviceGCController.cpp
index ffb911b06f..a05e54148f 100644
--- a/Source/Core/Core/HW/SI_DeviceGCController.cpp
+++ b/Source/Core/Core/HW/SI_DeviceGCController.cpp
@@ -67,6 +67,7 @@ int CSIDevice_GCController::RunBuffer(u8* _pBuffer, int _iLength)
switch (command)
{
case CMD_RESET:
+ case CMD_ID:
*(u32*)&_pBuffer[0] = SI_GC_CONTROLLER;
break;
diff --git a/Source/Core/Core/HW/SI_DeviceGCController.h b/Source/Core/Core/HW/SI_DeviceGCController.h
index 3b0346cbeb..9b44c2cfe5 100644
--- a/Source/Core/Core/HW/SI_DeviceGCController.h
+++ b/Source/Core/Core/HW/SI_DeviceGCController.h
@@ -18,6 +18,7 @@ protected:
CMD_DIRECT = 0x40,
CMD_ORIGIN = 0x41,
CMD_RECALIBRATE = 0x42,
+ CMD_ID = 0xff,
};
struct SOrigin
diff --git a/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp b/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp
index e0d43b2b0a..0f55b1f1c1 100644
--- a/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp
+++ b/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.cpp
@@ -21,13 +21,10 @@ int CSIDevice_GCSteeringWheel::RunBuffer(u8* _pBuffer, int _iLength)
switch (command)
{
case CMD_RESET:
+ case CMD_ID:
*(u32*)&_pBuffer[0] = SI_GC_STEERING;
break;
- // Seen in F-Zero GX
- case CMD_MOTOR_OFF:
- break;
-
// DEFAULT
default:
{
diff --git a/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.h b/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.h
index 791e30aca9..c53ffd3f94 100644
--- a/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.h
+++ b/Source/Core/Core/HW/SI_DeviceGCSteeringWheel.h
@@ -15,7 +15,7 @@ private:
CMD_RESET = 0x00,
CMD_ORIGIN = 0x41,
CMD_RECALIBRATE = 0x42,
- CMD_MOTOR_OFF = 0xff,
+ CMD_ID = 0xff,
};
enum EDirectCommands
diff --git a/Source/Core/Core/HW/SI_DeviceKeyboard.cpp b/Source/Core/Core/HW/SI_DeviceKeyboard.cpp
new file mode 100644
index 0000000000..bd1ba902ba
--- /dev/null
+++ b/Source/Core/Core/HW/SI_DeviceKeyboard.cpp
@@ -0,0 +1,191 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#include "Core/HW/GCKeyboard.h"
+#include "Core/HW/SI_DeviceKeyboard.h"
+
+// --- GameCube keyboard ---
+CSIDevice_Keyboard::CSIDevice_Keyboard(SIDevices device, int _iDeviceNumber)
+ : ISIDevice(device, _iDeviceNumber)
+{}
+
+int CSIDevice_Keyboard::RunBuffer(u8* _pBuffer, int _iLength)
+{
+ // For debug logging only
+ ISIDevice::RunBuffer(_pBuffer, _iLength);
+
+ // Read the command
+ EBufferCommands command = static_cast<EBufferCommands>(_pBuffer[3]);
+
+ // Handle it
+ switch (command)
+ {
+ case CMD_RESET:
+ case CMD_ID:
+ *(u32*)&_pBuffer[0] = SI_GC_KEYBOARD;
+ break;
+
+ case CMD_DIRECT:
+ {
+ INFO_LOG(SERIALINTERFACE, "Keyboard - Direct (Length: %d)", _iLength);
+ u32 high, low;
+ GetData(high, low);
+ for (int i = 0; i < (_iLength - 1) / 2; i++)
+ {
+ _pBuffer[i + 0] = (high >> (i * 8)) & 0xff;
+ _pBuffer[i + 4] = (low >> (i * 8)) & 0xff;
+ }
+ }
+ break;
+
+ default:
+ {
+ ERROR_LOG(SERIALINTERFACE, "Unknown SI command (0x%x)", command);
+ }
+ break;
+ }
+
+ return _iLength;
+}
+
+KeyboardStatus CSIDevice_Keyboard::GetKeyboardStatus()
+{
+ KeyboardStatus KeyStatus;
+ memset(&KeyStatus, 0, sizeof(KeyStatus));
+ Keyboard::GetStatus(ISIDevice::m_iDeviceNumber, &KeyStatus);
+ return KeyStatus;
+}
+
+bool CSIDevice_Keyboard::GetData(u32& _Hi, u32& _Low)
+{
+ KeyboardStatus KeyStatus = GetKeyboardStatus();
+ u8 key[3] = { 0x00, 0x00, 0x00 };
+ MapKeys(KeyStatus, key);
+ u8 checksum = key[0] ^ key[1] ^ key[2] ^ m_Counter;
+
+ _Hi = m_Counter << 24;
+ _Low = key[0] << 24 | key[1] << 16 | key[2] << 8 | checksum;
+
+ return true;
+}
+
+void CSIDevice_Keyboard::SendCommand(u32 _Cmd, u8 _Poll)
+{
+ UCommand command(_Cmd);
+
+ switch (command.Command)
+ {
+ case 0x00:
+ break;
+
+ case CMD_POLL:
+ {
+ m_Counter++;
+ m_Counter &= 15;
+ }
+ break;
+ default:
+ {
+ ERROR_LOG(SERIALINTERFACE, "Unknown direct command (0x%x)", _Cmd);
+ }
+ break;
+ }
+}
+
+void CSIDevice_Keyboard::DoState(PointerWrap& p)
+{
+ p.Do(m_Counter);
+}
+
+void CSIDevice_Keyboard::MapKeys(KeyboardStatus& KeyStatus, u8* key)
+{
+ u8 keys_held = 0;
+ const u8 MAX_KEYS_HELD = 3;
+
+ if (KeyStatus.key0x & KEYMASK_HOME) { key[keys_held++] = KEY_HOME; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_END) { key[keys_held++] = KEY_END; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_PGUP) { key[keys_held++] = KEY_PGUP; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_PGDN) { key[keys_held++] = KEY_PGDN; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_SCROLLLOCK) { key[keys_held++] = KEY_SCROLLLOCK; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_A) { key[keys_held++] = KEY_A; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_B) { key[keys_held++] = KEY_B; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_C) { key[keys_held++] = KEY_C; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_D) { key[keys_held++] = KEY_D; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_E) { key[keys_held++] = KEY_E; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_F) { key[keys_held++] = KEY_F; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_G) { key[keys_held++] = KEY_G; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_H) { key[keys_held++] = KEY_H; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_I) { key[keys_held++] = KEY_I; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_J) { key[keys_held++] = KEY_J; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key0x & KEYMASK_K) { key[keys_held++] = KEY_K; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_L) { key[keys_held++] = KEY_L; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_M) { key[keys_held++] = KEY_M; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_N) { key[keys_held++] = KEY_N; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_O) { key[keys_held++] = KEY_O; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_P) { key[keys_held++] = KEY_P; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_Q) { key[keys_held++] = KEY_Q; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_R) { key[keys_held++] = KEY_R; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_S) { key[keys_held++] = KEY_S; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_T) { key[keys_held++] = KEY_T; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_U) { key[keys_held++] = KEY_U; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_V) { key[keys_held++] = KEY_V; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_W) { key[keys_held++] = KEY_W; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_X) { key[keys_held++] = KEY_X; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_Y) { key[keys_held++] = KEY_Y; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_Z) { key[keys_held++] = KEY_Z; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key1x & KEYMASK_1) { key[keys_held++] = KEY_1; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_2) { key[keys_held++] = KEY_2; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_3) { key[keys_held++] = KEY_3; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_4) { key[keys_held++] = KEY_4; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_5) { key[keys_held++] = KEY_5; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_6) { key[keys_held++] = KEY_6; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_7) { key[keys_held++] = KEY_7; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_8) { key[keys_held++] = KEY_8; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_9) { key[keys_held++] = KEY_9; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_0) { key[keys_held++] = KEY_0; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_MINUS) { key[keys_held++] = KEY_MINUS; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_PLUS) { key[keys_held++] = KEY_PLUS; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_PRINTSCR) { key[keys_held++] = KEY_PRINTSCR; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_BRACE_OPEN) { key[keys_held++] = KEY_BRACE_OPEN; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_BRACE_CLOSE) { key[keys_held++] = KEY_BRACE_CLOSE; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_COLON) { key[keys_held++] = KEY_COLON; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key2x & KEYMASK_QUOTE) { key[keys_held++] = KEY_QUOTE; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_HASH) { key[keys_held++] = KEY_HASH; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_COMMA) { key[keys_held++] = KEY_COMMA; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_PERIOD) { key[keys_held++] = KEY_PERIOD; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_QUESTIONMARK) { key[keys_held++] = KEY_QUESTIONMARK; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_INTERNATIONAL1) { key[keys_held++] = KEY_INTERNATIONAL1; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F1) { key[keys_held++] = KEY_F1; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F2) { key[keys_held++] = KEY_F2; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F3) { key[keys_held++] = KEY_F3; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F4) { key[keys_held++] = KEY_F4; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F5) { key[keys_held++] = KEY_F5; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F6) { key[keys_held++] = KEY_F6; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F7) { key[keys_held++] = KEY_F7; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F8) { key[keys_held++] = KEY_F8; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F9) { key[keys_held++] = KEY_F9; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F10) { key[keys_held++] = KEY_F10; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key3x & KEYMASK_F11) { key[keys_held++] = KEY_F11; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_F12) { key[keys_held++] = KEY_F12; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_ESC) { key[keys_held++] = KEY_ESC; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_INSERT) { key[keys_held++] = KEY_INSERT; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_DELETE) { key[keys_held++] = KEY_DELETE; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_TILDE) { key[keys_held++] = KEY_TILDE; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_BACKSPACE) { key[keys_held++] = KEY_BACKSPACE; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_TAB) { key[keys_held++] = KEY_TAB; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_CAPSLOCK) { key[keys_held++] = KEY_CAPSLOCK; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_LEFTSHIFT) { key[keys_held++] = KEY_LEFTSHIFT; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_RIGHTSHIFT) { key[keys_held++] = KEY_RIGHTSHIFT; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_LEFTCONTROL) { key[keys_held++] = KEY_LEFTCONTROL; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_RIGHTALT) { key[keys_held++] = KEY_RIGHTALT; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_LEFTWINDOWS) { key[keys_held++] = KEY_LEFTWINDOWS; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_SPACE) { key[keys_held++] = KEY_SPACE; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_RIGHTWINDOWS) { key[keys_held++] = KEY_RIGHTWINDOWS; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key4x & KEYMASK_MENU) { key[keys_held++] = KEY_MENU; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key5x & KEYMASK_LEFTARROW) { key[keys_held++] = KEY_LEFTARROW; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key5x & KEYMASK_DOWNARROW) { key[keys_held++] = KEY_DOWNARROW; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key5x & KEYMASK_UPARROW) { key[keys_held++] = KEY_UPARROW; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key5x & KEYMASK_RIGHTARROW) { key[keys_held++] = KEY_RIGHTARROW; if (keys_held >= MAX_KEYS_HELD) return; }
+ if (KeyStatus.key5x & KEYMASK_ENTER) { key[keys_held++] = KEY_ENTER; if (keys_held >= MAX_KEYS_HELD) return; }
+}
diff --git a/Source/Core/Core/HW/SI_DeviceKeyboard.h b/Source/Core/Core/HW/SI_DeviceKeyboard.h
new file mode 100644
index 0000000000..923a5a8603
--- /dev/null
+++ b/Source/Core/Core/HW/SI_DeviceKeyboard.h
@@ -0,0 +1,66 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include "InputCommon/KeyboardStatus.h"
+
+class CSIDevice_Keyboard : public ISIDevice
+{
+protected:
+
+ // Commands
+ enum EBufferCommands
+ {
+ CMD_RESET = 0x00,
+ CMD_DIRECT = 0x54,
+ CMD_ID = 0xff,
+ };
+
+ enum EDirectCommands
+ {
+ CMD_WRITE = 0x40,
+ CMD_POLL = 0x54
+ };
+
+ union UCommand
+ {
+ u32 Hex;
+ struct
+ {
+ u32 Parameter1 : 8;
+ u32 Parameter2 : 8;
+ u32 Command : 8;
+ u32 : 8;
+ };
+ UCommand() {Hex = 0;}
+ UCommand(u32 _iValue) {Hex = _iValue;}
+ };
+
+ // PADAnalogMode
+ u8 m_Mode;
+
+ // Internal counter synchonizing GC and keyboard
+ u8 m_Counter;
+
+public:
+
+ // Constructor
+ CSIDevice_Keyboard(SIDevices device, int _iDeviceNumber);
+
+ // Run the SI Buffer
+ virtual int RunBuffer(u8* _pBuffer, int _iLength) override;
+
+ // Return true on new data
+ virtual bool GetData(u32& _Hi, u32& _Low) override;
+
+ virtual KeyboardStatus GetKeyboardStatus();
+ virtual void MapKeys(KeyboardStatus& KeyStatus, u8* key);
+
+ // Send a command directly
+ virtual void SendCommand(u32 _Cmd, u8 _Poll) override;
+
+ // Savestate support
+ virtual void DoState(PointerWrap& p) override;
+};
diff --git a/Source/Core/DolphinWX/ControllerConfigDiag.cpp b/Source/Core/DolphinWX/ControllerConfigDiag.cpp
index 62ca00949e..af287365af 100644
--- a/Source/Core/DolphinWX/ControllerConfigDiag.cpp
+++ b/Source/Core/DolphinWX/ControllerConfigDiag.cpp
@@ -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();
@@ -515,6 +520,11 @@ void ControllerConfigDiag::OnGameCubePortChanged(wxCommandEvent& event)
}
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();
+ }
}
diff --git a/Source/Core/DolphinWX/ControllerConfigDiag.h b/Source/Core/DolphinWX/ControllerConfigDiag.h
index 73f424a118..6a226eb1e0 100644
--- a/Source/Core/DolphinWX/ControllerConfigDiag.h
+++ b/Source/Core/DolphinWX/ControllerConfigDiag.h
@@ -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];
diff --git a/Source/Core/DolphinWX/InputConfigDiag.cpp b/Source/Core/DolphinWX/InputConfigDiag.cpp
index ff1528dfa1..9a97e89127 100644
--- a/Source/Core/DolphinWX/InputConfigDiag.cpp
+++ b/Source/Core/DolphinWX/InputConfigDiag.cpp
@@ -1055,14 +1055,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();
diff --git a/Source/Core/InputCommon/KeyboardStatus.h b/Source/Core/InputCommon/KeyboardStatus.h
new file mode 100644
index 0000000000..71599dc871
--- /dev/null
+++ b/Source/Core/InputCommon/KeyboardStatus.h
@@ -0,0 +1,198 @@
+// Copyright 2013 Dolphin Emulator Project
+// Licensed under GPLv2
+// Refer to the license.txt file included.
+
+#pragma once
+
+#include "Common/CommonTypes.h"
+
+enum KeyMasks
+{
+ KEYMASK_HOME = (1 << 0),
+ KEYMASK_END = (1 << 1),
+ KEYMASK_PGUP = (1 << 2),
+ KEYMASK_PGDN = (1 << 3),
+ KEYMASK_SCROLLLOCK = (1 << 4),
+ KEYMASK_A = (1 << 5),
+ KEYMASK_B = (1 << 6),
+ KEYMASK_C = (1 << 7),
+ KEYMASK_D = (1 << 8),
+ KEYMASK_E = (1 << 9),
+ KEYMASK_F = (1 << 10),
+ KEYMASK_G = (1 << 11),
+ KEYMASK_H = (1 << 12),
+ KEYMASK_I = (1 << 13),
+ KEYMASK_J = (1 << 14),
+ KEYMASK_K = (1 << 15),
+ KEYMASK_L = (1 << 0),
+ KEYMASK_M = (1 << 1),
+ KEYMASK_N = (1 << 2),
+ KEYMASK_O = (1 << 3),
+ KEYMASK_P = (1 << 4),
+ KEYMASK_Q = (1 << 5),
+ KEYMASK_R = (1 << 6),
+ KEYMASK_S = (1 << 7),
+ KEYMASK_T = (1 << 8),
+ KEYMASK_U = (1 << 9),
+ KEYMASK_V = (1 << 10),
+ KEYMASK_W = (1 << 11),
+ KEYMASK_X = (1 << 12),
+ KEYMASK_Y = (1 << 13),
+ KEYMASK_Z = (1 << 14),
+ KEYMASK_1 = (1 << 15),
+ KEYMASK_2 = (1 << 0),
+ KEYMASK_3 = (1 << 1),
+ KEYMASK_4 = (1 << 2),
+ KEYMASK_5 = (1 << 3),
+ KEYMASK_6 = (1 << 4),
+ KEYMASK_7 = (1 << 5),
+ KEYMASK_8 = (1 << 6),
+ KEYMASK_9 = (1 << 7),
+ KEYMASK_0 = (1 << 8),
+ KEYMASK_MINUS = (1 << 9),
+ KEYMASK_PLUS = (1 << 10),
+ KEYMASK_PRINTSCR = (1 << 11),
+ KEYMASK_BRACE_OPEN = (1 << 12),
+ KEYMASK_BRACE_CLOSE = (1 << 13),
+ KEYMASK_COLON = (1 << 14),
+ KEYMASK_QUOTE = (1 << 15),
+ KEYMASK_HASH = (1 << 0),
+ KEYMASK_COMMA = (1 << 1),
+ KEYMASK_PERIOD = (1 << 2),
+ KEYMASK_QUESTIONMARK = (1 << 3),
+ KEYMASK_INTERNATIONAL1 = (1 << 4),
+ KEYMASK_F1 = (1 << 5),
+ KEYMASK_F2 = (1 << 6),
+ KEYMASK_F3 = (1 << 7),
+ KEYMASK_F4 = (1 << 8),
+ KEYMASK_F5 = (1 << 9),
+ KEYMASK_F6 = (1 << 10),
+ KEYMASK_F7 = (1 << 11),
+ KEYMASK_F8 = (1 << 12),
+ KEYMASK_F9 = (1 << 13),
+ KEYMASK_F10 = (1 << 14),
+ KEYMASK_F11 = (1 << 15),
+ KEYMASK_F12 = (1 << 0),
+ KEYMASK_ESC = (1 << 1),
+ KEYMASK_INSERT = (1 << 2),
+ KEYMASK_DELETE = (1 << 3),
+ KEYMASK_TILDE = (1 << 4),
+ KEYMASK_BACKSPACE = (1 << 5),
+ KEYMASK_TAB = (1 << 6),
+ KEYMASK_CAPSLOCK = (1 << 7),
+ KEYMASK_LEFTSHIFT = (1 << 8),
+ KEYMASK_RIGHTSHIFT = (1 << 9),
+ KEYMASK_LEFTCONTROL = (1 << 10),
+ KEYMASK_RIGHTALT = (1 << 11),
+ KEYMASK_LEFTWINDOWS = (1 << 12),
+ KEYMASK_SPACE = (1 << 13),
+ KEYMASK_RIGHTWINDOWS = (1 << 14),
+ KEYMASK_MENU = (1 << 15),
+ KEYMASK_LEFTARROW = (1 << 0),
+ KEYMASK_DOWNARROW = (1 << 1),
+ KEYMASK_UPARROW = (1 << 2),
+ KEYMASK_RIGHTARROW = (1 << 3),
+ KEYMASK_ENTER = (1 << 4),
+};
+
+enum KeyScanCode
+{
+ KEY_HOME = 0x06,
+ KEY_END = 0x07,
+ KEY_PGUP = 0x08,
+ KEY_PGDN = 0x09,
+ KEY_SCROLLLOCK = 0x0A,
+ KEY_A = 0x10,
+ KEY_B = 0x11,
+ KEY_C = 0x12,
+ KEY_D = 0x13,
+ KEY_E = 0x14,
+ KEY_F = 0x15,
+ KEY_G = 0x16,
+ KEY_H = 0x17,
+ KEY_I = 0x18,
+ KEY_J = 0x19,
+ KEY_K = 0x1A,
+ KEY_L = 0x1B,
+ KEY_M = 0x1C,
+ KEY_N = 0x1D,
+ KEY_O = 0x1E,
+ KEY_P = 0x1F,
+ KEY_Q = 0x20,
+ KEY_R = 0x21,
+ KEY_S = 0x22,
+ KEY_T = 0x23,
+ KEY_U = 0x24,
+ KEY_V = 0x25,
+ KEY_W = 0x26,
+ KEY_X = 0x27,
+ KEY_Y = 0x28,
+ KEY_Z = 0x29,
+ KEY_1 = 0x2A,
+ KEY_2 = 0x2B,
+ KEY_3 = 0x2C,
+ KEY_4 = 0x2D,
+ KEY_5 = 0x2E,
+ KEY_6 = 0x2F,
+ KEY_7 = 0x30,
+ KEY_8 = 0x31,
+ KEY_9 = 0x32,
+ KEY_0 = 0x33,
+ KEY_MINUS = 0x34,
+ KEY_PLUS = 0x35,
+ KEY_PRINTSCR = 0x36,
+ KEY_BRACE_OPEN = 0x37,
+ KEY_BRACE_CLOSE = 0x38,
+ KEY_COLON = 0x39,
+ KEY_QUOTE = 0x3A,
+ KEY_HASH = 0x3B,
+ KEY_COMMA = 0x3C,
+ KEY_PERIOD = 0x3D,
+ KEY_QUESTIONMARK = 0x3E,
+ KEY_INTERNATIONAL1 = 0x3F,
+ KEY_F1 = 0x40,
+ KEY_F2 = 0x41,
+ KEY_F3 = 0x42,
+ KEY_F4 = 0x43,
+ KEY_F5 = 0x44,
+ KEY_F6 = 0x45,
+ KEY_F7 = 0x46,
+ KEY_F8 = 0x47,
+ KEY_F9 = 0x48,
+ KEY_F10 = 0x49,
+ KEY_F11 = 0x4A,
+ KEY_F12 = 0x4B,
+ KEY_ESC = 0x4C,
+ KEY_INSERT = 0x4D,
+ KEY_DELETE = 0x4E,
+ KEY_TILDE = 0x4F,
+ KEY_BACKSPACE = 0x50,
+ KEY_TAB = 0x51,
+ KEY_CAPSLOCK = 0x53,
+ KEY_LEFTSHIFT = 0x54,
+ KEY_RIGHTSHIFT = 0x55,
+ KEY_LEFTCONTROL = 0x56,
+ KEY_RIGHTALT = 0x57,
+ KEY_LEFTWINDOWS = 0x58,
+ KEY_SPACE = 0x59,
+ KEY_RIGHTWINDOWS = 0x5A,
+ KEY_MENU = 0x5B,
+ KEY_LEFTARROW = 0x5C,
+ KEY_DOWNARROW = 0x5D,
+ KEY_UPARROW = 0x5E,
+ KEY_RIGHTARROW = 0x5F,
+ KEY_ENTER = 0x61
+
+};
+
+struct KeyboardStatus
+{
+ u16 key0x;
+ u16 key1x;
+ u16 key2x;
+ u16 key3x;
+ u16 key4x;
+ u16 key5x;
+ u16 key6x;
+ s8 err;
+};