Lines Matching +full:input +full:- +full:value

1 // SPDX-License-Identifier: GPL-2.0+
18 * This driver will disable the lizard mode when the input device is opened
19 * and re-enable it when the input device is closed, so as not to break user
23 * the hidraw interface directly to create input devices (XTest, uinput...).
26 * - it will not send any command to the controller.
27 * - this input device will be removed, to avoid double input of the same
29 * When the client is closed, this input device will be created again.
31 * For additional functions, such as changing the right-pad margin or switching
32 * the led, you can use the user-space tool at:
38 #include <linux/input.h>
46 #include "hid-ids.h"
234 /* Input report identifiers */
290 struct input_dev __rcu *input; member
314 r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0]; in steam_recv_report()
316 hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n"); in steam_recv_report()
317 return -EINVAL; in steam_recv_report()
321 return -EINVAL; in steam_recv_report()
325 return -ENOMEM; in steam_recv_report()
333 ret = hid_hw_raw_request(steam->hdev, 0x00, in steam_recv_report()
337 memcpy(data, buf + 1, min(size, ret - 1)); in steam_recv_report()
350 r = steam->hdev->report_enum[HID_FEATURE_REPORT].report_id_hash[0]; in steam_send_report()
352 hid_err(steam->hdev, "No HID_FEATURE_REPORT submitted - nothing to read\n"); in steam_send_report()
353 return -EINVAL; in steam_send_report()
357 return -EINVAL; in steam_send_report()
361 return -ENOMEM; in steam_send_report()
373 ret = hid_hw_raw_request(steam->hdev, 0, in steam_send_report()
376 if (ret != -EPIPE) in steam_send_report()
379 } while (--retries); in steam_send_report()
383 hid_err(steam->hdev, "%s: error %d (%*ph)\n", __func__, in steam_send_report()
435 u8 cmd[] = {ID_GET_STRING_ATTRIBUTE, sizeof(steam->serial_no), ATTRIB_STR_UNIT_SERIAL}; in steam_get_serial()
438 mutex_lock(&steam->report_mutex); in steam_get_serial()
446 reply[1] > sizeof(steam->serial_no) || reply[2] != ATTRIB_STR_UNIT_SERIAL) { in steam_get_serial()
447 ret = -EIO; in steam_get_serial()
451 strscpy(steam->serial_no, reply + 3, reply[1]); in steam_get_serial()
453 mutex_unlock(&steam->report_mutex); in steam_get_serial()
465 mutex_lock(&steam->report_mutex); in steam_request_conn_status()
467 mutex_unlock(&steam->report_mutex); in steam_request_conn_status()
475 * and gain is measured in decibels, ranging from -24 to +6
496 mutex_lock(&steam->report_mutex); in steam_haptic_pulse()
498 mutex_unlock(&steam->report_mutex); in steam_haptic_pulse()
518 mutex_lock(&steam->report_mutex); in steam_haptic_rumble()
520 mutex_unlock(&steam->report_mutex); in steam_haptic_rumble()
528 steam_haptic_rumble(steam, 0, steam->rumble_left, in steam_haptic_rumble_cb()
529 steam->rumble_right, 2, 0); in steam_haptic_rumble_cb()
538 steam->rumble_left = effect->u.rumble.strong_magnitude; in steam_play_effect()
539 steam->rumble_right = effect->u.rumble.weak_magnitude; in steam_play_effect()
541 return schedule_work(&steam->rumble_work); in steam_play_effect()
547 if (steam->gamepad_mode) in steam_set_lizard_mode()
551 mutex_lock(&steam->report_mutex); in steam_set_lizard_mode()
556 mutex_unlock(&steam->report_mutex); in steam_set_lizard_mode()
558 mutex_lock(&steam->report_mutex); in steam_set_lizard_mode()
562 if (steam->quirks & STEAM_QUIRK_DECK) { in steam_set_lizard_mode()
570 mutex_unlock(&steam->report_mutex); in steam_set_lizard_mode()
576 mutex_unlock(&steam->report_mutex); in steam_set_lizard_mode()
592 if (!(steam->quirks & STEAM_QUIRK_DECK)) { in steam_input_open()
593 spin_lock_irqsave(&steam->lock, flags); in steam_input_open()
594 set_lizard_mode = !steam->client_opened && lizard_mode; in steam_input_open()
595 spin_unlock_irqrestore(&steam->lock, flags); in steam_input_open()
609 if (!(steam->quirks & STEAM_QUIRK_DECK)) { in steam_input_close()
610 spin_lock_irqsave(&steam->lock, flags); in steam_input_close()
611 set_lizard_mode = !steam->client_opened && lizard_mode; in steam_input_close()
612 spin_unlock_irqrestore(&steam->lock, flags); in steam_input_close()
635 spin_lock_irqsave(&steam->lock, flags); in steam_battery_get_property()
636 volts = steam->voltage; in steam_battery_get_property()
637 batt = steam->battery_charge; in steam_battery_get_property()
638 spin_unlock_irqrestore(&steam->lock, flags); in steam_battery_get_property()
642 val->intval = 1; in steam_battery_get_property()
645 val->intval = POWER_SUPPLY_SCOPE_DEVICE; in steam_battery_get_property()
648 val->intval = volts * 1000; /* mV -> uV */ in steam_battery_get_property()
651 val->intval = batt; in steam_battery_get_property()
654 ret = -EINVAL; in steam_battery_get_property()
667 steam->battery_desc.type = POWER_SUPPLY_TYPE_BATTERY; in steam_battery_register()
668 steam->battery_desc.properties = steam_battery_props; in steam_battery_register()
669 steam->battery_desc.num_properties = ARRAY_SIZE(steam_battery_props); in steam_battery_register()
670 steam->battery_desc.get_property = steam_battery_get_property; in steam_battery_register()
671 steam->battery_desc.name = devm_kasprintf(&steam->hdev->dev, in steam_battery_register()
672 GFP_KERNEL, "steam-controller-%s-battery", in steam_battery_register()
673 steam->serial_no); in steam_battery_register()
674 if (!steam->battery_desc.name) in steam_battery_register()
675 return -ENOMEM; in steam_battery_register()
678 spin_lock_irqsave(&steam->lock, flags); in steam_battery_register()
679 steam->voltage = 3000; in steam_battery_register()
680 steam->battery_charge = 100; in steam_battery_register()
681 spin_unlock_irqrestore(&steam->lock, flags); in steam_battery_register()
683 battery = power_supply_register(&steam->hdev->dev, in steam_battery_register()
684 &steam->battery_desc, &battery_cfg); in steam_battery_register()
687 hid_err(steam->hdev, in steam_battery_register()
692 rcu_assign_pointer(steam->battery, battery); in steam_battery_register()
693 power_supply_powers(battery, &steam->hdev->dev); in steam_battery_register()
699 struct hid_device *hdev = steam->hdev; in steam_input_register()
700 struct input_dev *input; in steam_input_register() local
704 input = rcu_dereference(steam->input); in steam_input_register()
706 if (input) { in steam_input_register()
711 input = input_allocate_device(); in steam_input_register()
712 if (!input) in steam_input_register()
713 return -ENOMEM; in steam_input_register()
715 input_set_drvdata(input, steam); in steam_input_register()
716 input->dev.parent = &hdev->dev; in steam_input_register()
717 input->open = steam_input_open; in steam_input_register()
718 input->close = steam_input_close; in steam_input_register()
720 input->name = (steam->quirks & STEAM_QUIRK_WIRELESS) ? "Wireless Steam Controller" : in steam_input_register()
721 (steam->quirks & STEAM_QUIRK_DECK) ? "Steam Deck" : in steam_input_register()
723 input->phys = hdev->phys; in steam_input_register()
724 input->uniq = steam->serial_no; in steam_input_register()
725 input->id.bustype = hdev->bus; in steam_input_register()
726 input->id.vendor = hdev->vendor; in steam_input_register()
727 input->id.product = hdev->product; in steam_input_register()
728 input->id.version = hdev->version; in steam_input_register()
730 input_set_capability(input, EV_KEY, BTN_TR2); in steam_input_register()
731 input_set_capability(input, EV_KEY, BTN_TL2); in steam_input_register()
732 input_set_capability(input, EV_KEY, BTN_TR); in steam_input_register()
733 input_set_capability(input, EV_KEY, BTN_TL); in steam_input_register()
734 input_set_capability(input, EV_KEY, BTN_Y); in steam_input_register()
735 input_set_capability(input, EV_KEY, BTN_B); in steam_input_register()
736 input_set_capability(input, EV_KEY, BTN_X); in steam_input_register()
737 input_set_capability(input, EV_KEY, BTN_A); in steam_input_register()
738 input_set_capability(input, EV_KEY, BTN_DPAD_UP); in steam_input_register()
739 input_set_capability(input, EV_KEY, BTN_DPAD_RIGHT); in steam_input_register()
740 input_set_capability(input, EV_KEY, BTN_DPAD_LEFT); in steam_input_register()
741 input_set_capability(input, EV_KEY, BTN_DPAD_DOWN); in steam_input_register()
742 input_set_capability(input, EV_KEY, BTN_SELECT); in steam_input_register()
743 input_set_capability(input, EV_KEY, BTN_MODE); in steam_input_register()
744 input_set_capability(input, EV_KEY, BTN_START); in steam_input_register()
745 input_set_capability(input, EV_KEY, BTN_THUMBR); in steam_input_register()
746 input_set_capability(input, EV_KEY, BTN_THUMBL); in steam_input_register()
747 input_set_capability(input, EV_KEY, BTN_THUMB); in steam_input_register()
748 input_set_capability(input, EV_KEY, BTN_THUMB2); in steam_input_register()
749 if (steam->quirks & STEAM_QUIRK_DECK) { in steam_input_register()
750 input_set_capability(input, EV_KEY, BTN_BASE); in steam_input_register()
751 input_set_capability(input, EV_KEY, BTN_TRIGGER_HAPPY1); in steam_input_register()
752 input_set_capability(input, EV_KEY, BTN_TRIGGER_HAPPY2); in steam_input_register()
753 input_set_capability(input, EV_KEY, BTN_TRIGGER_HAPPY3); in steam_input_register()
754 input_set_capability(input, EV_KEY, BTN_TRIGGER_HAPPY4); in steam_input_register()
756 input_set_capability(input, EV_KEY, BTN_GEAR_DOWN); in steam_input_register()
757 input_set_capability(input, EV_KEY, BTN_GEAR_UP); in steam_input_register()
760 input_set_abs_params(input, ABS_X, -32767, 32767, 0, 0); in steam_input_register()
761 input_set_abs_params(input, ABS_Y, -32767, 32767, 0, 0); in steam_input_register()
763 input_set_abs_params(input, ABS_HAT0X, -32767, 32767, in steam_input_register()
765 input_set_abs_params(input, ABS_HAT0Y, -32767, 32767, in steam_input_register()
768 if (steam->quirks & STEAM_QUIRK_DECK) { in steam_input_register()
769 input_set_abs_params(input, ABS_HAT2Y, 0, 32767, 0, 0); in steam_input_register()
770 input_set_abs_params(input, ABS_HAT2X, 0, 32767, 0, 0); in steam_input_register()
772 input_set_abs_params(input, ABS_RX, -32767, 32767, 0, 0); in steam_input_register()
773 input_set_abs_params(input, ABS_RY, -32767, 32767, 0, 0); in steam_input_register()
775 input_set_abs_params(input, ABS_HAT1X, -32767, 32767, in steam_input_register()
777 input_set_abs_params(input, ABS_HAT1Y, -32767, 32767, in steam_input_register()
780 input_abs_set_res(input, ABS_X, STEAM_DECK_JOYSTICK_RESOLUTION); in steam_input_register()
781 input_abs_set_res(input, ABS_Y, STEAM_DECK_JOYSTICK_RESOLUTION); in steam_input_register()
782 input_abs_set_res(input, ABS_RX, STEAM_DECK_JOYSTICK_RESOLUTION); in steam_input_register()
783 input_abs_set_res(input, ABS_RY, STEAM_DECK_JOYSTICK_RESOLUTION); in steam_input_register()
784 input_abs_set_res(input, ABS_HAT1X, STEAM_PAD_RESOLUTION); in steam_input_register()
785 input_abs_set_res(input, ABS_HAT1Y, STEAM_PAD_RESOLUTION); in steam_input_register()
786 input_abs_set_res(input, ABS_HAT2Y, STEAM_DECK_TRIGGER_RESOLUTION); in steam_input_register()
787 input_abs_set_res(input, ABS_HAT2X, STEAM_DECK_TRIGGER_RESOLUTION); in steam_input_register()
789 input_set_abs_params(input, ABS_HAT2Y, 0, 255, 0, 0); in steam_input_register()
790 input_set_abs_params(input, ABS_HAT2X, 0, 255, 0, 0); in steam_input_register()
792 input_set_abs_params(input, ABS_RX, -32767, 32767, in steam_input_register()
794 input_set_abs_params(input, ABS_RY, -32767, 32767, in steam_input_register()
797 input_abs_set_res(input, ABS_X, STEAM_JOYSTICK_RESOLUTION); in steam_input_register()
798 input_abs_set_res(input, ABS_Y, STEAM_JOYSTICK_RESOLUTION); in steam_input_register()
799 input_abs_set_res(input, ABS_RX, STEAM_PAD_RESOLUTION); in steam_input_register()
800 input_abs_set_res(input, ABS_RY, STEAM_PAD_RESOLUTION); in steam_input_register()
801 input_abs_set_res(input, ABS_HAT2Y, STEAM_TRIGGER_RESOLUTION); in steam_input_register()
802 input_abs_set_res(input, ABS_HAT2X, STEAM_TRIGGER_RESOLUTION); in steam_input_register()
804 input_abs_set_res(input, ABS_HAT0X, STEAM_PAD_RESOLUTION); in steam_input_register()
805 input_abs_set_res(input, ABS_HAT0Y, STEAM_PAD_RESOLUTION); in steam_input_register()
808 if (steam->quirks & STEAM_QUIRK_DECK) { in steam_input_register()
809 input_set_capability(input, EV_FF, FF_RUMBLE); in steam_input_register()
810 ret = input_ff_create_memless(input, NULL, steam_play_effect); in steam_input_register()
816 ret = input_register_device(input); in steam_input_register()
820 rcu_assign_pointer(steam->input, input); in steam_input_register()
824 input_free_device(input); in steam_input_register()
830 struct input_dev *input; in steam_input_unregister() local
832 input = rcu_dereference(steam->input); in steam_input_unregister()
834 if (!input) in steam_input_unregister()
836 RCU_INIT_POINTER(steam->input, NULL); in steam_input_unregister()
838 input_unregister_device(input); in steam_input_unregister()
846 battery = rcu_dereference(steam->battery); in steam_battery_unregister()
851 RCU_INIT_POINTER(steam->battery, NULL); in steam_battery_unregister()
868 if (!steam->serial_no[0]) { in steam_register()
874 strscpy(steam->serial_no, "XXXXXXXXXX", in steam_register()
875 sizeof(steam->serial_no)); in steam_register()
877 hid_info(steam->hdev, "Steam Controller '%s' connected", in steam_register()
878 steam->serial_no); in steam_register()
881 if (steam->quirks & STEAM_QUIRK_WIRELESS) in steam_register()
885 if (list_empty(&steam->list)) in steam_register()
886 list_add(&steam->list, &steam_devices); in steam_register()
890 spin_lock_irqsave(&steam->lock, flags); in steam_register()
891 client_opened = steam->client_opened; in steam_register()
892 spin_unlock_irqrestore(&steam->lock, flags); in steam_register()
906 if (steam->serial_no[0]) { in steam_unregister()
907 hid_info(steam->hdev, "Steam Controller '%s' disconnected", in steam_unregister()
908 steam->serial_no); in steam_unregister()
910 list_del_init(&steam->list); in steam_unregister()
912 steam->serial_no[0] = 0; in steam_unregister()
924 spin_lock_irqsave(&steam->lock, flags); in steam_work_connect_cb()
925 connected = steam->connected; in steam_work_connect_cb()
926 spin_unlock_irqrestore(&steam->lock, flags); in steam_work_connect_cb()
931 hid_err(steam->hdev, in steam_work_connect_cb()
946 steam->gamepad_mode = !steam->gamepad_mode; in steam_mode_switch_cb()
950 if (steam->gamepad_mode) in steam_mode_switch_cb()
953 spin_lock_irqsave(&steam->lock, flags); in steam_mode_switch_cb()
954 client_opened = steam->client_opened; in steam_mode_switch_cb()
955 spin_unlock_irqrestore(&steam->lock, flags); in steam_mode_switch_cb()
961 if (steam->gamepad_mode) { in steam_mode_switch_cb()
979 * 1-4: slots where up to 4 real game pads will be connected to. in steam_is_valve_interface()
983 rep_enum = &hdev->report_enum[HID_FEATURE_REPORT]; in steam_is_valve_interface()
984 return !list_empty(&rep_enum->report_list); in steam_is_valve_interface()
989 struct steam_device *steam = hdev->driver_data; in steam_client_ll_parse()
991 return hid_parse_report(hdev, steam->hdev->dev_rdesc, in steam_client_ll_parse()
992 steam->hdev->dev_rsize); in steam_client_ll_parse()
1006 struct steam_device *steam = hdev->driver_data; in steam_client_ll_open()
1009 spin_lock_irqsave(&steam->lock, flags); in steam_client_ll_open()
1010 steam->client_opened++; in steam_client_ll_open()
1011 spin_unlock_irqrestore(&steam->lock, flags); in steam_client_ll_open()
1020 struct steam_device *steam = hdev->driver_data; in steam_client_ll_close()
1025 spin_lock_irqsave(&steam->lock, flags); in steam_client_ll_close()
1026 steam->client_opened--; in steam_client_ll_close()
1027 connected = steam->connected && !steam->client_opened; in steam_client_ll_close()
1028 spin_unlock_irqrestore(&steam->lock, flags); in steam_client_ll_close()
1041 struct steam_device *steam = hdev->driver_data; in steam_client_ll_raw_request()
1043 return hid_hw_raw_request(steam->hdev, reportnum, buf, count, in steam_client_ll_raw_request()
1064 client_hdev->ll_driver = &steam_client_ll_driver; in steam_create_client_hid()
1065 client_hdev->dev.parent = hdev->dev.parent; in steam_create_client_hid()
1066 client_hdev->bus = hdev->bus; in steam_create_client_hid()
1067 client_hdev->vendor = hdev->vendor; in steam_create_client_hid()
1068 client_hdev->product = hdev->product; in steam_create_client_hid()
1069 client_hdev->version = hdev->version; in steam_create_client_hid()
1070 client_hdev->type = hdev->type; in steam_create_client_hid()
1071 client_hdev->country = hdev->country; in steam_create_client_hid()
1072 strscpy(client_hdev->name, hdev->name, in steam_create_client_hid()
1073 sizeof(client_hdev->name)); in steam_create_client_hid()
1074 strscpy(client_hdev->phys, hdev->phys, in steam_create_client_hid()
1075 sizeof(client_hdev->phys)); in steam_create_client_hid()
1081 client_hdev->group = HID_GROUP_STEAM; in steam_create_client_hid()
1102 if (hdev->group == HID_GROUP_STEAM) in steam_probe()
1105 * The non-valve interfaces (mouse and keyboard emulation) are in steam_probe()
1111 steam = devm_kzalloc(&hdev->dev, sizeof(*steam), GFP_KERNEL); in steam_probe()
1113 return -ENOMEM; in steam_probe()
1115 steam->hdev = hdev; in steam_probe()
1117 spin_lock_init(&steam->lock); in steam_probe()
1118 mutex_init(&steam->report_mutex); in steam_probe()
1119 steam->quirks = id->driver_data; in steam_probe()
1120 INIT_WORK(&steam->work_connect, steam_work_connect_cb); in steam_probe()
1121 INIT_DELAYED_WORK(&steam->mode_switch, steam_mode_switch_cb); in steam_probe()
1122 INIT_LIST_HEAD(&steam->list); in steam_probe()
1123 INIT_WORK(&steam->rumble_work, steam_haptic_rumble_cb); in steam_probe()
1141 if (steam->quirks & STEAM_QUIRK_WIRELESS) { in steam_probe()
1144 steam->connected = false; in steam_probe()
1148 steam->connected = true; in steam_probe()
1158 steam->client_hdev = steam_create_client_hid(hdev); in steam_probe()
1159 if (IS_ERR(steam->client_hdev)) { in steam_probe()
1160 ret = PTR_ERR(steam->client_hdev); in steam_probe()
1163 steam->client_hdev->driver_data = steam; in steam_probe()
1165 ret = hid_add_device(steam->client_hdev); in steam_probe()
1172 hid_destroy_device(steam->client_hdev); in steam_probe()
1174 if (steam->connected) in steam_probe()
1181 cancel_work_sync(&steam->work_connect); in steam_probe()
1182 cancel_delayed_work_sync(&steam->mode_switch); in steam_probe()
1183 cancel_work_sync(&steam->rumble_work); in steam_probe()
1192 if (!steam || hdev->group == HID_GROUP_STEAM) { in steam_remove()
1197 cancel_delayed_work_sync(&steam->mode_switch); in steam_remove()
1198 cancel_work_sync(&steam->work_connect); in steam_remove()
1199 hid_destroy_device(steam->client_hdev); in steam_remove()
1200 steam->client_hdev = NULL; in steam_remove()
1201 steam->client_opened = 0; in steam_remove()
1202 if (steam->quirks & STEAM_QUIRK_WIRELESS) { in steam_remove()
1215 spin_lock_irqsave(&steam->lock, flags); in steam_do_connect_event()
1216 changed = steam->connected != connected; in steam_do_connect_event()
1217 steam->connected = connected; in steam_do_connect_event()
1218 spin_unlock_irqrestore(&steam->lock, flags); in steam_do_connect_event()
1220 if (changed && schedule_work(&steam->work_connect) == 0) in steam_do_connect_event()
1226 * Some input data in the protocol has the opposite sign.
1227 * Clamp the values to 32767..-32767 so that the range is
1234 return x == -32768 ? -32767 : x; in steam_le16()
1243 * -------+-------+-----------+--------------------------
1244 * 4-7 | u32 | -- | sequence number
1245 * 8-10 | 24bit | see below | buttons
1248 * 13-15 | -- | -- | always 0
1249 * 16-17 | s16 | ABS_X/ABS_HAT0X | X value
1250 * 18-19 | s16 | ABS_Y/ABS_HAT0Y | Y value
1251 * 20-21 | s16 | ABS_RX | right-pad X value
1252 * 22-23 | s16 | ABS_RY | right-pad Y value
1253 * 24-25 | s16 | -- | * left trigger
1254 * 26-27 | s16 | -- | * right trigger
1255 * 28-29 | s16 | -- | * accelerometer X value
1256 * 30-31 | s16 | -- | * accelerometer Y value
1257 * 32-33 | s16 | -- | * accelerometer Z value
1258 * 34-35 | s16 | -- | gyro X value
1259 * 36-36 | s16 | -- | gyro Y value
1260 * 38-39 | s16 | -- | gyro Z value
1261 * 40-41 | s16 | -- | quaternion W value
1262 * 42-43 | s16 | -- | quaternion X value
1263 * 44-45 | s16 | -- | quaternion Y value
1264 * 46-47 | s16 | -- | quaternion Z value
1265 * 48-49 | -- | -- | always 0
1266 * 50-51 | s16 | -- | * left trigger (uncalibrated)
1267 * 52-53 | s16 | -- | * right trigger (uncalibrated)
1268 * 54-55 | s16 | -- | * joystick X value (uncalibrated)
1269 * 56-57 | s16 | -- | * joystick Y value (uncalibrated)
1270 * 58-59 | s16 | -- | * left-pad X value
1271 * 60-61 | s16 | -- | * left-pad Y value
1272 * 62-63 | u16 | -- | * battery voltage
1276 * ------+------------+--------------------------------
1285 * 9.0 | BTN_DPAD_UP | left-pad up
1286 * 9.1 | BTN_DPAD_RIGHT | left-pad right
1287 * 9.2 | BTN_DPAD_LEFT | left-pad left
1288 * 9.3 | BTN_DPAD_DOWN | left-pad down
1294 * 10.1 | -- | left-pad clicked
1295 * 10.2 | BTN_THUMBR | right-pad clicked
1296 * 10.3 | BTN_THUMB | left-pad touched (but see explanation below)
1297 * 10.4 | BTN_THUMB2 | right-pad touched
1298 * 10.5 | -- | unknown
1300 * 10.7 | -- | lpad_and_joy
1304 struct input_dev *input, u8 *data) in steam_do_input_event() argument
1315 input_report_abs(input, ABS_HAT2Y, data[11]); in steam_do_input_event()
1316 input_report_abs(input, ABS_HAT2X, data[12]); in steam_do_input_event()
1329 y = -steam_le16(data + 18); in steam_do_input_event()
1331 input_report_abs(input, lpad_touched ? ABS_HAT0X : ABS_X, x); in steam_do_input_event()
1332 input_report_abs(input, lpad_touched ? ABS_HAT0Y : ABS_Y, y); in steam_do_input_event()
1335 input_report_abs(input, ABS_X, 0); in steam_do_input_event()
1336 input_report_abs(input, ABS_Y, 0); in steam_do_input_event()
1340 input_report_abs(input, ABS_HAT0X, 0); in steam_do_input_event()
1341 input_report_abs(input, ABS_HAT0Y, 0); in steam_do_input_event()
1344 input_report_abs(input, ABS_RX, steam_le16(data + 20)); in steam_do_input_event()
1345 input_report_abs(input, ABS_RY, -steam_le16(data + 22)); in steam_do_input_event()
1347 input_event(input, EV_KEY, BTN_TR2, !!(b8 & BIT(0))); in steam_do_input_event()
1348 input_event(input, EV_KEY, BTN_TL2, !!(b8 & BIT(1))); in steam_do_input_event()
1349 input_event(input, EV_KEY, BTN_TR, !!(b8 & BIT(2))); in steam_do_input_event()
1350 input_event(input, EV_KEY, BTN_TL, !!(b8 & BIT(3))); in steam_do_input_event()
1351 input_event(input, EV_KEY, BTN_Y, !!(b8 & BIT(4))); in steam_do_input_event()
1352 input_event(input, EV_KEY, BTN_B, !!(b8 & BIT(5))); in steam_do_input_event()
1353 input_event(input, EV_KEY, BTN_X, !!(b8 & BIT(6))); in steam_do_input_event()
1354 input_event(input, EV_KEY, BTN_A, !!(b8 & BIT(7))); in steam_do_input_event()
1355 input_event(input, EV_KEY, BTN_SELECT, !!(b9 & BIT(4))); in steam_do_input_event()
1356 input_event(input, EV_KEY, BTN_MODE, !!(b9 & BIT(5))); in steam_do_input_event()
1357 input_event(input, EV_KEY, BTN_START, !!(b9 & BIT(6))); in steam_do_input_event()
1358 input_event(input, EV_KEY, BTN_GEAR_DOWN, !!(b9 & BIT(7))); in steam_do_input_event()
1359 input_event(input, EV_KEY, BTN_GEAR_UP, !!(b10 & BIT(0))); in steam_do_input_event()
1360 input_event(input, EV_KEY, BTN_THUMBR, !!(b10 & BIT(2))); in steam_do_input_event()
1361 input_event(input, EV_KEY, BTN_THUMBL, !!(b10 & BIT(6))); in steam_do_input_event()
1362 input_event(input, EV_KEY, BTN_THUMB, lpad_touched || lpad_and_joy); in steam_do_input_event()
1363 input_event(input, EV_KEY, BTN_THUMB2, !!(b10 & BIT(4))); in steam_do_input_event()
1364 input_event(input, EV_KEY, BTN_DPAD_UP, !!(b9 & BIT(0))); in steam_do_input_event()
1365 input_event(input, EV_KEY, BTN_DPAD_RIGHT, !!(b9 & BIT(1))); in steam_do_input_event()
1366 input_event(input, EV_KEY, BTN_DPAD_LEFT, !!(b9 & BIT(2))); in steam_do_input_event()
1367 input_event(input, EV_KEY, BTN_DPAD_DOWN, !!(b9 & BIT(3))); in steam_do_input_event()
1369 input_sync(input); in steam_do_input_event()
1376 * -------+-------+-----------+--------------------------
1377 * 4-7 | u32 | -- | sequence number
1378 * 8-15 | u64 | see below | buttons
1379 * 16-17 | s16 | ABS_HAT0X | left-pad X value
1380 * 18-19 | s16 | ABS_HAT0Y | left-pad Y value
1381 * 20-21 | s16 | ABS_HAT1X | right-pad X value
1382 * 22-23 | s16 | ABS_HAT1Y | right-pad Y value
1383 * 24-25 | s16 | -- | accelerometer X value
1384 * 26-27 | s16 | -- | accelerometer Y value
1385 * 28-29 | s16 | -- | accelerometer Z value
1386 * 30-31 | s16 | -- | gyro X value
1387 * 32-33 | s16 | -- | gyro Y value
1388 * 34-35 | s16 | -- | gyro Z value
1389 * 36-37 | s16 | -- | quaternion W value
1390 * 38-39 | s16 | -- | quaternion X value
1391 * 40-41 | s16 | -- | quaternion Y value
1392 * 42-43 | s16 | -- | quaternion Z value
1393 * 44-45 | u16 | ABS_HAT2Y | left trigger (uncalibrated)
1394 * 46-47 | u16 | ABS_HAT2X | right trigger (uncalibrated)
1395 * 48-49 | s16 | ABS_X | left joystick X
1396 * 50-51 | s16 | ABS_Y | left joystick Y
1397 * 52-53 | s16 | ABS_RX | right joystick X
1398 * 54-55 | s16 | ABS_RY | right joystick Y
1399 * 56-57 | u16 | -- | left pad pressure
1400 * 58-59 | u16 | -- | right pad pressure
1404 * ------+------------+--------------------------------
1413 * 9.0 | BTN_DPAD_UP | left-pad up
1414 * 9.1 | BTN_DPAD_RIGHT | left-pad right
1415 * 9.2 | BTN_DPAD_LEFT | left-pad left
1416 * 9.3 | BTN_DPAD_DOWN | left-pad down
1424 * 10.3 | -- | left pad touched
1425 * 10.4 | -- | right pad touched
1426 * 10.5 | -- | unknown
1428 * 10.7 | -- | unknown
1429 * 11.0 | -- | unknown
1430 * 11.1 | -- | unknown
1432 * 11.3 | -- | unknown
1433 * 11.4 | -- | unknown
1434 * 11.5 | -- | unknown
1435 * 11.6 | -- | unknown
1436 * 11.7 | -- | unknown
1437 * 12.0 | -- | unknown
1438 * 12.1 | -- | unknown
1439 * 12.2 | -- | unknown
1440 * 12.3 | -- | unknown
1441 * 12.4 | -- | unknown
1442 * 12.5 | -- | unknown
1443 * 12.6 | -- | unknown
1444 * 12.7 | -- | unknown
1445 * 13.0 | -- | unknown
1448 * 13.3 | -- | unknown
1449 * 13.4 | -- | unknown
1450 * 13.5 | -- | unknown
1451 * 13.6 | -- | left joystick touched
1452 * 13.7 | -- | right joystick touched
1453 * 14.0 | -- | unknown
1454 * 14.1 | -- | unknown
1456 * 14.3 | -- | unknown
1457 * 14.4 | -- | unknown
1458 * 14.5 | -- | unknown
1459 * 14.6 | -- | unknown
1460 * 14.7 | -- | unknown
1461 * 15.0 | -- | unknown
1462 * 15.1 | -- | unknown
1463 * 15.2 | -- | unknown
1464 * 15.3 | -- | unknown
1465 * 15.4 | -- | unknown
1466 * 15.5 | -- | unknown
1467 * 15.6 | -- | unknown
1468 * 15.7 | -- | unknown
1471 struct input_dev *input, u8 *data) in steam_do_deck_input_event() argument
1483 if (!(b9 & BIT(6)) && steam->did_mode_switch) { in steam_do_deck_input_event()
1484 steam->did_mode_switch = false; in steam_do_deck_input_event()
1485 cancel_delayed_work_sync(&steam->mode_switch); in steam_do_deck_input_event()
1486 } else if (!steam->client_opened && (b9 & BIT(6)) && !steam->did_mode_switch) { in steam_do_deck_input_event()
1487 steam->did_mode_switch = true; in steam_do_deck_input_event()
1488 schedule_delayed_work(&steam->mode_switch, 45 * HZ / 100); in steam_do_deck_input_event()
1491 if (!steam->gamepad_mode) in steam_do_deck_input_event()
1498 input_report_abs(input, ABS_HAT0X, steam_le16(data + 16)); in steam_do_deck_input_event()
1499 input_report_abs(input, ABS_HAT0Y, steam_le16(data + 18)); in steam_do_deck_input_event()
1501 input_report_abs(input, ABS_HAT0X, 0); in steam_do_deck_input_event()
1502 input_report_abs(input, ABS_HAT0Y, 0); in steam_do_deck_input_event()
1506 input_report_abs(input, ABS_HAT1X, steam_le16(data + 20)); in steam_do_deck_input_event()
1507 input_report_abs(input, ABS_HAT1Y, steam_le16(data + 22)); in steam_do_deck_input_event()
1509 input_report_abs(input, ABS_HAT1X, 0); in steam_do_deck_input_event()
1510 input_report_abs(input, ABS_HAT1Y, 0); in steam_do_deck_input_event()
1513 input_report_abs(input, ABS_X, steam_le16(data + 48)); in steam_do_deck_input_event()
1514 input_report_abs(input, ABS_Y, -steam_le16(data + 50)); in steam_do_deck_input_event()
1515 input_report_abs(input, ABS_RX, steam_le16(data + 52)); in steam_do_deck_input_event()
1516 input_report_abs(input, ABS_RY, -steam_le16(data + 54)); in steam_do_deck_input_event()
1518 input_report_abs(input, ABS_HAT2Y, steam_le16(data + 44)); in steam_do_deck_input_event()
1519 input_report_abs(input, ABS_HAT2X, steam_le16(data + 46)); in steam_do_deck_input_event()
1521 input_event(input, EV_KEY, BTN_TR2, !!(b8 & BIT(0))); in steam_do_deck_input_event()
1522 input_event(input, EV_KEY, BTN_TL2, !!(b8 & BIT(1))); in steam_do_deck_input_event()
1523 input_event(input, EV_KEY, BTN_TR, !!(b8 & BIT(2))); in steam_do_deck_input_event()
1524 input_event(input, EV_KEY, BTN_TL, !!(b8 & BIT(3))); in steam_do_deck_input_event()
1525 input_event(input, EV_KEY, BTN_Y, !!(b8 & BIT(4))); in steam_do_deck_input_event()
1526 input_event(input, EV_KEY, BTN_B, !!(b8 & BIT(5))); in steam_do_deck_input_event()
1527 input_event(input, EV_KEY, BTN_X, !!(b8 & BIT(6))); in steam_do_deck_input_event()
1528 input_event(input, EV_KEY, BTN_A, !!(b8 & BIT(7))); in steam_do_deck_input_event()
1529 input_event(input, EV_KEY, BTN_SELECT, !!(b9 & BIT(4))); in steam_do_deck_input_event()
1530 input_event(input, EV_KEY, BTN_MODE, !!(b9 & BIT(5))); in steam_do_deck_input_event()
1531 input_event(input, EV_KEY, BTN_START, !!(b9 & BIT(6))); in steam_do_deck_input_event()
1532 input_event(input, EV_KEY, BTN_TRIGGER_HAPPY3, !!(b9 & BIT(7))); in steam_do_deck_input_event()
1533 input_event(input, EV_KEY, BTN_TRIGGER_HAPPY4, !!(b10 & BIT(0))); in steam_do_deck_input_event()
1534 input_event(input, EV_KEY, BTN_THUMBL, !!(b10 & BIT(6))); in steam_do_deck_input_event()
1535 input_event(input, EV_KEY, BTN_THUMBR, !!(b11 & BIT(2))); in steam_do_deck_input_event()
1536 input_event(input, EV_KEY, BTN_DPAD_UP, !!(b9 & BIT(0))); in steam_do_deck_input_event()
1537 input_event(input, EV_KEY, BTN_DPAD_RIGHT, !!(b9 & BIT(1))); in steam_do_deck_input_event()
1538 input_event(input, EV_KEY, BTN_DPAD_LEFT, !!(b9 & BIT(2))); in steam_do_deck_input_event()
1539 input_event(input, EV_KEY, BTN_DPAD_DOWN, !!(b9 & BIT(3))); in steam_do_deck_input_event()
1540 input_event(input, EV_KEY, BTN_THUMB, !!(b10 & BIT(1))); in steam_do_deck_input_event()
1541 input_event(input, EV_KEY, BTN_THUMB2, !!(b10 & BIT(2))); in steam_do_deck_input_event()
1542 input_event(input, EV_KEY, BTN_TRIGGER_HAPPY1, !!(b13 & BIT(1))); in steam_do_deck_input_event()
1543 input_event(input, EV_KEY, BTN_TRIGGER_HAPPY2, !!(b13 & BIT(2))); in steam_do_deck_input_event()
1544 input_event(input, EV_KEY, BTN_BASE, !!(b14 & BIT(2))); in steam_do_deck_input_event()
1546 input_sync(input); in steam_do_deck_input_event()
1553 * -------+-------+---------------------------
1554 * 4-7 | u32 | sequence number
1555 * 8-11 | -- | always 0
1556 * 12-13 | u16 | voltage (mV)
1569 battery = rcu_dereference(steam->battery); in steam_do_battery_event()
1571 spin_lock_irqsave(&steam->lock, flags); in steam_do_battery_event()
1572 steam->voltage = volts; in steam_do_battery_event()
1573 steam->battery_charge = batt; in steam_do_battery_event()
1574 spin_unlock_irqrestore(&steam->lock, flags); in steam_do_battery_event()
1585 struct input_dev *input; in steam_raw_event() local
1591 if (steam->client_opened) in steam_raw_event()
1592 hid_input_report(steam->client_hdev, HID_FEATURE_REPORT, in steam_raw_event()
1595 * All messages are size=64, all values little-endian. in steam_raw_event()
1598 * -------+-------------------------------------------- in steam_raw_event()
1599 * 0-1 | always 0x01, 0x00, maybe protocol version? in steam_raw_event()
1602 * 4-n | payload data, depends on the type in steam_raw_event()
1605 * 0x01: input data (60 bytes) in steam_raw_event()
1608 * 0x09: Steam Deck input data (56 bytes) in steam_raw_event()
1616 if (steam->client_opened) in steam_raw_event()
1619 input = rcu_dereference(steam->input); in steam_raw_event()
1620 if (likely(input)) in steam_raw_event()
1621 steam_do_input_event(steam, input, data); in steam_raw_event()
1625 if (steam->client_opened) in steam_raw_event()
1628 input = rcu_dereference(steam->input); in steam_raw_event()
1629 if (likely(input)) in steam_raw_event()
1630 steam_do_deck_input_event(steam, input, data); in steam_raw_event()
1649 if (steam->quirks & STEAM_QUIRK_WIRELESS) { in steam_raw_event()
1651 battery = rcu_dereference(steam->battery); in steam_raw_event()
1679 if (!steam->client_opened) in steam_param_set_lizard_mode()
1716 .name = "hid-steam",