Open AaronKutch opened 1 year ago
Hi,
As minifb is mainly a prototyping library supporting all of this feels a bit out of scope for the library. In your case maybe something like winit
would be a better fit as it's a bit more complete lib. Now I'm not saying that you can't use minifb to build a complete application, but you may find areas were it doesn't support all the things you want.
I love minifb
because of how minimal it is. In this specific case, it seems to me that it just needs a little more extending. I don't mean for all the Controller
and Hat
stuff, just some missing stuff from the already existing keyboard and mouse support. I don't know what the mouse cross platform stuff looks like, but 5 button mouses are fairly common.
The Unknown(u32 (?))
I mentioned should allow for automatically including the extra stuff without needing to waste time coming up with new variants.
Cool. Yeah, but what should the value for the Unknown(u32)
be? should be like Unknown(0)
= can be mouse 4, 1 can be mouse 5 etc?
My understanding is that most operating systems give key codes, typically 2 or 4 bytes, to the program. If minifb
doesn't recognize a code, it can return something (and gui layer keybindings can ask for the button to be pressed when assigning a control, and it will know what code corresponds to what action, it doesn't have to be stable across OSes as long as it is a stable and unique code for the given run). For example, https://learn.microsoft.com/en-us/windows/win32/api/winuser/nf-winuser-mouse_event the dwFlags
code would be put into MouseButton::Unknown(... as u32)
. It seems that other interfaces merge mouse buttons with keyboard buttons (https://learn.microsoft.com/en-us/windows/win32/inputdev/virtual-key-codes), but as long as it is mapped to some Key::Unknown
or MouseButton::Unknown
, that works for me because I can make my own Button
struct combining things if necessary.
I moved to
rust_minifb
frompiston_window
, but am missing its extensive button system. There are an awful lot of obscure key codes, but it would be nice to support as many as possible in one fell swoop. One thing I have available is a 5 button mouse, but only 3 buttons are currently available in the mouse enum.What I would recommend is:
Unknown(u32)
variant (and not justUnknown
) that includes a field for codes we missClone
,Copy
,Debug
,Eq
,Hash
, andOrd
for all the enums so that I can use them in hashmaps and the likeget_buttons_pressed
or other unifications so that we don't need to poll all buttons with theget_mouse_down
function