Lines Matching +full:rx +full:- +full:input

1 // SPDX-License-Identifier: GPL-2.0-or-later
4 * Copyright (c) 2011-2013 David Herrmann <dh.herrmann@gmail.com>
19 * re-detection which causes all modules to be unloaded and then reload the
22 * wdata->input is a shared input device. It is always initialized prior to
24 * WIIMOD_FLAG_INPUT, then the input device will get registered after all
27 * called. This guarantees that no input interaction is done, anymore. However,
28 * the wiimote core keeps a reference to the input device so it is freed only
30 * input devices.
35 #include <linux/input.h>
37 #include "hid-wiimote.h"
45 * It uses the shared input device.
64 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_LEFT], in wiimod_keys_in_keys()
66 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_RIGHT], in wiimod_keys_in_keys()
68 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_DOWN], in wiimod_keys_in_keys()
70 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_UP], in wiimod_keys_in_keys()
72 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_PLUS], in wiimod_keys_in_keys()
74 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_TWO], in wiimod_keys_in_keys()
76 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_ONE], in wiimod_keys_in_keys()
78 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_B], in wiimod_keys_in_keys()
80 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_A], in wiimod_keys_in_keys()
82 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_MINUS], in wiimod_keys_in_keys()
84 input_report_key(wdata->input, wiimod_keys_map[WIIPROTO_KEY_HOME], in wiimod_keys_in_keys()
86 input_sync(wdata->input); in wiimod_keys_in_keys()
94 set_bit(EV_KEY, wdata->input->evbit); in wiimod_keys_probe()
96 set_bit(wiimod_keys_map[i], wdata->input->keybit); in wiimod_keys_probe()
112 * force-feedback effects. We provide an FF_RUMBLE memless ff device on the
113 * shared input device if this module is loaded.
125 spin_lock_irq(&wdata->state.lock); in wiimod_rumble_worker()
126 wiiproto_req_rumble(wdata, wdata->state.cache_rumble); in wiimod_rumble_worker()
127 spin_unlock_irq(&wdata->state.lock); in wiimod_rumble_worker()
138 * is set to non-zero then we start the rumble motor. If both are set to in wiimod_rumble_play()
142 if (eff->u.rumble.strong_magnitude || eff->u.rumble.weak_magnitude) in wiimod_rumble_play()
149 wdata->state.cache_rumble = value; in wiimod_rumble_play()
150 schedule_work(&wdata->rumble_worker); in wiimod_rumble_play()
158 INIT_WORK(&wdata->rumble_worker, wiimod_rumble_worker); in wiimod_rumble_probe()
160 set_bit(FF_RUMBLE, wdata->input->ffbit); in wiimod_rumble_probe()
161 if (input_ff_create_memless(wdata->input, NULL, wiimod_rumble_play)) in wiimod_rumble_probe()
162 return -ENOMEM; in wiimod_rumble_probe()
172 cancel_work_sync(&wdata->rumble_worker); in wiimod_rumble_remove()
174 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_rumble_remove()
176 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_rumble_remove()
190 * user-space request.
208 val->intval = POWER_SUPPLY_SCOPE_DEVICE; in wiimod_battery_get_property()
211 return -EINVAL; in wiimod_battery_get_property()
218 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_battery_get_property()
221 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_battery_get_property()
226 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_battery_get_property()
227 state = wdata->state.cmd_battery; in wiimod_battery_get_property()
228 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_battery_get_property()
230 val->intval = state * 100 / 255; in wiimod_battery_get_property()
240 wdata->battery_desc.properties = wiimod_battery_props; in wiimod_battery_probe()
241 wdata->battery_desc.num_properties = ARRAY_SIZE(wiimod_battery_props); in wiimod_battery_probe()
242 wdata->battery_desc.get_property = wiimod_battery_get_property; in wiimod_battery_probe()
243 wdata->battery_desc.type = POWER_SUPPLY_TYPE_BATTERY; in wiimod_battery_probe()
244 wdata->battery_desc.use_for_apm = 0; in wiimod_battery_probe()
245 wdata->battery_desc.name = kasprintf(GFP_KERNEL, "wiimote_battery_%s", in wiimod_battery_probe()
246 wdata->hdev->uniq); in wiimod_battery_probe()
247 if (!wdata->battery_desc.name) in wiimod_battery_probe()
248 return -ENOMEM; in wiimod_battery_probe()
250 wdata->battery = power_supply_register(&wdata->hdev->dev, in wiimod_battery_probe()
251 &wdata->battery_desc, in wiimod_battery_probe()
253 if (IS_ERR(wdata->battery)) { in wiimod_battery_probe()
254 hid_err(wdata->hdev, "cannot register battery device\n"); in wiimod_battery_probe()
255 ret = PTR_ERR(wdata->battery); in wiimod_battery_probe()
259 power_supply_powers(wdata->battery, &wdata->hdev->dev); in wiimod_battery_probe()
263 kfree(wdata->battery_desc.name); in wiimod_battery_probe()
264 wdata->battery_desc.name = NULL; in wiimod_battery_probe()
271 if (!wdata->battery_desc.name) in wiimod_battery_remove()
274 power_supply_unregister(wdata->battery); in wiimod_battery_remove()
275 kfree(wdata->battery_desc.name); in wiimod_battery_remove()
276 wdata->battery_desc.name = NULL; in wiimod_battery_remove()
296 struct device *dev = led_dev->dev->parent; in wiimod_led_get()
303 if (wdata->leds[i] == led_dev) { in wiimod_led_get()
304 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_led_get()
305 value = wdata->state.flags & WIIPROTO_FLAG_LED(i + 1); in wiimod_led_get()
306 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_led_get()
317 struct device *dev = led_dev->dev->parent; in wiimod_led_set()
324 if (wdata->leds[i] == led_dev) { in wiimod_led_set()
326 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_led_set()
327 state = wdata->state.flags; in wiimod_led_set()
332 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_led_set()
341 struct device *dev = &wdata->hdev->dev; in wiimod_led_probe()
350 return -ENOMEM; in wiimod_led_probe()
353 snprintf(name, namesz, "%s:blue:p%lu", dev_name(dev), ops->arg); in wiimod_led_probe()
354 led->name = name; in wiimod_led_probe()
355 led->brightness = 0; in wiimod_led_probe()
356 led->max_brightness = 1; in wiimod_led_probe()
357 led->brightness_get = wiimod_led_get; in wiimod_led_probe()
358 led->brightness_set = wiimod_led_set; in wiimod_led_probe()
360 wdata->leds[ops->arg] = led; in wiimod_led_probe()
365 /* enable LED1 to stop initial LED-blinking */ in wiimod_led_probe()
366 if (ops->arg == 0) { in wiimod_led_probe()
367 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_led_probe()
369 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_led_probe()
375 wdata->leds[ops->arg] = NULL; in wiimod_led_probe()
383 if (!wdata->leds[ops->arg]) in wiimod_led_remove()
386 led_classdev_unregister(wdata->leds[ops->arg]); in wiimod_led_remove()
387 kfree(wdata->leds[ops->arg]); in wiimod_led_remove()
388 wdata->leds[ops->arg] = NULL; in wiimod_led_remove()
422 * it via a separate input device.
430 if (!(wdata->state.flags & WIIPROTO_FLAG_ACCEL)) in wiimod_accel_in_accel()
453 input_report_abs(wdata->accel, ABS_RX, x - 0x200); in wiimod_accel_in_accel()
454 input_report_abs(wdata->accel, ABS_RY, y - 0x200); in wiimod_accel_in_accel()
455 input_report_abs(wdata->accel, ABS_RZ, z - 0x200); in wiimod_accel_in_accel()
456 input_sync(wdata->accel); in wiimod_accel_in_accel()
464 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_accel_open()
466 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_accel_open()
476 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_accel_close()
478 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_accel_close()
486 wdata->accel = input_allocate_device(); in wiimod_accel_probe()
487 if (!wdata->accel) in wiimod_accel_probe()
488 return -ENOMEM; in wiimod_accel_probe()
490 input_set_drvdata(wdata->accel, wdata); in wiimod_accel_probe()
491 wdata->accel->open = wiimod_accel_open; in wiimod_accel_probe()
492 wdata->accel->close = wiimod_accel_close; in wiimod_accel_probe()
493 wdata->accel->dev.parent = &wdata->hdev->dev; in wiimod_accel_probe()
494 wdata->accel->id.bustype = wdata->hdev->bus; in wiimod_accel_probe()
495 wdata->accel->id.vendor = wdata->hdev->vendor; in wiimod_accel_probe()
496 wdata->accel->id.product = wdata->hdev->product; in wiimod_accel_probe()
497 wdata->accel->id.version = wdata->hdev->version; in wiimod_accel_probe()
498 wdata->accel->name = WIIMOTE_NAME " Accelerometer"; in wiimod_accel_probe()
500 set_bit(EV_ABS, wdata->accel->evbit); in wiimod_accel_probe()
501 set_bit(ABS_RX, wdata->accel->absbit); in wiimod_accel_probe()
502 set_bit(ABS_RY, wdata->accel->absbit); in wiimod_accel_probe()
503 set_bit(ABS_RZ, wdata->accel->absbit); in wiimod_accel_probe()
504 input_set_abs_params(wdata->accel, ABS_RX, -500, 500, 2, 4); in wiimod_accel_probe()
505 input_set_abs_params(wdata->accel, ABS_RY, -500, 500, 2, 4); in wiimod_accel_probe()
506 input_set_abs_params(wdata->accel, ABS_RZ, -500, 500, 2, 4); in wiimod_accel_probe()
508 ret = input_register_device(wdata->accel); in wiimod_accel_probe()
510 hid_err(wdata->hdev, "cannot register input device\n"); in wiimod_accel_probe()
517 input_free_device(wdata->accel); in wiimod_accel_probe()
518 wdata->accel = NULL; in wiimod_accel_probe()
525 if (!wdata->accel) in wiimod_accel_remove()
528 input_unregister_device(wdata->accel); in wiimod_accel_remove()
529 wdata->accel = NULL; in wiimod_accel_remove()
544 * power. Therefore, as long as no application uses the IR input device, it is
557 if (!(wdata->state.flags & WIIPROTO_FLAGS_IR)) in wiimod_ir_in_ir()
587 * reordered. This allows to interleave packed and non-packed data to in wiimod_ir_in_ir()
589 * The resulting 10bit X/Y values are passed to the ABS_HAT? input dev. in wiimod_ir_in_ir()
600 input_report_abs(wdata->ir, xid, x); in wiimod_ir_in_ir()
601 input_report_abs(wdata->ir, yid, y); in wiimod_ir_in_ir()
604 input_sync(wdata->ir); in wiimod_ir_in_ir()
618 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_ir_change()
620 if (mode == (wdata->state.flags & WIIPROTO_FLAGS_IR)) { in wiimod_ir_change()
621 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
626 wdata->state.flags &= ~WIIPROTO_FLAGS_IR; in wiimod_ir_change()
630 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
634 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
641 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_ir_change()
644 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
649 if (wdata->state.cmd_err) { in wiimod_ir_change()
650 ret = -EIO; in wiimod_ir_change()
655 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_ir_change()
658 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
663 if (wdata->state.cmd_err) { in wiimod_ir_change()
664 ret = -EIO; in wiimod_ir_change()
708 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_ir_change()
709 wdata->state.flags &= ~WIIPROTO_FLAGS_IR; in wiimod_ir_change()
710 wdata->state.flags |= mode & WIIPROTO_FLAGS_IR; in wiimod_ir_change()
712 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_ir_change()
738 wdata->ir = input_allocate_device(); in wiimod_ir_probe()
739 if (!wdata->ir) in wiimod_ir_probe()
740 return -ENOMEM; in wiimod_ir_probe()
742 input_set_drvdata(wdata->ir, wdata); in wiimod_ir_probe()
743 wdata->ir->open = wiimod_ir_open; in wiimod_ir_probe()
744 wdata->ir->close = wiimod_ir_close; in wiimod_ir_probe()
745 wdata->ir->dev.parent = &wdata->hdev->dev; in wiimod_ir_probe()
746 wdata->ir->id.bustype = wdata->hdev->bus; in wiimod_ir_probe()
747 wdata->ir->id.vendor = wdata->hdev->vendor; in wiimod_ir_probe()
748 wdata->ir->id.product = wdata->hdev->product; in wiimod_ir_probe()
749 wdata->ir->id.version = wdata->hdev->version; in wiimod_ir_probe()
750 wdata->ir->name = WIIMOTE_NAME " IR"; in wiimod_ir_probe()
752 set_bit(EV_ABS, wdata->ir->evbit); in wiimod_ir_probe()
753 set_bit(ABS_HAT0X, wdata->ir->absbit); in wiimod_ir_probe()
754 set_bit(ABS_HAT0Y, wdata->ir->absbit); in wiimod_ir_probe()
755 set_bit(ABS_HAT1X, wdata->ir->absbit); in wiimod_ir_probe()
756 set_bit(ABS_HAT1Y, wdata->ir->absbit); in wiimod_ir_probe()
757 set_bit(ABS_HAT2X, wdata->ir->absbit); in wiimod_ir_probe()
758 set_bit(ABS_HAT2Y, wdata->ir->absbit); in wiimod_ir_probe()
759 set_bit(ABS_HAT3X, wdata->ir->absbit); in wiimod_ir_probe()
760 set_bit(ABS_HAT3Y, wdata->ir->absbit); in wiimod_ir_probe()
761 input_set_abs_params(wdata->ir, ABS_HAT0X, 0, 1023, 2, 4); in wiimod_ir_probe()
762 input_set_abs_params(wdata->ir, ABS_HAT0Y, 0, 767, 2, 4); in wiimod_ir_probe()
763 input_set_abs_params(wdata->ir, ABS_HAT1X, 0, 1023, 2, 4); in wiimod_ir_probe()
764 input_set_abs_params(wdata->ir, ABS_HAT1Y, 0, 767, 2, 4); in wiimod_ir_probe()
765 input_set_abs_params(wdata->ir, ABS_HAT2X, 0, 1023, 2, 4); in wiimod_ir_probe()
766 input_set_abs_params(wdata->ir, ABS_HAT2Y, 0, 767, 2, 4); in wiimod_ir_probe()
767 input_set_abs_params(wdata->ir, ABS_HAT3X, 0, 1023, 2, 4); in wiimod_ir_probe()
768 input_set_abs_params(wdata->ir, ABS_HAT3Y, 0, 767, 2, 4); in wiimod_ir_probe()
770 ret = input_register_device(wdata->ir); in wiimod_ir_probe()
772 hid_err(wdata->hdev, "cannot register input device\n"); in wiimod_ir_probe()
779 input_free_device(wdata->ir); in wiimod_ir_probe()
780 wdata->ir = NULL; in wiimod_ir_probe()
787 if (!wdata->ir) in wiimod_ir_remove()
790 input_unregister_device(wdata->ir); in wiimod_ir_remove()
791 wdata->ir = NULL; in wiimod_ir_remove()
825 * -----+----------+---------+---------+----+-----+ in wiimod_nunchuk_in_ext()
828 * -----+----------+---------+---------+----+-----+ in wiimod_nunchuk_in_ext()
832 * -----+----------+---------+---------+----+-----+ in wiimod_nunchuk_in_ext()
834 * -----+----------+---------+---------+----+-----+ in wiimod_nunchuk_in_ext()
842 * -----+-----------------------------------+-----+ in wiimod_nunchuk_in_ext()
844 * -----+--------+-----+-----+----+----+----+-----+ in wiimod_nunchuk_in_ext()
846 * -----+--------+-----+-----+----+----+----+-----+ in wiimod_nunchuk_in_ext()
856 bx -= 128; in wiimod_nunchuk_in_ext()
857 by -= 128; in wiimod_nunchuk_in_ext()
863 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_nunchuk_in_ext()
874 x -= 0x200; in wiimod_nunchuk_in_ext()
875 y -= 0x200; in wiimod_nunchuk_in_ext()
876 z -= 0x200; in wiimod_nunchuk_in_ext()
878 input_report_abs(wdata->extension.input, ABS_HAT0X, bx); in wiimod_nunchuk_in_ext()
879 input_report_abs(wdata->extension.input, ABS_HAT0Y, by); in wiimod_nunchuk_in_ext()
881 input_report_abs(wdata->extension.input, ABS_RX, x); in wiimod_nunchuk_in_ext()
882 input_report_abs(wdata->extension.input, ABS_RY, y); in wiimod_nunchuk_in_ext()
883 input_report_abs(wdata->extension.input, ABS_RZ, z); in wiimod_nunchuk_in_ext()
885 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_nunchuk_in_ext()
886 input_report_key(wdata->extension.input, in wiimod_nunchuk_in_ext()
889 input_report_key(wdata->extension.input, in wiimod_nunchuk_in_ext()
893 input_report_key(wdata->extension.input, in wiimod_nunchuk_in_ext()
896 input_report_key(wdata->extension.input, in wiimod_nunchuk_in_ext()
901 input_sync(wdata->extension.input); in wiimod_nunchuk_in_ext()
909 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_nunchuk_open()
910 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_nunchuk_open()
912 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_nunchuk_open()
922 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_nunchuk_close()
923 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_nunchuk_close()
925 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_nunchuk_close()
933 wdata->extension.input = input_allocate_device(); in wiimod_nunchuk_probe()
934 if (!wdata->extension.input) in wiimod_nunchuk_probe()
935 return -ENOMEM; in wiimod_nunchuk_probe()
937 input_set_drvdata(wdata->extension.input, wdata); in wiimod_nunchuk_probe()
938 wdata->extension.input->open = wiimod_nunchuk_open; in wiimod_nunchuk_probe()
939 wdata->extension.input->close = wiimod_nunchuk_close; in wiimod_nunchuk_probe()
940 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_nunchuk_probe()
941 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_nunchuk_probe()
942 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_nunchuk_probe()
943 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_nunchuk_probe()
944 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_nunchuk_probe()
945 wdata->extension.input->name = WIIMOTE_NAME " Nunchuk"; in wiimod_nunchuk_probe()
947 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_nunchuk_probe()
950 wdata->extension.input->keybit); in wiimod_nunchuk_probe()
952 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_nunchuk_probe()
953 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
954 set_bit(ABS_HAT0Y, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
955 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
956 ABS_HAT0X, -120, 120, 2, 4); in wiimod_nunchuk_probe()
957 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
958 ABS_HAT0Y, -120, 120, 2, 4); in wiimod_nunchuk_probe()
959 set_bit(ABS_RX, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
960 set_bit(ABS_RY, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
961 set_bit(ABS_RZ, wdata->extension.input->absbit); in wiimod_nunchuk_probe()
962 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
963 ABS_RX, -500, 500, 2, 4); in wiimod_nunchuk_probe()
964 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
965 ABS_RY, -500, 500, 2, 4); in wiimod_nunchuk_probe()
966 input_set_abs_params(wdata->extension.input, in wiimod_nunchuk_probe()
967 ABS_RZ, -500, 500, 2, 4); in wiimod_nunchuk_probe()
969 ret = input_register_device(wdata->extension.input); in wiimod_nunchuk_probe()
976 input_free_device(wdata->extension.input); in wiimod_nunchuk_probe()
977 wdata->extension.input = NULL; in wiimod_nunchuk_probe()
984 if (!wdata->extension.input) in wiimod_nunchuk_remove()
987 input_unregister_device(wdata->extension.input); in wiimod_nunchuk_remove()
988 wdata->extension.input = NULL; in wiimod_nunchuk_remove()
1002 * gamecube-like controller that can be hotplugged on the Wii Remote.
1046 __s8 rx, ry, lx, ly, lt, rt; in wiimod_classic_in_ext() local
1049 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_classic_in_ext()
1050 * 1 | RX <5:4> | LX <5:0> | in wiimod_classic_in_ext()
1051 * 2 | RX <3:2> | LY <5:0> | in wiimod_classic_in_ext()
1052 * -----+-----+-----+-----+-----------------------------+ in wiimod_classic_in_ext()
1053 * 3 |RX<1>| LT <5:4> | RY <5:1> | in wiimod_classic_in_ext()
1054 * -----+-----+-----------+-----------------------------+ in wiimod_classic_in_ext()
1056 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_classic_in_ext()
1057 * 5 | BDR | BDD | BLT | B- | BH | B+ | BRT | 1 | in wiimod_classic_in_ext()
1058 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_classic_in_ext()
1060 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_classic_in_ext()
1062 * RX and RY are right analog stick in wiimod_classic_in_ext()
1067 * BDR, BDD, BDL, BDU form the D-Pad with right, down, left, up buttons in wiimod_classic_in_ext()
1069 * B-, BH, B+ are +, HOME and - buttons in wiimod_classic_in_ext()
1071 * LSB of RX, RY, LT, and RT are not transmitted and always 0. in wiimod_classic_in_ext()
1075 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_classic_in_ext()
1076 * 1 | RX <5:4> | LX <5:1> | BDU | in wiimod_classic_in_ext()
1077 * 2 | RX <3:2> | LY <5:1> | BDL | in wiimod_classic_in_ext()
1078 * -----+-----+-----+-----+-----------------------+-----+ in wiimod_classic_in_ext()
1079 * 3 |RX<1>| LT <5:4> | RY <5:1> | in wiimod_classic_in_ext()
1080 * -----+-----+-----------+-----------------------------+ in wiimod_classic_in_ext()
1082 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_classic_in_ext()
1083 * 5 | BDR | BDD | BLT | B- | BH | B+ | BRT | EXT | in wiimod_classic_in_ext()
1084 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_classic_in_ext()
1086 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_classic_in_ext()
1091 static const s8 digital_to_analog[3] = {0x20, 0, -0x20}; in wiimod_classic_in_ext()
1093 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_classic_in_ext()
1095 lx = digital_to_analog[1 - !(ext[4] & 0x80) in wiimod_classic_in_ext()
1097 ly = digital_to_analog[1 - !(ext[4] & 0x40) in wiimod_classic_in_ext()
1100 lx = (ext[0] & 0x3e) - 0x20; in wiimod_classic_in_ext()
1101 ly = (ext[1] & 0x3e) - 0x20; in wiimod_classic_in_ext()
1105 lx = digital_to_analog[1 - !(ext[4] & 0x80) in wiimod_classic_in_ext()
1107 ly = digital_to_analog[1 - !(ext[4] & 0x40) in wiimod_classic_in_ext()
1110 lx = (ext[0] & 0x3f) - 0x20; in wiimod_classic_in_ext()
1111 ly = (ext[1] & 0x3f) - 0x20; in wiimod_classic_in_ext()
1115 rx = (ext[0] >> 3) & 0x18; in wiimod_classic_in_ext()
1116 rx |= (ext[1] >> 5) & 0x06; in wiimod_classic_in_ext()
1117 rx |= (ext[2] >> 7) & 0x01; in wiimod_classic_in_ext()
1124 rx <<= 1; in wiimod_classic_in_ext()
1129 input_report_abs(wdata->extension.input, ABS_HAT1X, lx); in wiimod_classic_in_ext()
1130 input_report_abs(wdata->extension.input, ABS_HAT1Y, ly); in wiimod_classic_in_ext()
1131 input_report_abs(wdata->extension.input, ABS_HAT2X, rx - 0x20); in wiimod_classic_in_ext()
1132 input_report_abs(wdata->extension.input, ABS_HAT2Y, ry - 0x20); in wiimod_classic_in_ext()
1133 input_report_abs(wdata->extension.input, ABS_HAT3X, rt); in wiimod_classic_in_ext()
1134 input_report_abs(wdata->extension.input, ABS_HAT3Y, lt); in wiimod_classic_in_ext()
1136 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1139 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1142 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1145 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1148 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1151 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1154 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1157 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1160 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1163 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1166 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1171 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1174 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1178 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_classic_in_ext()
1179 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1182 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1186 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1189 input_report_key(wdata->extension.input, in wiimod_classic_in_ext()
1195 input_sync(wdata->extension.input); in wiimod_classic_in_ext()
1203 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_classic_open()
1204 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_classic_open()
1206 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_classic_open()
1216 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_classic_close()
1217 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_classic_close()
1219 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_classic_close()
1227 wdata->extension.input = input_allocate_device(); in wiimod_classic_probe()
1228 if (!wdata->extension.input) in wiimod_classic_probe()
1229 return -ENOMEM; in wiimod_classic_probe()
1231 input_set_drvdata(wdata->extension.input, wdata); in wiimod_classic_probe()
1232 wdata->extension.input->open = wiimod_classic_open; in wiimod_classic_probe()
1233 wdata->extension.input->close = wiimod_classic_close; in wiimod_classic_probe()
1234 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_classic_probe()
1235 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_classic_probe()
1236 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_classic_probe()
1237 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_classic_probe()
1238 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_classic_probe()
1239 wdata->extension.input->name = WIIMOTE_NAME " Classic Controller"; in wiimod_classic_probe()
1241 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_classic_probe()
1244 wdata->extension.input->keybit); in wiimod_classic_probe()
1246 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_classic_probe()
1247 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_classic_probe()
1248 set_bit(ABS_HAT1Y, wdata->extension.input->absbit); in wiimod_classic_probe()
1249 set_bit(ABS_HAT2X, wdata->extension.input->absbit); in wiimod_classic_probe()
1250 set_bit(ABS_HAT2Y, wdata->extension.input->absbit); in wiimod_classic_probe()
1251 set_bit(ABS_HAT3X, wdata->extension.input->absbit); in wiimod_classic_probe()
1252 set_bit(ABS_HAT3Y, wdata->extension.input->absbit); in wiimod_classic_probe()
1253 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1254 ABS_HAT1X, -30, 30, 1, 1); in wiimod_classic_probe()
1255 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1256 ABS_HAT1Y, -30, 30, 1, 1); in wiimod_classic_probe()
1257 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1258 ABS_HAT2X, -30, 30, 1, 1); in wiimod_classic_probe()
1259 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1260 ABS_HAT2Y, -30, 30, 1, 1); in wiimod_classic_probe()
1261 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1262 ABS_HAT3X, -30, 30, 1, 1); in wiimod_classic_probe()
1263 input_set_abs_params(wdata->extension.input, in wiimod_classic_probe()
1264 ABS_HAT3Y, -30, 30, 1, 1); in wiimod_classic_probe()
1266 ret = input_register_device(wdata->extension.input); in wiimod_classic_probe()
1273 input_free_device(wdata->extension.input); in wiimod_classic_probe()
1274 wdata->extension.input = NULL; in wiimod_classic_probe()
1281 if (!wdata->extension.input) in wiimod_classic_remove()
1284 input_unregister_device(wdata->extension.input); in wiimod_classic_remove()
1285 wdata->extension.input = NULL; in wiimod_classic_remove()
1300 * balance-board data is sent via a standard Wii Remote extension. All other
1301 * data for non-present hardware is zeroed out.
1311 input_report_key(wdata->extension.input, BTN_A, in wiimod_bboard_in_keys()
1313 input_sync(wdata->extension.input); in wiimod_bboard_in_keys()
1321 struct wiimote_state *s = &wdata->state; in wiimod_bboard_in_ext()
1327 * -----+--------------------------+ in wiimod_bboard_in_ext()
1330 * -----+--------------------------+ in wiimod_bboard_in_ext()
1333 * -----+--------------------------+ in wiimod_bboard_in_ext()
1336 * -----+--------------------------+ in wiimod_bboard_in_ext()
1339 * -----+--------------------------+ in wiimod_bboard_in_ext()
1341 * These values represent the weight-measurements of the Wii-balance in wiimod_bboard_in_ext()
1344 * The balance-board is never reported interleaved with motionp. in wiimod_bboard_in_ext()
1365 if (val[i] <= s->calib_bboard[i][0]) { in wiimod_bboard_in_ext()
1367 } else if (val[i] < s->calib_bboard[i][1]) { in wiimod_bboard_in_ext()
1368 tmp = val[i] - s->calib_bboard[i][0]; in wiimod_bboard_in_ext()
1370 div = s->calib_bboard[i][1] - s->calib_bboard[i][0]; in wiimod_bboard_in_ext()
1373 tmp = val[i] - s->calib_bboard[i][1]; in wiimod_bboard_in_ext()
1375 div = s->calib_bboard[i][2] - s->calib_bboard[i][1]; in wiimod_bboard_in_ext()
1382 input_report_abs(wdata->extension.input, ABS_HAT0X, val[0]); in wiimod_bboard_in_ext()
1383 input_report_abs(wdata->extension.input, ABS_HAT0Y, val[1]); in wiimod_bboard_in_ext()
1384 input_report_abs(wdata->extension.input, ABS_HAT1X, val[2]); in wiimod_bboard_in_ext()
1385 input_report_abs(wdata->extension.input, ABS_HAT1Y, val[3]); in wiimod_bboard_in_ext()
1386 input_sync(wdata->extension.input); in wiimod_bboard_in_ext()
1394 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_bboard_open()
1395 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_bboard_open()
1397 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_bboard_open()
1407 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_bboard_close()
1408 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_bboard_close()
1410 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_bboard_close()
1429 return ret < 0 ? ret : -EIO; in wiimod_bboard_calib_show()
1434 return ret < 0 ? ret : -EIO; in wiimod_bboard_calib_show()
1439 spin_lock_irq(&wdata->state.lock); in wiimod_bboard_calib_show()
1443 wdata->state.calib_bboard[j][i] = buf[offs]; in wiimod_bboard_calib_show()
1444 wdata->state.calib_bboard[j][i] <<= 8; in wiimod_bboard_calib_show()
1445 wdata->state.calib_bboard[j][i] |= buf[offs + 1]; in wiimod_bboard_calib_show()
1449 spin_unlock_irq(&wdata->state.lock); in wiimod_bboard_calib_show()
1454 val = wdata->state.calib_bboard[j][i]; in wiimod_bboard_calib_show()
1478 return ret < 0 ? ret : -EIO; in wiimod_bboard_probe()
1483 return ret < 0 ? ret : -EIO; in wiimod_bboard_probe()
1491 wdata->state.calib_bboard[j][i] = buf[offs]; in wiimod_bboard_probe()
1492 wdata->state.calib_bboard[j][i] <<= 8; in wiimod_bboard_probe()
1493 wdata->state.calib_bboard[j][i] |= buf[offs + 1]; in wiimod_bboard_probe()
1498 wdata->extension.input = input_allocate_device(); in wiimod_bboard_probe()
1499 if (!wdata->extension.input) in wiimod_bboard_probe()
1500 return -ENOMEM; in wiimod_bboard_probe()
1502 ret = device_create_file(&wdata->hdev->dev, in wiimod_bboard_probe()
1505 hid_err(wdata->hdev, "cannot create sysfs attribute\n"); in wiimod_bboard_probe()
1509 input_set_drvdata(wdata->extension.input, wdata); in wiimod_bboard_probe()
1510 wdata->extension.input->open = wiimod_bboard_open; in wiimod_bboard_probe()
1511 wdata->extension.input->close = wiimod_bboard_close; in wiimod_bboard_probe()
1512 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_bboard_probe()
1513 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_bboard_probe()
1514 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_bboard_probe()
1515 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_bboard_probe()
1516 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_bboard_probe()
1517 wdata->extension.input->name = WIIMOTE_NAME " Balance Board"; in wiimod_bboard_probe()
1519 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_bboard_probe()
1520 set_bit(BTN_A, wdata->extension.input->keybit); in wiimod_bboard_probe()
1522 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_bboard_probe()
1523 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_bboard_probe()
1524 set_bit(ABS_HAT0Y, wdata->extension.input->absbit); in wiimod_bboard_probe()
1525 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_bboard_probe()
1526 set_bit(ABS_HAT1Y, wdata->extension.input->absbit); in wiimod_bboard_probe()
1527 input_set_abs_params(wdata->extension.input, in wiimod_bboard_probe()
1529 input_set_abs_params(wdata->extension.input, in wiimod_bboard_probe()
1531 input_set_abs_params(wdata->extension.input, in wiimod_bboard_probe()
1533 input_set_abs_params(wdata->extension.input, in wiimod_bboard_probe()
1536 ret = input_register_device(wdata->extension.input); in wiimod_bboard_probe()
1543 device_remove_file(&wdata->hdev->dev, in wiimod_bboard_probe()
1546 input_free_device(wdata->extension.input); in wiimod_bboard_probe()
1547 wdata->extension.input = NULL; in wiimod_bboard_probe()
1554 if (!wdata->extension.input) in wiimod_bboard_remove()
1557 input_unregister_device(wdata->extension.input); in wiimod_bboard_remove()
1558 wdata->extension.input = NULL; in wiimod_bboard_remove()
1559 device_remove_file(&wdata->hdev->dev, in wiimod_bboard_remove()
1625 __s16 rx, ry, lx, ly; in wiimod_pro_in_ext() local
1628 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_pro_in_ext()
1630 * -----+-----------------------+-----------------------+ in wiimod_pro_in_ext()
1632 * -----+-----------------------+-----------------------+ in wiimod_pro_in_ext()
1633 * 3 | RX <7:0> | in wiimod_pro_in_ext()
1634 * -----+-----------------------+-----------------------+ in wiimod_pro_in_ext()
1635 * 4 | 0 0 0 0 | RX <11:8> | in wiimod_pro_in_ext()
1636 * -----+-----------------------+-----------------------+ in wiimod_pro_in_ext()
1638 * -----+-----------------------+-----------------------+ in wiimod_pro_in_ext()
1640 * -----+-----------------------+-----------------------+ in wiimod_pro_in_ext()
1642 * -----+-----------------------+-----------------------+ in wiimod_pro_in_ext()
1644 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_pro_in_ext()
1645 * 9 | BDR | BDD | BLT | B- | BH | B+ | BRT | 1 | in wiimod_pro_in_ext()
1646 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_pro_in_ext()
1648 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_pro_in_ext()
1650 * -----+-----+-----------------+-----------+-----+-----+ in wiimod_pro_in_ext()
1651 * All buttons are low-active (0 if pressed) in wiimod_pro_in_ext()
1652 * RX and RY are right analog stick in wiimod_pro_in_ext()
1655 * BDR, BDD, BDL, BDU form the D-Pad with right, down, left, up buttons in wiimod_pro_in_ext()
1657 * B-, BH, B+ are +, HOME and - buttons in wiimod_pro_in_ext()
1669 rx = (ext[2] & 0xff) | ((ext[3] & 0x0f) << 8); in wiimod_pro_in_ext()
1673 /* zero-point offsets */ in wiimod_pro_in_ext()
1674 lx -= 0x800; in wiimod_pro_in_ext()
1675 ly = 0x800 - ly; in wiimod_pro_in_ext()
1676 rx -= 0x800; in wiimod_pro_in_ext()
1677 ry = 0x800 - ry; in wiimod_pro_in_ext()
1681 * null-position of the analog sticks. Users can retrigger calibration in wiimod_pro_in_ext()
1684 if (!(wdata->state.flags & WIIPROTO_FLAG_PRO_CALIB_DONE)) { in wiimod_pro_in_ext()
1685 wdata->state.flags |= WIIPROTO_FLAG_PRO_CALIB_DONE; in wiimod_pro_in_ext()
1687 wdata->state.calib_pro_sticks[0] = -lx; in wiimod_pro_in_ext()
1689 wdata->state.calib_pro_sticks[1] = -ly; in wiimod_pro_in_ext()
1690 if (abs(rx) < 500) in wiimod_pro_in_ext()
1691 wdata->state.calib_pro_sticks[2] = -rx; in wiimod_pro_in_ext()
1693 wdata->state.calib_pro_sticks[3] = -ry; in wiimod_pro_in_ext()
1697 lx += wdata->state.calib_pro_sticks[0]; in wiimod_pro_in_ext()
1698 ly += wdata->state.calib_pro_sticks[1]; in wiimod_pro_in_ext()
1699 rx += wdata->state.calib_pro_sticks[2]; in wiimod_pro_in_ext()
1700 ry += wdata->state.calib_pro_sticks[3]; in wiimod_pro_in_ext()
1702 input_report_abs(wdata->extension.input, ABS_X, lx); in wiimod_pro_in_ext()
1703 input_report_abs(wdata->extension.input, ABS_Y, ly); in wiimod_pro_in_ext()
1704 input_report_abs(wdata->extension.input, ABS_RX, rx); in wiimod_pro_in_ext()
1705 input_report_abs(wdata->extension.input, ABS_RY, ry); in wiimod_pro_in_ext()
1707 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1710 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1713 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1716 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1719 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1722 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1725 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1729 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1732 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1735 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1738 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1741 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1744 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1747 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1750 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1754 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1757 input_report_key(wdata->extension.input, in wiimod_pro_in_ext()
1761 input_sync(wdata->extension.input); in wiimod_pro_in_ext()
1769 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_pro_open()
1770 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_pro_open()
1772 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_pro_open()
1782 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_pro_close()
1783 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_pro_close()
1785 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_pro_close()
1796 * is set to non-zero then we start the rumble motor. If both are set to in wiimod_pro_play()
1800 if (eff->u.rumble.strong_magnitude || eff->u.rumble.weak_magnitude) in wiimod_pro_play()
1807 wdata->state.cache_rumble = value; in wiimod_pro_play()
1808 schedule_work(&wdata->rumble_worker); in wiimod_pro_play()
1821 r += sprintf(&out[r], "%+06hd:", wdata->state.calib_pro_sticks[0]); in wiimod_pro_calib_show()
1822 r += sprintf(&out[r], "%+06hd ", wdata->state.calib_pro_sticks[1]); in wiimod_pro_calib_show()
1823 r += sprintf(&out[r], "%+06hd:", wdata->state.calib_pro_sticks[2]); in wiimod_pro_calib_show()
1824 r += sprintf(&out[r], "%+06hd\n", wdata->state.calib_pro_sticks[3]); in wiimod_pro_calib_show()
1838 spin_lock_irq(&wdata->state.lock); in wiimod_pro_calib_store()
1839 wdata->state.flags &= ~WIIPROTO_FLAG_PRO_CALIB_DONE; in wiimod_pro_calib_store()
1840 spin_unlock_irq(&wdata->state.lock); in wiimod_pro_calib_store()
1844 return -EINVAL; in wiimod_pro_calib_store()
1846 spin_lock_irq(&wdata->state.lock); in wiimod_pro_calib_store()
1847 wdata->state.flags |= WIIPROTO_FLAG_PRO_CALIB_DONE; in wiimod_pro_calib_store()
1848 spin_unlock_irq(&wdata->state.lock); in wiimod_pro_calib_store()
1850 wdata->state.calib_pro_sticks[0] = x1; in wiimod_pro_calib_store()
1851 wdata->state.calib_pro_sticks[1] = y1; in wiimod_pro_calib_store()
1852 wdata->state.calib_pro_sticks[2] = x2; in wiimod_pro_calib_store()
1853 wdata->state.calib_pro_sticks[3] = y2; in wiimod_pro_calib_store()
1868 INIT_WORK(&wdata->rumble_worker, wiimod_rumble_worker); in wiimod_pro_probe()
1869 wdata->state.calib_pro_sticks[0] = 0; in wiimod_pro_probe()
1870 wdata->state.calib_pro_sticks[1] = 0; in wiimod_pro_probe()
1871 wdata->state.calib_pro_sticks[2] = 0; in wiimod_pro_probe()
1872 wdata->state.calib_pro_sticks[3] = 0; in wiimod_pro_probe()
1874 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_pro_probe()
1875 wdata->state.flags &= ~WIIPROTO_FLAG_PRO_CALIB_DONE; in wiimod_pro_probe()
1876 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_pro_probe()
1878 wdata->extension.input = input_allocate_device(); in wiimod_pro_probe()
1879 if (!wdata->extension.input) in wiimod_pro_probe()
1880 return -ENOMEM; in wiimod_pro_probe()
1882 set_bit(FF_RUMBLE, wdata->extension.input->ffbit); in wiimod_pro_probe()
1883 input_set_drvdata(wdata->extension.input, wdata); in wiimod_pro_probe()
1885 if (input_ff_create_memless(wdata->extension.input, NULL, in wiimod_pro_probe()
1887 ret = -ENOMEM; in wiimod_pro_probe()
1891 ret = device_create_file(&wdata->hdev->dev, in wiimod_pro_probe()
1894 hid_err(wdata->hdev, "cannot create sysfs attribute\n"); in wiimod_pro_probe()
1898 wdata->extension.input->open = wiimod_pro_open; in wiimod_pro_probe()
1899 wdata->extension.input->close = wiimod_pro_close; in wiimod_pro_probe()
1900 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_pro_probe()
1901 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_pro_probe()
1902 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_pro_probe()
1903 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_pro_probe()
1904 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_pro_probe()
1905 wdata->extension.input->name = WIIMOTE_NAME " Pro Controller"; in wiimod_pro_probe()
1907 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_pro_probe()
1910 wdata->extension.input->keybit); in wiimod_pro_probe()
1912 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_pro_probe()
1913 set_bit(ABS_X, wdata->extension.input->absbit); in wiimod_pro_probe()
1914 set_bit(ABS_Y, wdata->extension.input->absbit); in wiimod_pro_probe()
1915 set_bit(ABS_RX, wdata->extension.input->absbit); in wiimod_pro_probe()
1916 set_bit(ABS_RY, wdata->extension.input->absbit); in wiimod_pro_probe()
1917 input_set_abs_params(wdata->extension.input, in wiimod_pro_probe()
1918 ABS_X, -0x400, 0x400, 4, 100); in wiimod_pro_probe()
1919 input_set_abs_params(wdata->extension.input, in wiimod_pro_probe()
1920 ABS_Y, -0x400, 0x400, 4, 100); in wiimod_pro_probe()
1921 input_set_abs_params(wdata->extension.input, in wiimod_pro_probe()
1922 ABS_RX, -0x400, 0x400, 4, 100); in wiimod_pro_probe()
1923 input_set_abs_params(wdata->extension.input, in wiimod_pro_probe()
1924 ABS_RY, -0x400, 0x400, 4, 100); in wiimod_pro_probe()
1926 ret = input_register_device(wdata->extension.input); in wiimod_pro_probe()
1933 device_remove_file(&wdata->hdev->dev, in wiimod_pro_probe()
1936 input_free_device(wdata->extension.input); in wiimod_pro_probe()
1937 wdata->extension.input = NULL; in wiimod_pro_probe()
1946 if (!wdata->extension.input) in wiimod_pro_remove()
1949 input_unregister_device(wdata->extension.input); in wiimod_pro_remove()
1950 wdata->extension.input = NULL; in wiimod_pro_remove()
1951 cancel_work_sync(&wdata->rumble_worker); in wiimod_pro_remove()
1952 device_remove_file(&wdata->hdev->dev, in wiimod_pro_remove()
1955 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_pro_remove()
1957 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_pro_remove()
1970 * Guitar-Hero, Rock-Band and other games came bundled with drums which can
1971 * be plugged as extension to a Wiimote. Drum-reports are still not entirely
1974 * input device.
1987 input_report_abs(wdata->extension.input, code, *store); in wiimod_drums_report_pressure()
1990 input_report_abs(wdata->extension.input, code, *store); in wiimod_drums_report_pressure()
2000 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2003 * -----+-----+-----+-----------------------------+-----+ in wiimod_drums_in_ext()
2005 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2007 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2008 * 5 | ? | 1 | 1 | B- | 1 | B+ | 1 | ? | in wiimod_drums_in_ext()
2009 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2011 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2016 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2019 * -----+-----+-----+-----------------------------+-----+ in wiimod_drums_in_ext()
2021 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2023 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2024 * 5 | ? | 1 | 1 | B- | 1 | B+ | 1 |XXXXX| in wiimod_drums_in_ext()
2025 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2027 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_drums_in_ext()
2030 pressure = 7 - (ext[3] >> 5); in wiimod_drums_in_ext()
2045 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_drums_in_ext()
2051 o, &wdata->state.pressure_drums[0], in wiimod_drums_in_ext()
2054 r, &wdata->state.pressure_drums[1], in wiimod_drums_in_ext()
2057 y, &wdata->state.pressure_drums[2], in wiimod_drums_in_ext()
2060 g, &wdata->state.pressure_drums[3], in wiimod_drums_in_ext()
2063 b, &wdata->state.pressure_drums[4], in wiimod_drums_in_ext()
2066 /* Bass shares pressure with hi-hat (set via hhp) */ in wiimod_drums_in_ext()
2068 bass, &wdata->state.pressure_drums[5], in wiimod_drums_in_ext()
2070 /* Hi-hat has no on/off values, just pressure. Force to off/0. */ in wiimod_drums_in_ext()
2072 0, &wdata->state.pressure_drums[6], in wiimod_drums_in_ext()
2075 input_report_abs(wdata->extension.input, ABS_X, sx - 0x20); in wiimod_drums_in_ext()
2076 input_report_abs(wdata->extension.input, ABS_Y, sy - 0x20); in wiimod_drums_in_ext()
2078 input_report_key(wdata->extension.input, BTN_START, bp); in wiimod_drums_in_ext()
2079 input_report_key(wdata->extension.input, BTN_SELECT, bm); in wiimod_drums_in_ext()
2081 input_sync(wdata->extension.input); in wiimod_drums_in_ext()
2089 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_drums_open()
2090 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_drums_open()
2092 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_drums_open()
2102 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_drums_close()
2103 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_drums_close()
2105 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_drums_close()
2113 wdata->extension.input = input_allocate_device(); in wiimod_drums_probe()
2114 if (!wdata->extension.input) in wiimod_drums_probe()
2115 return -ENOMEM; in wiimod_drums_probe()
2117 input_set_drvdata(wdata->extension.input, wdata); in wiimod_drums_probe()
2118 wdata->extension.input->open = wiimod_drums_open; in wiimod_drums_probe()
2119 wdata->extension.input->close = wiimod_drums_close; in wiimod_drums_probe()
2120 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_drums_probe()
2121 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_drums_probe()
2122 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_drums_probe()
2123 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_drums_probe()
2124 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_drums_probe()
2125 wdata->extension.input->name = WIIMOTE_NAME " Drums"; in wiimod_drums_probe()
2127 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_drums_probe()
2128 set_bit(BTN_START, wdata->extension.input->keybit); in wiimod_drums_probe()
2129 set_bit(BTN_SELECT, wdata->extension.input->keybit); in wiimod_drums_probe()
2131 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_drums_probe()
2132 set_bit(ABS_X, wdata->extension.input->absbit); in wiimod_drums_probe()
2133 set_bit(ABS_Y, wdata->extension.input->absbit); in wiimod_drums_probe()
2134 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_drums_probe()
2135 set_bit(ABS_HAT0Y, wdata->extension.input->absbit); in wiimod_drums_probe()
2136 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_drums_probe()
2137 set_bit(ABS_HAT2X, wdata->extension.input->absbit); in wiimod_drums_probe()
2138 set_bit(ABS_HAT2Y, wdata->extension.input->absbit); in wiimod_drums_probe()
2139 set_bit(ABS_HAT3X, wdata->extension.input->absbit); in wiimod_drums_probe()
2140 set_bit(ABS_HAT3Y, wdata->extension.input->absbit); in wiimod_drums_probe()
2141 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2142 ABS_X, -32, 31, 1, 1); in wiimod_drums_probe()
2143 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2144 ABS_Y, -32, 31, 1, 1); in wiimod_drums_probe()
2145 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2147 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2149 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2151 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2153 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2155 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2157 input_set_abs_params(wdata->extension.input, in wiimod_drums_probe()
2160 ret = input_register_device(wdata->extension.input); in wiimod_drums_probe()
2167 input_free_device(wdata->extension.input); in wiimod_drums_probe()
2168 wdata->extension.input = NULL; in wiimod_drums_probe()
2175 if (!wdata->extension.input) in wiimod_drums_remove()
2178 input_unregister_device(wdata->extension.input); in wiimod_drums_remove()
2179 wdata->extension.input = NULL; in wiimod_drums_remove()
2192 * Guitar-Hero, Rock-Band and other games came bundled with guitars which can
2195 * input device.
2228 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_guitar_in_ext()
2231 * -----+-----+-----+-----+-----------------------------+ in wiimod_guitar_in_ext()
2233 * -----+-----+-----+-----+-----------------------------+ in wiimod_guitar_in_ext()
2235 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_guitar_in_ext()
2236 * 5 | 1 | BD | 1 | B- | 1 | B+ | 1 | 1 | in wiimod_guitar_in_ext()
2237 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_guitar_in_ext()
2239 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_guitar_in_ext()
2244 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_guitar_in_ext()
2247 * -----+-----+-----+-----+-----------------------+-----+ in wiimod_guitar_in_ext()
2249 * -----+-----+-----+-----+-----------------------------+ in wiimod_guitar_in_ext()
2251 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_guitar_in_ext()
2252 * 5 | 1 | BD | 1 | B- | 1 | B+ | 1 |XXXXX| in wiimod_guitar_in_ext()
2253 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_guitar_in_ext()
2255 * -----+-----+-----+-----+-----+-----+-----+-----+-----+ in wiimod_guitar_in_ext()
2272 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_guitar_in_ext()
2278 input_report_abs(wdata->extension.input, ABS_X, sx - 0x20); in wiimod_guitar_in_ext()
2279 input_report_abs(wdata->extension.input, ABS_Y, sy - 0x20); in wiimod_guitar_in_ext()
2280 input_report_abs(wdata->extension.input, ABS_HAT0X, tb); in wiimod_guitar_in_ext()
2281 input_report_abs(wdata->extension.input, ABS_HAT1X, wb - 0x10); in wiimod_guitar_in_ext()
2283 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2286 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2289 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2292 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2295 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2298 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2301 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2304 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2307 input_report_key(wdata->extension.input, in wiimod_guitar_in_ext()
2311 input_sync(wdata->extension.input); in wiimod_guitar_in_ext()
2319 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_guitar_open()
2320 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_guitar_open()
2322 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_guitar_open()
2332 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_guitar_close()
2333 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_guitar_close()
2335 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_guitar_close()
2343 wdata->extension.input = input_allocate_device(); in wiimod_guitar_probe()
2344 if (!wdata->extension.input) in wiimod_guitar_probe()
2345 return -ENOMEM; in wiimod_guitar_probe()
2347 input_set_drvdata(wdata->extension.input, wdata); in wiimod_guitar_probe()
2348 wdata->extension.input->open = wiimod_guitar_open; in wiimod_guitar_probe()
2349 wdata->extension.input->close = wiimod_guitar_close; in wiimod_guitar_probe()
2350 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_guitar_probe()
2351 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_guitar_probe()
2352 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_guitar_probe()
2353 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_guitar_probe()
2354 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_guitar_probe()
2355 wdata->extension.input->name = WIIMOTE_NAME " Guitar"; in wiimod_guitar_probe()
2357 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_guitar_probe()
2360 wdata->extension.input->keybit); in wiimod_guitar_probe()
2362 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_guitar_probe()
2363 set_bit(ABS_X, wdata->extension.input->absbit); in wiimod_guitar_probe()
2364 set_bit(ABS_Y, wdata->extension.input->absbit); in wiimod_guitar_probe()
2365 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_guitar_probe()
2366 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_guitar_probe()
2367 input_set_abs_params(wdata->extension.input, in wiimod_guitar_probe()
2368 ABS_X, -32, 31, 1, 1); in wiimod_guitar_probe()
2369 input_set_abs_params(wdata->extension.input, in wiimod_guitar_probe()
2370 ABS_Y, -32, 31, 1, 1); in wiimod_guitar_probe()
2371 input_set_abs_params(wdata->extension.input, in wiimod_guitar_probe()
2373 input_set_abs_params(wdata->extension.input, in wiimod_guitar_probe()
2376 ret = input_register_device(wdata->extension.input); in wiimod_guitar_probe()
2383 input_free_device(wdata->extension.input); in wiimod_guitar_probe()
2384 wdata->extension.input = NULL; in wiimod_guitar_probe()
2391 if (!wdata->extension.input) in wiimod_guitar_remove()
2394 input_unregister_device(wdata->extension.input); in wiimod_guitar_remove()
2395 wdata->extension.input = NULL; in wiimod_guitar_remove()
2411 * input device.
2444 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2447 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2449 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2451 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2452 * 4 | 0 | 0 | LBR | B- | 0 | B+ | RBR | LTT<5> | in wiimod_turntable_in_ext()
2453 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2455 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2460 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2463 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2465 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2467 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2468 * 5 | 0 | 0 | LBR | B- | 0 | B+ | RBR | XXXX | in wiimod_turntable_in_ext()
2469 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2471 *------+------+-----+-----+-----+-----+------+------+--------+ in wiimod_turntable_in_ext()
2490 if (wdata->state.flags & WIIPROTO_FLAG_MP_ACTIVE) { in wiimod_turntable_in_ext()
2496 input_report_abs(wdata->extension.input, ABS_X, sx); in wiimod_turntable_in_ext()
2497 input_report_abs(wdata->extension.input, ABS_Y, sy); in wiimod_turntable_in_ext()
2498 input_report_abs(wdata->extension.input, ABS_HAT0X, rtt); in wiimod_turntable_in_ext()
2499 input_report_abs(wdata->extension.input, ABS_HAT1X, ltt); in wiimod_turntable_in_ext()
2500 input_report_abs(wdata->extension.input, ABS_HAT2X, cs); in wiimod_turntable_in_ext()
2501 input_report_abs(wdata->extension.input, ABS_HAT3X, ed); in wiimod_turntable_in_ext()
2502 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2505 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2508 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2511 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2514 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2517 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2520 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2523 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2526 input_report_key(wdata->extension.input, in wiimod_turntable_in_ext()
2530 input_sync(wdata->extension.input); in wiimod_turntable_in_ext()
2538 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_turntable_open()
2539 wdata->state.flags |= WIIPROTO_FLAG_EXT_USED; in wiimod_turntable_open()
2541 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_turntable_open()
2551 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_turntable_close()
2552 wdata->state.flags &= ~WIIPROTO_FLAG_EXT_USED; in wiimod_turntable_close()
2554 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_turntable_close()
2562 wdata->extension.input = input_allocate_device(); in wiimod_turntable_probe()
2563 if (!wdata->extension.input) in wiimod_turntable_probe()
2564 return -ENOMEM; in wiimod_turntable_probe()
2566 input_set_drvdata(wdata->extension.input, wdata); in wiimod_turntable_probe()
2567 wdata->extension.input->open = wiimod_turntable_open; in wiimod_turntable_probe()
2568 wdata->extension.input->close = wiimod_turntable_close; in wiimod_turntable_probe()
2569 wdata->extension.input->dev.parent = &wdata->hdev->dev; in wiimod_turntable_probe()
2570 wdata->extension.input->id.bustype = wdata->hdev->bus; in wiimod_turntable_probe()
2571 wdata->extension.input->id.vendor = wdata->hdev->vendor; in wiimod_turntable_probe()
2572 wdata->extension.input->id.product = wdata->hdev->product; in wiimod_turntable_probe()
2573 wdata->extension.input->id.version = wdata->hdev->version; in wiimod_turntable_probe()
2574 wdata->extension.input->name = WIIMOTE_NAME " Turntable"; in wiimod_turntable_probe()
2576 set_bit(EV_KEY, wdata->extension.input->evbit); in wiimod_turntable_probe()
2579 wdata->extension.input->keybit); in wiimod_turntable_probe()
2581 set_bit(EV_ABS, wdata->extension.input->evbit); in wiimod_turntable_probe()
2582 set_bit(ABS_X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2583 set_bit(ABS_Y, wdata->extension.input->absbit); in wiimod_turntable_probe()
2584 set_bit(ABS_HAT0X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2585 set_bit(ABS_HAT1X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2586 set_bit(ABS_HAT2X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2587 set_bit(ABS_HAT3X, wdata->extension.input->absbit); in wiimod_turntable_probe()
2588 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2590 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2592 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2593 ABS_HAT0X, -8, 8, 0, 0); in wiimod_turntable_probe()
2594 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2595 ABS_HAT1X, -8, 8, 0, 0); in wiimod_turntable_probe()
2596 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2598 input_set_abs_params(wdata->extension.input, in wiimod_turntable_probe()
2600 ret = input_register_device(wdata->extension.input); in wiimod_turntable_probe()
2607 input_free_device(wdata->extension.input); in wiimod_turntable_probe()
2608 wdata->extension.input = NULL; in wiimod_turntable_probe()
2615 if (!wdata->extension.input) in wiimod_turntable_remove()
2618 input_unregister_device(wdata->extension.input); in wiimod_turntable_remove()
2619 wdata->extension.input = NULL; in wiimod_turntable_remove()
2633 * disables polling for Motion-Plus. This should be set only for devices which
2642 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_builtin_mp_probe()
2643 wdata->state.flags |= WIIPROTO_FLAG_BUILTIN_MP; in wiimod_builtin_mp_probe()
2644 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_builtin_mp_probe()
2654 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_builtin_mp_remove()
2655 wdata->state.flags |= WIIPROTO_FLAG_BUILTIN_MP; in wiimod_builtin_mp_remove()
2656 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_builtin_mp_remove()
2669 * disables motion-plus. This is needed for devices that advertise this but we
2678 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_no_mp_probe()
2679 wdata->state.flags |= WIIPROTO_FLAG_NO_MP; in wiimod_no_mp_probe()
2680 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_no_mp_probe()
2690 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_no_mp_remove()
2691 wdata->state.flags |= WIIPROTO_FLAG_NO_MP; in wiimod_no_mp_remove()
2692 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_no_mp_remove()
2705 * extension device for Wii Remotes. Many devices have them built-in so
2717 * -----+------------------------------+-----+-----+ in wiimod_mp_in_mp()
2721 * -----+------------------------------+-----+-----+ in wiimod_mp_in_mp()
2723 * -----+------------------------------+-----+-----+ in wiimod_mp_in_mp()
2725 * -----+------------------------------+-----+-----+ in wiimod_mp_in_mp()
2727 * -----+------------------------------+-----+-----+ in wiimod_mp_in_mp()
2737 * which is parsed by wiimote-core. in wiimod_mp_in_mp()
2748 x -= 8192; in wiimod_mp_in_mp()
2749 y -= 8192; in wiimod_mp_in_mp()
2750 z -= 8192; in wiimod_mp_in_mp()
2765 input_report_abs(wdata->mp, ABS_RX, x); in wiimod_mp_in_mp()
2766 input_report_abs(wdata->mp, ABS_RY, y); in wiimod_mp_in_mp()
2767 input_report_abs(wdata->mp, ABS_RZ, z); in wiimod_mp_in_mp()
2768 input_sync(wdata->mp); in wiimod_mp_in_mp()
2776 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_mp_open()
2777 wdata->state.flags |= WIIPROTO_FLAG_MP_USED; in wiimod_mp_open()
2780 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_mp_open()
2790 spin_lock_irqsave(&wdata->state.lock, flags); in wiimod_mp_close()
2791 wdata->state.flags &= ~WIIPROTO_FLAG_MP_USED; in wiimod_mp_close()
2794 spin_unlock_irqrestore(&wdata->state.lock, flags); in wiimod_mp_close()
2802 wdata->mp = input_allocate_device(); in wiimod_mp_probe()
2803 if (!wdata->mp) in wiimod_mp_probe()
2804 return -ENOMEM; in wiimod_mp_probe()
2806 input_set_drvdata(wdata->mp, wdata); in wiimod_mp_probe()
2807 wdata->mp->open = wiimod_mp_open; in wiimod_mp_probe()
2808 wdata->mp->close = wiimod_mp_close; in wiimod_mp_probe()
2809 wdata->mp->dev.parent = &wdata->hdev->dev; in wiimod_mp_probe()
2810 wdata->mp->id.bustype = wdata->hdev->bus; in wiimod_mp_probe()
2811 wdata->mp->id.vendor = wdata->hdev->vendor; in wiimod_mp_probe()
2812 wdata->mp->id.product = wdata->hdev->product; in wiimod_mp_probe()
2813 wdata->mp->id.version = wdata->hdev->version; in wiimod_mp_probe()
2814 wdata->mp->name = WIIMOTE_NAME " Motion Plus"; in wiimod_mp_probe()
2816 set_bit(EV_ABS, wdata->mp->evbit); in wiimod_mp_probe()
2817 set_bit(ABS_RX, wdata->mp->absbit); in wiimod_mp_probe()
2818 set_bit(ABS_RY, wdata->mp->absbit); in wiimod_mp_probe()
2819 set_bit(ABS_RZ, wdata->mp->absbit); in wiimod_mp_probe()
2820 input_set_abs_params(wdata->mp, in wiimod_mp_probe()
2821 ABS_RX, -16000, 16000, 4, 8); in wiimod_mp_probe()
2822 input_set_abs_params(wdata->mp, in wiimod_mp_probe()
2823 ABS_RY, -16000, 16000, 4, 8); in wiimod_mp_probe()
2824 input_set_abs_params(wdata->mp, in wiimod_mp_probe()
2825 ABS_RZ, -16000, 16000, 4, 8); in wiimod_mp_probe()
2827 ret = input_register_device(wdata->mp); in wiimod_mp_probe()
2834 input_free_device(wdata->mp); in wiimod_mp_probe()
2835 wdata->mp = NULL; in wiimod_mp_probe()
2842 if (!wdata->mp) in wiimod_mp_remove()
2845 input_unregister_device(wdata->mp); in wiimod_mp_remove()
2846 wdata->mp = NULL; in wiimod_mp_remove()