Improvements my frien
This commit is contained in:
@@ -128,8 +128,6 @@ Gamepad :: struct {
|
||||
MAX_GAMEPADS :: 4;
|
||||
MAX_MAPPINGS :: 4;
|
||||
|
||||
Action :: enum {}
|
||||
|
||||
Action_Mapping :: struct {
|
||||
gamepad_buttons: [MAX_MAPPINGS] Gamepad_Button;
|
||||
keys: [MAX_MAPPINGS] Key_Code;
|
||||
|
||||
@@ -1,5 +1,5 @@
|
||||
key_mappings : Table(SDL_Keycode, Key_Code);
|
||||
sdl_button_map : [SDL_CONTROLLER_BUTTON_MAX] Gamepad_Button;
|
||||
sdl_button_map : Table(SDL_GameControllerButton, Gamepad_Button);
|
||||
|
||||
init_sdl_input :: () {
|
||||
table_add(*key_mappings, SDLK_a, .A);//[SDLK_a] = .A;
|
||||
@@ -70,6 +70,13 @@ init_sdl_input :: () {
|
||||
table_add(*key_mappings, SDLK_UP, .UP);
|
||||
table_add(*key_mappings, SDLK_DOWN, .DOWN);
|
||||
|
||||
table_add(*sdl_button_map, SDL_CONTROLLER_BUTTON_A, .SPECIAL_BOTTOM);
|
||||
table_add(*sdl_button_map, SDL_CONTROLLER_BUTTON_B, .SPECIAL_RIGHT);
|
||||
table_add(*sdl_button_map, SDL_CONTROLLER_BUTTON_X, .SPECIAL_LEFT);
|
||||
table_add(*sdl_button_map, SDL_CONTROLLER_BUTTON_Y, .SPECIAL_TOP);
|
||||
table_add(*sdl_button_map, SDL_CONTROLLER_BUTTON_LEFTSHOULDER, .LEFT_BUMPER);
|
||||
table_add(*sdl_button_map, SDL_CONTROLLER_BUTTON_RIGHTSHOULDER, .RIGHT_BUMPER);
|
||||
|
||||
//glfw_key_map[GLFW_MOUSE_BUTTON_LEFT] = .MOUSE_LEFT;
|
||||
//glfw_key_map[GLFW_MOUSE_BUTTON_RIGHT] = .MOUSE_RIGHT;
|
||||
|
||||
@@ -237,11 +244,14 @@ sdl_gamepad_button_update :: (using event : SDL_ControllerButtonEvent) {
|
||||
return;
|
||||
}
|
||||
down := state == SDL_PRESSED;
|
||||
gamepad_button := sdl_button_map[button];
|
||||
|
||||
gamepad_button, success := table_find(*sdl_button_map, cast(SDL_GameControllerButton)button);
|
||||
|
||||
if success {
|
||||
gamepad := *engine.input.gamepads[which];
|
||||
|
||||
gamepad := *engine.input.gamepads[which];
|
||||
|
||||
update_gamepad_state(gamepad, gamepad_button, down);
|
||||
update_gamepad_state(gamepad, gamepad_button, down);
|
||||
}
|
||||
}
|
||||
|
||||
sdl_gamepad_device_event :: (using event : SDL_ControllerDeviceEvent) {
|
||||
|
||||
Reference in New Issue
Block a user