3 /* Copyright (C) 2021-2024 Harry Godden (hgn) - All Rights Reserved */
4 #define VG_MAX_CONTROLLERS 4
6 #include "vg_platform.h"
8 extern f32 controller_deadzone
;
10 typedef u32 vg_input_op
;
11 typedef vg_input_op
*vg_input_program
;
15 k_vg_input_type_button_u8
,
16 k_vg_input_type_axis_f32
,
17 k_vg_input_type_joy_v2f
52 SDL_GameController
*handle
; /* handle for controller. NULL if unused */
53 SDL_JoystickID instance_id
; /* uid used in events */
55 float axises
[ SDL_CONTROLLER_AXIS_MAX
];
56 u32 buttons
[ SDL_CONTROLLER_BUTTON_MAX
];
60 int active_controller_index
; /* most recent controller (by button press)
61 will be -1 if no controllers active */
63 /* what the user is currently using. the keyboard and controller are still
64 * active simultaneously, but this reflects what the UI should show */
67 k_input_method_controller
70 SDL_GameControllerType display_input_type
;
74 u8
vg_getkey( SDL_Keycode kc
);
75 void vg_process_inputs(void);
76 void async_vg_input_init( void *payload
, u32 size
);
77 void vg_input_init(void);
78 void vg_input_free(void);
79 struct vg_controller
*vg_active_controller(void);
80 u8
vg_controller_button( SDL_GameControllerButton button
);
81 f32
vg_controller_axis( SDL_GameControllerAxis axis
);
82 void vg_exec_input_program( enum vg_input_type type
, vg_input_op
*ops
,
84 const char *controller_button_str( SDL_GameControllerButton button
);
85 void vg_keyboard_key_string( vg_str
*str
, u32 key
, int special_glyphs
);
86 void vg_mouse_button_string( vg_str
*str
, u32 button
, int special_glyphs
);
87 void vg_joy_axis_string( vg_str
*str
, SDL_GameControllerAxis axis
,
89 void vg_joy_string( vg_str
*str
, vg_input_op op
, int special_glyphs
);
90 void vg_input_string( vg_str
*str
, vg_input_op
*ops
, int glyphs
);
91 void vg_input_device_event( SDL_Event
*ev
);
92 void vg_input_controller_event( SDL_Event
*ev
);