mirror of
https://github.com/LizardByte/Sunshine.git
synced 2026-02-05 12:15:38 +00:00
feat(input/linux): allow ds5 gamepads to have a fixed device mac based on controller index (#4158)
This commit is contained in:
@ -416,6 +416,30 @@ editing the `conf` file in a text editor. Use the examples as reference.
|
||||
</tr>
|
||||
</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
|
||||
|
||||
<table>
|
||||
|
||||
@ -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();
|
||||
|
||||
|
||||
@ -89,6 +89,32 @@ const config = ref(props.config)
|
||||
</div>
|
||||
</div>
|
||||
</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>
|
||||
|
||||
<!-- Home/Guide Button Emulation Timeout -->
|
||||
|
||||
@ -195,6 +195,8 @@
|
||||
"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_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_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",
|
||||
@ -213,6 +215,7 @@
|
||||
"gamepad_ds4": "DS4 (PS4)",
|
||||
"gamepad_ds4_manual": "DS4 selection options",
|
||||
"gamepad_ds5": "DS5 (PS5)",
|
||||
"gamepad_ds5_manual": "DS5 selection options",
|
||||
"gamepad_switch": "Nintendo Pro (Switch)",
|
||||
"gamepad_manual": "Manual DS4 options",
|
||||
"gamepad_x360": "X360 (Xbox 360)",
|
||||
|
||||
Reference in New Issue
Block a user