On Mon, Nov 1, 2010 at 1:58 PM, Ping Cheng <pingli...@gmail.com> wrote: > On Sun, Oct 31, 2010 at 2:23 PM, <ch...@cnpbagwell.com> wrote: >> From: Chris Bagwell <ch...@cnpbagwell.com> >> >> For Bamboo's/Tablet PC, channel 0 == 1st finger and channel 1 == 2nd finger. >> >> In older Bamboo kernel driver, serial #1 == 1st finger and serial #2 == >> 2nd finger. Mapping to channel was serial # - 1 and events had to >> come in isolated by separate BTN_TOOL_DOUBLETAP/TRIPLETAP messages. >> >> With newer MT kernel driver, MT slot 0 == 1st finger and MT slot 1 == >> 2nd finger. Take advantage of this straight mapping to channel. >> Code will map ST-style events to channel 0 and then MT packets will >> write to either channel 0 or 1 or both. >> >> For MT case of 1st finger, we will updated X/Y/PRESSURE values 2 times >> but left it this way for simplicity (we only dispatch 1 time correctly). >> >> Signed-off-by: Chris Bagwell <ch...@cnpbagwell.com> >> --- >> src/wcmUSB.c | 75 >> ++++++++++++++++++++++++++++++++++++++++++++++++++++++++- >> 1 files changed, 73 insertions(+), 2 deletions(-) >> >> diff --git a/src/wcmUSB.c b/src/wcmUSB.c >> index 186d660..5f65e73 100644 >> --- a/src/wcmUSB.c >> +++ b/src/wcmUSB.c >> @@ -36,6 +36,7 @@ >> typedef struct { >> int wcmLastToolSerial; >> int wcmBTNChannel; >> + int wcmMTChannel; >> int wcmEventCnt; >> struct input_event wcmEvents[MAX_USB_EVENTS]; >> } wcmUSBData; >> @@ -831,6 +832,59 @@ static int usbParseAbsEvent(WacomCommonPtr common, >> return change; >> } >> >> +/* FIXME: I'm compiling against 2.6.35 header files in /usr/include/linux */ >> +#define ABS_MT_SLOT 0x2f >> + >> +static int usbParseAbsMTEvent(WacomCommonPtr common, struct input_event >> *event) >> +{ >> +#ifndef ABS_MT_SLOT >> + /* requires Linux 2.6.36 or newer */ >> + return 0; > > Will we always fall to else since ABS_MT_SLOT is defined above?
Yep. I'll fix it once I settle on a preferred way of checking for it. I kinda wanted to point out by above code that most people will have 2.3.35 kernel installed with their distribution at best and if they just download and install a 2.3.36+ kernel that it still won't work unless they do some CPPFLAGS=-I/path/to/new/kernel/headers. > >> +#else >> + int change = 1; >> + wcmUSBData* private = common->private; >> + WacomDeviceState *ds, *dslast; >> + >> + ds = &common->wcmChannel[private->wcmMTChannel].work; >> + dslast = &common->wcmChannel[private->wcmMTChannel].valid.state; >> + >> + >> + switch(event->code) >> + { >> + case ABS_MT_SLOT: >> + if (event->value >= 0 && event->value < MAX_FINGERS) > > MAX_FINGERS is hardcoded to 2. With the new MT_SLOT protocol, > shouldn't we retrieve it from the kernel instead? Good idea... but a little hard because MAX_CHANNELS is hard coded to 3 and some structure sizes are based on these hard coded values. I can at least get the ball rolling and query the kernel and if its more then 2 slots then print some sort of error message to log file. Hows that sound for now? > > Thank you Chris. > > Ping > >> + { >> + private->wcmMTChannel = event->value; >> + ds->device_type = TOUCH_ID; >> + ds->device_id = TOUCH_DEVICE_ID; >> + ds->serial_num = event->value+1; >> + } >> + break; >> + >> + case ABS_MT_TRACKING_ID: >> + ds->proximity = (event->value != -1); >> + >> + /* time stamp of proximity change for gestures */ >> + ds->sample = (int)GetTimeInMillis(); >> + break; >> + >> + case ABS_MT_POSITION_X: >> + ds->x = event->value; >> + break; >> + >> + case ABS_MT_POSITION_Y: >> + ds->y = event->value; >> + break; >> + >> + case ABS_MT_PRESSURE: >> + ds->capacity = event->value; >> + default: >> + change = 0; >> + } >> + return change; >> +#endif >> +} >> + >> static struct >> { >> unsigned long device_type; >> @@ -1072,7 +1126,7 @@ static void usbDispatchEvents(InputInfoPtr pInfo) >> WacomDevicePtr priv = (WacomDevicePtr)pInfo->private; >> WacomCommonPtr common = priv->common; >> int channel; >> - int channel_change = 0, btn_channel_change = 0; >> + int channel_change = 0, btn_channel_change = 0, mt1_channel_change = >> 0; >> WacomChannelPtr pChannel; >> WacomDeviceState dslast; >> wcmUSBData* private = common->private; >> @@ -1160,7 +1214,15 @@ static void usbDispatchEvents(InputInfoPtr pInfo) >> /* absolute events */ >> if (event->type == EV_ABS) >> { >> - channel_change |= usbParseAbsEvent(common, event, >> ds); >> + if (usbParseAbsEvent(common, event, ds)) >> + channel_change |= 1; >> + else if (usbParseAbsMTEvent(common, event)) >> + { >> + if (private->wcmMTChannel == 0) >> + channel_change |= 1; >> + else if (private->wcmMTChannel == 1) >> + mt1_channel_change |= 1; >> + } >> } >> else if (event->type == EV_REL) >> { >> @@ -1225,6 +1287,15 @@ static void usbDispatchEvents(InputInfoPtr pInfo) >> btn_channel_change)) >> wcmEvent(common, channel, ds); >> >> + /* dispatch for second finger. first finger is handled above. */ >> + if (mt1_channel_change) >> + { >> + WacomDeviceState *mt1_ds; >> + >> + mt1_ds = &common->wcmChannel[private->wcmMTChannel].work; >> + wcmEvent(common, 1, mt1_ds); >> + } >> + >> /* dispatch pad events on generic tablets */ >> if (common->wcmProtocolLevel == WCM_PROTOCOL_GENERIC && >> btn_channel_change) >> -- >> 1.7.3.1 >> >> >> ------------------------------------------------------------------------------ >> Nokia and AT&T present the 2010 Calling All Innovators-North America contest >> Create new apps & games for the Nokia N8 for consumers in U.S. and Canada >> $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing >> Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store >> http://p.sf.net/sfu/nokia-dev2dev >> _______________________________________________ >> Linuxwacom-devel mailing list >> Linuxwacom-devel@lists.sourceforge.net >> https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel >> > ------------------------------------------------------------------------------ Nokia and AT&T present the 2010 Calling All Innovators-North America contest Create new apps & games for the Nokia N8 for consumers in U.S. and Canada $10 million total in prizes - $4M cash, 500 devices, nearly $6M in marketing Develop with Nokia Qt SDK, Web Runtime, or Java and Publish to Ovi Store http://p.sf.net/sfu/nokia-dev2dev _______________________________________________ Linuxwacom-devel mailing list Linuxwacom-devel@lists.sourceforge.net https://lists.sourceforge.net/lists/listinfo/linuxwacom-devel