Merge pull request #3890 from leoetlino/evdev-hotplug

evdev: Add hotplug support
This commit is contained in:
Pierre Bourdon
2016-07-29 17:43:49 +02:00
committed by GitHub
18 changed files with 258 additions and 39 deletions

View File

@ -36,6 +36,7 @@ void Initialize(void* const hwnd)
}
g_controller_interface.Initialize(hwnd);
g_controller_interface.RegisterHotplugCallback(LoadConfig);
// Load the saved controller config
s_config.LoadConfig(true);

View File

@ -86,6 +86,7 @@ std::string GCKeyboard::GetName() const
void GCKeyboard::GetInput(KeyboardStatus* const kb)
{
auto lock = ControllerEmu::GetStateLock();
m_keys0x->GetState(&kb->key0x, keys0_bitmasks);
m_keys1x->GetState(&kb->key1x, keys1_bitmasks);
m_keys2x->GetState(&kb->key2x, keys2_bitmasks);

View File

@ -35,6 +35,7 @@ void Initialize(void* const hwnd)
}
g_controller_interface.Initialize(hwnd);
g_controller_interface.RegisterHotplugCallback(LoadConfig);
// Load the saved controller config
s_config.LoadConfig(true);

View File

@ -81,6 +81,8 @@ std::string GCPad::GetName() const
void GCPad::GetInput(GCPadStatus* const pad)
{
auto lock = ControllerEmu::GetStateLock();
ControlState x, y, triggers[2];
// buttons
@ -116,6 +118,7 @@ void GCPad::GetInput(GCPadStatus* const pad)
void GCPad::SetOutput(const ControlState strength)
{
auto lock = ControllerEmu::GetStateLock();
m_rumble->controls[0]->control_ref->State(strength);
}
@ -190,5 +193,6 @@ void GCPad::LoadDefaults(const ControllerInterface& ciface)
bool GCPad::GetMicButton() const
{
auto lock = ControllerEmu::GetStateLock();
return (0.0f != m_buttons->controls.back()->control_ref->State());
}

View File

@ -37,6 +37,7 @@ void Initialize(void* const hwnd, InitializeMode init_mode)
}
g_controller_interface.Initialize(hwnd);
g_controller_interface.RegisterHotplugCallback(LoadConfig);
s_config.LoadConfig(false);

View File

@ -623,8 +623,11 @@ void Wiimote::Update()
return;
// returns true if a report was sent
if (Step())
return;
{
auto lock = ControllerEmu::GetStateLock();
if (Step())
return;
}
u8 data[MAX_PAYLOAD];
memset(data, 0, sizeof(data));
@ -646,6 +649,8 @@ void Wiimote::Update()
data[0] = 0xA1;
data[1] = m_reporting_mode;
auto lock = ControllerEmu::GetStateLock();
// core buttons
if (rptf.core)
GetButtonData(data + rptf.core);
@ -876,6 +881,7 @@ void Wiimote::ConnectOnInput()
}
u16 buttons = 0;
auto lock = ControllerEmu::GetStateLock();
m_buttons->GetState(&buttons, button_bitmasks);
m_dpad->GetState(&buttons, dpad_bitmasks);

View File

@ -186,6 +186,7 @@ void Initialize(void* const hwnd)
s_config.CreateController<HotkeyManager>();
g_controller_interface.Initialize(hwnd);
g_controller_interface.RegisterHotplugCallback(LoadConfig);
// load the saved controller config
s_config.LoadConfig(true);
@ -239,6 +240,7 @@ std::string HotkeyManager::GetName() const
void HotkeyManager::GetInput(HotkeyStatus* const kb)
{
auto lock = ControllerEmu::GetStateLock();
for (int set = 0; set < (NUM_HOTKEYS + 31) / 32; set++)
{
std::vector<u32> bitmasks;