31
31
from hidtools .hut import HUT
32
32
from hidtools .hid import HidUnit
33
33
from . import base
34
+ from . import test_multitouch
34
35
import libevdev
35
36
import pytest
36
37
@@ -517,7 +518,7 @@ def get_report_usages(report):
517
518
for usage in get_report_usages (report ):
518
519
yield usage
519
520
520
- def assertName (self , uhdev ):
521
+ def assertName (self , uhdev , type ):
521
522
"""
522
523
Assert that the name is as we expect.
523
524
@@ -526,7 +527,7 @@ def assertName(self, uhdev):
526
527
this assertion from the base class to work properly.
527
528
"""
528
529
evdev = uhdev .get_evdev ()
529
- expected_name = uhdev .name + " Pen"
530
+ expected_name = uhdev .name + type
530
531
if "wacom" not in expected_name .lower ():
531
532
expected_name = "Wacom " + expected_name
532
533
assert evdev .name == expected_name
@@ -549,6 +550,12 @@ def usage_id(page_name, usage_name):
549
550
usage_id ("Generic Desktop" , "Y" ): PhysRange (
550
551
PhysRange .CENTIMETER , 5 , 150
551
552
),
553
+ usage_id ("Digitizers" , "Width" ): PhysRange (
554
+ PhysRange .CENTIMETER , 5 , 150
555
+ ),
556
+ usage_id ("Digitizers" , "Height" ): PhysRange (
557
+ PhysRange .CENTIMETER , 5 , 150
558
+ ),
552
559
usage_id ("Digitizers" , "X Tilt" ): PhysRange (PhysRange .DEGREE , 90 , 180 ),
553
560
usage_id ("Digitizers" , "Y Tilt" ): PhysRange (PhysRange .DEGREE , 90 , 180 ),
554
561
usage_id ("Digitizers" , "Twist" ): PhysRange (PhysRange .DEGREE , 358 , 360 ),
@@ -603,7 +610,17 @@ def test_prop_pointer(self):
603
610
pass
604
611
605
612
606
- class TestOpaqueTablet (BaseTest .TestTablet ):
613
+ class PenTabletTest (BaseTest .TestTablet ):
614
+ def assertName (self , uhdev ):
615
+ super ().assertName (uhdev , " Pen" )
616
+
617
+
618
+ class TouchTabletTest (BaseTest .TestTablet ):
619
+ def assertName (self , uhdev ):
620
+ super ().assertName (uhdev , " Finger" )
621
+
622
+
623
+ class TestOpaqueTablet (PenTabletTest ):
607
624
def create_device (self ):
608
625
return OpaqueTablet ()
609
626
@@ -842,3 +859,64 @@ def offset_rotation(value):
842
859
libevdev .InputEvent (libevdev .EV_KEY .BTN_0 , 0 ),
843
860
],
844
861
)
862
+
863
+
864
+ class TestDTH2452Tablet (test_multitouch .BaseTest .TestMultitouch , TouchTabletTest ):
865
+ def create_device (self ):
866
+ return test_multitouch .Digitizer (
867
+ "DTH 2452" ,
868
+ rdesc = "05 0d 09 04 a1 01 85 0c 95 01 75 08 15 00 26 ff 00 81 03 09 54 81 02 09 22 a1 02 05 0d 95 01 75 01 25 01 09 42 81 02 81 03 09 47 81 02 95 05 81 03 09 51 26 ff 00 75 10 95 01 81 02 35 00 65 11 55 0e 05 01 09 30 26 a0 44 46 96 14 81 42 09 31 26 9a 26 46 95 0b 81 42 05 0d 75 08 95 01 15 00 09 48 26 5f 00 46 7c 14 81 02 09 49 25 35 46 7d 0b 81 02 45 00 65 00 55 00 c0 05 0d 09 22 a1 02 05 0d 95 01 75 01 25 01 09 42 81 02 81 03 09 47 81 02 95 05 81 03 09 51 26 ff 00 75 10 95 01 81 02 35 00 65 11 55 0e 05 01 09 30 26 a0 44 46 96 14 81 42 09 31 26 9a 26 46 95 0b 81 42 05 0d 75 08 95 01 15 00 09 48 26 5f 00 46 7c 14 81 02 09 49 25 35 46 7d 0b 81 02 45 00 65 00 55 00 c0 05 0d 09 22 a1 02 05 0d 95 01 75 01 25 01 09 42 81 02 81 03 09 47 81 02 95 05 81 03 09 51 26 ff 00 75 10 95 01 81 02 35 00 65 11 55 0e 05 01 09 30 26 a0 44 46 96 14 81 42 09 31 26 9a 26 46 95 0b 81 42 05 0d 75 08 95 01 15 00 09 48 26 5f 00 46 7c 14 81 02 09 49 25 35 46 7d 0b 81 02 45 00 65 00 55 00 c0 05 0d 09 22 a1 02 05 0d 95 01 75 01 25 01 09 42 81 02 81 03 09 47 81 02 95 05 81 03 09 51 26 ff 00 75 10 95 01 81 02 35 00 65 11 55 0e 05 01 09 30 26 a0 44 46 96 14 81 42 09 31 26 9a 26 46 95 0b 81 42 05 0d 75 08 95 01 15 00 09 48 26 5f 00 46 7c 14 81 02 09 49 25 35 46 7d 0b 81 02 45 00 65 00 55 00 c0 05 0d 09 22 a1 02 05 0d 95 01 75 01 25 01 09 42 81 02 81 03 09 47 81 02 95 05 81 03 09 51 26 ff 00 75 10 95 01 81 02 35 00 65 11 55 0e 05 01 09 30 26 a0 44 46 96 14 81 42 09 31 26 9a 26 46 95 0b 81 42 05 0d 75 08 95 01 15 00 09 48 26 5f 00 46 7c 14 81 02 09 49 25 35 46 7d 0b 81 02 45 00 65 00 55 00 c0 05 0d 27 ff ff 00 00 75 10 95 01 09 56 81 02 75 08 95 0e 81 03 09 55 26 ff 00 75 08 b1 02 85 0a 06 00 ff 09 c5 96 00 01 b1 02 c0 06 00 ff 09 01 a1 01 09 01 85 13 15 00 26 ff 00 75 08 95 3f 81 02 06 00 ff 09 01 15 00 26 ff 00 75 08 95 3f 91 02 c0" ,
869
+ input_info = (0x3 , 0x056A , 0x0383 ),
870
+ )
871
+
872
+ def test_contact_id_0 (self ):
873
+ """
874
+ Bring a finger in contact with the tablet, then hold it down and remove it.
875
+
876
+ Ensure that even with contact ID = 0 which is usually given as an invalid
877
+ touch event by most tablets with the exception of a few, that given the
878
+ confidence bit is set to 1 it should process it as a valid touch to cover
879
+ the few tablets using contact ID = 0 as a valid touch value.
880
+ """
881
+ uhdev = self .uhdev
882
+ evdev = uhdev .get_evdev ()
883
+
884
+ t0 = test_multitouch .Touch (0 , 50 , 100 )
885
+ r = uhdev .event ([t0 ])
886
+ events = uhdev .next_sync_events ()
887
+ self .debug_reports (r , uhdev , events )
888
+
889
+ slot = self .get_slot (uhdev , t0 , 0 )
890
+
891
+ assert libevdev .InputEvent (libevdev .EV_KEY .BTN_TOUCH , 1 ) in events
892
+ assert evdev .slots [slot ][libevdev .EV_ABS .ABS_MT_TRACKING_ID ] == 0
893
+ assert evdev .slots [slot ][libevdev .EV_ABS .ABS_MT_POSITION_X ] == 50
894
+ assert evdev .slots [slot ][libevdev .EV_ABS .ABS_MT_POSITION_Y ] == 100
895
+
896
+ t0 .tipswitch = False
897
+ if uhdev .quirks is None or "VALID_IS_INRANGE" not in uhdev .quirks :
898
+ t0 .inrange = False
899
+ r = uhdev .event ([t0 ])
900
+ events = uhdev .next_sync_events ()
901
+ self .debug_reports (r , uhdev , events )
902
+ assert libevdev .InputEvent (libevdev .EV_KEY .BTN_TOUCH , 0 ) in events
903
+ assert evdev .slots [slot ][libevdev .EV_ABS .ABS_MT_TRACKING_ID ] == - 1
904
+
905
+ def test_confidence_false (self ):
906
+ """
907
+ Bring a finger in contact with the tablet with confidence set to false.
908
+
909
+ Ensure that the confidence bit being set to false should not result in a touch event.
910
+ """
911
+ uhdev = self .uhdev
912
+ evdev = uhdev .get_evdev ()
913
+
914
+ t0 = test_multitouch .Touch (1 , 50 , 100 )
915
+ t0 .confidence = False
916
+ r = uhdev .event ([t0 ])
917
+ events = uhdev .next_sync_events ()
918
+ self .debug_reports (r , uhdev , events )
919
+
920
+ slot = self .get_slot (uhdev , t0 , 0 )
921
+
922
+ assert not events
0 commit comments