Raylib 5.0 bug workaround: Check VERSION and panic if VERSION != 5.0, in which case there is info in the message about how to remove the workaround.

This commit is contained in:
Karl Zylinski
2023-12-18 11:19:11 +01:00
parent 2a0e4f7a8c
commit 2362be11bf

View File

@@ -1190,8 +1190,10 @@ foreign lib {
IsMouseButtonDown :: proc(button: MouseButton) -> bool --- // Detect if a mouse button is being pressed
IsMouseButtonReleased :: proc(button: MouseButton) -> bool --- // Detect if a mouse button has been released once
// See IsMouseButtonUp below: This proc is broken is Raylib 5
// IsMouseButtonUp :: proc(button: MouseButton) -> bool --- Detect if a mouse button is NOT being pressed
when VERSION != "5.0" {
#panic("IsMouseButtonUp was broken in Raylib 5.0 but should be fixed in Raylib > 5.1. Remove this panic and the when clause around it and also remove the workaround version of IsMouseButtonUp just after the end of the 'foreign lib {' block ends.")
IsMouseButtonUp :: proc(button: MouseButton) -> bool ---
}
GetMouseX :: proc() -> c.int --- // Returns mouse position X
GetMouseY :: proc() -> c.int --- // Returns mouse position Y
@@ -1709,7 +1711,7 @@ foreign lib {
DetachAudioMixedProcessor :: proc(processor: AudioCallback) --- // Detach audio stream processor from the entire audio pipeline
}
// TODO: remove this when Raylib releases a new binary version with this bug fixed
// Workaround for broken IsMouseButtonUp in Raylib 5.0. Remove this proc when migrating to Raylib 5.1 or later and re-enable IsMouseButtonUp inside `foreign lib {` block.
IsMouseButtonUp :: proc(button: MouseButton) -> bool {
return !IsMouseButtonDown(button)
}