feat(input/linux): allow ds5 gamepads to have a fixed device mac based on controller index (#4158)
This commit is contained in:
parent
319319c2df
commit
cc6e853fba
6 changed files with 66 additions and 4 deletions
|
|
@ -1216,6 +1216,7 @@ namespace config {
|
|||
bool_f(vars, "ds4_back_as_touchpad_click", input.ds4_back_as_touchpad_click);
|
||||
bool_f(vars, "motion_as_ds4", input.motion_as_ds4);
|
||||
bool_f(vars, "touchpad_as_ds4", input.touchpad_as_ds4);
|
||||
bool_f(vars, "ds5_inputtino_randomize_mac", input.ds5_inputtino_randomize_mac);
|
||||
|
||||
bool_f(vars, "mouse", input.mouse);
|
||||
bool_f(vars, "keyboard", input.keyboard);
|
||||
|
|
|
|||
|
|
@ -193,6 +193,7 @@ namespace config {
|
|||
bool ds4_back_as_touchpad_click;
|
||||
bool motion_as_ds4;
|
||||
bool touchpad_as_ds4;
|
||||
bool ds5_inputtino_randomize_mac;
|
||||
|
||||
bool keyboard;
|
||||
bool mouse;
|
||||
|
|
|
|||
|
|
@ -42,8 +42,15 @@ namespace platf::gamepad {
|
|||
.version = 0x8111});
|
||||
}
|
||||
|
||||
auto create_ds5() {
|
||||
return inputtino::PS5Joypad::create({.name = "Sunshine PS5 (virtual) pad", .vendor_id = 0x054C, .product_id = 0x0CE6, .version = 0x8111});
|
||||
auto create_ds5(int globalIndex) {
|
||||
std::string device_mac = ""; // Inputtino checks empty() to generate a random MAC
|
||||
|
||||
if (!config::input.ds5_inputtino_randomize_mac && globalIndex >= 0 && globalIndex <= 255) {
|
||||
// Generate private virtual device MAC based on gamepad globalIndex between 0 (00) and 255 (ff)
|
||||
device_mac = std::format("02:00:00:00:00:{:02x}", globalIndex);
|
||||
}
|
||||
|
||||
return inputtino::PS5Joypad::create({.name = "Sunshine PS5 (virtual) pad", .vendor_id = 0x054C, .product_id = 0x0CE6, .version = 0x8111, .device_phys = device_mac, .device_uniq = device_mac});
|
||||
}
|
||||
|
||||
int alloc(input_raw_t *raw, const gamepad_id_t &id, const gamepad_arrival_t &metadata, feedback_queue_t feedback_queue) {
|
||||
|
|
@ -138,7 +145,7 @@ namespace platf::gamepad {
|
|||
}
|
||||
case DualSenseWired:
|
||||
{
|
||||
auto ds5 = create_ds5();
|
||||
auto ds5 = create_ds5(id.globalIndex);
|
||||
if (ds5) {
|
||||
(*ds5).set_on_rumble(on_rumble_fn);
|
||||
(*ds5).set_on_led([feedback_queue, idx = id.clientRelativeIndex, gamepad](int r, int g, int b) {
|
||||
|
|
@ -267,7 +274,7 @@ namespace platf::gamepad {
|
|||
return gps;
|
||||
}
|
||||
|
||||
auto ds5 = create_ds5();
|
||||
auto ds5 = create_ds5(-1); // Index -1 will result in a random MAC virtual device, which is fine for probing
|
||||
auto switchPro = create_switch();
|
||||
auto xOne = create_xbox_one();
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue