-
-
Notifications
You must be signed in to change notification settings - Fork 24
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
SDL2 - SDL_Keycode #63
Comments
That's the disadvantage of my current approach. The SDL3 bindings will have both C and D-style enums, which will solve this kind of problem. You can emulate what you were doing before with something like this: enum strToKeycodeCT = (){
SDL_Keycode[string] ret;
static foreach(member; __traits(allMembers, sdl.keycode)){
static if(is(typeof(__traits(getMember, sdl.keycode, member)) == SDL_Keycode)){
ret[member] = __traits(getMember, sdl.keycode, member);
}
}
return ret;
}();
immutable strToKeycode = strToKeycodeCT;
void main(){
import std.stdio: writeln;
writeln(strToKeycode["SDLK_a"]);
writeln(strToKeycode["SDLK_ESCAPE"]);
} Technically this will include a key for |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
For key bindings provided by the user of my engine, my code uses:
Up until version 1.2.4 this worked since SDL_Keycode was defined as:
enum SDL_Keycode { }
However, in later versions of the bindings, the code changed to:
Now this automated conversion from string containing the enum member name to enum member is not possible anymore:
Is there an easy way to restore the original behaviour?
My engine uses a config file to allow the user to configure SDL_Keycode (and SDL_EventType) to allow rebind-able keys (on runtime) to be coupled to in engine events, e.g.:
The text was updated successfully, but these errors were encountered: