-
Notifications
You must be signed in to change notification settings - Fork 109
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 API design #83
Comments
Also, I just noticed that contrary to just what a site having a HTML button does, wasm target does not treat touch as mouse... |
I'll try and include that in the input redesign. There's back-end work to support all of this ongoing in the new |
This is a general clean-up of the back-end architecture: * The context object no longer includes the back-end, making it much more lightweight/efficient. * WASM bug-fixes including background colors (finally!) * GL (WASM and native) includes a call-back for when you want to render natively. * Other platforms include access to BACKEND for access to dirty details. This varies in usefulness by platform, currently. Amethyst will get its own branch/PR soon to improve native access. FIXES #53 Assists #83 * WIP: Remove backend linkage from console types. * WIP: It doesn't actually render anything, but platform is removed from the main context now. * Success in removing the platform entry from bterm. Only works for native as of yet. * Cleanup imports. * Curses non-functional but now compiles. * Curses system working. * Curses uses the real VirtualKeyCode. * Crossterm is working in the new environment. * Sparse console support in crossterm. No multiple fonts, obviously. * Crossterm also uses the real VirtualKeyCode. * Amethyst back-end works. * Oops - forgot to set default back to opengl. * WASM doesn't do anything, but it compiles now. * Almost works. * Move framebuffer. * WASM testing success. * WASM exposes actual VirtualKeyCode from winit, also. * WebGL/WASM background colors are working once more. FIXES #53. * Warning fixes. * Fix build script for wasm. * Add the option to pass-through native GL to a callback, for native rendering when needed (GL only for now).
Now that the back-end cleanup is done, I'm tracking implementation work in the new branch: https://github.com/thebracket/bracket-lib/tree/input_api |
…ionality is in place for native (no other platform, including WASM yet). The beginnings of an event queue work, with minimal events so far. The new example, input_harness, demonstrates the mouse and event queue funcitonality so far.
I don't think touch and mouse click should be treated a the same thing. winit has dedicated events for touch support and it's quite different from mouse (no left/right buttons, but you can have simultaneous touch events at different places. Touch also has a notion of pressure, see winit's doc). I've focused the current design on mouse/keyboard. Pushing it further would include touch & joystick support but I guess we're not there yet. |
I'm going to pretend that Touch events don't exist for the first pass. There's a lot of them, and I don't have much in the way of devices that can test them. I'll get the basics going, and revisit touch. |
Some libraries, e.g. winit, seem to use pointer events instead, and those work across most browsers and seem to react to mouse OR touch? |
It's been a pretty solid day in terms of implementing this:
The context object is now small, support |
I'm out of time for now; apparently I need to fix RLTK example 13. |
Thanks, I've started using this in my bracket port. I will probably submit some PR next week because I still have issues but don't feel the urge to answer to them. |
I think there's a misunderstanding about the input API.
I've created the pull request #95 to demonstrate what I had in mind. |
I've integrated the PR, and taken a stab at making it work across back-ends. It's good on native and WASM, not bad on Amethyst, and poor-but-working on Curses/Crossterm (since neither actually supports key_key events, and Curses doesn't do mouse_up either - so there's some nasty emulation that doesn't reflect keys held down properly). I think we're getting closer. |
Looks nice! As far as doryen-rs is concerned, everything on the input API works as intended (at least using the native backend). I'll try to see if everything still works on WASM target |
I'm going to take one more stab at the console-based back-ends (particularly scan codes and keyboard latches), and do a little more testing - but I'm pretty sure this one will be merged very soon. :-) |
Alright! I've cleaned up a lot of niggling things on the
With that, I think I'll start merging. |
It's merged! |
This issue is dedicated to designing a keyboard/mouse API that works well for both real time and turn by turn games, on native and WASM target.
Issues with current implementation :
API proposal :
I prefer a pop_event function to an iterator to avoid having to deal with a clear_event function in case the game logic is updated more than once per tick.
As for input events, winit does it pretty well, we should stick to it :
Keyboard events can be defined as KeyPress/KeyRelease (or KeyInput with a state).
Both events contain both key_code and scan_code when possible.
Mouse button events are MousePress/MouseRelease (or MouseInput) and MouseWheel for scrolling events
Text input can use a dedicated CharEvent containing a char field.
The text was updated successfully, but these errors were encountered: