linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
From: Dave Hansen <dave@sr71.net>
To: Daniel Willmann <d.willmann@tu-bs.de>
Cc: Alan Cox <alan@lxorguk.ukuu.org.uk>,
	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 <hdaps-devel@lists.sourceforge.net>
Subject: Re: [Hdaps-devel] Re: [ltp] IBM HDAPS Someone interested? (Userspace accelerometer viewer)
Date: Tue, 12 Jul 2005 08:55:33 -0700	[thread overview]
Message-ID: <1121183733.8317.17.camel@localhost> (raw)
In-Reply-To: <20050711220911.00da2396@elara.orbit.homelinux.net>

On Mon, 2005-07-11 at 22:09 +0200, Daniel Willmann wrote: 
> 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

Thanks for doing this.  A few comments below.

> +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);

I'm not sure this is a good idea to do in the driver.  Reversing the
movement like this is something that surely should be going into the
input layer.  It might even be there already.

> +       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);

Why do you suppress the events like this?  I think this is done inside
of the input layer already.  What happens if you don't do this?

> +       if (ibm_hdaps_joystick_registered)
> +       {
> +               snprintf(buf, 256, "enabled\n");
> +       }
> +       else
> +               snprintf(buf, 256, "disabled\n");

Please follow the coding style that Jesper and I have been working with:

        if () {
        	foo();
        } else {
        	bar();
        } 

> +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;
> +}

I think this makes the sysfs interface a bit counter-intuitive.  The
"cat joystick_enable" shows "enabled" or "disabled", but you have to
echo "0" and "1" into it to get it to do what you want.

> +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;
> +}

Since that fuzz variable is actually part of the input layer, we should
probably have a conversation with the input people to see if they want a
generic, adjustable fuzz for all ABS input devices, instead of
duplicating it in a bunch of drivers.

BTW, I don't think there's a need for a different fuzzx and fuzzy.

-- Dave


  reply	other threads:[~2005-07-12 15:57 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                                               ` [Hdaps-devel] " Daniel Willmann
2005-07-12 15:55                                                 ` Dave Hansen [this message]
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=1121183733.8317.17.camel@localhost \
    --to=dave@sr71.net \
    --cc=Eric.Piel@tremplin-utc.net \
    --cc=abonilla@linuxwireless.org \
    --cc=alan@lxorguk.ukuu.org.uk \
    --cc=borislav@users.sourceforge.net \
    --cc=d.willmann@tu-bs.de \
    --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).