linux-kernel.vger.kernel.org archive mirror
 help / color / mirror / Atom feed
* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a PS/2 Trackpad
@ 2003-05-02  9:41 Hans-Georg Thien
  0 siblings, 0 replies; 10+ messages in thread
From: Hans-Georg Thien @ 2003-05-02  9:41 UTC (permalink / raw)
  To: linux-kernel

Ups, it seems that the majordomo has eaten the initial part of the mail...
(Multipart EMail problem?)

Here is the initial posting without the patch

[InitialPart]

Sorry for this long text and my bad english. And please be kind to me -
it is my very first posting to this mailing list ...

I have written a *very small* patch against the linux 2.4.20 kernel and
I want to submit it now.

The short story
---------------
The trackpad on the MacIntosh iBook Notebooks have a feature that
prevents unintended trackpad input while typing on the keyboard. There
are no mouse-moves or mouse-taps for a short period of time after each
keystroke.

I believe that many people with i386 notebooks would like this feature
and I want to give it to the linux community.

First I had the idea of writing a loadable kernel module "trackpad" that
implements that feature and is loadable via

insmod keybd_irq=? mouse_irq=? delay=?

The long story
--------------
My first approach was - because I came from the bad old M$-DOS times -
write something like a "terminate and stay resident program"

       Procedure LoadModule
         Save the currentlly installed handlers for keyboard and mouse.
         Install your own interrupt handlers for keyboard and mouse.
       End

       Procedure UnloadModule
         Stop and remove "reset-timer" if necessary
         Restore the saved interrupt handlers for keyboard and mouse
       End

       Procedure KbdHandler
         Stop or modify "reset-timer" if necessary
         Set global variable block_mouse_events=1
         Start a timer that resets block_mouse_events=0 after ??? mSec
         Call the old keyboard interrupt handler
       End

       Proceure MouseHandler
         if block_mouse_events>0 then
           call ACK(mouse irq) if necessary
           do nothing
         else
           call old mouse interrupt handler
       End


So I bought the book "Linux Device Drivers" written by Alessandro Rubini
& Jonathan Corbert. It is an excellent book about LKM, but I couldn't
find a way  to "save and restore" irq-handlers as in the design
described above.

That's why I requested a little help in the newsgroup at
comp.os.linux.development.system. This ended up with some people who
said "don't mess around with irq-handlers in that way".

While trying to gain a deeper understanding of irq-handling - espically
for mouse and keyboard handlers - I found out that the keyboard and
mouse interrupts are handled *both* in
/usr/src/linux/drivers/char/pc_keyb.c.

Ok, that is only true for PS/2 mice, but the majority of notebooks on
the market have a PS/2 trackpad. On modifiying the pc_keyb.c file there
is no longer a need to save/restore Interrupt handlers or to call them
indirecty via a function pointer. Unfortunatly it has to be compiled in
the kernel and cannot be written as a LKM module.

But anyway - I sad down and got a working solution very quickly! I'm
very glad with it! I needed not more than 45 minutes to get this
working! Works in textmode (gpm) and under X11 as expected!


Testing
-------
I have tested my patch only on my own notebook (Compaq M300). It would
help a lot if there are some volunteers...


Future Plans
------------
[x] make the "disable trackpad time" configurable via the /proc
filesystem. Do you think that /proc/sys/kernel/trackpad is a good place
for it? There are other files under the /proc/sys/kernel directory that
fall in the category "keyboard handling", e.g. ctrl-alt-del or sysrq.

[x] make a /proc entry to allow "disable trackpad" and "enable
trackpad". That would allow to turn the builtin trackpad off when an
external mouse is pluged in, and to re-enable it when an external mouse
is unplugged again.

[/InitialPart]




^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a PS/2 Trackpad
  2003-05-06  9:29 ` wwp
@ 2003-05-06 11:27   ` Hans-Georg Thien
  0 siblings, 0 replies; 10+ messages in thread
From: Hans-Georg Thien @ 2003-05-06 11:27 UTC (permalink / raw)
  To: wwp; +Cc: linux-kernel

