add 2 finger scroll
This commit is contained in:
@@ -20,6 +20,7 @@ evcode_finger_xpos = 53
|
||||
evcode_finger_ypos = 54
|
||||
evcode_finger_pressure = 58
|
||||
evcode_finger_mv_id = 0x39
|
||||
evcode_finger_mv_slot = 0x2f
|
||||
|
||||
# wacom digitizer dimensions
|
||||
wacom_width = 15725
|
||||
@@ -139,11 +140,18 @@ def read_finger(args, remote_device):
|
||||
|
||||
t_mv_start = 0
|
||||
|
||||
mt_list = {}
|
||||
mt_slot = 0
|
||||
|
||||
while True:
|
||||
_, _, e_type, e_code, e_value = struct.unpack('2IHHi', remote_device.read(16))
|
||||
|
||||
if e_type == e_type_abs:
|
||||
|
||||
if e_code == evcode_finger_mv_slot:
|
||||
mt_slot = e_value
|
||||
|
||||
if mt_slot == 0:
|
||||
# handle x direction
|
||||
if e_code == evcode_finger_xpos:
|
||||
log.debug(e_value)
|
||||
@@ -183,21 +191,36 @@ def read_finger(args, remote_device):
|
||||
last_x = 0
|
||||
last_y = 0
|
||||
|
||||
del mt_list[mt_slot]
|
||||
else:
|
||||
mt_list[mt_slot] = e_value
|
||||
|
||||
# only move when x and y are updated for smoother mouse
|
||||
if new_x and new_y:
|
||||
|
||||
if rel_orig_x != -1 and rel_orig_y != -1:
|
||||
x_vect = y - rel_orig_y
|
||||
y_vect = rel_orig_x - x
|
||||
x_vect = rel_orig_x - x
|
||||
y_vect = rel_orig_y - y
|
||||
|
||||
if(args.orientation == "bottom"):
|
||||
mouse.move(old_x - x, old_y - y)
|
||||
arg_x = 2 * (x_vect - last_x)
|
||||
arg_y = 2 * (y_vect - last_y)
|
||||
if(args.orientation == "top"):
|
||||
mouse.move(x - old_x, y - old_y)
|
||||
arg_x = 2 * (last_x - x_vect)
|
||||
arg_y = 2 * (last_y - y_vect)
|
||||
if(args.orientation == "left"):
|
||||
mouse.move(2 * (x_vect - last_x), 2 * (y_vect - last_y))
|
||||
arg_x = 2 * (last_y - y_vect)
|
||||
arg_y = 2 * (x_vect - last_x)
|
||||
if(args.orientation == "right"):
|
||||
mouse.move(old_y - y, x - old_x)
|
||||
arg_x = 2 * (y_vect - last_y)
|
||||
arg_y = 2 * (last_x - x_vect)
|
||||
|
||||
m_speed = 1
|
||||
|
||||
if len(mt_list) > 1:
|
||||
mouse.scroll(0.2 * arg_x, 0.2 * arg_y)
|
||||
else:
|
||||
mouse.move(m_speed * arg_x, m_speed * arg_y)
|
||||
|
||||
new_x = new_y = False
|
||||
|
||||
|
||||
Reference in New Issue
Block a user