Input: wacom - cleanup multitouch code when touch_max is 2
Subsystems (2)
PATCH 1/1 Input: wacom - cleanup multitouch code when touch_max is 2
Historically we dealt with touch_max equals to 2 differently from other MT devices. Now we use input_mt_*() to process all MT events, as long as touch_max is greater than 1. So, there is no need to take (touch_max == 2) as a special case any more.
--- drivers/input/tablet/wacom_wac.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)
drivers/input/tablet/wacom_wac.c +6 -20
@@ -1217,8 +1217,8 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)* a=(pi*r^2)/C. */ int a = data[5 ]; -int x_res =input_abs_get_res (input,ABS_X ); -int y_res =input_abs_get_res (input,ABS_Y ); +int x_res =input_abs_get_res (input,ABS_MT_POSITION_X ); +int y_res =input_abs_get_res (input,ABS_MT_POSITION_Y ); width =2 *int_sqrt (a *WACOM_CONTACT_AREA_SCALE ); height = width * y_res / x_res; }
@@ -1587,7 +1587,7 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,input_abs_set_res (input_dev,ABS_X , features->x_resolution);input_abs_set_res (input_dev,ABS_Y , features->y_resolution); }else { -if (features->touch_max <=2 ) { +if (features->touch_max ==1 ) {input_set_abs_params (input_dev,ABS_X ,0 , features->x_max, features->x_fuzz,0 ); input_set_abs_params(input_dev, ABS_Y, 0,
@@ -1815,14 +1815,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,case MTTPC :case MTTPC_B :case TABLETPC2FG : -if (features->device_type ==BTN_TOOL_FINGER ) { -unsigned int flags =INPUT_MT_DIRECT ; - -if (wacom_wac->features.type ==TABLETPC2FG ) - flags =0 ; - -input_mt_init_slots (input_dev, features->touch_max, flags); - } +if ((features->device_type ==BTN_TOOL_FINGER ) && features->touch_max >1 ) +input_mt_init_slots (input_dev, features->touch_max,INPUT_MT_DIRECT );/* fall through */ case TABLETPC :
@@ -1883,10 +1877,6 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,__set_bit (BTN_RIGHT , input_dev->keybit);if (features->touch_max) { -/* touch interface */ -unsigned int flags =INPUT_MT_POINTER ; - -__set_bit (INPUT_PROP_POINTER , input_dev->propbit);if (features->pktlen ==WACOM_PKGLEN_BBTOUCH3 ) { input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
@@ -1894,12 +1884,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,input_set_abs_params (input_dev,ABS_MT_TOUCH_MINOR ,0 , features->y_max,0 ,0 ); - }else { -__set_bit (BTN_TOOL_FINGER , input_dev->keybit); -__set_bit (BTN_TOOL_DOUBLETAP , input_dev->keybit); - flags =0 ; } -input_mt_init_slots (input_dev, features->touch_max, flags); +input_mt_init_slots (input_dev, features->touch_max,INPUT_MT_POINTER ); }else {/* buttons/keys only interface */ __clear_bit (ABS_X , input_dev->absbit);
Signature · 1 line
1.9.1
Quoted 63 lines · Ping Cheng
Historically we dealt with
touch_maxequals to 2 differently from other MT devices. Now we use input_mt_*() to process all MT events, as long astouch_maxis greater than 1. So, there is no need to take (touch_max== 2) as a special case any more.Signed-off-by Ping Cheng <[email protected]>--- drivers/input/tablet/wacom_wac.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)drivers/input/tablet/wacom_wac.c +5
-15@@ -1217,8 +1217,8 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)* a=(pi*r^2)/C. */ int a = data[5 ]; -int x_res =input_abs_get_res (input,ABS_X ); -int y_res =input_abs_get_res (input,ABS_Y ); +int x_res =input_abs_get_res (input,ABS_MT_POSITION_X ); +int y_res =input_abs_get_res (input,ABS_MT_POSITION_Y ); width =2 *int_sqrt (a *WACOM_CONTACT_AREA_SCALE ); height = width * y_res / x_res; }@@ -1587,7 +1587,7 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,input_abs_set_res (input_dev,ABS_X , features->x_resolution);input_abs_set_res (input_dev,ABS_Y , features->y_resolution); }else { -if (features->touch_max <=2 ) { +if (features->touch_max ==1 ) {input_set_abs_params (input_dev,ABS_X ,0 , features->x_max, features->x_fuzz,0 ); input_set_abs_params(input_dev, ABS_Y, 0,@@ -1815,14 +1815,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,case MTTPC :case MTTPC_B :case TABLETPC2FG : -if (features->device_type ==BTN_TOOL_FINGER ) { -unsigned int flags =INPUT_MT_DIRECT ; - -if (wacom_wac->features.type ==TABLETPC2FG ) - flags =0 ; - -input_mt_init_slots (input_dev, features->touch_max, flags); - } +if ((features->device_type ==BTN_TOOL_FINGER ) && features->touch_max >1 ) +input_mt_init_slots (input_dev, features->touch_max,INPUT_MT_DIRECT );/* fall through */ case TABLETPC :@@ -1883,10 +1877,6 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,__set_bit (BTN_RIGHT , input_dev->keybit);if (features->touch_max) { -/* touch interface */ -unsigned int flags =INPUT_MT_POINTER ; - -__set_bit (INPUT_PROP_POINTER , input_dev->propbit);if (features->pktlen ==WACOM_PKGLEN_BBTOUCH3 ) { input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,
drivers/input/tablet/wacom_wac.c int wacom_setup_input_capabilities(struct input_dev *input_dev, · line 1888
Quoted 10 lines
drivers/input/tablet/wacom_wac.c +1
-5@@ -1894,12 +1884,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,input_set_abs_params (input_dev,ABS_MT_TOUCH_MINOR ,0 , features->y_max,0 ,0 ); - }else { -__set_bit (BTN_TOOL_FINGER , input_dev->keybit); -__set_bit (BTN_TOOL_DOUBLETAP , input_dev->keybit); - flags =0 ; } -input_mt_init_slots (input_dev, features->touch_max, flags); +input_mt_init_slots (input_dev, features->touch_max,INPUT_MT_POINTER );
I think you want to use 'input_mt_init_slots(input_dev, features->touch_max + 1, INPUT_MT_POINTER)' instead. This is one more slot than necessary, but the number of slots is used in deciding which of the BTN_TOOL_*TAP buttons the kernel will advertise. Our protocol has the driver sending one more TAP than expected to differentiate touch and pad (e.g. single-touch device needs DOUBLETAP and two-finger touch needs TRIPLETAP). Adding one to the number of slots ensures a high enough TAP is advertised.
Aside from that... Reviewed-by: Jason Gerecke <[email protected]>
Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....
Quoted 10 lines
drivers/input/tablet/wacom_wac.c +0
-1}else {/* buttons/keys only interface */ __clear_bit (ABS_X , input_dev->absbit); --1.9.1
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html
Jason Gerecke
Reviewed-byQuoted 86 lines · Jason Gerecke
Quoted 63 lines · Ping Cheng
Historically we dealt with
touch_maxequals to 2 differently from other MT devices. Now we use input_mt_*() to process all MT events, as long astouch_maxis greater than 1. So, there is no need to take (touch_max== 2) as a special case any more.Signed-off-by Ping Cheng <[email protected]>--- drivers/input/tablet/wacom_wac.c | 26 ++++++-------------------- 1 file changed, 6 insertions(+), 20 deletions(-)drivers/input/tablet/wacom_wac.c +5
-15@@ -1217,8 +1217,8 @@ static void wacom_bpt3_touch_msg(struct wacom_wac *wacom, unsigned char *data)* a=(pi*r^2)/C. */ int a = data[5 ]; -int x_res =input_abs_get_res (input,ABS_X ); -int y_res =input_abs_get_res (input,ABS_Y ); +int x_res =input_abs_get_res (input,ABS_MT_POSITION_X ); +int y_res =input_abs_get_res (input,ABS_MT_POSITION_Y ); width =2 *int_sqrt (a *WACOM_CONTACT_AREA_SCALE ); height = width * y_res / x_res; }@@ -1587,7 +1587,7 @@ static void wacom_abs_set_axis(struct input_dev *input_dev,input_abs_set_res (input_dev,ABS_X , features->x_resolution);input_abs_set_res (input_dev,ABS_Y , features->y_resolution); }else { -if (features->touch_max <=2 ) { +if (features->touch_max ==1 ) {input_set_abs_params (input_dev,ABS_X ,0 , features->x_max, features->x_fuzz,0 ); input_set_abs_params(input_dev, ABS_Y, 0,@@ -1815,14 +1815,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,case MTTPC :case MTTPC_B :case TABLETPC2FG : -if (features->device_type ==BTN_TOOL_FINGER ) { -unsigned int flags =INPUT_MT_DIRECT ; - -if (wacom_wac->features.type ==TABLETPC2FG ) - flags =0 ; - -input_mt_init_slots (input_dev, features->touch_max, flags); - } +if ((features->device_type ==BTN_TOOL_FINGER ) && features->touch_max >1 ) +input_mt_init_slots (input_dev, features->touch_max,INPUT_MT_DIRECT );/* fall through */ case TABLETPC :@@ -1883,10 +1877,6 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,__set_bit (BTN_RIGHT , input_dev->keybit);if (features->touch_max) { -/* touch interface */ -unsigned int flags =INPUT_MT_POINTER ; - -__set_bit (INPUT_PROP_POINTER , input_dev->propbit);if (features->pktlen ==WACOM_PKGLEN_BBTOUCH3 ) { input_set_abs_params(input_dev, ABS_MT_TOUCH_MAJOR,drivers/input/tablet/wacom_wac.c int wacom_setup_input_capabilities(struct input_dev *input_dev, · line 1888
Quoted 10 lines
drivers/input/tablet/wacom_wac.c +1
-5@@ -1894,12 +1884,8 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,input_set_abs_params (input_dev,ABS_MT_TOUCH_MINOR ,0 , features->y_max,0 ,0 ); - }else { -__set_bit (BTN_TOOL_FINGER , input_dev->keybit); -__set_bit (BTN_TOOL_DOUBLETAP , input_dev->keybit); - flags =0 ; } -input_mt_init_slots (input_dev, features->touch_max, flags); +input_mt_init_slots (input_dev, features->touch_max,INPUT_MT_POINTER );I think you want to use '
input_mt_init_slots(input_dev, features->touch_max + 1, INPUT_MT_POINTER)' instead. This is one more slot than necessary, but the number of slots is used in deciding which of the BTN_TOOL_*TAP buttons the kernel will advertise. Our protocol has the driver sending one more TAP than expected to differentiate touch and pad (e.g. single-touch device needs DOUBLETAP and two-finger touch needs TRIPLETAP). Adding one to the number of slots ensures a high enough TAP is advertised.Aside from that... Reviewed-by: Jason Gerecke <[email protected]>
Quoted 14 lines
Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....Quoted 6 lines
drivers/input/tablet/wacom_wac.c +0
-1}else {/* buttons/keys only interface */ __clear_bit (ABS_X , input_dev->absbit); --1.9.1
Ping has explained things to me in a bit more detail, and my reservations have been calmed. We used to use TAP+1 hack to differentiate PAD and touch in the days before the MT protocol. We don't rely on that behavior at all when ABS_MT_* events are used, which is the case with the BAMBOO_PT and INTUOS_HT devices that this would effect. Therefore, without qualification...
Jason
---
Now instead of four in the eights place /
you’ve got three, ‘Cause you added one /
(That is to say, eight) to the two, /
But you can’t take seven from three, /
So you look at the sixty-fours....
--
To unsubscribe from this list: send the line "unsubscribe linux-input" in the body of a message to [email protected]
More majordomo info at http://vger.kernel.org/majordomo-info.html