diff mbox series

HID: hid-steam: Fix Lizard Mode disabling

Message ID 20241225155507.30288-1-eugenyshcheglov@gmail.com
State New
Headers show
Series HID: hid-steam: Fix Lizard Mode disabling | expand

Commit Message

Eugeny Shcheglov Dec. 25, 2024, 3:55 p.m. UTC
Disable Lizard Mode by setting the lizard_mode option.
Set lizard_mode to 0 to disable switching between Desktop and Gamepad
using the Options button, and use Gamepad input.

Signed-off-by: Eugeny Shcheglov <eugenyshcheglov@gmail.com>
---
 drivers/hid/hid-steam.c | 20 ++++++++++----------
 1 file changed, 10 insertions(+), 10 deletions(-)
diff mbox series

Patch

diff --git a/drivers/hid/hid-steam.c b/drivers/hid/hid-steam.c
index 6439913372a8..c64f716c9c14 100644
--- a/drivers/hid/hid-steam.c
+++ b/drivers/hid/hid-steam.c
@@ -10,7 +10,7 @@ 
  * This controller has a builtin emulation of mouse and keyboard: the right pad
  * can be used as a mouse, the shoulder buttons are mouse buttons, A and B
  * buttons are ENTER and ESCAPE, and so on. This is implemented as additional
- * HID interfaces.
+ * HID interfaces. Joystick input is blocked when Lizard Mode is active.
  *
  * This is known as the "lizard mode", because apparently lizards like to use
  * the computer from the coach, without a proper mouse and keyboard.
@@ -555,9 +555,6 @@  static int steam_play_effect(struct input_dev *dev, void *data,
 
 static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
 {
-	if (steam->gamepad_mode)
-		enable = false;
-
 	if (enable) {
 		mutex_lock(&steam->report_mutex);
 		/* enable esc, enter, cursors */
@@ -566,6 +563,7 @@  static void steam_set_lizard_mode(struct steam_device *steam, bool enable)
 		steam_send_report_byte(steam, ID_LOAD_DEFAULT_SETTINGS);
 		mutex_unlock(&steam->report_mutex);
 	} else {
+		steam->gamepad_mode = true;
 		mutex_lock(&steam->report_mutex);
 		/* disable esc, enter, cursor */
 		steam_send_report_byte(steam, ID_CLEAR_DIGITAL_MAPPINGS);
@@ -1590,12 +1588,14 @@  static void steam_do_deck_input_event(struct steam_device *steam,
 	b13 = data[13];
 	b14 = data[14];
 
-	if (!(b9 & BIT(6)) && steam->did_mode_switch) {
-		steam->did_mode_switch = false;
-		cancel_delayed_work_sync(&steam->mode_switch);
-	} else if (!steam->client_opened && (b9 & BIT(6)) && !steam->did_mode_switch) {
-		steam->did_mode_switch = true;
-		schedule_delayed_work(&steam->mode_switch, 45 * HZ / 100);
+	if (lizard_mode) {
+		if (!(b9 & BIT(6)) && steam->did_mode_switch) {
+			steam->did_mode_switch = false;
+			cancel_delayed_work_sync(&steam->mode_switch);
+		} else if (!steam->client_opened && (b9 & BIT(6)) && !steam->did_mode_switch) {
+			steam->did_mode_switch = true;
+			schedule_delayed_work(&steam->mode_switch, 45 * HZ / 100);
+		}
 	}
 
 	if (!steam->gamepad_mode)