Lines Matching full:analog
7 * Analog joystick and gamepad driver for Linux
23 #define DRIVER_DESC "Analog joystick and gamepad driver"
39 MODULE_PARM_DESC(map, "Describes analog joysticks type/capabilities");
91 struct analog { struct
101 struct analog analog[2]; argument
116 * analog_decode() decodes analog joystick data and reports input events.
119 static void analog_decode(struct analog *analog, int *axes, int *initial, int buttons) in analog_decode() argument
121 struct input_dev *dev = analog->dev; in analog_decode()
124 if (analog->mask & ANALOG_HAT_FCS) in analog_decode()
132 if (analog->mask & (0x10 << i)) in analog_decode()
133 input_report_key(dev, analog->buttons[j++], (buttons >> i) & 1); in analog_decode()
135 if (analog->mask & ANALOG_HBTN_CHF) in analog_decode()
137 input_report_key(dev, analog->buttons[j++], (buttons >> (i + 10)) & 1); in analog_decode()
139 if (analog->mask & ANALOG_BTN_TL) in analog_decode()
141 if (analog->mask & ANALOG_BTN_TR) in analog_decode()
143 if (analog->mask & ANALOG_BTN_TL2) in analog_decode()
145 if (analog->mask & ANALOG_BTN_TR2) in analog_decode()
149 if (analog->mask & (1 << i)) in analog_decode()
153 if (analog->mask & analog_exts[i]) { in analog_decode()
164 * analog_cooked_read() reads analog joystick data.
246 * analog_poll() repeatedly polls the Analog joysticks.
254 char saitek = !!(port->analog[0].mask & ANALOG_SAITEK); in analog_poll()
255 char chf = !!(port->analog[0].mask & ANALOG_ANY_CHF); in analog_poll()
275 if (port->analog[i].mask) in analog_poll()
276 analog_decode(port->analog + i, port->axes, port->initial, port->buttons); in analog_poll()
334 * analog_name() constructs a name for an analog joystick.
337 static void analog_name(struct analog *analog) in analog_name() argument
341 seq_buf_init(&s, analog->name, sizeof(analog->name)); in analog_name()
342 seq_buf_printf(&s, "Analog %d-axis %d-button", in analog_name()
343 hweight8(analog->mask & ANALOG_AXES_STD), in analog_name()
344 hweight8(analog->mask & ANALOG_BTNS_STD) + !!(analog->mask & ANALOG_BTNS_CHF) * 2 + in analog_name()
345 hweight16(analog->mask & ANALOG_BTNS_GAMEPAD) + !!(analog->mask & ANALOG_HBTN_CHF) * 4); in analog_name()
347 if (analog->mask & ANALOG_HATS_ALL) in analog_name()
349 hweight16(analog->mask & ANALOG_HATS_ALL)); in analog_name()
351 if (analog->mask & ANALOG_HAT_FCS) in analog_name()
353 if (analog->mask & ANALOG_ANY_CHF) in analog_name()
354 seq_buf_printf(&s, (analog->mask & ANALOG_SAITEK) ? " Saitek" : " CHF"); in analog_name()
356 seq_buf_printf(&s, (analog->mask & ANALOG_GAMEPAD) ? " gamepad" : " joystick"); in analog_name()
363 static int analog_init_device(struct analog_port *port, struct analog *analog, int index) in analog_init_device() argument
369 analog_name(analog); in analog_init_device()
370 snprintf(analog->phys, sizeof(analog->phys), in analog_init_device()
372 analog->buttons = (analog->mask & ANALOG_GAMEPAD) ? analog_pad_btn : analog_joy_btn; in analog_init_device()
374 analog->dev = input_dev = input_allocate_device(); in analog_init_device()
378 input_dev->name = analog->name; in analog_init_device()
379 input_dev->phys = analog->phys; in analog_init_device()
382 input_dev->id.product = analog->mask >> 4; in analog_init_device()
394 if (analog->mask & (1 << i)) { in analog_init_device()
407 if (analog->mask & ANALOG_SAITEK) { in analog_init_device()
418 if (analog->mask & analog_exts[i]) in analog_init_device()
425 if (analog->mask & (0x10 << i)) in analog_init_device()
426 set_bit(analog->buttons[j++], input_dev->keybit); in analog_init_device()
428 if (analog->mask & ANALOG_BTNS_CHF) in analog_init_device()
430 set_bit(analog->buttons[j++], input_dev->keybit); in analog_init_device()
432 if (analog->mask & ANALOG_HBTN_CHF) in analog_init_device()
434 set_bit(analog->buttons[j++], input_dev->keybit); in analog_init_device()
437 if (analog->mask & (ANALOG_BTN_TL << i)) in analog_init_device()
440 analog_decode(analog, port->axes, port->initial, port->buttons); in analog_init_device()
442 error = input_register_device(analog->dev); in analog_init_device()
444 input_free_device(analog->dev); in analog_init_device()
458 struct analog *analog = port->analog; in analog_init_masks() local
465 printk(KERN_WARNING "analog.c: Unknown joystick device found " in analog_init_masks()
466 "(data=%#x, %s), probably not analog joystick.\n", in analog_init_masks()
474 analog[0].mask = i & 0xfffff; in analog_init_masks()
476 analog[0].mask &= ~(ANALOG_AXES_STD | ANALOG_HAT_FCS | ANALOG_BTNS_GAMEPAD) in analog_init_masks()
480 analog[0].mask &= ~(ANALOG_HAT2_CHF) in analog_init_masks()
481 | ((analog[0].mask & ANALOG_HBTN_CHF) ? 0 : ANALOG_HAT2_CHF); in analog_init_masks()
483 analog[0].mask &= ~(ANALOG_THROTTLE | ANALOG_BTN_TR | ANALOG_BTN_TR2) in analog_init_masks()
484 | ((~analog[0].mask & ANALOG_HAT_FCS) >> 8) in analog_init_masks()
485 | ((~analog[0].mask & ANALOG_HAT_FCS) << 2) in analog_init_masks()
486 | ((~analog[0].mask & ANALOG_HAT_FCS) << 4); in analog_init_masks()
488 analog[0].mask &= ~(ANALOG_THROTTLE | ANALOG_RUDDER) in analog_init_masks()
489 | (((~analog[0].mask & ANALOG_BTNS_TLR ) >> 10) in analog_init_masks()
490 & ((~analog[0].mask & ANALOG_BTNS_TLR2) >> 12)); in analog_init_masks()
492 analog[1].mask = ((i >> 20) & 0xff) | ((i >> 12) & 0xf0000); in analog_init_masks()
494 analog[1].mask &= (analog[0].mask & ANALOG_EXTENSIONS) ? ANALOG_GAMEPAD in analog_init_masks()
495 : (((ANALOG_BTNS_STD | port->mask) & ~analog[0].mask) | ANALOG_GAMEPAD); in analog_init_masks()
501 if ((analog[0].mask & 0x7) == 0x7) max[2] = (max[0] + max[1]) >> 1; in analog_init_masks()
502 if ((analog[0].mask & 0xb) == 0xb) max[3] = (max[0] + max[1]) >> 1; in analog_init_masks()
503 if ((analog[0].mask & ANALOG_BTN_TL) && !(analog[0].mask & ANALOG_BTN_TL2)) max[2] >>= 1; in analog_init_masks()
504 if ((analog[0].mask & ANALOG_BTN_TR) && !(analog[0].mask & ANALOG_BTN_TR2)) max[3] >>= 1; in analog_init_masks()
505 if ((analog[0].mask & ANALOG_HAT_FCS)) max[3] >>= 1; in analog_init_masks()
513 return -!(analog[0].mask || analog[1].mask); in analog_init_masks()
601 if (port->analog[i].mask) { in analog_connect()
602 err = analog_init_device(port, port->analog + i, i); in analog_connect()
610 if (port->analog[i].mask) in analog_connect()
611 input_unregister_device(port->analog[i].dev); in analog_connect()
624 if (port->analog[i].mask) in analog_disconnect()
625 input_unregister_device(port->analog[i].dev); in analog_disconnect()
628 printk(KERN_INFO "analog.c: %d out of %d reads (%d%%) on %s failed\n", in analog_disconnect()
673 printk(KERN_WARNING "analog.c: Bad config for port %d - \"%s\"\n", i, js[i]); in analog_parse_options()
686 .name = "analog",