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

Input #7

Open
1 of 3 tasks
amerkoleci opened this issue Nov 2, 2021 · 1 comment
Open
1 of 3 tasks

Input #7

amerkoleci opened this issue Nov 2, 2021 · 1 comment

Comments

@amerkoleci
Copy link
Owner

amerkoleci commented Nov 2, 2021

  • Create a new project
  • Implement SDL support
  • Implement Windows support
@roy-t
Copy link

roy-t commented Nov 2, 2021

I did some research for Windows. DirectInput seems to be deprecated. There are special APIs for the Xbox360/One controller but for high-dpi mice and keyboards listening to raw input window messages seems to be the way to go.

I've implemented this here: https://github.com/roy-t/MiniEngine3/blob/main/src/Backend/Mini.Engine.Windows/InputService.cs, Mouse.cs, MouseDecoder.cs, Keyboard.cs, KeyboardDecoder.cs. For keyboards it also handles both virtual key characters and scan codes, which is another important thing to consider. I haven't added controller support yet.

I also wanted to tackle another problem. I want every system in my engine to get all input events, so to never miss anything, even if a frame took multiple seconds to render.

What I did is give every system its own keyboard/mouse instance. When the system is updated it iterates through all the input events to model the state of the mouse/keyboard after each event. You can see that system in action in https://github.com/roy-t/MiniEngine3/blob/main/src/Mini.Engine/Controllers/CameraController.cs

This might be a bit overkill as you would not expect the same key/button to have multiple events in a single frame. But I kinda got carried away with it.

Feel free to use this as inspiration or to copy paste it :).

@amerkoleci amerkoleci changed the title Input support Input Nov 2, 2021
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