Added controller support.
Added SDL3 controller mappings and loaded with raylib. Updated input manager to get active controller, check for disconnect etc and then use that within the poll input proc.
This commit is contained in:
+10
-3
@@ -1,5 +1,6 @@
|
||||
package game
|
||||
|
||||
import "core:strings"
|
||||
import rl "vendor:raylib"
|
||||
|
||||
VIEWPORT_W :: 1280
|
||||
@@ -32,19 +33,25 @@ Game :: struct {
|
||||
res_index: int
|
||||
}
|
||||
|
||||
// AO: lets me load this at compile time!
|
||||
gamepad_compat := #load("../gamecontrollerdb.txt", string)
|
||||
|
||||
// ------------------------------------------------------------------------------
|
||||
// Game Lifecycle
|
||||
// ------------------------------------------------------------------------------
|
||||
game_init :: proc(game: ^Game) {
|
||||
//rl.SetConfigFlags({.WINDOW_RESIZABLE, .MSAA_4X_HINT})
|
||||
rl.SetConfigFlags({.MSAA_4X_HINT})
|
||||
|
||||
rl.SetConfigFlags({.WINDOW_ALWAYS_RUN, .MSAA_4X_HINT})
|
||||
game.res_index = 2
|
||||
game.window_w = RESOLUTIONS[game.res_index].width
|
||||
game.window_h = RESOLUTIONS[game.res_index].height
|
||||
|
||||
rl.InitWindow(game.window_w, game.window_h, WINDOW_TITLE)
|
||||
rl.SetTargetFPS(60)
|
||||
rl.SetExitKey(.KEY_NULL)
|
||||
|
||||
gamepad_cstr := strings.clone_to_cstring(gamepad_compat)
|
||||
defer delete(gamepad_cstr)
|
||||
rl.SetGamepadMappings(gamepad_cstr)
|
||||
|
||||
// init any global managers
|
||||
audio_init(&game.audio)
|
||||
|
||||
Reference in New Issue
Block a user