Skip to content

Commit

Permalink
Made printing bytes to the console optional.
Browse files Browse the repository at this point in the history
  • Loading branch information
MissingNO123 committed Sep 23, 2017
1 parent 50edd70 commit c7f2a80
Showing 1 changed file with 13 additions and 10 deletions.
23 changes: 13 additions & 10 deletions gamepad.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,6 +5,9 @@

done=False

#edit this to True to print the bytes that are sent.
print_bytes=False

buttonMappings = [
HIDButtons.A,
HIDButtons.B,
Expand Down Expand Up @@ -54,7 +57,7 @@ class KBDButtons(int):

#time.sleep(3)
#server.hid_press(HIDButtons.X) #to show it works
#server.send()
#server.send(print_bytes)

pygame.init()
screen = pygame.display.set_mode((320, 240))
Expand Down Expand Up @@ -91,10 +94,10 @@ class KBDButtons(int):
pos = pygame.mouse.get_pos()
server.touch(pos[0], pos[1])
#print("THSC: ",pos[0],",",pos[1])
server.send()
server.send(print_bytes)
elif event.type == pygame.MOUSEBUTTONUP:
server.clear_touch()
server.send()
server.send(print_bytes)

#Keyboard Mappings
elif event.type == pygame.KEYDOWN:
Expand Down Expand Up @@ -164,7 +167,7 @@ class KBDButtons(int):
if event.key == pygame.K_ESCAPE:
server.clear_everything()
done = True
server.send()
server.send(print_bytes)

elif event.type == pygame.KEYUP:
if event.key == KBDButtons.D_UP:
Expand Down Expand Up @@ -209,17 +212,17 @@ class KBDButtons(int):
server.special_unpress(Special_Buttons.HOME)
if event.key == KBDButtons.POWER: #pw
server.special_unpress(Special_Buttons.POWER)
server.send()
server.send(print_bytes)

# Possible joystick actions: JOYAXISMOTION JOYBALLMOTION JOYBUTTONDOWN JOYBUTTONUP JOYHATMOTION
if event.type == pygame.JOYBUTTONDOWN:
print("Joystick {} button {} pressed.".format(event.joy,event.button))
server.press(buttonMappings[event.button])
server.send()
server.send(print_bytes)
if event.type == pygame.JOYBUTTONUP:
print("Joystick {} button {} released.".format(event.joy,event.button))
server.unpress(buttonMappings[event.button])
server.send()
server.send(print_bytes)
if event.type == pygame.JOYAXISMOTION:
#if event.axis in range(2,3): print("Joystick {} axis {} moved to {}.".format(event.joy,event.axis, event.value))
if event.axis == 0: server.circle_pad_coords[0] = int(32767*event.value) #ls x
Expand All @@ -232,13 +235,13 @@ class KBDButtons(int):
else: server.unpress(HIDButtons.R)
if event.axis == 4: print("soon") #rs y
if event.axis == 5: print("TM") #rs x
server.send()
server.send(print_bytes)

#server.send() #0sx 1sy 4cy 5cx 2l 3r
#server.send(print_bytes) #0sx 1sy 4cy 5cx 2l 3r
print("clearing everything...")
server.clear_everything()
for i in range(1,50):
server.send()
server.send(print_bytes)
pygame.quit()


Expand Down

0 comments on commit c7f2a80

Please sign in to comment.