Not-Nik / raylib-zig

Manually tweaked, auto-generated raylib bindings for zig. https://github.com/raysan5/raylib
MIT License
517 stars 102 forks source link

disable exit key #3

Closed pfgithub closed 4 years ago

pfgithub commented 4 years ago

Currently, this is required to disable the exit key:

ray.SetExitKey(@ptrCast(*const ray.KeyboardKey, &@as(c_int, 0)).*);

This would be nicer if the KeyboardKey enum was non-exhaustive, then it would be,

ray.SetExitKey(@intToEnum(ray.KeyboardKey, 0));

or if KeyboardKey had a null option,

ray.SetExitKey(.KEY_NULL);
Not-Nik commented 4 years ago

Yup, you're completely right. Thanks for the feedback, I'll get right to it.

Not-Nik commented 4 years ago

Should work now. Feel free to reopen if it doesn't

Not-Nik commented 4 years ago

PS: you mixed up enumToInt and intToEnum. The latter would have worked before this fix, but with raylib-zig I'm trying to avoid conversions as much as possible, to improve code readability.

pfgithub commented 4 years ago

intToEnum is what I meant, and that didn't work before the fix because the enum is exhaustive and 0 is not a valid option. I didn't try, but I'm assuming it would also trigger a runtime panic if I forced it to be runtime.