mirror of
https://github.com/LizardByte/Sunshine.git
synced 2025-01-06 00:56:13 +00:00
Add setting for suppressing input from mouse, keyboard, or gamepads (#941)
This commit is contained in:
parent
31885434f2
commit
f238cf5303
@ -408,6 +408,10 @@ input_t input {
|
||||
platf::supported_gamepads().front().data(),
|
||||
platf::supported_gamepads().front().size(),
|
||||
}, // Default gamepad
|
||||
|
||||
false,
|
||||
false,
|
||||
false,
|
||||
};
|
||||
|
||||
sunshine_t sunshine {
|
||||
@ -947,6 +951,10 @@ void apply_config(std::unordered_map<std::string, std::string> &&vars) {
|
||||
|
||||
string_restricted_f(vars, "gamepad"s, input.gamepad, platf::supported_gamepads());
|
||||
|
||||
bool_f(vars, "mouse", input.mouse);
|
||||
bool_f(vars, "keyboard", input.keyboard);
|
||||
bool_f(vars, "controller", input.controller);
|
||||
|
||||
int port = sunshine.port;
|
||||
int_f(vars, "port"s, port);
|
||||
sunshine.port = (std::uint16_t)port;
|
||||
|
@ -100,6 +100,10 @@ struct input_t {
|
||||
std::chrono::duration<double> key_repeat_period;
|
||||
|
||||
std::string gamepad;
|
||||
|
||||
bool keyboard;
|
||||
bool mouse;
|
||||
bool controller;
|
||||
};
|
||||
|
||||
namespace flag {
|
||||
|
@ -263,11 +263,19 @@ void print(void *payload) {
|
||||
}
|
||||
|
||||
void passthrough(std::shared_ptr<input_t> &input, PNV_REL_MOUSE_MOVE_PACKET packet) {
|
||||
if(!config::input.mouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
input->mouse_left_button_timeout = DISABLE_LEFT_BUTTON_DELAY;
|
||||
platf::move_mouse(platf_input, util::endian::big(packet->deltaX), util::endian::big(packet->deltaY));
|
||||
}
|
||||
|
||||
void passthrough(std::shared_ptr<input_t> &input, PNV_ABS_MOUSE_MOVE_PACKET packet) {
|
||||
if(!config::input.mouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(input->mouse_left_button_timeout == DISABLE_LEFT_BUTTON_DELAY) {
|
||||
input->mouse_left_button_timeout = ENABLE_LEFT_BUTTON_DELAY;
|
||||
}
|
||||
@ -313,6 +321,10 @@ void passthrough(std::shared_ptr<input_t> &input, PNV_ABS_MOUSE_MOVE_PACKET pack
|
||||
}
|
||||
|
||||
void passthrough(std::shared_ptr<input_t> &input, PNV_MOUSE_BUTTON_PACKET packet) {
|
||||
if(!config::input.mouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto release = util::endian::little(packet->header.magic) == MOUSE_BUTTON_UP_EVENT_MAGIC_GEN5;
|
||||
auto button = util::endian::big(packet->button);
|
||||
if(button > 0 && button < mouse_press.size()) {
|
||||
@ -430,6 +442,10 @@ void repeat_key(short key_code) {
|
||||
}
|
||||
|
||||
void passthrough(std::shared_ptr<input_t> &input, PNV_KEYBOARD_PACKET packet) {
|
||||
if(!config::input.keyboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto release = util::endian::little(packet->header.magic) == KEY_UP_EVENT_MAGIC;
|
||||
auto keyCode = packet->keyCode & 0x00FF;
|
||||
|
||||
@ -467,14 +483,26 @@ void passthrough(std::shared_ptr<input_t> &input, PNV_KEYBOARD_PACKET packet) {
|
||||
}
|
||||
|
||||
void passthrough(PNV_SCROLL_PACKET packet) {
|
||||
if(!config::input.mouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
platf::scroll(platf_input, util::endian::big(packet->scrollAmt1));
|
||||
}
|
||||
|
||||
void passthrough(PSS_HSCROLL_PACKET packet) {
|
||||
if(!config::input.mouse) {
|
||||
return;
|
||||
}
|
||||
|
||||
platf::hscroll(platf_input, util::endian::big(packet->scrollAmount));
|
||||
}
|
||||
|
||||
void passthrough(PNV_UNICODE_PACKET packet) {
|
||||
if(!config::input.keyboard) {
|
||||
return;
|
||||
}
|
||||
|
||||
auto size = util::endian::big(packet->header.size) - sizeof(packet->header.magic);
|
||||
platf::unicode(platf_input, packet->text, size);
|
||||
}
|
||||
@ -521,6 +549,10 @@ int updateGamepads(std::vector<gamepad_t> &gamepads, std::int16_t old_state, std
|
||||
}
|
||||
|
||||
void passthrough(std::shared_ptr<input_t> &input, PNV_MULTI_CONTROLLER_PACKET packet) {
|
||||
if(!config::input.controller) {
|
||||
return;
|
||||
}
|
||||
|
||||
if(updateGamepads(input->gamepads, input->active_gamepad_state, packet->activeGamepadMask, input->rumble_queue)) {
|
||||
return;
|
||||
}
|
||||
|
@ -297,6 +297,57 @@
|
||||
If back_button_timeout < 0, then the Home/Guide button will not be emulated<br />
|
||||
</div>
|
||||
</div>
|
||||
<!--Enable Mouse Input-->
|
||||
<div class="mb-3">
|
||||
<label for="mouse" class="form-label"
|
||||
>Enable Mouse Input</label
|
||||
>
|
||||
<select
|
||||
id="mouse"
|
||||
class="form-select"
|
||||
v-model="config.mouse"
|
||||
>
|
||||
<option value="disabled">Disabled</option>
|
||||
<option value="enabled">Enabled</option>
|
||||
</select>
|
||||
<div class="form-text">
|
||||
Allows guests to control the host system with the mouse
|
||||
</div>
|
||||
</div>
|
||||
<!--Enable Keyboard Input-->
|
||||
<div class="mb-3">
|
||||
<label for="keyboard" class="form-label"
|
||||
>Enable Keyboard Input</label
|
||||
>
|
||||
<select
|
||||
id="keyboard"
|
||||
class="form-select"
|
||||
v-model="config.keyboard"
|
||||
>
|
||||
<option value="disabled">Disabled</option>
|
||||
<option value="enabled">Enabled</option>
|
||||
</select>
|
||||
<div class="form-text">
|
||||
Allows guests to control the host system with the keyboard
|
||||
</div>
|
||||
</div>
|
||||
<!--Enable Gamepad Input-->
|
||||
<div class="mb-3">
|
||||
<label for="gamepad" class="form-label"
|
||||
>Enable Gamepad Input</label
|
||||
>
|
||||
<select
|
||||
id="gamepad"
|
||||
class="form-select"
|
||||
v-model="config.controller"
|
||||
>
|
||||
<option value="disabled">Disabled</option>
|
||||
<option value="enabled">Enabled</option>
|
||||
</select>
|
||||
<div class="form-text">
|
||||
Allows guests to control the host system with a gamepad / controller
|
||||
</div>
|
||||
</div>
|
||||
<!-- Key Repeat Delay-->
|
||||
<div class="mb-3" v-if="platform === 'windows'">
|
||||
<label for="key_repeat_delay" class="form-label"
|
||||
@ -952,6 +1003,9 @@
|
||||
this.config.origin_pin_allowed || "pc";
|
||||
this.config.origin_web_ui_allowed =
|
||||
this.config.origin_web_ui_allowed || "lan";
|
||||
this.config.mouse = this.config.mouse || "enabled";
|
||||
this.config.keyboard = this.config.keyboard || "enabled";
|
||||
this.config.controller = this.config.controller || "enabled";
|
||||
this.config.hevc_mode = this.config.hevc_mode || 0;
|
||||
this.config.encoder = this.config.encoder || "";
|
||||
this.config.nv_preset = this.config.nv_preset || "p4";
|
||||
|
Loading…
Reference in New Issue
Block a user