From 148bc1283824a2da10f05bd2904c176f17495107 Mon Sep 17 00:00:00 2001 From: Thomas Lavocat Date: Wed, 4 Sep 2019 01:59:07 +0200 Subject: [PATCH] =?UTF-8?q?Ajout=20du=20deuxi=C3=A8me=20joystick?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit Maintenant on a un effet de caméra. --- control.py | 36 ++++++++++++++++++++++++++++-------- 1 file changed, 28 insertions(+), 8 deletions(-) diff --git a/control.py b/control.py index 2599a30..82250ff 100644 --- a/control.py +++ b/control.py @@ -237,9 +237,10 @@ t1 = threading.Thread(target=dis_phrase_thread) t1.start() absx = -1 -prev_absx = -1 absy = -1 -prev_absy = -1 + +absrx = -1 +absry = -1 prev_action = -1 @@ -251,9 +252,14 @@ while (True) : absx = raffine_entree(event.state) if event.code =="ABS_Y": absy = raffine_entree(event.state) + if event.code =="ABS_RX": + absrx = raffine_entree(event.state) + if event.code =="ABS_RY": + absry = raffine_entree(event.state) - if abs(absx) < DEAD_ZONE and abs(absy) < DEAD_ZONE : - neutral = 2 + + if abs(absx) < DEAD_ZONE and abs(absy) < DEAD_ZONE and abs(absrx) < DEAD_ZONE : + neutral = 3 action_voulue = -1 if abs(absx) > DEAD_ZONE : @@ -280,13 +286,27 @@ while (True) : elif (absx <0 and absx < -40) and (absy >0 and absy > 40) : action_voulue = 10 + if abs(absrx) > DEAD_ZONE : + if absrx < -DEAD_ZONE : + action_voulue = 15 + elif absrx > DEAD_ZONE : + action_voulue = 16 - if neutral == 2 : + if abs(absrx) > DEAD_ZONE and abs(absy) > DEAD_ZONE : + print("absy : {}".format(absx)) + print("absx : {}".format(absy)) + if (absrx <0 and absrx < -DEAD_ZONE) and (absy <0 and absy < -40) : + action_voulue = 3 + elif (absrx >0 and absrx > DEAD_ZONE) and (absy <0 and absy < -40) : + action_voulue = 4 + elif (absrx >0 and absrx > DEAD_ZONE) and (absy >0 and absy > 40) : + action_voulue = 9 + elif (absrx <0 and absrx < -DEAD_ZONE) and (absy >0 and absy > 40) : + action_voulue = 8 + + if neutral == 3 : action_voulue = 1 if action_voulue > -1 : actions[action_voulue]() - - prev_absx = absx -