wwp wrote:
> Hi Hans-Georg Thien,
> 
> 
> Would it be possible to enable/disable this feature from userspace using an
> echo 1 > /proc/blabla, or only using insmod/modprobe -r?
> Anyway, very good idea!
> 
> 
I'm working on an "echo ??? >/proc/something?" solution, where ??? is

delay=1200 # adjust trackpad to delay 1200 mSec after last keystroke
delay=0    # no delay, => disable that feature


-Hans



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a PS/2 Trackpad
  2003-05-01 21:48 Hans-Georg Thien
  2003-05-01 22:13 ` Måns Rullgård
@ 2003-05-06  9:29 ` wwp
  2003-05-06 11:27   ` Hans-Georg Thien
  1 sibling, 1 reply; 10+ messages in thread
From: wwp @ 2003-05-06  9:29 UTC (permalink / raw)
  To: Hans-Georg Thien, linux-kernel

Hi Hans-Georg Thien,


On Thu, 01 May 2003 23:48:21 +0200 Hans-Georg Thien <1682-600@onlinehome.de>
wrote:

> Sorry for this long text and my bad english. And please be kind to me -
> it is my very first posting to this mailing list ...
> 
> I have written a *very small* patch against the linux 2.4.20 kernel and
> I want to submit it now.

Would it be possible to enable/disable this feature from userspace using an
echo 1 > /proc/blabla, or only using insmod/modprobe -r?
Anyway, very good idea!


Regards,

-- 
wwp

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a  PS/2 Trackpad
  2003-05-05 22:48 ` Hans-Georg Thien
@ 2003-05-06  9:04   ` Alex Riesen
  0 siblings, 0 replies; 10+ messages in thread
From: Alex Riesen @ 2003-05-06  9:04 UTC (permalink / raw)
  To: Hans-Georg Thien; +Cc: linux-kernel

Hans-Georg Thien, Tue, May 06, 2003 00:48:13 +0200:
> Hans-Georg Thien <1682-600@onlinehome.de> writes:
> 
> >The short story
> >---------------
> >Apple MacIntosh iBook Notebooks computers have a nice feature that
> >prevents unintended trackpad input while typing on the keyboard. There
> >are no mouse-moves or mouse-taps for a short period of time after each
> >keystroke. I wanted to have this feature on my i386 notebook ...
> 
> I have eliminated the use of a timer. The patch has been simple before, 
> and now it is even more simple :)
> 
> 
> diff -urN -X /tmp/dontdiff 
> /usr/src/linux-2.4.20/Documentation/Configure.help 
> /usr/src/linux/Documentation/Configure.help
> --- /usr/src/linux-2.4.20/Documentation/Configure.help	Fri Nov 29 
> 00:53:08 2002
> +++ /usr/src/linux/Documentation/Configure.help	Thu May  1 02:12:04 
> 2003

Very needed thing, thanks a lot.
But could you please be more careful with these line wraps?
One have to apply your patch per hand.


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh   a  PS/2 Trackpad
       [not found] ` <mailman.1052174881.22701.linux-kernel2news@redhat.com>
@ 2003-05-06  3:24   ` Pete Zaitcev
  0 siblings, 0 replies; 10+ messages in thread
From: Pete Zaitcev @ 2003-05-06  3:24 UTC (permalink / raw)
  To: Hans-Georg Thien; +Cc: linux-kernel

> I have eliminated the use of a timer. The patch has been simple before, 
> and now it is even more simple :)

It's pretty good, but I disagree with gratious whitespaces
like these:

> @@ -430,6 +440,7 @@
>   }
> 
> 
> +
>   static inline void handle_mouse_event(unsigned char scancode)
>   {
>   #ifdef CONFIG_PSMOUSE

-- Pete

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a  PS/2 Trackpad
       [not found] <3EB19625.6040904@onlinehome.de.suse.lists.linux.kernel>
  2003-05-01 22:29 ` Andi Kleen
