aboutsummaryrefslogtreecommitdiff
path: root/src/gunner/controller.c
diff options
context:
space:
mode:
Diffstat (limited to 'src/gunner/controller.c')
-rw-r--r--src/gunner/controller.c88
1 files changed, 8 insertions, 80 deletions
diff --git a/src/gunner/controller.c b/src/gunner/controller.c
index 4e56a27..1ac76ff 100644
--- a/src/gunner/controller.c
+++ b/src/gunner/controller.c
@@ -1,86 +1,14 @@
-// Keyboard things
-
-b32 is_key_pressed(i32 btn)
-{
- return IsKeyPressed(btn);
-}
-
-b32 is_key_held(i32 btn)
-{
- return IsKeyDown(btn);
-}
-
-b32 is_key_released(i32 btn)
-{
- return IsKeyReleased(btn);
-}
-
-// Mouse things
-
-b32 is_mouse_pressed(i32 btn)
-{
- return IsMouseButtonPressed(btn);
-}
-
-b32 is_mouse_held(i32 btn)
-{
- return IsMouseButtonDown(btn);
-}
-
-b32 is_mouse_released(i32 btn)
-{
- return IsMouseButtonReleased(btn);
-}
-
-void set_mouse_scale(f32 x, f32 y)
-{
- SetMouseScale(x, y);
-}
-
-vec2 get_mouse_pos(void)
-{
- Vector2 pos = GetMousePosition();
- return (vec2){FP_TO_FIXED(pos.x), FP_TO_FIXED(pos.y)};
-}
-
-fx32 get_wheel_movement(void)
-{
- return FP_TO_FIXED(GetMouseWheelMove());
-}
-
-// Gamepad things
-
-b32 is_button_pressed(i32 btn)
-{
- return IsGamepadButtonPressed(0, btn);
-}
-
-b32 is_button_held(i32 btn)
-{
- return IsGamepadButtonDown(0, btn);
-}
-
-b32 is_button_released(i32 btn)
-{
- return IsGamepadButtonReleased(0, btn);
-}
-
-i32 last_button_press(void)
-{
- return GetGamepadButtonPressed();
-}
-
// Movement things
-vec2 get_dir_input(void)
+Vector2 get_dir_input(void)
{
- fx32 cont_x = FP_TO_FIXED(GetGamepadAxisMovement(0, 0));
- fx32 cont_y = FP_TO_FIXED(GetGamepadAxisMovement(0, 1));
+ f32 cont_x = GetGamepadAxisMovement(0, 0);
+ f32 cont_y = GetGamepadAxisMovement(0, 1);
- fx32 key_w = IsKeyDown(KEY_W) ? FIXED_POINT_ONE : 0;
- fx32 key_s = IsKeyDown(KEY_S) ? FIXED_POINT_ONE : 0;
- fx32 key_a = IsKeyDown(KEY_A) ? FIXED_POINT_ONE : 0;
- fx32 key_d = IsKeyDown(KEY_D) ? FIXED_POINT_ONE : 0;
+ f32 key_w = IsKeyDown(KEY_W) ? 1.f: 0.f;
+ f32 key_s = IsKeyDown(KEY_S) ? 1.f: 0.f;
+ f32 key_a = IsKeyDown(KEY_A) ? 1.f: 0.f;
+ f32 key_d = IsKeyDown(KEY_D) ? 1.f: 0.f;
// Either Gamepad or Keyboard control, not both!
if(key_w != 0 || key_s != 0 || key_a != 0 || key_d != 0){
@@ -88,5 +16,5 @@ vec2 get_dir_input(void)
cont_y = key_s - key_w;
}
- return (vec2){cont_x, cont_y};
+ return (Vector2){cont_x, cont_y};
}