Lines Matching +full:adc +full:- +full:joystick

1 // SPDX-License-Identifier: GPL-2.0-or-later
3 * Copyright (c) 1998-2001 Vojtech Pavlik
7 * FP-Gaming Assassin 3D joystick driver for Linux
17 #define DRIVER_DESC "FP-Gaming Assassin 3D joystick driver"
32 static char *a3d_names[] = { NULL, "FP-Gaming Assassin 3D", "MadCatz Panther", "OEM Panther",
37 struct gameport *adc; member
68 t--; in a3d_read_packet()
89 for (i = 0; i < count - 2; i++) in a3d_csum()
91 return (csum & 0x3f) != ((data[count - 2] << 3) | data[count - 1]); in a3d_csum()
96 struct input_dev *dev = a3d->dev; in a3d_read()
98 switch (a3d->mode) { in a3d_read()
104 … input_report_rel(dev, REL_X, ((data[5] << 6) | (data[6] << 3) | data[ 7]) - ((data[5] & 4) << 7)); in a3d_read()
105 … input_report_rel(dev, REL_Y, ((data[8] << 6) | (data[9] << 3) | data[10]) - ((data[8] & 4) << 7)); in a3d_read()
113 a3d->axes[0] = ((signed char)((data[11] << 6) | (data[12] << 3) | (data[13]))) + 128; in a3d_read()
114 a3d->axes[1] = ((signed char)((data[14] << 6) | (data[15] << 3) | (data[16]))) + 128; in a3d_read()
115 a3d->axes[2] = ((signed char)((data[17] << 6) | (data[18] << 3) | (data[19]))) + 128; in a3d_read()
116 a3d->axes[3] = ((signed char)((data[20] << 6) | (data[21] << 3) | (data[22]))) + 128; in a3d_read()
118 a3d->buttons = ((data[3] << 3) | data[4]) & 0xf; in a3d_read()
124 …input_report_rel(dev, REL_X, ((data[ 9] << 6) | (data[10] << 3) | data[11]) - ((data[ 9] & 4) << 7… in a3d_read()
125 …input_report_rel(dev, REL_Y, ((data[12] << 6) | (data[13] << 3) | data[14]) - ((data[12] & 4) << 7… in a3d_read()
138 input_report_abs(dev, ABS_HAT0X, ( data[5] & 1) - ((data[5] >> 2) & 1)); in a3d_read()
139 input_report_abs(dev, ABS_HAT0Y, ((data[5] >> 1) & 1) - ((data[6] >> 2) & 1)); in a3d_read()
140 input_report_abs(dev, ABS_HAT1X, ((data[4] >> 1) & 1) - ( data[3] & 1)); in a3d_read()
141 input_report_abs(dev, ABS_HAT1Y, ((data[4] >> 2) & 1) - ( data[4] & 1)); in a3d_read()
156 * a3d_poll() reads and analyzes A3D joystick data.
164 a3d->reads++; in a3d_poll()
165 if (a3d_read_packet(a3d->gameport, a3d->length, data) != a3d->length || in a3d_poll()
166 data[0] != a3d->mode || a3d_csum(data, a3d->length)) in a3d_poll()
167 a3d->bads++; in a3d_poll()
180 struct a3d *a3d = gameport->port_data; in a3d_adc_cooked_read()
184 axes[i] = (a3d->axes[i] < 254) ? a3d->axes[i] : -1; in a3d_adc_cooked_read()
185 *buttons = a3d->buttons; in a3d_adc_cooked_read()
196 struct a3d *a3d = gameport->port_data; in a3d_adc_open()
199 return -1; in a3d_adc_open()
201 gameport_start_polling(a3d->gameport); in a3d_adc_open()
211 struct a3d *a3d = gameport->port_data; in a3d_adc_close()
213 gameport_stop_polling(a3d->gameport); in a3d_adc_close()
224 gameport_start_polling(a3d->gameport); in a3d_open()
236 gameport_stop_polling(a3d->gameport); in a3d_close()
247 struct gameport *adc; in a3d_connect() local
255 err = -ENOMEM; in a3d_connect()
259 a3d->dev = input_dev; in a3d_connect()
260 a3d->gameport = gameport; in a3d_connect()
271 err = -ENODEV; in a3d_connect()
275 a3d->mode = data[0]; in a3d_connect()
277 if (!a3d->mode || a3d->mode > 5) { in a3d_connect()
279 "(%s, id=%d), contact <vojtech@ucw.cz>\n", gameport->phys, a3d->mode); in a3d_connect()
280 err = -ENODEV; in a3d_connect()
287 snprintf(a3d->phys, sizeof(a3d->phys), "%s/input0", gameport->phys); in a3d_connect()
289 input_dev->name = a3d_names[a3d->mode]; in a3d_connect()
290 input_dev->phys = a3d->phys; in a3d_connect()
291 input_dev->id.bustype = BUS_GAMEPORT; in a3d_connect()
292 input_dev->id.vendor = GAMEPORT_ID_VENDOR_MADCATZ; in a3d_connect()
293 input_dev->id.product = a3d->mode; in a3d_connect()
294 input_dev->id.version = 0x0100; in a3d_connect()
295 input_dev->dev.parent = &gameport->dev; in a3d_connect()
296 input_dev->open = a3d_open; in a3d_connect()
297 input_dev->close = a3d_close; in a3d_connect()
301 if (a3d->mode == A3D_MODE_PXL) { in a3d_connect()
305 a3d->length = 33; in a3d_connect()
307 input_dev->evbit[0] |= BIT_MASK(EV_ABS) | BIT_MASK(EV_KEY) | in a3d_connect()
309 input_dev->relbit[0] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y); in a3d_connect()
310 input_dev->absbit[0] |= BIT_MASK(ABS_X) | BIT_MASK(ABS_Y) | in a3d_connect()
314 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_RIGHT) | in a3d_connect()
317 input_dev->keybit[BIT_WORD(BTN_JOYSTICK)] |= in a3d_connect()
326 48, input_abs_get_val(input_dev, axes[i]) * 2 - 48, 0, 8); in a3d_connect()
329 input_set_abs_params(input_dev, ABS_HAT0X + i, -1, 1, 0, 0); in a3d_connect()
333 a3d->length = 29; in a3d_connect()
335 input_dev->evbit[0] |= BIT_MASK(EV_KEY) | BIT_MASK(EV_REL); in a3d_connect()
336 input_dev->relbit[0] |= BIT_MASK(REL_X) | BIT_MASK(REL_Y); in a3d_connect()
337 input_dev->keybit[BIT_WORD(BTN_MOUSE)] |= BIT_MASK(BTN_RIGHT) | in a3d_connect()
342 if (!(a3d->adc = adc = gameport_allocate_port())) in a3d_connect()
343 printk(KERN_ERR "a3d: Not enough memory for ADC port\n"); in a3d_connect()
345 adc->port_data = a3d; in a3d_connect()
346 adc->open = a3d_adc_open; in a3d_connect()
347 adc->close = a3d_adc_close; in a3d_connect()
348 adc->cooked_read = a3d_adc_cooked_read; in a3d_connect()
349 adc->fuzz = 1; in a3d_connect()
351 gameport_set_name(adc, a3d_names[a3d->mode]); in a3d_connect()
352 gameport_set_phys(adc, "%s/gameport0", gameport->phys); in a3d_connect()
353 adc->dev.parent = &gameport->dev; in a3d_connect()
355 gameport_register_port(adc); in a3d_connect()
359 err = input_register_device(a3d->dev); in a3d_connect()
365 fail3: if (a3d->adc) in a3d_connect()
366 gameport_unregister_port(a3d->adc); in a3d_connect()
378 input_unregister_device(a3d->dev); in a3d_disconnect()
379 if (a3d->adc) in a3d_disconnect()
380 gameport_unregister_port(a3d->adc); in a3d_disconnect()
388 .name = "adc",