summaryrefslogtreecommitdiffhomepage
path: root/src/input.c
diff options
context:
space:
mode:
authorrealtradam <[email protected]>2024-05-11 22:40:22 -0400
committerrealtradam <[email protected]>2024-05-11 22:40:22 -0400
commit963ca487e39dc6f5fa28ea230610d140bf1583fb (patch)
tree8f208c6b152b68ae75c9df7b59ccaee9e6105445 /src/input.c
parent8855c3de33c487e09b6a8fd474b0dd351ab3581c (diff)
downloadtojam2024-963ca487e39dc6f5fa28ea230610d140bf1583fb.tar.gz
tojam2024-963ca487e39dc6f5fa28ea230610d140bf1583fb.zip
attempt at first person camera
Diffstat (limited to 'src/input.c')
-rw-r--r--src/input.c56
1 files changed, 56 insertions, 0 deletions
diff --git a/src/input.c b/src/input.c
index 6ac092f..5a43ae5 100644
--- a/src/input.c
+++ b/src/input.c
@@ -4,12 +4,19 @@ joypad_buttons_t pressed_p1;
joypad_buttons_t held_p1;
joypad_inputs_t inputs_p1;
+joypad_buttons_t pressed_p2;
+joypad_buttons_t held_p2;
+joypad_inputs_t inputs_p2;
+
void updateController()
{
joypad_poll();
pressed_p1 = joypad_get_buttons_pressed(JOYPAD_PORT_1);
held_p1 = joypad_get_buttons_held(JOYPAD_PORT_1);
inputs_p1 = joypad_get_inputs(JOYPAD_PORT_1);
+ pressed_p2 = joypad_get_buttons_pressed(JOYPAD_PORT_2);
+ held_p2 = joypad_get_buttons_held(JOYPAD_PORT_2);
+ inputs_p2 = joypad_get_inputs(JOYPAD_PORT_2);
float x = inputs_p1.stick_x;
@@ -82,4 +89,53 @@ void updateController()
inputs_p1.stick_x = x / 55.0f * 127.0f;
inputs_p1.stick_y = y / 55.0f * 127.0f;
+ x = inputs_p2.stick_x;
+ y = inputs_p2.stick_y;
+
+ if(x > 60)
+ {
+ x = 60.0f;
+ }
+ else if(x < -60)
+ {
+ x = -60.0f;
+ }
+ else if((x > -5) && (x < 5))
+ {
+ x = 0.0f;
+ }
+
+ if(y > 60)
+ {
+ y = 60;
+ }
+ else if(y < -60)
+ {
+ y = -60;
+ }
+ else if((y > -5) && (y < 5))
+ {
+ y = 0;
+ }
+
+ if(x > 0)
+ {
+ x -= 5;
+ }
+ else if(x < 0)
+ {
+ x += 5;
+ }
+
+ if(y > 0)
+ {
+ y -= 5;
+ }
+ else if(y < 0)
+ {
+ y += 5;
+ }
+
+ inputs_p2.stick_x = x / 55.0f * 127.0f;
+ inputs_p2.stick_y = y / 55.0f * 127.0f;
}