mirror of https://github.com/RPCS3/rpcs3.git
Input: Fix filter button for evdev and DS4
This commit is contained in:
parent
c870bbb885
commit
c077426e95
|
@ -153,8 +153,22 @@ void ds4_pad_handler::GetNextButtonPress(const std::string& padId, const std::fu
|
||||||
blacklist.clear();
|
blacklist.clear();
|
||||||
|
|
||||||
std::shared_ptr<DS4Device> device = GetDevice(padId);
|
std::shared_ptr<DS4Device> device = GetDevice(padId);
|
||||||
|
if (device == nullptr || device->hidDevice == nullptr)
|
||||||
|
return;
|
||||||
|
|
||||||
if (CheckDeviceState(device) == false)
|
// Now that we have found a device, get its status
|
||||||
|
DS4DataStatus status = GetRawData(device);
|
||||||
|
|
||||||
|
if (status == DS4DataStatus::ReadError)
|
||||||
|
{
|
||||||
|
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
||||||
|
hid_close(device->hidDevice);
|
||||||
|
device->hidDevice = nullptr;
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
// return if nothing new has happened. ignore this to get the current state for blacklist
|
||||||
|
if (!get_blacklist && status != DS4DataStatus::NewData)
|
||||||
return;
|
return;
|
||||||
|
|
||||||
// Get the current button values
|
// Get the current button values
|
||||||
|
@ -241,28 +255,6 @@ std::shared_ptr<ds4_pad_handler::DS4Device> ds4_pad_handler::GetDevice(const std
|
||||||
return device;
|
return device;
|
||||||
}
|
}
|
||||||
|
|
||||||
bool ds4_pad_handler::CheckDeviceState(std::shared_ptr<DS4Device> device)
|
|
||||||
{
|
|
||||||
if (device == nullptr || device->hidDevice == nullptr)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
// Now that we have found a device, get its status
|
|
||||||
DS4DataStatus status = GetRawData(device);
|
|
||||||
|
|
||||||
if (status == DS4DataStatus::ReadError)
|
|
||||||
{
|
|
||||||
// this also can mean disconnected, either way deal with it on next loop and reconnect
|
|
||||||
hid_close(device->hidDevice);
|
|
||||||
device->hidDevice = nullptr;
|
|
||||||
return false;
|
|
||||||
}
|
|
||||||
|
|
||||||
if (status != DS4DataStatus::NewData)
|
|
||||||
return false;
|
|
||||||
|
|
||||||
return true;
|
|
||||||
}
|
|
||||||
|
|
||||||
void ds4_pad_handler::TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold)
|
void ds4_pad_handler::TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold)
|
||||||
{
|
{
|
||||||
// Update the pad button values based on their type and thresholds.
|
// Update the pad button values based on their type and thresholds.
|
||||||
|
|
|
@ -154,7 +154,6 @@ private:
|
||||||
|
|
||||||
private:
|
private:
|
||||||
std::shared_ptr<DS4Device> GetDevice(const std::string& padId);
|
std::shared_ptr<DS4Device> GetDevice(const std::string& padId);
|
||||||
bool CheckDeviceState(std::shared_ptr<DS4Device> device);
|
|
||||||
void TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold = false) override;
|
void TranslateButtonPress(u64 keyCode, bool& pressed, u16& val, bool ignore_threshold = false) override;
|
||||||
void ProcessDataToPad(const std::shared_ptr<DS4Device>& ds4Device, const std::shared_ptr<Pad>& pad);
|
void ProcessDataToPad(const std::shared_ptr<DS4Device>& ds4Device, const std::shared_ptr<Pad>& pad);
|
||||||
// Copies data into padData if status is NewData, otherwise buffer is untouched
|
// Copies data into padData if status is NewData, otherwise buffer is untouched
|
||||||
|
|
|
@ -221,12 +221,14 @@ void evdev_joystick_handler::GetNextButtonPress(const std::string& padId, const
|
||||||
// Add device if not yet present
|
// Add device if not yet present
|
||||||
m_pad_index = add_device(padId, true);
|
m_pad_index = add_device(padId, true);
|
||||||
|
|
||||||
if (m_pad_index < 0) return;
|
if (m_pad_index < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
EvdevDevice& device = devices[m_pad_index];
|
EvdevDevice& device = devices[m_pad_index];
|
||||||
|
|
||||||
// Check if our device is connected
|
// Check if our device is connected
|
||||||
if (!update_device(device, false)) return;
|
if (!update_device(device, false))
|
||||||
|
return;
|
||||||
|
|
||||||
auto& dev = device.device;
|
auto& dev = device.device;
|
||||||
|
|
||||||
|
@ -236,10 +238,11 @@ void evdev_joystick_handler::GetNextButtonPress(const std::string& padId, const
|
||||||
|
|
||||||
// Grab any pending sync event.
|
// Grab any pending sync event.
|
||||||
if (ret == LIBEVDEV_READ_STATUS_SYNC)
|
if (ret == LIBEVDEV_READ_STATUS_SYNC)
|
||||||
{
|
|
||||||
ret = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL | LIBEVDEV_READ_FLAG_SYNC, &evt);
|
ret = libevdev_next_event(dev, LIBEVDEV_READ_FLAG_NORMAL | LIBEVDEV_READ_FLAG_SYNC, &evt);
|
||||||
}
|
|
||||||
if (ret < 0) return;
|
// return if nothing new has happened. ignore this to get the current state for blacklist
|
||||||
|
if (!get_blacklist && ret < 0)
|
||||||
|
return;
|
||||||
|
|
||||||
auto data = GetButtonValues(dev);
|
auto data = GetButtonValues(dev);
|
||||||
|
|
||||||
|
|
Loading…
Reference in New Issue