Skip to content
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

5 button mouse support and more #312

Open
AaronKutch opened this issue Feb 22, 2023 · 5 comments
Open

5 button mouse support and more #312

AaronKutch opened this issue Feb 22, 2023 · 5 comments

Comments

@AaronKutch
Copy link

AaronKutch commented Feb 22, 2023

I moved to rust_minifb from piston_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:

  • For every enum, have an Unknown(u32) variant (and not just Unknown) that includes a field for codes we miss
  • Implement Clone, Copy, Debug, Eq, Hash, and Ord for all the enums so that I can use them in hashmaps and the like
  • We probably want a get_buttons_pressed or other unifications so that we don't need to poll all buttons with the get_mouse_down function
@emoon
Copy link
Owner

emoon commented Feb 23, 2023

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.

@AaronKutch
Copy link
Author

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.

@AaronKutch
Copy link
Author

The Unknown(u32 (?)) I mentioned should allow for automatically including the extra stuff without needing to waste time coming up with new variants.

@emoon
Copy link
Owner

emoon commented Feb 23, 2023

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?

@AaronKutch
Copy link
Author

AaronKutch commented Feb 23, 2023

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants