Lines Matching +full:button +full:- +full:up

1 // SPDX-License-Identifier: GPL-2.0
5 * Copyright (c) 2012-2013 David Herrmann <dh.herrmann@gmail.com>
17 * 1: Toggle left button (down, up, ...)
18 * 2: Toggle right button
19 * 3: Toggle middle button
22 * w: Move mouse up
24 * r: Move wheel up
27 * Additionally to 3 button mouse, 3 keyboard LEDs are also supported (LED_NUML,
35 * gcc -o ./uhid_test -Wall -I./include ./samples/uhid/uhid-example.c
53 * We emulate a basic 3 button mouse with wheel and 3 keyboard LEDs. This is
54 * the report-descriptor as the kernel will parse it:
61 * Button.0001
62 * Button.0002
63 * Button.0003
77 * Logical Minimum(-128)
98 * Button.0001 ---> Key.LeftBtn
99 * Button.0002 ---> Key.RightBtn
100 * Button.0003 ---> Key.MiddleBtn
101 * GenericDesktop.X ---> Relative.X
102 * GenericDesktop.Y ---> Relative.Y
103 * GenericDesktop.Wheel ---> Relative.Wheel
104 * LED.NumLock ---> LED.NumLock
105 * LED.CapsLock ---> LED.CapsLock
106 * LED.ScrollLock ---> LED.ScrollLock
119 0x05, 0x09, /* USAGE_PAGE (Button) */
120 0x19, 0x01, /* USAGE_MINIMUM (Button 1) */
121 0x29, 0x03, /* USAGE_MAXIMUM (Button 3) */
134 0x15, 0x81, /* LOGICAL_MINIMUM (-127) */
166 return -errno; in uhid_write()
170 return -EFAULT; in uhid_write()
182 strcpy((char*)ev.u.create.name, "test-uhid-device"); in create()
211 if (ev->u.output.rtype != UHID_OUTPUT_REPORT) in handle_output()
214 if (ev->u.output.size != 2) in handle_output()
216 /* first byte is report-id which is 0x02 for LEDs in our rdesc */ in handle_output()
217 if (ev->u.output.data[0] != 0x2) in handle_output()
222 ev->u.output.data[1]); in handle_output()
233 fprintf(stderr, "Read HUP on uhid-cdev\n"); in event()
234 return -EFAULT; in event()
236 fprintf(stderr, "Cannot read uhid-cdev: %m\n"); in event()
237 return -errno; in event()
239 fprintf(stderr, "Invalid size read from uhid-dev: %zd != %zu\n", in event()
241 return -EFAULT; in event()
246 fprintf(stderr, "UHID_START from uhid-dev\n"); in event()
249 fprintf(stderr, "UHID_STOP from uhid-dev\n"); in event()
252 fprintf(stderr, "UHID_OPEN from uhid-dev\n"); in event()
255 fprintf(stderr, "UHID_CLOSE from uhid-dev\n"); in event()
258 fprintf(stderr, "UHID_OUTPUT from uhid-dev\n"); in event()
262 fprintf(stderr, "UHID_OUTPUT_EV from uhid-dev\n"); in event()
265 fprintf(stderr, "Invalid event from uhid-dev: %u\n", ev.type); in event()
309 return -EFAULT; in keyboard()
312 return -errno; in keyboard()
336 abs_hor = -20; in keyboard()
350 abs_ver = -20; in keyboard()
371 wheel = -1; in keyboard()
378 return -ECANCELED; in keyboard()
407 if (!strcmp(argv[1], "-h") || !strcmp(argv[1], "--help")) { in main()
415 fprintf(stderr, "Open uhid-cdev %s\n", path); in main()
418 fprintf(stderr, "Cannot open uhid-cdev %s: %m\n", path); in main()
436 ret = poll(pfds, 2, -1); in main()
446 fprintf(stderr, "Received HUP on uhid-cdev\n"); in main()