Pastebin launched a little side project called VERYVIRAL.com, check it out ;-) Want more features on Pastebin? Sign Up, it's FREE!
Guest

touchpad state control, linux psmouse driver patch

By: rkraevskiy on Mar 21st, 2013  |  syntax: Diff  |  size: 3.17 KB  |  views: 358  |  expires: Never
download  |  raw  |  embed  |  report abuse  |  print
Text below is selected. Please press Ctrl+C to copy to your clipboard. (⌘+C on Mac)
  1. Touchpad state control psmouse driver patch by rkraevskiy@gmail.com
  2.  
  3. to check touchpad state:
  4.     cat /sys/bus/serio/drivers/psmouse/serio1/enabled
  5.     1 -> touchpad is enabled
  6.     0 -> touchpad is disabled
  7.  
  8. to disable touchpad:
  9.     echo 0 >/sys/bus/serio/drivers/psmouse/serio1/enabled
  10.  
  11. to enable touchpad:
  12.     echo 1 >/sys/bus/serio/drivers/psmouse/serio1/enabled
  13.  
  14.  
  15. In /etc/acpi/handler.sh
  16.  
  17.     button/lid)
  18.         STATE=`cat  /proc/acpi/button/lid/LID/state | cut -c13-`
  19.         case "$STATE" in
  20.             closed)
  21.                 echo 0 >/sys/bus/serio/drivers/psmouse/serio1/enabled
  22.                 ;;
  23.             open)
  24.                 echo 1 >/sys/bus/serio/drivers/psmouse/serio1/enabled
  25.                 ;;
  26.         esac
  27.         ;;
  28.  
  29.  
  30.  
  31. diff -ur a/drivers/input/mouse/psmouse-base.c b/drivers/input/mouse/psmouse-base.c
  32. --- a/drivers/input/mouse/psmouse-base.c        2012-12-11 05:30:57.000000000 +0200
  33. +++ b/drivers/input/mouse/psmouse-base.c        2012-12-21 23:57:06.000000000 +0200
  34. @@ -87,6 +87,9 @@
  35.  PSMOUSE_DEFINE_ATTR(resync_time, S_IWUSR | S_IRUGO,
  36.                         (void *) offsetof(struct psmouse, resync_time),
  37.                         psmouse_show_int_attr, psmouse_set_int_attr);
  38. +PSMOUSE_DEFINE_ATTR(enabled, S_IWUSR | S_IRUGO,
  39. +                       NULL,
  40. +                       psmouse_attr_show_enabled, psmouse_attr_set_enabled);
  41.  
  42.  static struct attribute *psmouse_attributes[] = {
  43.         &psmouse_attr_protocol.dattr.attr,
  44. @@ -94,6 +97,7 @@
  45.         &psmouse_attr_resolution.dattr.attr,
  46.         &psmouse_attr_resetafter.dattr.attr,
  47.         &psmouse_attr_resync_time.dattr.attr,
  48. +       &psmouse_attr_enabled.dattr.attr,
  49.         NULL
  50.  };
  51.  
  52. @@ -1419,7 +1423,7 @@
  53.         psmouse->resetafter = psmouse_resetafter;
  54.         psmouse->resync_time = parent ? 0 : psmouse_resync_time;
  55.         psmouse->smartscroll = psmouse_smartscroll;
  56. -
  57. +       psmouse->enabled = true;
  58.         psmouse_switch_protocol(psmouse, NULL);
  59.  
  60.         psmouse_set_state(psmouse, PSMOUSE_CMD_MODE);
  61. @@ -1602,7 +1606,7 @@
  62.         retval = attr->set(psmouse, attr->data, buf, count);
  63.  
  64.         if (attr->protect) {
  65. -               if (retval != -ENODEV)
  66. +               if (retval != -ENODEV && psmouse->enabled)
  67.                         psmouse_activate(psmouse);
  68.  
  69.                 if (parent)
  70. @@ -1637,6 +1641,26 @@
  71.         return count;
  72.  }
  73.  
  74. +
  75. +static ssize_t psmouse_attr_show_enabled(struct psmouse *psmouse, void *data, char *buf)
  76. +{
  77. +       return sprintf(buf, "%d\n", psmouse->enabled);
  78. +}
  79. +
  80. +static ssize_t psmouse_attr_set_enabled(struct psmouse *psmouse, void *data, const char *buf, size_t count)
  81. +{
  82. +       unsigned int value;
  83. +       int err;
  84. +
  85. +       err = kstrtouint(buf, 10, &value);
  86. +       if (err){
  87. +               return err;
  88. +       }
  89. +      
  90. +       psmouse->enabled = (value!=0);
  91. +       return count;
  92. +}
  93. +
  94.  static ssize_t psmouse_attr_show_protocol(struct psmouse *psmouse, void *data, char *buf)
  95.  {
  96.         return sprintf(buf, "%s\n", psmouse_protocol_by_type(psmouse->type)->name);
  97. diff -ur a/drivers/input/mouse/psmouse.h b/drivers/input/mouse/psmouse.h
  98. --- a/drivers/input/mouse/psmouse.h     2012-12-11 05:30:57.000000000 +0200
  99. +++ b/drivers/input/mouse/psmouse.h     2012-12-21 23:53:54.000000000 +0200
  100. @@ -62,6 +62,7 @@
  101.         unsigned int resolution;
  102.         unsigned int resetafter;
  103.         unsigned int resync_time;
  104. +       bool enabled;
  105.         bool smartscroll;       /* Logitech only */
  106.  
  107.         psmouse_ret_t (*protocol_handler)(struct psmouse *psmouse);