Re: [Linuxwacom-devel] [PATCH] hid-wacom: add support to Intuos4 pad buttons and dial

2012-02-02 Thread Aristeu Rozanski
On Thu, Feb 02, 2012 at 09:32:03AM -0600, Chris Bagwell wrote:
 Hi Aristeu,
 
 I'm sure people will be happy to see this patch.  I've a question for you 
 below.
 
 On Wed, Feb 1, 2012 at 11:23 AM, Aristeu Rozanski a...@redhat.com wrote:
  This patch adds support for the pad buttons and dial in the bluetooth 
  version
  of Intuos4.
 
  Signed-off-by: Aristeu Rozanski a...@redhat.com
 
  ---
   drivers/hid/hid-wacom.c |   38 ++
   1 file changed, 38 insertions(+)
 
  --- linus-2.6.orig/drivers/hid/hid-wacom.c      2012-02-01 
  11:54:09.0 -0500
  +++ linus-2.6/drivers/hid/hid-wacom.c   2012-02-01 12:17:46.166583951 -0500
  @@ -363,6 +363,35 @@            input_report_key(input, BTN_STYLUS2, d
         return;
   }
 
  +static void wacom_i4_parse_pad_report(struct wacom_data *wdata,
  +                       struct input_dev *input, unsigned char *data)
  +{
  +       input_report_key(input, BTN_0, (data[2]  0x01));
  +       input_report_key(input, BTN_1, (data[3]  0x01));
  +       input_report_key(input, BTN_2, (data[3]  0x02));
  +       input_report_key(input, BTN_3, (data[3]  0x04));
  +       input_report_key(input, BTN_4, (data[3]  0x08));
  +       input_report_key(input, BTN_5, (data[3]  0x10));
  +       input_report_key(input, BTN_6, (data[3]  0x20));
  +       input_report_key(input, BTN_7, (data[3]  0x40));
  +       input_report_key(input, BTN_8, (data[3]  0x80));
  +
  +       if (data[1]  0x80)
  +               input_report_abs(input, ABS_WHEEL, (data[1]  0x7f));
  +       else
  +               /* Out of proximity, clear wheel value. */
  +               input_report_abs(input, ABS_WHEEL, 0);
  +
  +       if (data[1] | (data[2]  0x01) | data[3]) {
  +               input_report_key(input, wdata-tool, 1);
  +               input_report_key(input, BTN_TOOL_FINGER, 1);
  +       } else {
  +               input_report_key(input, wdata-tool, 0);
  +               input_report_abs(input, BTN_TOOL_FINGER, 0);
  +       }
 
 I'm assuming your sending BTN_TOOL_FINGER because thats what Intuos4
 does in wacom_wac.c kernel driver?
yep.

 For drivers that want to use Protocol 4 or  5 style events (see
 http://sourceforge.net/apps/mediawiki/linuxwacom/index.php?title=Kernel_Input_Event_Overview
 ), this does inform xf86-input-wacom to treat these as PAD events
 so, for example, ABS_WHEEL is treated as a wheel on PAD device and not
 a wheel on mouse puck or airbrush.
but that's intended. it's a wheel on the side of the tablet:
 === +-+
 === | |
 === | |
 === | |
  w  | |
 w=w | |
  w  | |
 === | |
 === | |
 === | |
 === +-+

 But Protocol 4and 5 drivers are also required to send a value in
 ABS_MISC as described in above link.  If not, the serial # is stuck
 with fixed value of zero and then the same data structure in
 xf86-input-wacom will be used to store all events for all hotplugged
 devices.  I'm not exactly sure what that would visually result in but
 I assume if you leave pen in proximity while you click a tablet button
 that the pen would be forced out of proximity when you release the
 button.  Or maybe jump to location (0,0).
 
 One option is to update xf86-input-wacom so that driver does not have
 to send serial #'s always.  Over last year, xf86-input-wacom::wcmUSB.c
 has added a function called usbInitToolType() that peeks at all
 buffered events to detect tool type.  Right now, it only does it to
 see which hotplug device type to send events to.  We could also change
 to decide which data structure/array location (called channel
 internally) as well;  We could at least do this for the PAD device
 which is always force to last channel by convention.
 
 I do not know if these Bluetooth Intuos4 support mouse pucks.  If so,
 then we have to become concerned with only 1 tool with overlapping
 ABS_WHEEL events are allowed in proximity at the same time.
thanks for the explanation, I never fully got the reason for the serial.
I'll rework the patch to get it right.

-- 
Aristeu


--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


[Linuxwacom-devel] [PATCH] hid-wacom: add support to Intuos4 pad buttons and dial

2012-02-01 Thread Aristeu Rozanski
This patch adds support for the pad buttons and dial in the bluetooth version
of Intuos4.

Signed-off-by: Aristeu Rozanski a...@redhat.com

---
 drivers/hid/hid-wacom.c |   38 ++
 1 file changed, 38 insertions(+)

--- linus-2.6.orig/drivers/hid/hid-wacom.c  2012-02-01 11:54:09.0 
-0500
+++ linus-2.6/drivers/hid/hid-wacom.c   2012-02-01 12:17:46.166583951 -0500
@@ -363,6 +363,35 @@input_report_key(input, BTN_STYLUS2, d
return;
 }
 
+static void wacom_i4_parse_pad_report(struct wacom_data *wdata,
+   struct input_dev *input, unsigned char *data)
+{
+   input_report_key(input, BTN_0, (data[2]  0x01));
+   input_report_key(input, BTN_1, (data[3]  0x01));
+   input_report_key(input, BTN_2, (data[3]  0x02));
+   input_report_key(input, BTN_3, (data[3]  0x04));
+   input_report_key(input, BTN_4, (data[3]  0x08));
+   input_report_key(input, BTN_5, (data[3]  0x10));
+   input_report_key(input, BTN_6, (data[3]  0x20));
+   input_report_key(input, BTN_7, (data[3]  0x40));
+   input_report_key(input, BTN_8, (data[3]  0x80));
+
+   if (data[1]  0x80)
+   input_report_abs(input, ABS_WHEEL, (data[1]  0x7f));
+   else
+   /* Out of proximity, clear wheel value. */
+   input_report_abs(input, ABS_WHEEL, 0);
+
+   if (data[1] | (data[2]  0x01) | data[3]) {
+   input_report_key(input, wdata-tool, 1);
+   input_report_key(input, BTN_TOOL_FINGER, 1);
+   } else {
+   input_report_key(input, wdata-tool, 0);
+   input_report_abs(input, BTN_TOOL_FINGER, 0);
+   }
+   input_sync(input);
+}
+
 static void wacom_i4_parse_report(struct hid_device *hdev,
struct wacom_data *wdata,
struct input_dev *input, unsigned char *data)
@@ -377,6 +406,7 @@ case 0x03: /* Features Report */
wdata-features = data[2];
break;
case 0x0C: /* Button report */
+   wacom_i4_parse_pad_report(wdata, input, data);
break;
default:
hid_err(hdev, Unknown report: %d,%d\n, data[0], data[1]);
@@ -474,6 +504,14 @@input_set_abs_params(input, ABS_DISTAN
input_set_abs_params(input, ABS_X, 0, 40640, 4, 0);
input_set_abs_params(input, ABS_Y, 0, 25400, 4, 0);
input_set_abs_params(input, ABS_PRESSURE, 0, 2047, 0, 0);
+   input_set_abs_params(input, ABS_WHEEL, 0, 71, 0, 0);
+   __set_bit(BTN_2, input-keybit);
+   __set_bit(BTN_3, input-keybit);
+   __set_bit(BTN_4, input-keybit);
+   __set_bit(BTN_5, input-keybit);
+   __set_bit(BTN_6, input-keybit);
+   __set_bit(BTN_7, input-keybit);
+   __set_bit(BTN_8, input-keybit);
break;
}
 

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel


[Linuxwacom-devel] [PATCH] hid-wacom: fix proximity tool release

2012-02-01 Thread Aristeu Rozanski
Don't zero the current tool before reporting its release to the input
subsystem.

Signed-off-by: Aristeu Rozanski a...@redhat.com

--- linus-2.6.orig/drivers/hid/hid-wacom.c  2012-02-01 12:04:39.660958537 
-0500
+++ linus-2.6/drivers/hid/hid-wacom.c   2012-02-01 12:05:12.205959440 -0500
@@ -322,10 +322,10 @@ static void wacom_i4_parse_pen_report(st
 
switch (data[1]) {
case 0x80: /* Out of proximity report */
-   wdata-tool = 0;
input_report_key(input, BTN_TOUCH, 0);
input_report_abs(input, ABS_PRESSURE, 0);
input_report_key(input, wdata-tool, 0);
+   wdata-tool = 0;
input_sync(input);
break;
case 0xC2: /* Tool report */

--
Keep Your Developer Skills Current with LearnDevNow!
The most comprehensive online learning library for Microsoft developers
is just $99.99! Visual Studio, SharePoint, SQL - plus HTML5, CSS3, MVC3,
Metro Style Apps, more. Free future releases when you subscribe now!
http://p.sf.net/sfu/learndevnow-d2d
___
Linuxwacom-devel mailing list
Linuxwacom-devel@lists.sourceforge.net
https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel