aboutsummaryrefslogtreecommitdiff
path: root/src/splitscreen_duo/input.py
diff options
context:
space:
mode:
Diffstat (limited to 'src/splitscreen_duo/input.py')
-rw-r--r--src/splitscreen_duo/input.py31
1 files changed, 30 insertions, 1 deletions
diff --git a/src/splitscreen_duo/input.py b/src/splitscreen_duo/input.py
index 1a1e5d0..a9c13c3 100644
--- a/src/splitscreen_duo/input.py
+++ b/src/splitscreen_duo/input.py
@@ -23,10 +23,19 @@ class Input:
if event.type == pygame.KEYDOWN:
if event.key == pygame.K_UP:
return "UP"
+
if event.key == pygame.K_DOWN:
return "DOWN"
+
+ if event.key == pygame.K_LEFT:
+ return "LEFT"
+
+ if event.key == pygame.K_RIGHT:
+ return "RIGHT"
+
if event.key == pygame.K_RETURN:
return "SELECT"
+
if event.key == pygame.K_ESCAPE:
return "QUIT"
@@ -37,14 +46,34 @@ class Input:
return None
if event.type == pygame.JOYAXISMOTION:
- if event.axis == 1: # Y-axis
+ if event.axis == 0: # X-axis (left/right)
+ if event.value < -0.5: # Joystick left
+ return "LEFT"
+
+ if event.value > 0.5: # Joystick right
+ return "RIGHT"
+ elif event.axis == 1: # Y-axis (up/down)
if event.value < -0.5: # Joystick up
return "UP"
+
if event.value > 0.5: # Joystick down
return "DOWN"
+ elif event.type == pygame.JOYHATMOTION:
+ if event.value[0] == -1: # D-pad left
+ return "LEFT"
+
+ if event.value[0] == 1: # D-pad right
+ return "RIGHT"
+
+ if event.value[1] == 1: # D-pad up
+ return "UP"
+
+ if event.value[1] == -1: # D-pad down
+ return "DOWN"
elif event.type == pygame.JOYBUTTONDOWN:
if event.button == 0: # Button A or select
return "SELECT"
+
if event.button == 1: # Button B
return "QUIT"