@ 2003-05-05 22:48 ` Hans-Georg Thien
  2003-05-06  9:04   ` Alex Riesen
       [not found] ` <mailman.1052174881.22701.linux-kernel2news@redhat.com>
  2 siblings, 1 reply; 10+ messages in thread
From: Hans-Georg Thien @ 2003-05-05 22:48 UTC (permalink / raw)
  To: linux-kernel; +Cc: Alan Cox

Hans-Georg Thien <1682-600@onlinehome.de> writes:

> The short story
> ---------------
> Apple MacIntosh iBook Notebooks computers have a nice feature that
> prevents unintended trackpad input while typing on the keyboard. There
> are no mouse-moves or mouse-taps for a short period of time after each
> keystroke. I wanted to have this feature on my i386 notebook ...

I have eliminated the use of a timer. The patch has been simple before, 
and now it is even more simple :)


diff -urN -X /tmp/dontdiff 
/usr/src/linux-2.4.20/Documentation/Configure.help 
/usr/src/linux/Documentation/Configure.help
--- /usr/src/linux-2.4.20/Documentation/Configure.help	Fri Nov 29 
00:53:08 2002
+++ /usr/src/linux/Documentation/Configure.help	Thu May  1 02:12:04 2003
@@ -17752,6 +17752,16 @@
    <ftp://gnu.systemy.it/pub/gpm/>) solves this problem, or you can get
    the "mconv2" utility from <ftp://ibiblio.org/pub/Linux/system/mouse/>.

+Disable trackpad while typing
+CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+  For people with a notebook that have a build in PS/2 trackpad.
+
+  It prevents unintended mouse moves and mouse taps while typing on
+  the notebook keyboard.
+
+  The majority of notebooks on the market have a PS/2 trackpad.
+  So you will probably say "Y" if you have a notebook with a trackpad.
+
  C&T 82C710 mouse port support (as on TI Travelmate)
  CONFIG_82C710_MOUSE
    This is a certain kind of PS/2 mouse used on the TI Travelmate. If
diff -urN -X /tmp/dontdiff /usr/src/linux-2.4.20/drivers/char/Config.in 
/usr/src/linux/drivers/char/Config.in
--- /usr/src/linux-2.4.20/drivers/char/Config.in	Fri Nov 29 00:53:12 2002
+++ /usr/src/linux/drivers/char/Config.in	Thu May  1 02:30:45 2003
@@ -170,6 +170,13 @@
  tristate 'Mouse Support (not serial and bus mice)' CONFIG_MOUSE
  if [ "$CONFIG_MOUSE" != "n" ]; then
     bool '  PS/2 mouse (aka "auxiliary device") support' CONFIG_PSMOUSE
+
+   if [ "$CONFIG_PSMOUSE" = "y" ]
+   then
+     bool '    Disable Trackpad while typing on Notebooks' 
CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+   fi
+
+
     tristate '  C&T 82C710 mouse port support (as on TI Travelmate)' 
CONFIG_82C710_MOUSE
     tristate '  PC110 digitizer pad support' CONFIG_PC110_PAD
     tristate '  MK712 touch screen support' CONFIG_MK712_MOUSE
diff -urN -X /tmp/dontdiff /usr/src/linux-2.4.20/drivers/char/pc_keyb.c 
/usr/src/linux/drivers/char/pc_keyb.c
--- /usr/src/linux-2.4.20/drivers/char/pc_keyb.c	Fri Nov 29 00:53:12 2002
+++ /usr/src/linux/drivers/char/pc_keyb.c	Tue May  6 02:07:27 2003
@@ -13,6 +13,11 @@
   * Code fixes to handle mouse ACKs properly.
   * C. Scott Ananian <cananian@alumni.princeton.edu> 1999-01-29.
   *
+ * Implemented the "disable trackpad while typing" feature. This prevents
+ * unintended mouse moves and mouse taps while typing on the keyboard on
+ * notebooks with a PS/2 trackpad.
+ * Hans-Georg Thien <1682-600@onlinehome.de> 2003-04-30.
+ *
   */

  #include <linux/config.h>
@@ -67,6 +72,11 @@
  static void aux_write_ack(int val);
  static void __aux_write_ack(int val);
  static int aux_reconnect = 0;
+
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+static int last_kbd_event = 0; /* used to hold timestamp of last kbd 
event */
+#endif
+
  #endif

  #ifndef kbd_controller_present
@@ -430,6 +440,7 @@
  }


+
  static inline void handle_mouse_event(unsigned char scancode)
  {
  #ifdef CONFIG_PSMOUSE
@@ -449,6 +460,11 @@
  		return;
  	}

+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+        /* do nothing if time since last kbd event is less then 1Sec */
+        if ( abs(jiffies - last_kbd_event) < HZ ) return;
+#endif
+
  	prev_code = scancode;
  	add_mouse_randomness(scancode);
  	if (aux_count) {
@@ -467,8 +483,14 @@

  static unsigned char kbd_exists = 1;

+
  static inline void handle_keyboard_event(unsigned char scancode)
  {
+
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+        last_kbd_event = jiffies;
+#endif
+
  #ifdef CONFIG_VT
  	kbd_exists = 1;
  	if (do_acknowledge(scancode))



^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a  PS/2 Trackpad
       [not found] ` <fa.ianmvqa.8le6bo@ifi.uio.no>
