pygame._sdl2.touch
pygame module to work with touch input
get the number of touch devices
get the a touch device id for a given index
the number of active fingers for a given touch device
get information about an active finger

New in pygame 2: 本模块需要SDL2。

pygame._sdl2.touch.get_num_devices()
get the number of touch devices
get_num_devices() -> int

返回可用触摸设备的数量。

pygame._sdl2.touch.get_device()
get the a touch device id for a given index
get_device(index) -> touchid
参数

index (int) -- 此数字至少为0且小于 number of devices

返回与给定的 index

pygame._sdl2.touch.get_num_fingers()
the number of active fingers for a given touch device
get_num_fingers(touchid) -> int

返回id为的触摸设备的活动手指数 touchid

pygame._sdl2.touch.get_finger()
get information about an active finger
get_finger(touchid, index) -> int
参数
  • touchid (int) -- 触摸设备ID。

  • index (int) -- 要返回有关信息的手指的索引,介于0和 number of active fingers

返回手指的判决书 index 活动状态为 touchid 。DICT包含以下密钥:

id         the id of the finger (an integer).
x          the normalized x position of the finger, between 0 and 1.
y          the normalized y position of the finger, between 0 and 1.
pressure   the amount of pressure applied by the finger, between 0 and 1.



Edit on GitHub