about summary refs log tree commit diff stats
path: root/src/controls.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/controls.c')
-rw-r--r--src/controls.c16
1 files changed, 15 insertions, 1 deletions
diff --git a/src/controls.c b/src/controls.c
index ac5aa3d..544813e 100644
--- a/src/controls.c
+++ b/src/controls.c
@@ -1,5 +1,19 @@
 #include "pong.h"
 
+/* Checks what button the player is pressing amongst all control inputs. */
 int player_controls() {
-	return(0);
+	if( IsMouseButtonDown(MOUSE_LEFT_BUTTON) || IsKeyDown(KEY_SPACE) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_RIGHT_FACE_DOWN) ) {
+		return(CONTROLLER_ACTIVATE);
+	} else if( IsKeyDown(KEY_ESCAPE) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_MIDDLE_RIGHT) ) {
+		return(CONTROLLER_PAUSE);
+	} else if( IsKeyDown(KEY_A) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_LEFT) ) {
+		return(CONTROLLER_LEFT);
+	} else if( IsKeyDown(KEY_D) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_RIGHT) ) {
+		return(CONTROLLER_RIGHT);
+	} else if( IsKeyDown(KEY_W) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_UP) ) {
+		return(CONTROLLER_UP);
+	} else if( IsKeyDown(KEY_S) || IsGamepadButtonDown(1, GAMEPAD_BUTTON_LEFT_FACE_DOWN) ) {
+		return(CONTROLLER_DOWN);
+	}
+	return(-1);
 }