|
|
@ -3,7 +3,6 @@ import pygame
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
class Joystick():
|
|
|
|
class Joystick():
|
|
|
|
|
|
|
|
|
|
|
|
def __init__(self, navigator, light, configuration, camera):
|
|
|
|
def __init__(self, navigator, light, configuration, camera):
|
|
|
|
# joystick
|
|
|
|
# joystick
|
|
|
|
pygame.joystick.init()
|
|
|
|
pygame.joystick.init()
|
|
|
@ -40,13 +39,13 @@ class Joystick():
|
|
|
|
button = self.joystick.get_button(i)
|
|
|
|
button = self.joystick.get_button(i)
|
|
|
|
dict['Button {}'.format(i)] = button
|
|
|
|
dict['Button {}'.format(i)] = button
|
|
|
|
|
|
|
|
|
|
|
|
if i == c['LIGHT'] and button == 1 and button not in self.pressed:
|
|
|
|
if i == c['LIGHT'] and button == 1 and i not in self.pressed:
|
|
|
|
self.light.switch()
|
|
|
|
self.light.switch()
|
|
|
|
self.pressed.append(i)
|
|
|
|
self.pressed.append(i)
|
|
|
|
elif i == c['LIGHT'] and button == 0 and button in self.pressed:
|
|
|
|
elif i == c['LIGHT'] and button == 0 and i in self.pressed:
|
|
|
|
self.pressed.remove(i)
|
|
|
|
self.pressed.remove(i)
|
|
|
|
|
|
|
|
|
|
|
|
elif i == c['MUSIC'] and button == 1 and button not in self.pressed:
|
|
|
|
elif i == c['MUSIC'] and button == 1 and i not in self.pressed:
|
|
|
|
if self.splaying:
|
|
|
|
if self.splaying:
|
|
|
|
self.sound.stop()
|
|
|
|
self.sound.stop()
|
|
|
|
self.splaying = False
|
|
|
|
self.splaying = False
|
|
|
@ -54,25 +53,25 @@ class Joystick():
|
|
|
|
self.sound.play()
|
|
|
|
self.sound.play()
|
|
|
|
self.splaying = True
|
|
|
|
self.splaying = True
|
|
|
|
self.pressed.append(i)
|
|
|
|
self.pressed.append(i)
|
|
|
|
elif i == c['MUSIC'] and button == 0 and button in self.pressed:
|
|
|
|
elif i == c['MUSIC'] and button == 0 and i in self.pressed:
|
|
|
|
self.pressed.remove(i)
|
|
|
|
self.pressed.remove(i)
|
|
|
|
|
|
|
|
|
|
|
|
elif i == c['VOLIN'] and button == 1 and button not in self.pressed:
|
|
|
|
elif i == c['VOLIN'] and button == 1 and i not in self.pressed:
|
|
|
|
self.sound.set_volume(self.sound.get_volume() + 0.1)
|
|
|
|
self.sound.set_volume(self.sound.get_volume() + 0.1)
|
|
|
|
self.pressed.append(i)
|
|
|
|
self.pressed.append(i)
|
|
|
|
elif i == c['VOLIN'] and button == 0 and button in self.pressed:
|
|
|
|
elif i == c['VOLIN'] and button == 0 and i in self.pressed:
|
|
|
|
self.sound.set_volume(self.sound.get_volume() - 0.1)
|
|
|
|
self.sound.set_volume(self.sound.get_volume() - 0.1)
|
|
|
|
self.pressed.remove(i)
|
|
|
|
self.pressed.remove(i)
|
|
|
|
|
|
|
|
|
|
|
|
elif i == c['VOLDE'] and button == 1 and button not in self.pressed:
|
|
|
|
elif i == c['VOLDE'] and button == 1 and i not in self.pressed:
|
|
|
|
self.pressed.append(i)
|
|
|
|
self.pressed.append(i)
|
|
|
|
elif i == c['VOLDE'] and button == 0 and button in self.pressed:
|
|
|
|
elif i == c['VOLDE'] and button == 0 and i in self.pressed:
|
|
|
|
self.pressed.remove(i)
|
|
|
|
self.pressed.remove(i)
|
|
|
|
|
|
|
|
|
|
|
|
elif i == c['REC'] and button == 1 and button not in self.pressed:
|
|
|
|
elif i == c['REC'] and button == 1 and i not in self.pressed:
|
|
|
|
self._save_camimg()
|
|
|
|
self._save_camimg()
|
|
|
|
self.pressed.append(i)
|
|
|
|
self.pressed.append(i)
|
|
|
|
elif i == c['REC'] and button == 0 and button in self.pressed:
|
|
|
|
elif i == c['REC'] and button == 0 and i in self.pressed:
|
|
|
|
self.pressed.remove(i)
|
|
|
|
self.pressed.remove(i)
|
|
|
|
|
|
|
|
|
|
|
|
# hats
|
|
|
|
# hats
|
|
|
@ -91,6 +90,7 @@ class Joystick():
|
|
|
|
return dict
|
|
|
|
return dict
|
|
|
|
|
|
|
|
|
|
|
|
def _save_camimg(self):
|
|
|
|
def _save_camimg(self):
|
|
|
|
|
|
|
|
self.camera.new_frame()
|
|
|
|
img = self.camera.image
|
|
|
|
img = self.camera.image
|
|
|
|
if os.path.isfile('image.jpg'):
|
|
|
|
if os.path.isfile('image.jpg'):
|
|
|
|
count = 0
|
|
|
|
count = 0
|
|
|
|