Ajout du deuxième joystick
Maintenant on a un effet de caméra.
This commit is contained in:
36
control.py
36
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
|
||||
|
||||
|
||||
Reference in New Issue
Block a user