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
50 f32 hidden_mouse_travel
;
53 SDL_GameController
*handle
; /* handle for controller. NULL if unused */
54 SDL_JoystickID instance_id
; /* uid used in events */
56 float axises
[ SDL_CONTROLLER_AXIS_MAX
];
57 u32 buttons
[ SDL_CONTROLLER_BUTTON_MAX
];
61 int active_controller_index
; /* most recent controller (by button press)
62 will be -1 if no controllers active */
64 /* what the user is currently using. the keyboard and controller are still
65 * active simultaneously, but this reflects what the UI should show */
68 k_input_method_controller
71 SDL_GameControllerType display_input_type
;
75 u8
vg_getkey( SDL_Keycode kc
);
76 void vg_process_inputs(void);
77 void async_vg_input_init( void *payload
, u32 size
);
78 void vg_input_init(void);
79 void vg_input_free(void);
80 struct vg_controller
*vg_active_controller(void);
81 u8
vg_controller_button( SDL_GameControllerButton button
);
82 f32
vg_controller_axis( SDL_GameControllerAxis axis
);
83 void vg_exec_input_program( enum vg_input_type type
, vg_input_op
*ops
,
85 const char *controller_button_str( SDL_GameControllerButton button
);
86 void vg_keyboard_key_string( vg_str
*str
, u32 key
, int special_glyphs
);
87 void vg_mouse_button_string( vg_str
*str
, u32 button
, int special_glyphs
);
88 void vg_joy_axis_string( vg_str
*str
, SDL_GameControllerAxis axis
,
90 void vg_joy_string( vg_str
*str
, vg_input_op op
, int special_glyphs
);
91 void vg_input_string( vg_str
*str
, vg_input_op
*ops
, int glyphs
);
92 void vg_input_device_event( SDL_Event
*ev
);
93 void vg_input_controller_event( SDL_Event
*ev
);