diff options
Diffstat (limited to 'src/controller.c')
| -rw-r--r-- | src/controller.c | 96 |
1 files changed, 0 insertions, 96 deletions
diff --git a/src/controller.c b/src/controller.c deleted file mode 100644 index 434e3d6..0000000 --- a/src/controller.c +++ /dev/null @@ -1,96 +0,0 @@ -#include "controller.h" - -#include <raylib.h> - -// 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) -{ - fx32 cont_x = FP_TO_FIXED(GetGamepadAxisMovement(0, 0)); - fx32 cont_y = FP_TO_FIXED(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; - - // Either Gamepad or Keyboard control, not both! - if(key_w != 0 || key_s != 0 || key_a != 0 || key_d != 0){ - cont_x = key_d - key_a; - cont_y = key_s - key_w; - } - - return (vec2){cont_x, cont_y}; -} |
