@@ -785,25 +785,6 @@ static int wacom_intuos_irq(struct wacom_wac *wacom)
785785 return 1 ;
786786}
787787
788- static int find_slot_from_contactid (struct wacom_wac * wacom , int contactid )
789- {
790- int touch_max = wacom -> features .touch_max ;
791- int i ;
792-
793- if (!wacom -> slots )
794- return -1 ;
795-
796- for (i = 0 ; i < touch_max ; ++ i ) {
797- if (wacom -> slots [i ] == contactid )
798- return i ;
799- }
800- for (i = 0 ; i < touch_max ; ++ i ) {
801- if (wacom -> slots [i ] == -1 )
802- return i ;
803- }
804- return -1 ;
805- }
806-
807788static int int_dist (int x1 , int y1 , int x2 , int y2 )
808789{
809790 int x = x2 - x1 ;
@@ -833,8 +814,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
833814 for (i = 0 ; i < contacts_to_send ; i ++ ) {
834815 int offset = (WACOM_BYTES_PER_24HDT_PACKET * i ) + 1 ;
835816 bool touch = data [offset ] & 0x1 && !wacom -> shared -> stylus_in_proximity ;
836- int id = data [offset + 1 ];
837- int slot = find_slot_from_contactid (wacom , id );
817+ int slot = input_mt_get_slot_by_key (input , data [offset + 1 ]);
838818
839819 if (slot < 0 )
840820 continue ;
@@ -856,9 +836,7 @@ static int wacom_24hdt_irq(struct wacom_wac *wacom)
856836 input_report_abs (input , ABS_MT_WIDTH_MINOR , min (w , h ));
857837 input_report_abs (input , ABS_MT_ORIENTATION , w > h );
858838 }
859- wacom -> slots [slot ] = touch ? id : -1 ;
860839 }
861-
862840 input_mt_report_pointer_emulation (input , true);
863841
864842 wacom -> num_contacts_left -= contacts_to_send ;
@@ -895,7 +873,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
895873 int offset = (WACOM_BYTES_PER_MT_PACKET + x_offset ) * i + 3 ;
896874 bool touch = data [offset ] & 0x1 ;
897875 int id = le16_to_cpup ((__le16 * )& data [offset + 1 ]);
898- int slot = find_slot_from_contactid ( wacom , id );
876+ int slot = input_mt_get_slot_by_key ( input , id );
899877
900878 if (slot < 0 )
901879 continue ;
@@ -908,9 +886,7 @@ static int wacom_mt_touch(struct wacom_wac *wacom)
908886 input_report_abs (input , ABS_MT_POSITION_X , x );
909887 input_report_abs (input , ABS_MT_POSITION_Y , y );
910888 }
911- wacom -> slots [slot ] = touch ? id : -1 ;
912889 }
913-
914890 input_mt_report_pointer_emulation (input , true);
915891
916892 wacom -> num_contacts_left -= contacts_to_send ;
@@ -942,12 +918,11 @@ static int wacom_tpc_mt_touch(struct wacom_wac *wacom)
942918 contact_with_no_pen_down_count ++ ;
943919 }
944920 }
921+ input_mt_report_pointer_emulation (input , true);
945922
946923 /* keep touch state for pen event */
947924 wacom -> shared -> touch_down = (contact_with_no_pen_down_count > 0 );
948925
949- input_mt_report_pointer_emulation (input , true);
950-
951926 return 1 ;
952927}
953928
@@ -1104,12 +1079,15 @@ static int wacom_bpt_touch(struct wacom_wac *wacom)
11041079static void wacom_bpt3_touch_msg (struct wacom_wac * wacom , unsigned char * data )
11051080{
11061081 struct input_dev * input = wacom -> input ;
1107- int slot_id = data [0 ] - 2 ; /* data[0] is between 2 and 17 */
11081082 bool touch = data [1 ] & 0x80 ;
1083+ int slot = input_mt_get_slot_by_key (input , data [0 ]);
1084+
1085+ if (slot < 0 )
1086+ return ;
11091087
11101088 touch = touch && !wacom -> shared -> stylus_in_proximity ;
11111089
1112- input_mt_slot (input , slot_id );
1090+ input_mt_slot (input , slot );
11131091 input_mt_report_slot_state (input , MT_TOOL_FINGER , touch );
11141092
11151093 if (touch ) {
@@ -1162,7 +1140,6 @@ static int wacom_bpt3_touch(struct wacom_wac *wacom)
11621140 wacom_bpt3_button_msg (wacom , data + offset );
11631141
11641142 }
1165-
11661143 input_mt_report_pointer_emulation (input , true);
11671144
11681145 input_sync (input );
@@ -1639,17 +1616,11 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
16391616 } else if (features -> device_type == BTN_TOOL_FINGER ) {
16401617 __clear_bit (ABS_MISC , input_dev -> absbit );
16411618
1642- __set_bit (BTN_TOOL_FINGER , input_dev -> keybit );
1643- __set_bit (BTN_TOOL_DOUBLETAP , input_dev -> keybit );
1644- __set_bit (BTN_TOOL_TRIPLETAP , input_dev -> keybit );
1645- __set_bit (BTN_TOOL_QUADTAP , input_dev -> keybit );
1646-
1647- input_mt_init_slots (input_dev , features -> touch_max , 0 );
1648-
16491619 input_set_abs_params (input_dev , ABS_MT_TOUCH_MAJOR ,
16501620 0 , features -> x_max , 0 , 0 );
16511621 input_set_abs_params (input_dev , ABS_MT_TOUCH_MINOR ,
16521622 0 , features -> y_max , 0 , 0 );
1623+ input_mt_init_slots (input_dev , features -> touch_max , INPUT_MT_POINTER );
16531624 }
16541625 break ;
16551626
@@ -1680,21 +1651,14 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
16801651
16811652 case MTSCREEN :
16821653 case MTTPC :
1683- if (features -> device_type == BTN_TOOL_FINGER ) {
1684- wacom_wac -> slots = kmalloc (features -> touch_max *
1685- sizeof (int ),
1686- GFP_KERNEL );
1687- if (!wacom_wac -> slots )
1688- return - ENOMEM ;
1689-
1690- for (i = 0 ; i < features -> touch_max ; i ++ )
1691- wacom_wac -> slots [i ] = -1 ;
1692- }
1693- /* fall through */
1694-
16951654 case TABLETPC2FG :
16961655 if (features -> device_type == BTN_TOOL_FINGER ) {
1697- input_mt_init_slots (input_dev , features -> touch_max , 0 );
1656+ unsigned int flags = INPUT_MT_DIRECT ;
1657+
1658+ if (wacom_wac -> features .type == TABLETPC2FG )
1659+ flags = 0 ;
1660+
1661+ input_mt_init_slots (input_dev , features -> touch_max , flags );
16981662 }
16991663 /* fall through */
17001664
@@ -1737,28 +1701,26 @@ int wacom_setup_input_capabilities(struct input_dev *input_dev,
17371701 __set_bit (INPUT_PROP_POINTER , input_dev -> propbit );
17381702
17391703 if (features -> device_type == BTN_TOOL_FINGER ) {
1704+ unsigned int flags = INPUT_MT_POINTER ;
1705+
17401706 __set_bit (BTN_LEFT , input_dev -> keybit );
17411707 __set_bit (BTN_FORWARD , input_dev -> keybit );
17421708 __set_bit (BTN_BACK , input_dev -> keybit );
17431709 __set_bit (BTN_RIGHT , input_dev -> keybit );
17441710
1745- __set_bit (BTN_TOOL_FINGER , input_dev -> keybit );
1746- __set_bit (BTN_TOOL_DOUBLETAP , input_dev -> keybit );
1747- input_mt_init_slots (input_dev , features -> touch_max , 0 );
1748-
17491711 if (features -> pktlen == WACOM_PKGLEN_BBTOUCH3 ) {
1750- __set_bit (BTN_TOOL_TRIPLETAP ,
1751- input_dev -> keybit );
1752- __set_bit (BTN_TOOL_QUADTAP ,
1753- input_dev -> keybit );
1754-
17551712 input_set_abs_params (input_dev ,
17561713 ABS_MT_TOUCH_MAJOR ,
17571714 0 , features -> x_max , 0 , 0 );
17581715 input_set_abs_params (input_dev ,
17591716 ABS_MT_TOUCH_MINOR ,
17601717 0 , features -> y_max , 0 , 0 );
1718+ } else {
1719+ __set_bit (BTN_TOOL_FINGER , input_dev -> keybit );
1720+ __set_bit (BTN_TOOL_DOUBLETAP , input_dev -> keybit );
1721+ flags = 0 ;
17611722 }
1723+ input_mt_init_slots (input_dev , features -> touch_max , flags );
17621724 } else if (features -> device_type == BTN_TOOL_PEN ) {
17631725 __set_bit (BTN_TOOL_RUBBER , input_dev -> keybit );
17641726 __set_bit (BTN_TOOL_PEN , input_dev -> keybit );
0 commit comments