Lines Matching +full:5 +full:- +full:button
2 # SPDX-License-Identifier: GPL-2.0
3 # -*- coding: utf-8 -*-
34 """Represents whether a button is pressed on the stylus"""
43 https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states
59 self, touch: BtnTouch, tool: Optional[ToolType], button: Optional[bool]
63 self.button = button # type: ignore
66 def from_evdev(cls, evdev, test_button) -> "PenState":
69 button = False
86 # we take only the provided button into account
88 button = bool(evdev.value[test_button.value])
91 # the button will be released after
93 button = False
95 return cls((touch, tool, button)) # type: ignore
99 ) -> "PenState":
106 button = self.button
127 button = bool(ev.value)
130 # the button will be released after
132 button = False
134 new_state = PenState((touch, tool, button)) # type: ignore
146 def valid_transitions(self) -> Tuple["PenState", ...]:
206 def historically_tolerated_transitions(self) -> Tuple["PenState", ...]:
208 for skipping the in-range state, due to historical reasons.
271 def legal_transitions() -> Dict[str, Tuple["PenState", ...]]:
273 we don't have Invert nor Erase bits, so just move in/out-of-range or proximity.
274 … https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states
277 "in-range": (PenState.PEN_IS_IN_RANGE,),
278 "in-range -> out-of-range": (
282 "in-range -> touch": (PenState.PEN_IS_IN_RANGE, PenState.PEN_IS_IN_CONTACT),
283 "in-range -> touch -> release": (
288 "in-range -> touch -> release -> out-of-range": (
297 def legal_transitions_with_invert() -> Dict[str, Tuple["PenState", ...]]:
301 … https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states
304 "hover-erasing": (PenState.PEN_IS_IN_RANGE_WITH_ERASING_INTENT,),
305 "hover-erasing -> out-of-range": (
309 "hover-erasing -> erase": (
313 "hover-erasing -> erase -> release": (
318 "hover-erasing -> erase -> release -> out-of-range": (
324 "hover-erasing -> in-range": (
328 "in-range -> hover-erasing": (
335 def legal_transitions_with_button() -> Dict[str, Tuple["PenState", ...]]:
337 we now have a button.
340 "hover-button": (PenState.PEN_IS_IN_RANGE_WITH_BUTTON,),
341 "hover-button -> out-of-range": (
345 "in-range -> button-press": (
349 "in-range -> button-press -> button-release": (
354 "in-range -> touch -> button-press -> button-release": (
360 "in-range -> touch -> button-press -> release -> button-release": (
367 "in-range -> button-press -> touch -> release -> button-release": (
374 "in-range -> button-press -> touch -> button-release -> release": (
384 def tolerated_transitions() -> Dict[str, Tuple["PenState", ...]]:
389 "direct-in-contact": (PenState.PEN_IS_IN_CONTACT,),
390 "direct-in-contact -> out-of-range": (
397 def tolerated_transitions_with_invert() -> Dict[str, Tuple["PenState", ...]]:
401 … https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states
404 "direct-erase": (PenState.PEN_IS_ERASING,),
405 "direct-erase -> out-of-range": (
412 def broken_transitions() -> Dict[str, Tuple["PenState", ...]]:
415 For example, a pen that has the eraser button might wobble between
419 "in-range -> touch -> erase -> hover-erase": (
425 "in-range -> erase -> hover-erase": (
430 "hover-erase -> erase -> touch -> in-range": (
436 "hover-erase -> touch -> in-range": (
441 "touch -> erase -> touch -> erase": (
499 def assert_expected_input_events(self, evdev, button): argument
509 if button is not None:
510 buttons.remove(button)
514 assert self.current_state == PenState.from_evdev(evdev, button)
542 def move_to(self, pen, state, button): argument
585 assert button is not None
586 pen.barrelswitch = button == BtnPressed.PRIMARY_PRESSED
587 pen.secondarybarrelswitch = button == BtnPressed.SECONDARY_PRESSED
593 assert button is not None
594 pen.barrelswitch = button == BtnPressed.PRIMARY_PRESSED
595 pen.secondarybarrelswitch = button == BtnPressed.SECONDARY_PRESSED
613 def event(self, pen, button): argument
661 self, from_state, pen, evdev, events, allow_intermediate_states, button argument
664 pen.assert_expected_input_events(evdev, button)
677 state = state.apply(sync_events, not allow_intermediate_states, button)
680 state = state.apply(sync_events, not allow_intermediate_states, button)
683 self, state_list, scribble, allow_intermediate_states, button=None argument
697 uhdev.move_to(p, PenState.PEN_IS_OUT_OF_RANGE, button)
698 events = self.post(uhdev, p, button)
700 cur_state, p, evdev, events, allow_intermediate_states, button
708 p.y -= 1
709 events = self.post(uhdev, p, button)
711 cur_state, p, evdev, events, allow_intermediate_states, button
714 uhdev.move_to(p, state, button)
717 p.y -= 1
718 events = self.post(uhdev, p, button)
720 cur_state, p, evdev, events, allow_intermediate_states, button
731 we don't have Invert nor Erase bits, so just move in/out-of-range or proximity.
732 … https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states
763 """Rework the transition state machine by adding the primary button."""
768 button=BtnPressed.PRIMARY_PRESSED,
784 """Rework the transition state machine by adding the secondary button."""
789 button=BtnPressed.SECONDARY_PRESSED,
805 """Rework the transition state machine by adding the secondary button."""
810 button=BtnPressed.THIRD_PRESSED,
829 … https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states
849 … https://docs.microsoft.com/en-us/windows-hardware/design/component-guidelines/windows-pen-states
865 For example, a pen that has the eraser button might wobble between
879 # surface, in-range stays to 1, but when
880 # the pen moves in-range gets reverted to 0
903 the second button as an eraser
921 def move_to(self, pen, state, button): argument
960 assert button is not None
961 pen.barrelswitch = button == BtnPressed.PRIMARY_PRESSED
962 pen.eraser = button == BtnPressed.SECONDARY_PRESSED
967 assert button is not None
968 pen.barrelswitch = button == BtnPressed.PRIMARY_PRESSED
969 pen.eraser = button == BtnPressed.SECONDARY_PRESSED
1023 def move_to(self, pen, state, button, debug=True): argument
1061 assert button is not None
1062 pen.barrelswitch = button == BtnPressed.PRIMARY_PRESSED
1063 pen.eraser = button == BtnPressed.SECONDARY_PRESSED
1068 assert button is not None
1069 pen.barrelswitch = button == BtnPressed.PRIMARY_PRESSED
1070 pen.eraser = button == BtnPressed.SECONDARY_PRESSED
1074 def send_intermediate_state(self, pen, state, button): argument
1076 self.move_to(intermediate_pen, state, button, debug=False)
1077 return super().event(intermediate_pen, button)
1079 def event(self, pen, button): argument
1082 # the pen reliably sends in-range events in a normal case (non emulation of eraser mode)
1086 self.send_intermediate_state(pen, PenState.PEN_IS_IN_RANGE, button)
1089 if button == BtnPressed.SECONDARY_PRESSED:
1094 pen, PenState.PEN_IS_OUT_OF_RANGE, button
1102 pen, PenState.PEN_IS_OUT_OF_RANGE, button
1110 pen, PenState.PEN_IS_OUT_OF_RANGE, button
1115 pen, PenState.PEN_IS_IN_RANGE_WITH_BUTTON, button
1123 pen, PenState.PEN_IS_OUT_OF_RANGE, button
1128 pen, PenState.PEN_IS_IN_RANGE, button
1132 rs.extend(super().event(pen, button))
1140 and 3rd button through Invert
1160 def move_to(self, pen, state, button, debug=True): argument
1201 assert button is not None
1202 pen.barrelswitch = button == BtnPressed.PRIMARY_PRESSED
1203 pen.secondarytipswitch = button == BtnPressed.SECONDARY_PRESSED
1204 pen.invert = button == BtnPressed.THIRD_PRESSED
1209 assert button is not None
1210 pen.barrelswitch = button == BtnPressed.PRIMARY_PRESSED
1211 pen.secondarytipswitch = button == BtnPressed.SECONDARY_PRESSED
1212 pen.invert = button == BtnPressed.THIRD_PRESSED
1246 def event(self, pen, button): argument
1250 # going out-of-prox: the eraser mode is activated by presenting
1264 self.send_intermediate_state(pen, PenState.PEN_IS_OUT_OF_RANGE, button)
1280 self.send_intermediate_state(pen, PenState.PEN_IS_OUT_OF_RANGE, button)
1286 self.send_intermediate_state(pen, PenState.PEN_IS_IN_RANGE, button)
1289 rs.extend(super().event(pen, button))
1301 # return PenDigitizer('uhid test egalax-capacitive_0eef_7224',
1309 # return PenDigitizer('uhid test egalax-capacitive_0eef_72fa',
1317 # return PenDigitizer('uhid test egalax-capacitive_0eef_7336',
1325 # return PenDigitizer('uhid test egalax-capacitive_0eef_7337',
1333 # return PenDigitizer('uhid test egalax-capacitive_0eef_7349',
1341 # return PenDigitizer('uhid test egalax-capacitive_0eef_73f4',
1460 …5c 26 ff 00 81 02 09 5e 81 02 09 70 a1 02 15 01 25 06 09 72 09 73 09 74 09 75 09 76 09 77 81 20 09…
1469 …5a 09 3c 09 45 09 32 75 01 95 06 25 01 81 02 95 02 81 03 09 3d 55 0e 65 14 36 d8 dc 46 28 23 16 d8…
1498 hid_bpfs = [("Huion__Kamvas-Pro-19.bpf.o", True)]
1503 … 10 95 02 81 02 05 0d 09 30 26 ff 3f 75 10 95 01 81 02 09 3d 09 3e 15 a6 25 5a 75 08 95 02 81 02 c…