Merge pull request #7298 from spycrab/usb_keyboard_hotkey

Hotkeys: Add "Toggle USB Keyboard" hotkey
This commit is contained in:
spycrab 2018-08-07 07:47:20 +02:00 committed by GitHub
commit ddf09a0841
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
6 changed files with 33 additions and 5 deletions

View File

@ -20,7 +20,7 @@
#include "InputCommon/GCPadStatus.h" #include "InputCommon/GCPadStatus.h"
// clang-format off // clang-format off
constexpr std::array<const char*, 130> s_hotkey_labels{{ constexpr std::array<const char*, 131> s_hotkey_labels{{
_trans("Open"), _trans("Open"),
_trans("Change Disc"), _trans("Change Disc"),
_trans("Eject Disc"), _trans("Eject Disc"),
@ -68,6 +68,7 @@ constexpr std::array<const char*, 130> s_hotkey_labels{{
_trans("Connect Wii Remote 3"), _trans("Connect Wii Remote 3"),
_trans("Connect Wii Remote 4"), _trans("Connect Wii Remote 4"),
_trans("Connect Balance Board"), _trans("Connect Balance Board"),
_trans("Toggle USB Keyboard"),
_trans("Next Profile for Wii Remote 1"), _trans("Next Profile for Wii Remote 1"),
_trans("Previous Profile for Wii Remote 1"), _trans("Previous Profile for Wii Remote 1"),
@ -271,7 +272,7 @@ constexpr std::array<HotkeyGroupInfo, NUM_HOTKEY_GROUPS> s_groups_info = {
{_trans("Stepping"), HK_STEP, HK_SKIP}, {_trans("Stepping"), HK_STEP, HK_SKIP},
{_trans("Program Counter"), HK_SHOW_PC, HK_SET_PC}, {_trans("Program Counter"), HK_SHOW_PC, HK_SET_PC},
{_trans("Breakpoint"), HK_BP_TOGGLE, HK_MBP_ADD}, {_trans("Breakpoint"), HK_BP_TOGGLE, HK_MBP_ADD},
{_trans("Wii"), HK_TRIGGER_SYNC_BUTTON, HK_BALANCEBOARD_CONNECT}, {_trans("Wii"), HK_TRIGGER_SYNC_BUTTON, HK_TOGGLE_USB_KEYBOARD},
{_trans("Controller Profile"), HK_NEXT_WIIMOTE_PROFILE_1, HK_PREV_GAME_WIIMOTE_PROFILE_4}, {_trans("Controller Profile"), HK_NEXT_WIIMOTE_PROFILE_1, HK_PREV_GAME_WIIMOTE_PROFILE_4},
{_trans("Graphics Toggles"), HK_TOGGLE_CROP, HK_TOGGLE_TEXTURES}, {_trans("Graphics Toggles"), HK_TOGGLE_CROP, HK_TOGGLE_TEXTURES},
{_trans("Internal Resolution"), HK_INCREASE_IR, HK_DECREASE_IR}, {_trans("Internal Resolution"), HK_INCREASE_IR, HK_DECREASE_IR},

View File

@ -66,6 +66,7 @@ enum Hotkey
HK_WIIMOTE3_CONNECT, HK_WIIMOTE3_CONNECT,
HK_WIIMOTE4_CONNECT, HK_WIIMOTE4_CONNECT,
HK_BALANCEBOARD_CONNECT, HK_BALANCEBOARD_CONNECT,
HK_TOGGLE_USB_KEYBOARD,
HK_NEXT_WIIMOTE_PROFILE_1, HK_NEXT_WIIMOTE_PROFILE_1,
HK_PREV_WIIMOTE_PROFILE_1, HK_PREV_WIIMOTE_PROFILE_1,

View File

@ -238,6 +238,12 @@ void HotkeyScheduler::Run()
if (wiimote_id > -1) if (wiimote_id > -1)
emit ConnectWiiRemote(wiimote_id); emit ConnectWiiRemote(wiimote_id);
if (IsHotkey(HK_TOGGLE_USB_KEYBOARD))
{
Settings::Instance().SetUSBKeyboardConnected(
!Settings::Instance().IsUSBKeyboardConnected());
}
} }
if (IsHotkey(HK_PREV_WIIMOTE_PROFILE_1)) if (IsHotkey(HK_PREV_WIIMOTE_PROFILE_1))

View File

@ -520,3 +520,17 @@ void Settings::SetBatchModeEnabled(bool batch)
{ {
m_batch = batch; m_batch = batch;
} }
bool Settings::IsUSBKeyboardConnected() const
{
return SConfig::GetInstance().m_WiiKeyboard;
}
void Settings::SetUSBKeyboardConnected(bool connected)
{
if (IsUSBKeyboardConnected() != connected)
{
SConfig::GetInstance().m_WiiKeyboard = connected;
emit USBKeyboardConnectionChanged(connected);
}
}

View File

@ -87,6 +87,9 @@ public:
bool IsBatchModeEnabled() const; bool IsBatchModeEnabled() const;
void SetBatchModeEnabled(bool batch); void SetBatchModeEnabled(bool batch);
bool IsUSBKeyboardConnected() const;
void SetUSBKeyboardConnected(bool connected);
// Graphics // Graphics
void SetHideCursor(bool hide_cursor); void SetHideCursor(bool hide_cursor);
bool GetHideCursor() const; bool GetHideCursor() const;
@ -169,6 +172,7 @@ signals:
void AutoUpdateTrackChanged(const QString& mode); void AutoUpdateTrackChanged(const QString& mode);
void AnalyticsToggled(bool enabled); void AnalyticsToggled(bool enabled);
void DevicesChanged(); void DevicesChanged();
void USBKeyboardConnectionChanged(bool connected);
private: private:
bool m_batch = false; bool m_batch = false;

View File

@ -24,6 +24,7 @@
#include "Core/Core.h" #include "Core/Core.h"
#include "Core/IOS/IOS.h" #include "Core/IOS/IOS.h"
#include "DolphinQt/Settings.h"
#include "DolphinQt/Settings/USBDeviceAddToWhitelistDialog.h" #include "DolphinQt/Settings/USBDeviceAddToWhitelistDialog.h"
#include "UICommon/USBUtils.h" #include "UICommon/USBUtils.h"
@ -73,6 +74,8 @@ void WiiPane::ConnectLayout()
connect(m_pal60_mode_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig); connect(m_pal60_mode_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig);
connect(m_sd_card_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig); connect(m_sd_card_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig);
connect(m_connect_keyboard_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig); connect(m_connect_keyboard_checkbox, &QCheckBox::toggled, this, &WiiPane::OnSaveConfig);
connect(&Settings::Instance(), &Settings::USBKeyboardConnectionChanged,
m_connect_keyboard_checkbox, &QCheckBox::setChecked);
// Whitelisted USB Passthrough Devices // Whitelisted USB Passthrough Devices
connect(m_whitelist_usb_list, &QListWidget::itemClicked, this, &WiiPane::ValidateSelectionState); connect(m_whitelist_usb_list, &QListWidget::itemClicked, this, &WiiPane::ValidateSelectionState);
@ -190,7 +193,6 @@ void WiiPane::OnEmulationStateChanged(bool running)
m_screensaver_checkbox->setEnabled(!running); m_screensaver_checkbox->setEnabled(!running);
m_pal60_mode_checkbox->setEnabled(!running); m_pal60_mode_checkbox->setEnabled(!running);
m_sd_card_checkbox->setEnabled(!running); m_sd_card_checkbox->setEnabled(!running);
m_connect_keyboard_checkbox->setEnabled(!running);
m_system_language_choice->setEnabled(!running); m_system_language_choice->setEnabled(!running);
m_aspect_ratio_choice->setEnabled(!running); m_aspect_ratio_choice->setEnabled(!running);
m_wiimote_motor->setEnabled(!running); m_wiimote_motor->setEnabled(!running);
@ -203,7 +205,7 @@ void WiiPane::LoadConfig()
{ {
m_screensaver_checkbox->setChecked(Config::Get(Config::SYSCONF_SCREENSAVER)); m_screensaver_checkbox->setChecked(Config::Get(Config::SYSCONF_SCREENSAVER));
m_pal60_mode_checkbox->setChecked(Config::Get(Config::SYSCONF_PAL60)); m_pal60_mode_checkbox->setChecked(Config::Get(Config::SYSCONF_PAL60));
m_connect_keyboard_checkbox->setChecked(SConfig::GetInstance().m_WiiKeyboard); m_connect_keyboard_checkbox->setChecked(Settings::Instance().IsUSBKeyboardConnected());
m_sd_card_checkbox->setChecked(SConfig::GetInstance().m_WiiSDCard); m_sd_card_checkbox->setChecked(SConfig::GetInstance().m_WiiSDCard);
m_aspect_ratio_choice->setCurrentIndex(Config::Get(Config::SYSCONF_WIDESCREEN)); m_aspect_ratio_choice->setCurrentIndex(Config::Get(Config::SYSCONF_WIDESCREEN));
m_system_language_choice->setCurrentIndex(Config::Get(Config::SYSCONF_LANGUAGE)); m_system_language_choice->setCurrentIndex(Config::Get(Config::SYSCONF_LANGUAGE));
@ -221,7 +223,7 @@ void WiiPane::OnSaveConfig()
{ {
Config::SetBase(Config::SYSCONF_SCREENSAVER, m_screensaver_checkbox->isChecked()); Config::SetBase(Config::SYSCONF_SCREENSAVER, m_screensaver_checkbox->isChecked());
Config::SetBase(Config::SYSCONF_PAL60, m_pal60_mode_checkbox->isChecked()); Config::SetBase(Config::SYSCONF_PAL60, m_pal60_mode_checkbox->isChecked());
SConfig::GetInstance().m_WiiKeyboard = m_connect_keyboard_checkbox->isChecked(); Settings::Instance().SetUSBKeyboardConnected(m_connect_keyboard_checkbox->isChecked());
SConfig::GetInstance().m_WiiSDCard = m_sd_card_checkbox->isChecked(); SConfig::GetInstance().m_WiiSDCard = m_sd_card_checkbox->isChecked();
Config::SetBase<u32>(Config::SYSCONF_SENSOR_BAR_POSITION, Config::SetBase<u32>(Config::SYSCONF_SENSOR_BAR_POSITION,
TranslateSensorBarPosition(m_wiimote_ir_sensor_position->currentIndex())); TranslateSensorBarPosition(m_wiimote_ir_sensor_position->currentIndex()));