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
|
|
@ -416,6 +416,30 @@ editing the `conf` file in a text editor. Use the examples as reference.
|
||||||
</tr>
|
</tr>
|
||||||
</table>
|
</table>
|
||||||
|
|
||||||
|
### ds5_inputtino_randomize_mac
|
||||||
|
|
||||||
|
<table>
|
||||||
|
<tr>
|
||||||
|
<td>Description</td>
|
||||||
|
<td colspan="2">
|
||||||
|
Randomize the MAC-Address for the generated virtual controller.
|
||||||
|
@hint{Only applies on linux for gamepads created as PS5-style controllers}
|
||||||
|
</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Default</td>
|
||||||
|
<td colspan="2">@code{}
|
||||||
|
enabled
|
||||||
|
@endcode</td>
|
||||||
|
</tr>
|
||||||
|
<tr>
|
||||||
|
<td>Example</td>
|
||||||
|
<td colspan="2">@code{}
|
||||||
|
ds5_inputtino_randomize_mac = enabled
|
||||||
|
@endcode</td>
|
||||||
|
</tr>
|
||||||
|
</table>
|
||||||
|
|
||||||
### back_button_timeout
|
### back_button_timeout
|
||||||
|
|
||||||
<table>
|
<table>
|
||||||
|
|
|
||||||
|
|
@ -1216,6 +1216,7 @@ namespace config {
|
||||||
bool_f(vars, "ds4_back_as_touchpad_click", input.ds4_back_as_touchpad_click);
|
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, "motion_as_ds4", input.motion_as_ds4);
|
||||||
bool_f(vars, "touchpad_as_ds4", input.touchpad_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, "mouse", input.mouse);
|
||||||
bool_f(vars, "keyboard", input.keyboard);
|
bool_f(vars, "keyboard", input.keyboard);
|
||||||
|
|
|
||||||
|
|
@ -193,6 +193,7 @@ namespace config {
|
||||||
bool ds4_back_as_touchpad_click;
|
bool ds4_back_as_touchpad_click;
|
||||||
bool motion_as_ds4;
|
bool motion_as_ds4;
|
||||||
bool touchpad_as_ds4;
|
bool touchpad_as_ds4;
|
||||||
|
bool ds5_inputtino_randomize_mac;
|
||||||
|
|
||||||
bool keyboard;
|
bool keyboard;
|
||||||
bool mouse;
|
bool mouse;
|
||||||
|
|
|
||||||
|
|
@ -42,8 +42,15 @@ namespace platf::gamepad {
|
||||||
.version = 0x8111});
|
.version = 0x8111});
|
||||||
}
|
}
|
||||||
|
|
||||||
auto create_ds5() {
|
auto create_ds5(int globalIndex) {
|
||||||
return inputtino::PS5Joypad::create({.name = "Sunshine PS5 (virtual) pad", .vendor_id = 0x054C, .product_id = 0x0CE6, .version = 0x8111});
|
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) {
|
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:
|
case DualSenseWired:
|
||||||
{
|
{
|
||||||
auto ds5 = create_ds5();
|
auto ds5 = create_ds5(id.globalIndex);
|
||||||
if (ds5) {
|
if (ds5) {
|
||||||
(*ds5).set_on_rumble(on_rumble_fn);
|
(*ds5).set_on_rumble(on_rumble_fn);
|
||||||
(*ds5).set_on_led([feedback_queue, idx = id.clientRelativeIndex, gamepad](int r, int g, int b) {
|
(*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;
|
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 switchPro = create_switch();
|
||||||
auto xOne = create_xbox_one();
|
auto xOne = create_xbox_one();
|
||||||
|
|
||||||
|
|
|
||||||
|
|
@ -89,6 +89,32 @@ const config = ref(props.config)
|
||||||
</div>
|
</div>
|
||||||
</div>
|
</div>
|
||||||
</template>
|
</template>
|
||||||
|
<template v-if="config.gamepad === 'ds5' || (config.gamepad === 'auto' && platform === 'linux')">
|
||||||
|
<div class="mb-3 accordion">
|
||||||
|
<div class="accordion-item">
|
||||||
|
<h2 class="accordion-header">
|
||||||
|
<button class="accordion-button" type="button" data-bs-toggle="collapse"
|
||||||
|
data-bs-target="#panelsStayOpen-collapseOne">
|
||||||
|
{{ $t(config.gamepad === 'ds5' ? 'config.gamepad_ds5_manual' : 'config.gamepad_auto') }}
|
||||||
|
</button>
|
||||||
|
</h2>
|
||||||
|
<div id="panelsStayOpen-collapseOne" class="accordion-collapse collapse show"
|
||||||
|
aria-labelledby="panelsStayOpen-headingOne">
|
||||||
|
<div class="accordion-body">
|
||||||
|
<!-- Controller MAC randomization (Linux only) -->
|
||||||
|
<template v-if="config.gamepad === 'ds5' || (config.gamepad === 'auto' && platform === 'linux')">
|
||||||
|
<Checkbox class="mb-3"
|
||||||
|
id="ds5_inputtino_randomize_mac"
|
||||||
|
locale-prefix="config"
|
||||||
|
v-model="config.ds5_inputtino_randomize_mac"
|
||||||
|
default="true"
|
||||||
|
></Checkbox>
|
||||||
|
</template>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</div>
|
||||||
|
</template>
|
||||||
</template>
|
</template>
|
||||||
|
|
||||||
<!-- Home/Guide Button Emulation Timeout -->
|
<!-- Home/Guide Button Emulation Timeout -->
|
||||||
|
|
|
||||||
|
|
@ -195,6 +195,8 @@
|
||||||
"dd_wa_hdr_toggle_delay": "High-contrast workaround for HDR",
|
"dd_wa_hdr_toggle_delay": "High-contrast workaround for HDR",
|
||||||
"ds4_back_as_touchpad_click": "Map Back/Select to Touchpad Click",
|
"ds4_back_as_touchpad_click": "Map Back/Select to Touchpad Click",
|
||||||
"ds4_back_as_touchpad_click_desc": "When forcing DS4 emulation, map Back/Select to Touchpad Click",
|
"ds4_back_as_touchpad_click_desc": "When forcing DS4 emulation, map Back/Select to Touchpad Click",
|
||||||
|
"ds5_inputtino_randomize_mac": "Randomize virtual controller MAC",
|
||||||
|
"ds5_inputtino_randomize_mac_desc": "Upon controller registration use a random MAC instead of one based on the controllers internal index to avoid mixing configuration settings of different controllers when the are swapped on client-side.",
|
||||||
"encoder": "Force a Specific Encoder",
|
"encoder": "Force a Specific Encoder",
|
||||||
"encoder_desc": "Force a specific encoder, otherwise Sunshine will select the best available option. Note: If you specify a hardware encoder on Windows, it must match the GPU where the display is connected.",
|
"encoder_desc": "Force a specific encoder, otherwise Sunshine will select the best available option. Note: If you specify a hardware encoder on Windows, it must match the GPU where the display is connected.",
|
||||||
"encoder_software": "Software",
|
"encoder_software": "Software",
|
||||||
|
|
@ -213,6 +215,7 @@
|
||||||
"gamepad_ds4": "DS4 (PS4)",
|
"gamepad_ds4": "DS4 (PS4)",
|
||||||
"gamepad_ds4_manual": "DS4 selection options",
|
"gamepad_ds4_manual": "DS4 selection options",
|
||||||
"gamepad_ds5": "DS5 (PS5)",
|
"gamepad_ds5": "DS5 (PS5)",
|
||||||
|
"gamepad_ds5_manual": "DS5 selection options",
|
||||||
"gamepad_switch": "Nintendo Pro (Switch)",
|
"gamepad_switch": "Nintendo Pro (Switch)",
|
||||||
"gamepad_manual": "Manual DS4 options",
|
"gamepad_manual": "Manual DS4 options",
|
||||||
"gamepad_x360": "X360 (Xbox 360)",
|
"gamepad_x360": "X360 (Xbox 360)",
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue