From: Daniel Willmann <d.willmann@tu-bs.de>
To: Alan Cox <alan@lxorguk.ukuu.org.uk>
Cc: Paul Sladen <thinkpad@paul.sladen.org>,
Alejandro Bonilla <abonilla@linuxwireless.org>,
Vojtech Pavlik <vojtech@suse.cz>, Pavel Machek <pavel@suse.cz>,
linux-thinkpad@linux-thinkpad.org,
Eric Piel <Eric.Piel@tremplin-utc.net>,
borislav@users.sourceforge.net,
"'Yani Ioannou'" <yani.ioannou@gmail.com>,
Linux Kernel Mailing List <linux-kernel@vger.kernel.org>,
hdaps-devel@lists.sourceforge.net
Subject: Re: [Hdaps-devel] Re: [ltp] IBM HDAPS Someone interested? (Userspace accelerometer viewer)
Date: Mon, 11 Jul 2005 22:09:11 +0200 [thread overview]
Message-ID: <20050711220911.00da2396@elara.orbit.homelinux.net> (raw)
In-Reply-To: <1121092015.7407.68.camel@localhost.localdomain>
[-- Attachment #1: Type: text/plain, Size: 889 bytes --]
Hello,
On Mon, 11 Jul 2005 15:26:57 +0100
Alan Cox <alan@lxorguk.ukuu.org.uk> wrote:
> Is the quality good enough to use it DEC itsy style as an input device
> for games like Marble madness ?
it sure is good enough to play neverball.
I have implemented an absolute input driver (aka joystick) on the
basis of Dave's 0.02 version of the driver. I attached the diff to this
mail or just get it from:
http://thebe.orbit.homelinux.net/~alphaone/ibm_hdaps_joystick.tar.gz
Before you can use your thinkpad as a joystick you have to set the
upper and lower bounds for both axis and if any of your axis are
reversed (like X40) through the files in
/sys/devices/platform/ibm_hdaps/ I wrote a little python script to
calibrate and enable the joystick which is included in the tarball or
can be downloaded from
http://thebe.orbit.homelinux.net/svn/ibm-hdaps/util/calibrate.py
Regards,
Daniel
[-- Attachment #2: ibm_hdaps_joystick.patch --]
[-- Type: text/x-patch, Size: 11667 bytes --]
Index: ibm_hdaps.c
===================================================================
--- ibm_hdaps.c (revision 23)
+++ ibm_hdaps.c (revision 27)
@@ -5,6 +5,7 @@
* http://www.almaden.ibm.com/cs/people/marksmith/tpaps.html
*
* Copyright (c) 2005 Jesper Juhl <jesper.juhl@gmail.com>
+ * Copyright (c) 2005 Daniel Willmann <d.willmann@tu-bs.de>
*
* This program is free software; you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
@@ -356,18 +357,7 @@
**************************************************************************/
static struct input_dev hdaps_idev;
-static u16 restx = 0;
-static u16 resty = 0;
-static void hdaps_calibrate(void)
-{
- struct hdaps_accel_data accel_data;
- accelerometer_read(&accel_data);
- restx = accel_data.x_accel;
- resty = accel_data.y_accel;
- printk("restx: %d resty: %d\n", restx, resty);
-}
-
static struct miscdevice ibm_hdaps_dev = {
.minor = MISC_DYNAMIC_MINOR,
.name = "ibm_hdaps",
@@ -376,41 +366,64 @@
static struct timer_list ibm_hdaps_poll_timer;
-static unsigned long ibm_hdaps_mousedev_fuzz = 4;
static unsigned long ibm_hdaps_poll_int_msecs = 25;
-static void ibm_hdaps_mousedev_poll(unsigned long unused)
+static unsigned int ibm_hdaps_joystick_reversex = 0;
+static unsigned int ibm_hdaps_joystick_reversey = 0;
+static u16 lastx = 0, lasty = 0;
+
+static void ibm_hdaps_joystick_poll(unsigned long unused)
{
- int movex, movey;
+ int posx, posy;
struct hdaps_accel_data accel_data;
accelerometer_read(&accel_data);
- movex = restx - accel_data.x_accel;
- movey = resty - accel_data.y_accel;
- if (abs(movex) > ibm_hdaps_mousedev_fuzz)
- input_report_rel(&hdaps_idev, REL_Y, movex);
- if (abs(movey) > ibm_hdaps_mousedev_fuzz)
- input_report_rel(&hdaps_idev, REL_X, movey);
+ posx = accel_data.x_accel;
+ posy = accel_data.y_accel;
+
+ if (ibm_hdaps_joystick_reversex)
+ posy = hdaps_idev.absmax[ABS_X] + (hdaps_idev.absmin[ABS_X] - posy);
+ if (ibm_hdaps_joystick_reversey)
+ posx = hdaps_idev.absmax[ABS_Y] + (hdaps_idev.absmin[ABS_Y] - posx);
+
+ if (abs(posx-lastx) > 0)
+ input_report_abs(&hdaps_idev, ABS_Y, posx);
+ if (abs(posy-lasty) > 0)
+ input_report_abs(&hdaps_idev, ABS_X, posy);
input_sync(&hdaps_idev);
+ lastx = posx;
+ lasty = posy;
mod_timer(&ibm_hdaps_poll_timer,
jiffies + msecs_to_jiffies(ibm_hdaps_poll_int_msecs));
}
-static int calibrated = 0;
-static int ibm_hdaps_mousedev_registered = 0;
-static int ibm_hdaps_mousedev_enable(void)
+static int ibm_hdaps_joystick_registered = 0;
+
+static void ibm_hdaps_joystick_disable(void)
{
- printk("ibm_hdaps_mousedev_enable()\n");
+ if (!ibm_hdaps_joystick_registered)
+ return;
+
+ del_timer_sync(&ibm_hdaps_poll_timer);
+ input_unregister_device(&hdaps_idev);
+ ibm_hdaps_joystick_registered = 0;
+
+ return;
+}
+
+static int ibm_hdaps_joystick_enable(void)
+{
+ printk(KERN_DEBUG "ibm_hdaps_joystick_enable()\n");
hdaps_idev.dev = &ibm_hdaps_plat_dev.dev;
init_input_dev(&hdaps_idev);
- hdaps_idev.evbit[0] = BIT(EV_KEY) | BIT(EV_REL);
- hdaps_idev.relbit[0] = BIT(REL_X) | BIT(REL_Y);
- hdaps_idev.keybit[LONG(BTN_LEFT)] = BIT(BTN_LEFT);
+ hdaps_idev.name = "IBM Accelerometer";
+ hdaps_idev.evbit[0] = BIT(EV_ABS);
+ hdaps_idev.absbit[0] = BIT(ABS_X) | BIT(ABS_Y);
input_register_device(&hdaps_idev);
- ibm_hdaps_mousedev_registered = 1;
+ ibm_hdaps_joystick_registered = 1;
init_timer(&ibm_hdaps_poll_timer);
- ibm_hdaps_poll_timer.function = ibm_hdaps_mousedev_poll;
+ ibm_hdaps_poll_timer.function = ibm_hdaps_joystick_poll;
ibm_hdaps_poll_timer.expires =
jiffies + msecs_to_jiffies(ibm_hdaps_poll_int_msecs);
add_timer(&ibm_hdaps_poll_timer);
@@ -418,39 +431,199 @@
return 1;
}
-static void ibm_hdaps_mousedev_disable(void)
+static ssize_t
+hdaps_joystick_enable_read(struct device *dev, char *buf)
{
- if (!ibm_hdaps_mousedev_registered)
- return;
+ if (ibm_hdaps_joystick_registered)
+ {
+ snprintf(buf, 256, "enabled\n");
+ }
+ else
+ snprintf(buf, 256, "disabled\n");
+ return strlen(buf)+1;
+}
- del_timer_sync(&ibm_hdaps_poll_timer);
- input_unregister_device(&hdaps_idev);
+static ssize_t
+hdaps_joystick_enable_store(struct device *dev, const char * buf, size_t count)
+{
+ if ((strncmp(buf, "1", 1) == 0)&&(!ibm_hdaps_joystick_registered))
+ {
+ ibm_hdaps_joystick_enable();
+ }
+ else if ((strncmp(buf, "0", 1) == 0)&&(ibm_hdaps_joystick_registered))
+ {
+ ibm_hdaps_joystick_disable();
+ }
+ return count;
+}
+static DEVICE_ATTR(joystick_enable, S_IWUGO | S_IRUGO, hdaps_joystick_enable_read, hdaps_joystick_enable_store);
- return;
+static ssize_t
+hdaps_joystick_fuzzx_read(struct device *dev, char *buf)
+{
+ snprintf(buf, 256, "%hu\n", hdaps_idev.absfuzz[ABS_X]);
+ return strlen(buf)+1;
}
static ssize_t
-hdaps_mousedev_enable_store(struct device *dev, struct device_attribute *attr,
- const char * buf, size_t count)
+hdaps_joystick_fuzzx_store(struct device *dev, const char * buf, size_t count)
{
- if (!calibrated)
+ uint16_t temp;
+ if (ibm_hdaps_joystick_registered)
return -EINVAL;
+ if (sscanf(buf, "%hu", &temp) == 1)
+ {
+ hdaps_idev.absfuzz[ABS_X] = temp;
+ }
+ return count;
+}
+static DEVICE_ATTR(joystick_fuzzx, S_IWUGO | S_IRUGO, hdaps_joystick_fuzzx_read, hdaps_joystick_fuzzx_store);
- ibm_hdaps_mousedev_enable();
+static ssize_t
+hdaps_joystick_fuzzy_read(struct device *dev, char *buf)
+{
+ snprintf(buf, 256, "%hu\n", hdaps_idev.absfuzz[ABS_Y]);
+ return strlen(buf)+1;
+}
+
+static ssize_t
+hdaps_joystick_fuzzy_store(struct device *dev, const char * buf, size_t count)
+{
+ uint16_t temp;
+ if (ibm_hdaps_joystick_registered)
+ return -EINVAL;
+ if (sscanf(buf, "%hu", &temp) == 1)
+ {
+ hdaps_idev.absfuzz[ABS_Y] = temp;
+ }
return count;
}
-static DEVICE_ATTR(mousedev_enable,S_IWUGO, NULL, hdaps_mousedev_enable_store);
+static DEVICE_ATTR(joystick_fuzzy, S_IWUGO | S_IRUGO, hdaps_joystick_fuzzy_read, hdaps_joystick_fuzzy_store);
-ssize_t hdaps_calibrate_store(struct device *dev,
- struct device_attribute *attr,
- const char * buf, size_t count)
+static ssize_t
+hdaps_joystick_minx_read(struct device *dev, char *buf)
{
- hdaps_calibrate();
- calibrated = 1;
+ snprintf(buf, 256, "%hu\n", hdaps_idev.absmin[ABS_X]);
+ return strlen(buf)+1;
+}
+
+static ssize_t
+hdaps_joystick_minx_store(struct device *dev, const char * buf, size_t count)
+{
+ uint16_t temp;
+ if (ibm_hdaps_joystick_registered)
+ return -EINVAL;
+ if (sscanf(buf, "%hu", &temp) == 1)
+ {
+ hdaps_idev.absmin[ABS_X] = temp;
+ }
return count;
}
-static DEVICE_ATTR(calibrate,S_IWUGO, NULL, hdaps_calibrate_store);
+static DEVICE_ATTR(joystick_minx, S_IWUGO | S_IRUGO, hdaps_joystick_minx_read, hdaps_joystick_minx_store);
+static ssize_t
+hdaps_joystick_miny_read(struct device *dev, char *buf)
+{
+ snprintf(buf, 256, "%hu\n", hdaps_idev.absmin[ABS_Y]);
+ return strlen(buf)+1;
+}
+
+static ssize_t
+hdaps_joystick_miny_store(struct device *dev, const char * buf, size_t count)
+{
+ uint16_t temp;
+ if (ibm_hdaps_joystick_registered)
+ return -EINVAL;
+ if (sscanf(buf, "%hu", &temp) == 1)
+ {
+ hdaps_idev.absmin[ABS_Y] = temp;
+ }
+ return count;
+}
+static DEVICE_ATTR(joystick_miny, S_IWUGO | S_IRUGO, hdaps_joystick_miny_read, hdaps_joystick_miny_store);
+
+static ssize_t
+hdaps_joystick_maxx_read(struct device *dev, char *buf)
+{
+ snprintf(buf, 256, "%hu\n", hdaps_idev.absmax[ABS_X]);
+ return strlen(buf)+1;
+}
+
+static ssize_t
+hdaps_joystick_maxx_store(struct device *dev, const char * buf, size_t count)
+{
+ uint16_t temp;
+ if (ibm_hdaps_joystick_registered)
+ return -EINVAL;
+ if (sscanf(buf, "%hu", &temp) == 1)
+ {
+ hdaps_idev.absmax[ABS_X] = temp;
+ }
+ return count;
+}
+static DEVICE_ATTR(joystick_maxx, S_IWUGO | S_IRUGO, hdaps_joystick_maxx_read, hdaps_joystick_maxx_store);
+
+static ssize_t
+hdaps_joystick_maxy_read(struct device *dev, char *buf)
+{
+ snprintf(buf, 256, "%hu\n", hdaps_idev.absmax[ABS_Y]);
+ return strlen(buf)+1;
+}
+
+static ssize_t
+hdaps_joystick_maxy_store(struct device *dev, const char * buf, size_t count)
+{
+ uint16_t temp;
+ if (ibm_hdaps_joystick_registered)
+ return -EINVAL;
+ if (sscanf(buf, "%hu", &temp) == 1)
+ {
+ hdaps_idev.absmax[ABS_Y] = temp;
+ }
+ return count;
+}
+static DEVICE_ATTR(joystick_maxy, S_IWUGO | S_IRUGO, hdaps_joystick_maxy_read, hdaps_joystick_maxy_store);
+
+static ssize_t
+hdaps_joystick_reversex_read(struct device *dev, char *buf)
+{
+ snprintf(buf, 256, "%hu\n", ibm_hdaps_joystick_reversex);
+ return strlen(buf)+1;
+}
+
+static ssize_t
+hdaps_joystick_reversex_store(struct device *dev, const char * buf, size_t count)
+{
+ if (ibm_hdaps_joystick_registered)
+ return -EINVAL;
+ if (strncmp(buf, "1", 1) == 0)
+ ibm_hdaps_joystick_reversex = 1;
+ else if (strncmp(buf, "0", 1) == 0)
+ ibm_hdaps_joystick_reversex = 0;
+ return count;
+}
+static DEVICE_ATTR(joystick_reversex, S_IWUGO | S_IRUGO, hdaps_joystick_reversex_read, hdaps_joystick_reversex_store);
+
+static ssize_t
+hdaps_joystick_reversey_read(struct device *dev, char *buf)
+{
+ snprintf(buf, 256, "%hu\n", ibm_hdaps_joystick_reversey);
+ return strlen(buf)+1;
+}
+
+static ssize_t
+hdaps_joystick_reversey_store(struct device *dev, const char * buf, size_t count)
+{
+ if (ibm_hdaps_joystick_registered)
+ return -EINVAL;
+ if (strncmp(buf, "1", 1) == 0)
+ ibm_hdaps_joystick_reversey = 1;
+ else if (strncmp(buf, "0", 1) == 0)
+ ibm_hdaps_joystick_reversey = 0;
+ return count;
+}
+static DEVICE_ATTR(joystick_reversey, S_IWUGO | S_IRUGO, hdaps_joystick_reversey_read, hdaps_joystick_reversey_store);
+
static int ibm_hdaps_init(void)
{
int retval;
@@ -475,8 +648,15 @@
printk(KERN_DEBUG "ibm_hdaps_init: platform_dev_register\n");
platform_device_register(&ibm_hdaps_plat_dev);
- device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_calibrate);
- device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_mousedev_enable);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_enable);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_fuzzx);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_fuzzy);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_minx);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_miny);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_maxx);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_maxy);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_reversex);
+ device_create_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_reversey);
printk(KERN_DEBUG "ibm_hdaps_init: done\n");
return 0;
@@ -484,10 +664,17 @@
static void ibm_hdaps_exit(void)
{
- ibm_hdaps_mousedev_disable();
+ ibm_hdaps_joystick_disable();
- device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_calibrate);
- device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_mousedev_enable);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_enable);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_fuzzx);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_fuzzy);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_minx);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_miny);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_maxx);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_maxy);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_reversex);
+ device_remove_file(&ibm_hdaps_plat_dev.dev, &dev_attr_joystick_reversey);
platform_device_unregister(&ibm_hdaps_plat_dev);
misc_deregister(&ibm_hdaps_dev);
next prev parent reply other threads:[~2005-07-11 20:13 UTC|newest]
Thread overview: 66+ messages / expand[flat|nested] mbox.gz Atom feed top
[not found] <42B6F6F6.2040704@zipman.it>
2005-06-20 17:28 ` [ltp] Re: IBM HDAPS Someone interested? Alejandro Bonilla
2005-06-20 19:51 ` Yani Ioannou
2005-06-20 20:11 ` Yani Ioannou
2005-06-20 20:25 ` Alejandro Bonilla
2005-06-20 20:34 ` Yani Ioannou
2005-06-20 20:48 ` Alejandro Bonilla
2005-06-20 21:35 ` Lee Revell
2005-06-20 21:57 ` Alejandro Bonilla
2005-06-20 23:35 ` Lee Revell
2005-06-22 10:49 ` Pavel Machek
2005-06-22 12:50 ` Alejandro Bonilla
2005-06-23 7:13 ` Vojtech Pavlik
2005-06-23 10:06 ` Eric Piel
2005-06-23 12:53 ` Alejandro Bonilla
2005-06-23 13:18 ` Vojtech Pavlik
2005-06-23 20:22 ` Eric Piel
2005-06-23 20:42 ` Lee Revell
2005-06-25 6:17 ` [ltp] IBM HDAPS Someone interested? (Accelerometer) Paul Sladen
2005-06-25 11:31 ` Vojtech Pavlik
2005-06-25 14:47 ` Pavel Machek
2005-06-25 15:00 ` Vojtech Pavlik
2005-06-25 18:14 ` Alejandro Bonilla
2005-06-25 20:14 ` Vojtech Pavlik
2005-06-27 12:33 ` Lenz Grimmer
2005-06-27 13:10 ` Alejandro Bonilla
2005-06-27 21:02 ` Lee Revell
2005-06-28 3:22 ` Alejandro Bonilla
2005-06-28 5:40 ` Lee Revell
2005-06-28 15:40 ` Vojtech Pavlik
2005-06-25 18:13 ` Alejandro Bonilla
2005-06-25 20:09 ` Vojtech Pavlik
2005-06-25 22:41 ` Alejandro Bonilla
2005-06-27 3:35 ` [Hdaps-devel] " Shawn Starr
2005-07-03 8:37 ` Alejandro Bonilla
2005-07-03 10:16 ` Vojtech Pavlik
2005-07-03 11:07 ` Jesper Juhl
2005-07-03 18:17 ` Jesper Juhl
2005-07-03 19:21 ` [Hdaps-devel] " Dave Hansen
2005-07-03 18:29 ` Alejandro Bonilla
2005-07-03 19:37 ` Dave Hansen
2005-07-03 19:42 ` Jesper Juhl
2005-07-03 18:52 ` Alejandro Bonilla
2005-07-03 19:42 ` Henrik Brix Andersen
2005-07-03 20:03 ` Jesper Juhl
2005-07-03 20:53 ` Tomasz Torcz
2005-07-03 19:41 ` Dave Hansen
2005-07-11 9:42 ` [ltp] IBM HDAPS Someone interested? (Userspace accelerometer viewer) Paul Sladen
2005-07-11 14:26 ` Alan Cox
2005-07-11 16:53 ` [Hdaps-devel] " Dave Hansen
2005-07-11 17:31 ` Paul RIVIER
2005-07-11 20:09 ` Daniel Willmann [this message]
2005-07-12 15:55 ` [Hdaps-devel] " Dave Hansen
2005-07-11 15:13 ` Pavel Machek
2005-07-12 9:41 ` Matthew Garrett
2005-07-11 16:21 ` [Hdaps-devel] " Dave Hansen
2005-07-13 16:27 ` Alejandro Bonilla
2005-06-25 17:42 ` [ltp] IBM HDAPS Someone interested? (Accelerometer) Alejandro Bonilla
2005-06-27 10:36 ` P
2005-06-23 15:33 ` [ltp] Re: IBM HDAPS Someone interested? Jan Knutar
2005-06-23 17:08 ` Lee Revell
2005-06-23 20:47 ` Andrew Haninger
2005-06-24 9:16 ` P
2005-06-24 12:56 ` Alejandro Bonilla
2005-06-24 17:20 ` Alejandro Bonilla
2005-06-20 20:53 ` Vojtech Pavlik
[not found] ` <005b01c575bd_724fac60_600cc60a@amer.sykes.com>
2005-06-20 20:25 ` Pavel Machek
Reply instructions:
You may reply publicly to this message via plain-text email
using any one of the following methods:
* Save the following mbox file, import it into your mail client,
and reply-to-all from there: mbox
Avoid top-posting and favor interleaved quoting:
https://en.wikipedia.org/wiki/Posting_style#Interleaved_style
* Reply using the --to, --cc, and --in-reply-to
switches of git-send-email(1):
git send-email \
--in-reply-to=20050711220911.00da2396@elara.orbit.homelinux.net \
--to=d.willmann@tu-bs.de \
--cc=Eric.Piel@tremplin-utc.net \
--cc=abonilla@linuxwireless.org \
--cc=alan@lxorguk.ukuu.org.uk \
--cc=borislav@users.sourceforge.net \
--cc=hdaps-devel@lists.sourceforge.net \
--cc=linux-kernel@vger.kernel.org \
--cc=linux-thinkpad@linux-thinkpad.org \
--cc=pavel@suse.cz \
--cc=thinkpad@paul.sladen.org \
--cc=vojtech@suse.cz \
--cc=yani.ioannou@gmail.com \
/path/to/YOUR_REPLY
https://kernel.org/pub/software/scm/git/docs/git-send-email.html
* If your mail client supports setting the In-Reply-To header
via mailto: links, try the mailto: link
Be sure your reply has a Subject: header at the top and a blank line
before the message body.
This is a public inbox, see mirroring instructions
for how to clone and mirror all data and code used for this inbox;
as well as URLs for NNTP newsgroup(s).