Qt/Input: add disconnected label to the devicenames

This commit is contained in:
Megamouse 2018-12-22 17:48:42 +01:00
parent bdb5606317
commit 6dcf66b064
11 changed files with 119 additions and 53 deletions

View file

@ -74,14 +74,14 @@ void xinput_pad_handler::init_config(pad_config* cfg, const std::string& name)
cfg->from_default();
}
void xinput_pad_handler::GetNextButtonPress(const std::string& padId, const std::function<void(u16, std::string, int[])>& callback, const std::function<void()>& fail_callback, bool get_blacklist, std::vector<std::string> buttons)
void xinput_pad_handler::GetNextButtonPress(const std::string& padId, const std::function<void(u16, std::string, std::string, int[])>& callback, const std::function<void(std::string)>& fail_callback, bool get_blacklist, std::vector<std::string> buttons)
{
if (get_blacklist)
blacklist.clear();
int device_number = GetDeviceNumber(padId);
if (device_number < 0)
return fail_callback();
return fail_callback(padId);
DWORD dwResult;
XINPUT_STATE state;
@ -90,7 +90,7 @@ void xinput_pad_handler::GetNextButtonPress(const std::string& padId, const std:
// Simply get the state of the controller from XInput.
dwResult = (*xinputGetState)(static_cast<u32>(device_number), &state);
if (dwResult != ERROR_SUCCESS)
return fail_callback();
return fail_callback(padId);
// Check for each button in our list if its corresponding (maybe remapped) button or axis was pressed.
// Return the new value if the button was pressed (aka. its value was bigger than 0 or the defined threshold)
@ -131,9 +131,9 @@ void xinput_pad_handler::GetNextButtonPress(const std::string& padId, const std:
int preview_values[6] = { data[LT], data[RT], data[LSXPos] - data[LSXNeg], data[LSYPos] - data[LSYNeg], data[RSXPos] - data[RSXNeg], data[RSYPos] - data[RSYNeg] };
if (pressed_button.first > 0)
return callback(pressed_button.first, pressed_button.second, preview_values);
return callback(pressed_button.first, pressed_button.second, padId, preview_values);
else
return callback(0, "", preview_values);
return callback(0, "", padId, preview_values);
}
void xinput_pad_handler::TestVibration(const std::string& padId, u32 largeMotor, u32 smallMotor)