veandco / go-sdl2

SDL2 binding for Go
https://godoc.org/github.com/veandco/go-sdl2
BSD 3-Clause "New" or "Revised" License
2.17k stars 219 forks source link

0.4.21 compiler error with sdl2 2.0.8 #523

Closed kazzmir closed 2 years ago

kazzmir commented 2 years ago

go-sdl2 0.4.21 references SDL_SensorType in sdl/gamecontroller.go like so:

static SDL_bool SDL_GameControllerHasSensor(SDL_GameController *gamecontroller, SDL_SensorType type)
{
    return SDL_FALSE;
}
..other functions..

But since SDL_SensorType is not defined in sdl 2.0.8 this results in a compiler error.

../../.go/pkg/mod/github.com/veandco/go-sdl2@v0.4.21/sdl/gamecontroller.go:227:86: error: unknown type name 'SDL_SensorType'; did you mean 'SDL_EventType'?
 static float SDL_GameControllerGetSensorDataRate(SDL_GameController *gamecontroller, SDL_SensorType type)

A simple fix would be to typedef SDL_SensorType in gamecontroller.go if the version is not at least 2.0.14

typedef SDL_SensorType int;
veeableful commented 2 years ago

Hi @kazzmir, thanks for reporting this issue! It should be fixed in v0.4.22 now.

kazzmir commented 2 years ago

works great!