@ 2003-05-02 11:44   ` Hans-Georg Thien
  0 siblings, 0 replies; 10+ messages in thread
From: Hans-Georg Thien @ 2003-05-02 11:44 UTC (permalink / raw)
  To: linux-kernel; +Cc: ak

Andi Kleen wrote:
> Hans-Georg Thien <1682-600@onlinehome.de> writes:
> 
> 
>>The short story
>>---------------
>>The trackpad on the MacIntosh iBook Notebooks have a feature that
>>prevents unintended trackpad input while typing on the keyboard. There
>>are no mouse-moves or mouse-taps for a short period of time after each
>>keystroke.
> 
> 
> Very nice. In fact I wanted something like this for my ibook for a
> long time.
> 
> But it won't work on an ibook of course because it doesn't use the
> pc_keyb driver. Instead it uses the Input layer for the adb device.
> In fact in 2.5 there is only the input layer for everything including
> PC keyboards. It should be probably moved there too.
> 
Sounds good! I will look into 2.5 soon. But I fear that a lot of time 
will pass until 2.6 is available and I think it is a good interim 
solution for the 2.4 users.

> One suggestion: don't make it a CONFIG_*. Recompiling a kernel
> to change things like that is not good. Make it an ioctl that
> can be configured at runtime.
> 
that's why I would prefer a LKM instead of a kernel patch. If you know a 
clean way to save/restore irq-handlers please let me know. That would 
also allow to make it portable to other platforms like Apple iBook or 
notebooks with other than PS/2 trackpads.

Implementing an ioctl() is a nice idea too. But why not have it 
configurable via the /proc interface? If you use ioctl() you still need 
to write a userspace program. Ok, that's not difficult, but I think it's 
more comfortable if you can simply use

   #/etc/rc.d/trackpad, set trackpad delay time
   echo "trackpad delay=2000" > /proc/something

   #/etc/hotplug???  external mouse is just plugged in, disable trackpad
   echo "trackpad disable=1" > /proc/something

   #/etc/hotplug???  external mouse is just revmoved, re-enable trackpad
   echo "trackpad disable=0" > /proc/something

> Another one: the disable_trackpad_timer_while_typing variable is not 
> really needed. You can manage all state by checking the timer with
> timer_pending()
> 
yes ok, so I can save one variable. But I would than have to make the 
enable_trackpad_timer a static global var. That's not really bad, but I 
feel that "complex datastructures" better hidden in a function, - but 
it's only a "feeling"

-Hans


^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a  PS/2 Trackpad
       [not found] <3EB19625.6040904@onlinehome.de.suse.lists.linux.kernel>
@ 2003-05-01 22:29 ` Andi Kleen
  2003-05-05 22:48 ` Hans-Georg Thien
       [not found] ` <mailman.1052174881.22701.linux-kernel2news@redhat.com>
  2 siblings, 0 replies; 10+ messages in thread
From: Andi Kleen @ 2003-05-01 22:29 UTC (permalink / raw)
  To: Hans-Georg Thien; +Cc: linux-kernel

Hans-Georg Thien <1682-600@onlinehome.de> writes:

> The short story
> ---------------
> The trackpad on the MacIntosh iBook Notebooks have a feature that
> prevents unintended trackpad input while typing on the keyboard. There
> are no mouse-moves or mouse-taps for a short period of time after each
> keystroke.

