Comments (1)
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 :).
from alimer.
Related Issues (9)
Recommend Projects
-
React
A declarative, efficient, and flexible JavaScript library for building user interfaces.
-
Vue.js
🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
-
Typescript
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
-
TensorFlow
An Open Source Machine Learning Framework for Everyone
-
Django
The Web framework for perfectionists with deadlines.
-
Laravel
A PHP framework for web artisans
-
D3
Bring data to life with SVG, Canvas and HTML. 📊📈🎉
-
Recommend Topics
-
javascript
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
-
web
Some thing interesting about web. New door for the world.
-
server
A server is a program made to process requests and deliver data to clients.
-
Machine learning
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
-
Visualization
Some thing interesting about visualization, use data art
-
Game
Some thing interesting about game, make everyone happy.
Recommend Org
-
Facebook
We are working to build community through open source technology. NB: members must have two-factor auth.
-
Microsoft
Open source projects and samples from Microsoft.
-
Google
Google ❤️ Open Source for everyone.
-
Alibaba
Alibaba Open Source for everyone
-
D3
Data-Driven Documents codes.
-
Tencent
China tencent open source team.
from alimer.