Lines Matching +full:max +full:- +full:fingers

1 // SPDX-License-Identifier: GPL-2.0-only
11 #include "hid-ids.h"
21 * https://vvvv.org/contribution/udraw-hid
26 * - the touch area which works as a touchpad
27 * - the tablet area which works as a touchpad/drawing tablet
28 * - a joypad with a d-pad, and 7 buttons
29 * - an accelerometer device
46 * Accelerometer min/max values
51 int max; member
66 #define MAX_PRESSURE (255 - PRESSURE_OFFSET)
76 * The device's two-finger support is pretty unreliable, as
77 * the device could report a single touch when the two fingers
78 * are too close together, and the distance between fingers, even
94 accel_limits[offset].max); in clamp_accel()
95 axis = (axis - accel_limits[offset].min) / in clamp_accel()
96 ((accel_limits[offset].max - in clamp_accel()
121 input_report_key(udraw->joy_input_dev, BTN_WEST, data[0] & 1); in udraw_raw_event()
122 input_report_key(udraw->joy_input_dev, BTN_SOUTH, !!(data[0] & 2)); in udraw_raw_event()
123 input_report_key(udraw->joy_input_dev, BTN_EAST, !!(data[0] & 4)); in udraw_raw_event()
124 input_report_key(udraw->joy_input_dev, BTN_NORTH, !!(data[0] & 8)); in udraw_raw_event()
126 input_report_key(udraw->joy_input_dev, BTN_SELECT, !!(data[1] & 1)); in udraw_raw_event()
127 input_report_key(udraw->joy_input_dev, BTN_START, !!(data[1] & 2)); in udraw_raw_event()
128 input_report_key(udraw->joy_input_dev, BTN_MODE, !!(data[1] & 16)); in udraw_raw_event()
133 y = -127; in udraw_raw_event()
136 y = -127; in udraw_raw_event()
151 x = -127; in udraw_raw_event()
154 x = -127; in udraw_raw_event()
157 y = -127; in udraw_raw_event()
158 x = -127; in udraw_raw_event()
164 input_report_abs(udraw->joy_input_dev, ABS_X, x); in udraw_raw_event()
165 input_report_abs(udraw->joy_input_dev, ABS_Y, y); in udraw_raw_event()
167 input_sync(udraw->joy_input_dev); in udraw_raw_event()
179 /* Save the last one-finger touch */ in udraw_raw_event()
180 udraw->last_one_finger_x = x; in udraw_raw_event()
181 udraw->last_one_finger_y = y; in udraw_raw_event()
182 udraw->last_two_finger_x = -1; in udraw_raw_event()
183 udraw->last_two_finger_y = -1; in udraw_raw_event()
188 * to user-space otherwise it'll look as if it jumped. in udraw_raw_event()
193 if (udraw->last_two_finger_x == -1) { in udraw_raw_event()
195 udraw->last_two_finger_x = x; in udraw_raw_event()
196 udraw->last_two_finger_y = y; in udraw_raw_event()
198 x = udraw->last_one_finger_x; in udraw_raw_event()
199 y = udraw->last_one_finger_y; in udraw_raw_event()
202 * Offset the 2-finger coords using the in udraw_raw_event()
205 x = x - (udraw->last_two_finger_x in udraw_raw_event()
206 - udraw->last_one_finger_x); in udraw_raw_event()
207 y = y - (udraw->last_two_finger_y in udraw_raw_event()
208 - udraw->last_one_finger_y); in udraw_raw_event()
214 input_report_key(udraw->touch_input_dev, BTN_TOUCH, 1); in udraw_raw_event()
215 input_report_key(udraw->touch_input_dev, BTN_TOOL_FINGER, in udraw_raw_event()
217 input_report_key(udraw->touch_input_dev, BTN_TOOL_DOUBLETAP, in udraw_raw_event()
220 input_report_abs(udraw->touch_input_dev, ABS_X, x); in udraw_raw_event()
221 input_report_abs(udraw->touch_input_dev, ABS_Y, y); in udraw_raw_event()
223 input_report_key(udraw->touch_input_dev, BTN_TOUCH, 0); in udraw_raw_event()
224 input_report_key(udraw->touch_input_dev, BTN_TOOL_FINGER, 0); in udraw_raw_event()
225 input_report_key(udraw->touch_input_dev, BTN_TOOL_DOUBLETAP, 0); in udraw_raw_event()
227 input_sync(udraw->touch_input_dev); in udraw_raw_event()
233 level = clamp(data[13] - PRESSURE_OFFSET, in udraw_raw_event()
236 input_report_key(udraw->pen_input_dev, BTN_TOUCH, (level != 0)); in udraw_raw_event()
237 input_report_key(udraw->pen_input_dev, BTN_TOOL_PEN, 1); in udraw_raw_event()
238 input_report_abs(udraw->pen_input_dev, ABS_PRESSURE, level); in udraw_raw_event()
239 input_report_abs(udraw->pen_input_dev, ABS_X, x); in udraw_raw_event()
240 input_report_abs(udraw->pen_input_dev, ABS_Y, y); in udraw_raw_event()
242 input_report_key(udraw->pen_input_dev, BTN_TOUCH, 0); in udraw_raw_event()
243 input_report_key(udraw->pen_input_dev, BTN_TOOL_PEN, 0); in udraw_raw_event()
244 input_report_abs(udraw->pen_input_dev, ABS_PRESSURE, 0); in udraw_raw_event()
246 input_sync(udraw->pen_input_dev); in udraw_raw_event()
255 input_report_abs(udraw->accel_input_dev, ABS_X, x); in udraw_raw_event()
256 input_report_abs(udraw->accel_input_dev, ABS_Y, y); in udraw_raw_event()
257 input_report_abs(udraw->accel_input_dev, ABS_Z, z); in udraw_raw_event()
258 input_sync(udraw->accel_input_dev); in udraw_raw_event()
268 return hid_hw_open(udraw->hdev); in udraw_open()
275 hid_hw_close(udraw->hdev); in udraw_close()
283 input_dev = devm_input_allocate_device(&hdev->dev); in allocate_and_setup()
287 input_dev->name = name; in allocate_and_setup()
288 input_dev->phys = hdev->phys; in allocate_and_setup()
289 input_dev->dev.parent = &hdev->dev; in allocate_and_setup()
290 input_dev->open = udraw_open; in allocate_and_setup()
291 input_dev->close = udraw_close; in allocate_and_setup()
292 input_dev->uniq = hdev->uniq; in allocate_and_setup()
293 input_dev->id.bustype = hdev->bus; in allocate_and_setup()
294 input_dev->id.vendor = hdev->vendor; in allocate_and_setup()
295 input_dev->id.product = hdev->product; in allocate_and_setup()
296 input_dev->id.version = hdev->version; in allocate_and_setup()
311 input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); in udraw_setup_touch()
318 set_bit(BTN_TOUCH, input_dev->keybit); in udraw_setup_touch()
319 set_bit(BTN_TOOL_FINGER, input_dev->keybit); in udraw_setup_touch()
320 set_bit(BTN_TOOL_DOUBLETAP, input_dev->keybit); in udraw_setup_touch()
322 set_bit(INPUT_PROP_POINTER, input_dev->propbit); in udraw_setup_touch()
324 udraw->touch_input_dev = input_dev; in udraw_setup_touch()
338 input_dev->evbit[0] = BIT(EV_ABS) | BIT(EV_KEY); in udraw_setup_pen()
347 set_bit(BTN_TOUCH, input_dev->keybit); in udraw_setup_pen()
348 set_bit(BTN_TOOL_PEN, input_dev->keybit); in udraw_setup_pen()
350 set_bit(INPUT_PROP_POINTER, input_dev->propbit); in udraw_setup_pen()
352 udraw->pen_input_dev = input_dev; in udraw_setup_pen()
366 input_dev->evbit[0] = BIT(EV_ABS); in udraw_setup_accel()
369 input_set_abs_params(input_dev, ABS_X, -512, 512, 0, 0); in udraw_setup_accel()
370 input_set_abs_params(input_dev, ABS_Y, -512, 512, 0, 0); in udraw_setup_accel()
371 input_set_abs_params(input_dev, ABS_Z, -512, 512, 0, 0); in udraw_setup_accel()
373 set_bit(INPUT_PROP_ACCELEROMETER, input_dev->propbit); in udraw_setup_accel()
375 udraw->accel_input_dev = input_dev; in udraw_setup_accel()
389 input_dev->evbit[0] = BIT(EV_KEY) | BIT(EV_ABS); in udraw_setup_joypad()
391 set_bit(BTN_SOUTH, input_dev->keybit); in udraw_setup_joypad()
392 set_bit(BTN_NORTH, input_dev->keybit); in udraw_setup_joypad()
393 set_bit(BTN_EAST, input_dev->keybit); in udraw_setup_joypad()
394 set_bit(BTN_WEST, input_dev->keybit); in udraw_setup_joypad()
395 set_bit(BTN_SELECT, input_dev->keybit); in udraw_setup_joypad()
396 set_bit(BTN_START, input_dev->keybit); in udraw_setup_joypad()
397 set_bit(BTN_MODE, input_dev->keybit); in udraw_setup_joypad()
399 input_set_abs_params(input_dev, ABS_X, -127, 127, 0, 0); in udraw_setup_joypad()
400 input_set_abs_params(input_dev, ABS_Y, -127, 127, 0, 0); in udraw_setup_joypad()
402 udraw->joy_input_dev = input_dev; in udraw_setup_joypad()
412 udraw = devm_kzalloc(&hdev->dev, sizeof(struct udraw), GFP_KERNEL); in udraw_probe()
414 return -ENOMEM; in udraw_probe()
416 udraw->hdev = hdev; in udraw_probe()
417 udraw->last_two_finger_x = -1; in udraw_probe()
418 udraw->last_two_finger_y = -1; in udraw_probe()
433 return -ENOMEM; in udraw_probe()
436 ret = input_register_device(udraw->joy_input_dev) || in udraw_probe()
437 input_register_device(udraw->touch_input_dev) || in udraw_probe()
438 input_register_device(udraw->pen_input_dev) || in udraw_probe()
439 input_register_device(udraw->accel_input_dev); in udraw_probe()
461 .name = "hid-udraw",