Very nice. In fact I wanted something like this for my ibook for a
long time.

But it won't work on an ibook of course because it doesn't use the
pc_keyb driver. Instead it uses the Input layer for the adb device.
In fact in 2.5 there is only the input layer for everything including
PC keyboards. It should be probably moved there too.

One suggestion: don't make it a CONFIG_*. Recompiling a kernel
to change things like that is not good. Make it an ioctl that
can be configured at runtime.

Another one: the disable_trackpad_timer_while_typing variable is not 
really needed. You can manage all state by checking the timer with
timer_pending()

-Andi

^ permalink raw reply	[flat|nested] 10+ messages in thread

* Re: [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a PS/2 Trackpad
  2003-05-01 21:48 Hans-Georg Thien
@ 2003-05-01 22:13 ` Måns Rullgård
  2003-05-06  9:29 ` wwp
  1 sibling, 0 replies; 10+ messages in thread
From: Måns Rullgård @ 2003-05-01 22:13 UTC (permalink / raw)
  To: linux-kernel

Hans-Georg Thien <1682-600@onlinehome.de> writes:

>  static inline void handle_keyboard_event(unsigned char scancode)
>  {
> +
> +#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
> +
> +        /* setup a timer to re-enable the trackpad */
> +        static struct timer_list enable_trackpad_timer;
> +        static int enable_trackpad_timer_initialized=0;
> +
> +        disable_trackpad_while_typing=1; /* disable trackpad */
> +
> +        if(enable_trackpad_timer_initialized)
> +        {
> +                 /* trackpad timer already exists, - just restart it */
> +                 mod_timer(&enable_trackpad_timer, jiffies+trackpad_delay);
> +        }
> +        else
> +        {
> +                 /* no trackpad timer yet. Initialize and start it */
> +                 init_timer(&enable_trackpad_timer);
> +                 enable_trackpad_timer.expires=jiffies+trackpad_delay;
> +                 enable_trackpad_timer.function=enable_trackpad;
> +                 add_timer(&enable_trackpad_timer);
> +                 enable_trackpad_timer_initialized=1;

The else block would probably be better off in some initialization
function.  Maybe the same place that sets up the interrupt handler is
appropriate.

-- 
Måns Rullgård
mru@users.sf.net


^ permalink raw reply	[flat|nested] 10+ messages in thread

* [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a PS/2 Trackpad
@ 2003-05-01 21:48 Hans-Georg Thien
  2003-05-01 22:13 ` Måns Rullgård
  2003-05-06  9:29 ` wwp
  0 siblings, 2 replies; 10+ messages in thread
From: Hans-Georg Thien @ 2003-05-01 21:48 UTC (permalink / raw)
  To: linux-kernel

[-- Attachment #1: Type: text/plain, Size: 3564 bytes --]

Sorry for this long text and my bad english. And please be kind to me -
it is my very first posting to this mailing list ...

I have written a *very small* patch against the linux 2.4.20 kernel and
I want to submit it now.

The short story
---------------
The trackpad on the MacIntosh iBook Notebooks have a feature that
prevents unintended trackpad input while typing on the keyboard. There
are no mouse-moves or mouse-taps for a short period of time after each
keystroke.

I believe that many people with i386 notebooks would like this feature 
and I want to give it to the linux community.

First I had the idea of writing a loadable kernel module "trackpad" that
implements that feature and is loadable via

insmod keybd_irq=? mouse_irq=? delay=?

The long story
--------------
My first approach was - because I came from the bad old M$-DOS times -
write something like a "terminate and stay resident program"

      Procedure LoadModule
        Save the currentlly installed handlers for keyboard and mouse.
        Install your own interrupt handlers for keyboard and mouse.
      End

      Procedure UnloadModule
        Stop and remove "reset-timer" if necessary
        Restore the saved interrupt handlers for keyboard and mouse
      End

      Procedure KbdHandler
        Stop or modify "reset-timer" if necessary
        Set global variable block_mouse_events=1
        Start a timer that resets block_mouse_events=0 after ??? mSec
        Call the old keyboard interrupt handler
      End

      Proceure MouseHandler
        if block_mouse_events>0 then
          call ACK(mouse irq) if necessary
          do nothing
        else
          call old mouse interrupt handler
      End


So I bought the book "Linux Device Drivers" written by Alessandro Rubini
& Jonathan Corbert. It is an excellent book about LKM, but I couldn't
find a way  to "save and restore" irq-handlers as in the design
described above.

That's why I requested a little help in the newsgroup at
comp.os.linux.development.system. This ended up with some people who
said "don't mess around with irq-handlers in that way".

While trying to gain a deeper understanding of irq-handling - espically
for mouse and keyboard handlers - I found out that the keyboard and
mouse interrupts are handled *both* in
/usr/src/linux/drivers/char/pc_keyb.c.

Ok, that is only true for PS/2 mice, but the majority of notebooks on
the market have a PS/2 trackpad. On modifiying the pc_keyb.c file there
is no longer a need to save/restore Interrupt handlers or to call them
indirecty via a function pointer. Unfortunatly it has to be compiled in
the kernel and cannot be written as a LKM module.

But anyway - I sad down and got a working solution very quickly! I'm
very glad with it! I needed not more than 45 minutes to get this
working! Works in textmode (gpm) and under X11 as expected!


Testing
-------
I have tested my patch only on my own notebook (Compaq M300). It would
help a lot if there are some volunteers...


Future Plans
------------
[x] make the "disable trackpad time" configurable via the /proc
filesystem. Do you think that /proc/sys/kernel/trackpad is a good place
for it? There are other files under the /proc/sys/kernel directory that
fall in the category "keyboard handling", e.g. ctrl-alt-del or sysrq.

[x] make a /proc entry to allow "disable trackpad" and "enable
trackpad". That would allow to turn the builtin trackpad off when an
external mouse is pluged in, and to re-enable it when an external mouse
is unplugged again.


Here is the patch
-----------------



[-- Attachment #2: trackpad_patch.diff --]
[-- Type: text/plain, Size: 4183 bytes --]

diff -urN -X /tmp/dontdiff linux-2.4.20/Documentation/Configure.help /usr/src/linux/Documentation/Configure.help
--- linux-2.4.20/Documentation/Configure.help	Fri Nov 29 00:53:08 2002
+++ /usr/src/linux/Documentation/Configure.help	Thu May  1 02:12:04 2003
@@ -17752,6 +17752,16 @@
   <ftp://gnu.systemy.it/pub/gpm/>) solves this problem, or you can get
   the "mconv2" utility from <ftp://ibiblio.org/pub/Linux/system/mouse/>.
 
+Disable trackpad while typing
+CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+  For people with a notebook that have a build in trackpad.
+
+  It prevents unintended mouse moves and mouse taps while typing on
+  the notebook keyboard.
+
+  The majority of notebooks on the market have a PS/2 trackpad. 
+  So you will probably say "Y" if you have a notebook with a trackpad.
+
 C&T 82C710 mouse port support (as on TI Travelmate)
 CONFIG_82C710_MOUSE
   This is a certain kind of PS/2 mouse used on the TI Travelmate. If
diff -urN -X /tmp/dontdiff linux-2.4.20/drivers/char/Config.in /usr/src/linux/drivers/char/Config.in
--- linux-2.4.20/drivers/char/Config.in	Fri Nov 29 00:53:12 2002
+++ /usr/src/linux/drivers/char/Config.in	Thu May  1 02:30:45 2003
@@ -170,6 +170,13 @@
 tristate 'Mouse Support (not serial and bus mice)' CONFIG_MOUSE
 if [ "$CONFIG_MOUSE" != "n" ]; then
    bool '  PS/2 mouse (aka "auxiliary device") support' CONFIG_PSMOUSE
+
+   if [ "$CONFIG_PSMOUSE" = "y" ]
+   then
+     bool '    Disable Trackpad while typing on Notebooks' CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+   fi
+
+
    tristate '  C&T 82C710 mouse port support (as on TI Travelmate)' CONFIG_82C710_MOUSE
    tristate '  PC110 digitizer pad support' CONFIG_PC110_PAD
    tristate '  MK712 touch screen support' CONFIG_MK712_MOUSE
diff -urN -X /tmp/dontdiff linux-2.4.20/drivers/char/pc_keyb.c /usr/src/linux/drivers/char/pc_keyb.c
--- linux-2.4.20/drivers/char/pc_keyb.c	Fri Nov 29 00:53:12 2002
+++ /usr/src/linux/drivers/char/pc_keyb.c	Thu May  1 02:30:45 2003
@@ -13,6 +13,11 @@
  * Code fixes to handle mouse ACKs properly.
  * C. Scott Ananian <cananian@alumni.princeton.edu> 1999-01-29.
  *
+ * Implemented the "disable trackpad while typing" feature. This prevents
+ * unintended mouse moves and mouse taps while typing on the keyboard on
+ * notebooks with a PS/2 trackpad.
+ * Hans-Georg Thien <1682-600@onlinehome.de> 2003-04-30.
+ *
  */
 
 #include <linux/config.h>
@@ -85,6 +90,10 @@
 /*
  *	PS/2 Auxiliary Device
  */
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+static int disable_trackpad_while_typing=0;
+static int trackpad_delay=HZ;  /* delay trackpad for 1Sec after a key-event */
+#endif
 
 static int __init psaux_init(void);
 
@@ -449,6 +458,10 @@
 		return;
 	}
 
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+        if(disable_trackpad_while_typing > 0) return;
+#endif
+
 	prev_code = scancode;
 	add_mouse_randomness(scancode);
 	if (aux_count) {
@@ -467,8 +480,42 @@
 
 static unsigned char kbd_exists = 1;
 
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+
+void enable_trackpad(unsigned long ptr)
+{
+        disable_trackpad_while_typing=0; /* re-enable trackpad */
+}
+
+#endif
+
 static inline void handle_keyboard_event(unsigned char scancode)
 {
+
+#ifdef CONFIG_DISABLE_TRACKPAD_WHILE_TYPING
+
+        /* setup a timer to re-enable the trackpad */
+        static struct timer_list enable_trackpad_timer;
+        static int enable_trackpad_timer_initialized=0;
+
+        disable_trackpad_while_typing=1; /* disable trackpad */
+
+        if(enable_trackpad_timer_initialized)
+        {
+                 /* trackpad timer already exists, - just restart it */
+                 mod_timer(&enable_trackpad_timer, jiffies+trackpad_delay);
+        }
+        else
+        {
+                 /* no trackpad timer yet. Initialize and start it */
+                 init_timer(&enable_trackpad_timer);
+                 enable_trackpad_timer.expires=jiffies+trackpad_delay;
+                 enable_trackpad_timer.function=enable_trackpad;
+                 add_timer(&enable_trackpad_timer);
+                 enable_trackpad_timer_initialized=1;
+        }
+#endif
+
 #ifdef CONFIG_VT
 	kbd_exists = 1;
 	if (do_acknowledge(scancode))



^ permalink raw reply	[flat|nested] 10+ messages in thread

end of thread, other threads:[~2003-05-06 11:12 UTC | newest]

Thread overview: 10+ messages (download: mbox.gz / follow: Atom feed)
-- links below jump to the message on this page --
2003-05-02  9:41 [RFC][PATCH] "Disable Trackpad while typing" on Notebooks withh a PS/2 Trackpad Hans-Georg Thien
     [not found] <fa.pum5p2l.umu1r1@ifi.uio.no>
     [not found] ` <fa.ianmvqa.8le6bo@ifi.uio.no>
2003-05-02 11:44   ` Hans-Georg Thien
     [not found] <3EB19625.6040904@onlinehome.de.suse.lists.linux.kernel>
2003-05-01 22:29 ` Andi Kleen
2003-05-05 22:48 ` Hans-Georg Thien
2003-05-06  9:04   ` Alex Riesen
     [not found] ` <mailman.1052174881.22701.linux-kernel2news@redhat.com>
2003-05-06  3:24   ` Pete Zaitcev
  -- strict thread matches above, loose matches on Subject: below --
2003-05-01 21:48 Hans-Georg Thien
2003-05-01 22:13 ` Måns Rullgård
2003-05-06  9:29 ` wwp
2003-05-06 11:27   ` Hans-Georg Thien

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).