Lines Matching +full:swap +full:- +full:xy
1 // SPDX-License-Identifier: GPL-2.0
19 * - Standard 1 button mouse
20 * - All standard Apple Extended protocol (handler ID 4)
21 * - mouseman and trackman mice & trackballs
22 * - PowerBook Trackpad (default setup: enable tapping)
23 * - MicroSpeed mouse & trackball (needs testing)
24 * - CH Products Trackball Pro (needs testing)
25 * - Contour Design (Contour Mouse)
26 * - Hunter digital (NoHandsMouse)
27 * - Kensignton TurboMouse 5 (needs testing)
28 * - Mouse Systems A3 mice and trackballs <aidan@kublai.com>
29 * - MacAlly 2-buttons mouse (needs testing) <pochini@denise.shiny.it>
54 MODULE_AUTHOR("Franz Sirl <Franz.Sirl-kernel@lauterbach.com>");
263 #define ADBMOUSE_MACALLY2 9 /* MacAlly 2-button mouse */
297 if (ahid->flags & FLAG_CAPSLOCK_IGNORE_NEXT) { in adbhid_input_keycode()
300 ahid->flags &= ~FLAG_CAPSLOCK_IGNORE_NEXT; in adbhid_input_keycode()
303 ahid->flags |= FLAG_CAPSLOCK_TRANSLATE in adbhid_input_keycode()
307 !(ahid->flags & FLAG_POWER_KEY_PRESSED)) { in adbhid_input_keycode()
311 if (ahid->flags & FLAG_CAPSLOCK_TRANSLATE) { in adbhid_input_keycode()
313 if (ahid->flags & FLAG_CAPSLOCK_DOWN) { in adbhid_input_keycode()
316 ahid->flags &= ~FLAG_CAPSLOCK_DOWN; in adbhid_input_keycode()
320 ahid->flags &= ~FLAG_CAPSLOCK_TRANSLATE; in adbhid_input_keycode()
332 input_report_key(ahid->input, KEY_CAPSLOCK, 1); in adbhid_input_keycode()
333 input_sync(ahid->input); in adbhid_input_keycode()
334 input_report_key(ahid->input, KEY_CAPSLOCK, 0); in adbhid_input_keycode()
335 input_sync(ahid->input); in adbhid_input_keycode()
352 ahid->flags &= ~FLAG_POWER_KEY_PRESSED; in adbhid_input_keycode()
354 ahid->flags |= FLAG_POWER_KEY_PRESSED; in adbhid_input_keycode()
357 if (ahid->flags & FLAG_FN_KEY_PRESSED) { in adbhid_input_keycode()
360 ahid->flags &= ~FLAG_POWER_FROM_FN; in adbhid_input_keycode()
362 ahid->flags |= FLAG_POWER_FROM_FN; in adbhid_input_keycode()
363 } else if (ahid->flags & FLAG_POWER_FROM_FN) { in adbhid_input_keycode()
365 ahid->flags &= ~FLAG_POWER_FROM_FN; in adbhid_input_keycode()
371 ahid->flags &= ~FLAG_FN_KEY_PRESSED; in adbhid_input_keycode()
373 if (ahid->flags & FLAG_EMU_FWDEL_DOWN) { in adbhid_input_keycode()
374 ahid->flags &= ~FLAG_EMU_FWDEL_DOWN; in adbhid_input_keycode()
379 ahid->flags |= FLAG_FN_KEY_PRESSED; in adbhid_input_keycode()
383 if (ahid->flags & FLAG_FN_KEY_PRESSED) { in adbhid_input_keycode()
386 ahid->flags &= ~FLAG_EMU_FWDEL_DOWN; in adbhid_input_keycode()
388 ahid->flags |= FLAG_EMU_FWDEL_DOWN; in adbhid_input_keycode()
394 key = adbhid[id]->keycode[keycode]; in adbhid_input_keycode()
396 input_report_key(adbhid[id]->input, key, !up_flag); in adbhid_input_keycode()
397 input_sync(adbhid[id]->input); in adbhid_input_keycode()
415 Handler 1 -- 100cpi original Apple mouse protocol. in adbhid_mouse_input()
416 Handler 2 -- 200cpi original Apple mouse protocol. in adbhid_mouse_input()
418 For Apple's standard one-button mouse protocol the data array will in adbhid_mouse_input()
423 data[1] = bxxx xxxx First button and x-axis motion. in adbhid_mouse_input()
424 data[2] = byyy yyyy Second button and y-axis motion. in adbhid_mouse_input()
426 Handler 4 -- Apple Extended mouse protocol. in adbhid_mouse_input()
428 For Apple's 3-button mouse protocol the data array will contain the in adbhid_mouse_input()
433 data[1] = bxxx xxxx Left button and x-axis motion. in adbhid_mouse_input()
434 data[2] = byyy yyyy Second button and y-axis motion. in adbhid_mouse_input()
436 high bits of y-axis motion. XY is additional in adbhid_mouse_input()
437 high bits of x-axis motion. in adbhid_mouse_input()
439 MacAlly 2-button mouse protocol. in adbhid_mouse_input()
441 For MacAlly 2-button mouse protocol the data array will contain the in adbhid_mouse_input()
446 data[1] = bxxx xxxx Left button and x-axis motion. in adbhid_mouse_input()
447 data[2] = byyy yyyy Right button and y-axis motion. in adbhid_mouse_input()
458 switch (adbhid[id]->mouse_kind) in adbhid_mouse_input()
488 input_report_key(adbhid[id]->input, BTN_LEFT, !((data[1] >> 7) & 1)); in adbhid_mouse_input()
489 input_report_key(adbhid[id]->input, BTN_MIDDLE, !((data[2] >> 7) & 1)); in adbhid_mouse_input()
491 if (nb >= 4 && adbhid[id]->mouse_kind != ADBMOUSE_TRACKPAD) in adbhid_mouse_input()
492 input_report_key(adbhid[id]->input, BTN_RIGHT, !((data[3] >> 7) & 1)); in adbhid_mouse_input()
494 input_report_rel(adbhid[id]->input, REL_X, in adbhid_mouse_input()
495 ((data[2]&0x7f) < 64 ? (data[2]&0x7f) : (data[2]&0x7f)-128 )); in adbhid_mouse_input()
496 input_report_rel(adbhid[id]->input, REL_Y, in adbhid_mouse_input()
497 ((data[1]&0x7f) < 64 ? (data[1]&0x7f) : (data[1]&0x7f)-128 )); in adbhid_mouse_input()
499 input_sync(adbhid[id]->input); in adbhid_mouse_input()
512 switch (adbhid[id]->original_handler_id) { in adbhid_buttons_input()
520 input_report_key(adbhid[id]->input, KEY_SOUND, down); in adbhid_buttons_input()
524 input_report_key(adbhid[id]->input, KEY_MUTE, down); in adbhid_buttons_input()
528 input_report_key(adbhid[id]->input, KEY_VOLUMEDOWN, down); in adbhid_buttons_input()
532 input_report_key(adbhid[id]->input, KEY_VOLUMEUP, down); in adbhid_buttons_input()
549 * -- Cort in adbhid_buttons_input()
554 input_report_key(adbhid[id]->input, KEY_MUTE, down); in adbhid_buttons_input()
558 input_report_key(adbhid[id]->input, KEY_VOLUMEDOWN, down); in adbhid_buttons_input()
562 input_report_key(adbhid[id]->input, KEY_VOLUMEUP, down); in adbhid_buttons_input()
566 input_report_key(adbhid[id]->input, KEY_EJECTCD, down); in adbhid_buttons_input()
574 input_report_key(adbhid[id]->input, KEY_BRIGHTNESSDOWN, down); in adbhid_buttons_input()
582 input_report_key(adbhid[id]->input, KEY_BRIGHTNESSUP, down); in adbhid_buttons_input()
586 input_report_key(adbhid[id]->input, KEY_SWITCHVIDEOMODE, down); in adbhid_buttons_input()
590 input_report_key(adbhid[id]->input, KEY_KBDILLUMTOGGLE, down); in adbhid_buttons_input()
594 input_report_key(adbhid[id]->input, KEY_KBDILLUMDOWN, down); in adbhid_buttons_input()
602 input_report_key(adbhid[id]->input, KEY_KBDILLUMUP, down); in adbhid_buttons_input()
625 input_sync(adbhid[id]->input); in adbhid_buttons_input()
691 leds = (test_bit(LED_SCROLLL, dev->led) ? 4 : 0) | in adbhid_kbd_event()
692 (test_bit(LED_NUML, dev->led) ? 1 : 0) | in adbhid_kbd_event()
693 (test_bit(LED_CAPSL, dev->led) ? 2 : 0); in adbhid_kbd_event()
694 real_leds(leds, adbhid->id); in adbhid_kbd_event()
698 return -1; in adbhid_kbd_event()
710 if (ahid && ahid->id == ADB_KEYBOARD) in adbhid_kbd_capslock_remember()
711 if (ahid->flags & FLAG_CAPSLOCK_TRANSLATE) in adbhid_kbd_capslock_remember()
712 ahid->flags |= FLAG_CAPSLOCK_IGNORE_NEXT; in adbhid_kbd_capslock_remember()
727 del_timer_sync(&adbhid[i]->input->timer); in adb_message_handler()
764 return -EEXIST; in adbhid_input_register()
770 err = -ENOMEM; in adbhid_input_register()
774 sprintf(hid->phys, "adb%d:%d.%02x/input", id, default_id, original_handler_id); in adbhid_input_register()
776 hid->input = input_dev; in adbhid_input_register()
777 hid->id = default_id; in adbhid_input_register()
778 hid->original_handler_id = original_handler_id; in adbhid_input_register()
779 hid->current_handler_id = current_handler_id; in adbhid_input_register()
780 hid->mouse_kind = mouse_kind; in adbhid_input_register()
781 hid->flags = 0; in adbhid_input_register()
783 input_dev->name = hid->name; in adbhid_input_register()
784 input_dev->phys = hid->phys; in adbhid_input_register()
785 input_dev->id.bustype = BUS_ADB; in adbhid_input_register()
786 input_dev->id.vendor = 0x0001; in adbhid_input_register()
787 input_dev->id.product = (id << 12) | (default_id << 8) | original_handler_id; in adbhid_input_register()
788 input_dev->id.version = 0x0100; in adbhid_input_register()
792 hid->keycode = kmemdup(adb_to_linux_keycodes, in adbhid_input_register()
794 if (!hid->keycode) { in adbhid_input_register()
795 err = -ENOMEM; in adbhid_input_register()
799 sprintf(hid->name, "ADB keyboard"); in adbhid_input_register()
804 input_dev->id.version = ADB_KEYBOARD_UNKNOWN; in adbhid_input_register()
811 input_dev->id.version = ADB_KEYBOARD_ANSI; in adbhid_input_register()
818 input_dev->id.version = ADB_KEYBOARD_ISO; in adbhid_input_register()
819 swap(hid->keycode[10], hid->keycode[50]); in adbhid_input_register()
825 input_dev->id.version = ADB_KEYBOARD_JIS; in adbhid_input_register()
831 if (hid->keycode[i]) in adbhid_input_register()
832 set_bit(hid->keycode[i], input_dev->keybit); in adbhid_input_register()
834 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_LED) | in adbhid_input_register()
836 input_dev->ledbit[0] = BIT_MASK(LED_SCROLLL) | in adbhid_input_register()
838 input_dev->event = adbhid_kbd_event; in adbhid_input_register()
839 input_dev->keycodemax = KEY_FN; in adbhid_input_register()
840 input_dev->keycodesize = sizeof(hid->keycode[0]); in adbhid_input_register()
844 sprintf(hid->name, "ADB mouse"); in adbhid_input_register()
846 input_dev->evbit[0] = BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); in adbhid_input_register()
847 input_dev->keybit[BIT_WORD(BTN_MOUSE)] = BIT_MASK(BTN_LEFT) | in adbhid_input_register()
849 input_dev->relbit[0] = BIT_MASK(REL_X) | BIT_MASK(REL_Y); in adbhid_input_register()
855 sprintf(hid->name, "ADB adjustable keyboard buttons"); in adbhid_input_register()
856 input_dev->evbit[0] = BIT_MASK(EV_KEY) | in adbhid_input_register()
858 set_bit(KEY_SOUND, input_dev->keybit); in adbhid_input_register()
859 set_bit(KEY_MUTE, input_dev->keybit); in adbhid_input_register()
860 set_bit(KEY_VOLUMEUP, input_dev->keybit); in adbhid_input_register()
861 set_bit(KEY_VOLUMEDOWN, input_dev->keybit); in adbhid_input_register()
864 sprintf(hid->name, "ADB Powerbook buttons"); in adbhid_input_register()
865 input_dev->evbit[0] = BIT_MASK(EV_KEY) | in adbhid_input_register()
867 set_bit(KEY_MUTE, input_dev->keybit); in adbhid_input_register()
868 set_bit(KEY_VOLUMEUP, input_dev->keybit); in adbhid_input_register()
869 set_bit(KEY_VOLUMEDOWN, input_dev->keybit); in adbhid_input_register()
870 set_bit(KEY_BRIGHTNESSUP, input_dev->keybit); in adbhid_input_register()
871 set_bit(KEY_BRIGHTNESSDOWN, input_dev->keybit); in adbhid_input_register()
872 set_bit(KEY_EJECTCD, input_dev->keybit); in adbhid_input_register()
873 set_bit(KEY_SWITCHVIDEOMODE, input_dev->keybit); in adbhid_input_register()
874 set_bit(KEY_KBDILLUMTOGGLE, input_dev->keybit); in adbhid_input_register()
875 set_bit(KEY_KBDILLUMDOWN, input_dev->keybit); in adbhid_input_register()
876 set_bit(KEY_KBDILLUMUP, input_dev->keybit); in adbhid_input_register()
879 if (hid->name[0]) in adbhid_input_register()
885 err = -ENODEV; in adbhid_input_register()
889 input_dev->keycode = hid->keycode; in adbhid_input_register()
899 input_dev->rep[REP_DELAY] = 500; /* input layer default: 250 */ in adbhid_input_register()
900 input_dev->rep[REP_PERIOD] = 66; /* input layer default: 33 */ in adbhid_input_register()
907 kfree(hid->keycode); in adbhid_input_register()
916 input_unregister_device(adbhid[id]->input); in adbhid_input_unregister()
917 kfree(adbhid[id]->keycode); in adbhid_input_unregister()
928 if (adbhid[id]->input->id.product != in adbhid_input_reregister()
970 ->get it to send separate codes for left and right shift, in adbhid_probe()
992 /* Try to switch all mice to handler 4, or 2 for three-button in adbhid_probe()
1070 desc = "MacAlly 2-button"; in adbhid_probe()
1211 0 - 3 Button is mouse (set also for double clicking!!!) in init_microspeed()
1212 4 - 7 Button is locking (affects change speed also) in init_microspeed()
1213 8 - 11 Button changes speed in init_microspeed()
1215 13 - 15 unused 0 in init_microspeed()
1216 16 - 23 normal speed in init_microspeed()
1217 24 - 31 changed speed in init_microspeed()
1221 0 - 7 Product code in init_microspeed()
1222 8 - 23 undefined, reserved in init_microspeed()
1223 24 - 31 Version number in init_microspeed()