diff options
author | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-25 09:53:45 +1000 |
---|---|---|
committer | Peter Hutterer <peter.hutterer@who-t.net> | 2009-06-25 09:53:45 +1000 |
commit | 9325f944669058bd72343749be02e75279df8761 (patch) | |
tree | 8c9c642591a32c0d09c14c738a3a1e4c9d7cf472 | |
parent | 4780db3bc7c4625c53372721ae897329367f9d42 (diff) |
Add Thinkpad HDAPS accelerometer device (#22442)
-rw-r--r-- | src/Makefile.am | 2 | ||||
-rw-r--r-- | src/hdaps.c | 82 |
2 files changed, 83 insertions, 1 deletions
diff --git a/src/Makefile.am b/src/Makefile.am index ed9430b..b86bdf6 100644 --- a/src/Makefile.am +++ b/src/Makefile.am @@ -22,7 +22,7 @@ LIBNAME=libfakedev.a AM_LDFLAGS = $(LIBNAME) -noinst_PROGRAMS=btn0 absrel abs pen dummy synaptics allbtn wacom powermate waltop barcode btn0_left +noinst_PROGRAMS=btn0 absrel abs pen dummy synaptics allbtn wacom powermate waltop barcode btn0_left hdaps noinst_LIBRARIES=$(LIBNAME) libfakedev_a_SOURCES=fakedev.c fakedev.h diff --git a/src/hdaps.c b/src/hdaps.c new file mode 100644 index 0000000..5f4381c --- /dev/null +++ b/src/hdaps.c @@ -0,0 +1,82 @@ +/* + * Copyright © 2009 Red Hat, Inc. + * + * Permission to use, copy, modify, distribute, and sell this software + * and its documentation for any purpose is hereby granted without + * fee, provided that the above copyright notice appear in all copies + * and that both that copyright notice and this permission notice + * appear in supporting documentation, and that the name of Red Hat + * not be used in advertising or publicity pertaining to distribution + * of the software without specific, written prior permission. Red + * Hat makes no representations about the suitability of this software + * for any purpose. It is provided "as is" without express or implied + * warranty. + * + * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE, + * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN + * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR + * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS + * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, + * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN + * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE. + * + * Authors: + * Peter Hutterer (peter.hutterer@redhat.com) + */ + + +/* creates a device that looks like my hdaps touchpad */ + +#include <stdio.h> +#include <unistd.h> +#include <linux/input.h> +#include <linux/uinput.h> + +#include "fakedev.h" + + +static int hdaps_setup(struct uinput_user_dev* dev, int fd) +{ + + if (ioctl(fd, UI_SET_EVBIT, EV_ABS) == -1) goto error; + if (ioctl(fd, UI_SET_EVBIT, EV_SYN) == -1) goto error; + + /* axes */ + if (ioctl(fd, UI_SET_ABSBIT, ABS_X) == -1) goto error; + if (ioctl(fd, UI_SET_ABSBIT, ABS_Y) == -1) goto error; + + dev->absmin[ABS_X] = -32768; + dev->absmax[ABS_X] = 32767; + + dev->absmin[ABS_Y] = -32768; + dev->absmax[ABS_Y] = 32767; + + dev->id.bustype = 0x19; + dev->id.vendor = 0x1014; + dev->id.product = 0x5054; + dev->id.version = 0x4801; + + return 0; + +error: + perror("ioctl failed."); + return -1; +} + +static int hdaps_run(int fd) +{ + return 0; +} + +struct test_device hdaps_dev = { + .name = "ThinkPad HDAPS accelerometer data", + .setup = hdaps_setup, + .run = hdaps_run, +}; + + +struct test_device* get_device(void) +{ + return &hdaps_dev; +} + |