Rajout des diagonnales
Le premier joystick est complété
This commit is contained in:
26
control.py
26
control.py
@@ -238,10 +238,8 @@ t1.start()
|
|||||||
|
|
||||||
absx = -1
|
absx = -1
|
||||||
prev_absx = -1
|
prev_absx = -1
|
||||||
state_absx=False
|
|
||||||
absy = -1
|
absy = -1
|
||||||
prev_absy = -1
|
prev_absy = -1
|
||||||
state_absy=False
|
|
||||||
|
|
||||||
prev_action = -1
|
prev_action = -1
|
||||||
|
|
||||||
@@ -251,32 +249,36 @@ while (True) :
|
|||||||
for event in events:
|
for event in events:
|
||||||
if event.code =="ABS_X":
|
if event.code =="ABS_X":
|
||||||
absx = raffine_entree(event.state)
|
absx = raffine_entree(event.state)
|
||||||
if (absx > 0 and absx>DEAD_ZONE) or (absx <0 and absx<-DEAD_ZONE):
|
|
||||||
state_absx = True
|
|
||||||
if event.code =="ABS_Y":
|
if event.code =="ABS_Y":
|
||||||
absy = raffine_entree(event.state)
|
absy = raffine_entree(event.state)
|
||||||
if (absy > 0 and absy>DEAD_ZONE) or (absy <0 and absy<-DEAD_ZONE):
|
|
||||||
state_absy = True
|
|
||||||
|
|
||||||
if abs(absx) < DEAD_ZONE and abs(absy) < DEAD_ZONE :
|
if abs(absx) < DEAD_ZONE and abs(absy) < DEAD_ZONE :
|
||||||
neutral = 2
|
neutral = 2
|
||||||
|
|
||||||
action_voulue = -1
|
action_voulue = -1
|
||||||
if state_absx == True :
|
if abs(absx) > DEAD_ZONE :
|
||||||
if absx < -80 :
|
if absx < -80 :
|
||||||
action_voulue = 13
|
action_voulue = 13
|
||||||
elif absx > 80 :
|
elif absx > 80 :
|
||||||
action_voulue = 14
|
action_voulue = 14
|
||||||
#print("absx : {}".format(absx))
|
|
||||||
state_absx = False
|
|
||||||
|
|
||||||
if state_absy == True :
|
if abs(absy) > DEAD_ZONE :
|
||||||
if absy < -80 :
|
if absy < -80 :
|
||||||
action_voulue = 2
|
action_voulue = 2
|
||||||
elif absy > 80 :
|
elif absy > 80 :
|
||||||
action_voulue = 7
|
action_voulue = 7
|
||||||
#print("absy : {}".format(absx))
|
|
||||||
state_absy = False
|
if abs(absx) > DEAD_ZONE and abs(absy) > DEAD_ZONE :
|
||||||
|
print("absy : {}".format(absx))
|
||||||
|
print("absx : {}".format(absy))
|
||||||
|
if (absx <0 and absx < -40) and (absy <0 and absy < -40) :
|
||||||
|
action_voulue = 5
|
||||||
|
elif (absx >0 and absx > 40) and (absy <0 and absy < -40) :
|
||||||
|
action_voulue = 6
|
||||||
|
elif (absx >0 and absx > 40) and (absy >0 and absy > 40) :
|
||||||
|
action_voulue = 11
|
||||||
|
elif (absx <0 and absx < -40) and (absy >0 and absy > 40) :
|
||||||
|
action_voulue = 10
|
||||||
|
|
||||||
|
|
||||||
if neutral == 2 :
|
if neutral == 2 :
|
||||||
|
|||||||
Reference in New Issue
Block a user