Commit graph

2914 commits

Author SHA1 Message Date
Robert Bragg 7929999c1c
Android: rework keycode handling (#2890)
The recent overhaul of the keyboard API broke keyboard input on Android.

The recent keyboard changes also broke building against the
game-activity backend of android-activity because it was assumed that
the backend is based on the NDK input API which isn't the case with
with game-activity since it doesn't use the InputQueue API from the NDK.

Any alphanumeric keycodes were being mapped to `Unidentified` Keys
which meant even crude keyboard input support was broken.

We do need to expose `getUnicodeChar` (or the ability to look
up characters based on the current character map and modifiers) but
for now we should at least map alphanumeric keycodes to `Key::Character`
for basic interim support of virtual keyboards.

This moves all the keycode mapping into a separate `keycodes.rs` file
to reduce clutter.

This adds back the mapping from Android key codes to Winit key codes
that we had before the keyboard API overhaul.

Android activity does expose scan codes but key codes currently seem
like the more appropriate mapping to Winit physical key codes.

This removes the gnarly, unsafe cfg() guarded digging into
'native-activity' and 'game-activity' specific implementation details. I
never intended to expose these details in the public API and really
hope to avoid there being a release of Winit that would depend on this.

I'm also hoping/considering if I can get away with sealing this without
necessarily requiring a semver breaking release of android_activity
since this absolutely should never have been possible, and can probably
safely assume this was the only code in the wild that has briefly done
this.

I'm also a bit unclear as to what led to doing this. There is a
`.key_code()` and `.scan_code()` getter and we even already accessed the
keycode in the Android backend so I'm not sure how those APIs were missed.
2023-06-21 19:49:44 +02:00
Kirill Chibisov 7094a223af
Bring OptionAsAlt back for macOS
The correct handling of this setting requires to change the events
we're getting from the macOS on the fly and call `interpretKeyEvents`,
which could affect handling of the next events, meaning that we can't
provide them on `KeyEvent`.
2023-06-20 19:07:49 +00:00
John Nunley b2a46d0439
Fill the windows in the examples with a solid color
Fixes #776.
2023-06-19 18:46:38 +00:00
bbb651 4748890935
Add MouseButton::{Back, Forward} to MouseInput
Add named variants for physical back and forward keys which could
be found on some mice. The macOS bits may not work on all the
hardware given that apple doesn't directly support such a thing.

Co-authored-by: daxpedda <daxpedda@gmail.com>
2023-06-16 08:51:09 +00:00
daxpedda 6300cf915e
On Web, implement DeviceEvents (#2871) 2023-06-14 10:26:26 +02:00
daxpedda 9a9c9b15ba
Implement ResizeObserver (#2859)
Co-authored-by: Liam Murphy <43807659+Liamolucko@users.noreply.github.com>
2023-06-14 09:43:53 +02:00
dAxpeDDa 7ce86c3d2a Use Window.requestIdleCallback() 2023-06-14 00:03:23 +02:00
daxpedda a444637b18 Revert "Send modifiers first"
This reverts commit e17977d7c7.
2023-06-14 00:01:37 +02:00
daxpedda f0d88c52a3
Fix pointer deltas on Firefox and send coalesced events together (#2878) 2023-06-13 15:49:27 +02:00
dAxpeDDa e17977d7c7 Send modifiers first 2023-06-13 14:33:08 +02:00
dAxpeDDa a7a8ff0bbb Drop pointerrawupdate support 2023-06-13 10:23:48 +02:00
dAxpeDDa fc046add78 Resume propagation of events 2023-06-12 00:48:14 +02:00
dAxpeDDa ab4a4a89e6 Remove unused EventListenerOptions 2023-06-11 19:44:52 +02:00
dAxpeDDa f7a400ddf6 Improve media queries take 2 2023-06-09 20:38:54 +02:00
Xiaopeng Li 07d39abddd
Fix panic when destroying window (#2773)
* Fix crash when destroying window

* Add a comment to draw_rect

---------

Co-authored-by: Xiaopeng Li <lixiaopeng.jetspark@bytedance.com>
2023-06-09 16:20:27 +03:00
Imbris 0c8bf25ae4
Fix compilation on aarch64-linux
aarch64 defines `c_char` as `u8` and not `i8`. Use `c_char`
alias directly.
2023-06-09 11:46:01 +00:00
dAxpeDDa b5785ba785 Revert "Fix Window::set_inner_size()"
This reverts commit e220a75556.
2023-06-08 09:09:46 +02:00
dAxpeDDa 9797ed86f0 Fix unable to ignore scale factor resize suggestion 2023-06-07 22:46:14 +02:00
dAxpeDDa e220a75556 Fix Window::set_inner_size() 2023-06-07 14:53:59 +02:00
dAxpeDDa 29d3729ac8 Disallow more methods 2023-06-07 12:53:47 +02:00
Robin Thunström 4a36741f9c
On Android, change default implementation to ignore volume keys and let operating system handle them (#2748) 2023-06-06 23:04:51 +02:00
dAxpeDDa ab46aa5b79 Replace beforeunload with pagehide 2023-06-05 16:40:53 +02:00
dAxpeDDa 12fb37d827 Make media queries more robust 2023-06-05 16:11:22 +02:00
dAxpeDDa c88a4ab221 Use correct canvas size for scale factor change 2023-06-05 15:39:17 +02:00
daxpedda 8f7f3efc0d
On Web, implement Send and Sync where appropriate (#2834) 2023-06-05 02:44:54 +02:00
dAxpeDDa eb2d3894ef Document unpreventable events 2023-06-05 02:04:37 +02:00
dAxpeDDa 3f4f580181 Add pointerrawupdate support 2023-06-05 02:04:37 +02:00
dAxpeDDa d3aeff8838 Remove unnecessary preventDefault() calls 2023-06-05 02:04:37 +02:00
dAxpeDDa 0786d534f4 Take IntoIterator in send_events() 2023-06-05 02:04:37 +02:00
dAxpeDDa b4b2389d0a Split modifier handling in all pointer events 2023-06-05 02:04:37 +02:00
dAxpeDDa 964e342f69 Prevent text selection 2023-06-05 02:04:37 +02:00
dAxpeDDa a134a59917 Remove MouseEvent fallback support 2023-06-05 02:04:37 +02:00
dAxpeDDa fbba203c4a Focus window on touch press 2023-06-05 02:04:37 +02:00
dAxpeDDa 61bd8b8254 Send position on button release 2023-06-05 02:04:37 +02:00
dAxpeDDa 587fa67571 Split cursor move handlers 2023-06-05 02:04:37 +02:00
dAxpeDDa 7500a88230 Fix up changelog 2023-06-04 13:45:43 +02:00
dAxpeDDa 82d0380ea6 Ignore pen input on Web 2023-06-04 00:23:47 +02:00
John Nunley 642ce2bfa7
Port to windows-sys v0.48.0 (#2842) 2023-06-04 00:02:37 +02:00
dAxpeDDa 5bbe87960e Replace instant with web-time 2023-06-03 16:05:44 +02:00
Kirill Chibisov cf77f82ae3
Update remaining actions to v3
This somehow was left unnoticed.
2023-06-03 17:00:55 +03:00
Kirill Chibisov 72cf4e577f
Add missing Hash impls on bitflags
Some bitflags in public API lost their `Hash` implementations.

Fixes: 31ebc5caf (Update `bitflags` to `2.0`)
2023-06-03 16:44:52 +03:00
dAxpeDDa 4f3eacf01e On Web, handle coalesced events 2023-06-02 18:48:34 +02:00
George Burton 31ebc5caf4
Update bitflags to 2.0
Co-authored-by: dAxpeDDa <daxpedda@gmail.com>
2023-06-02 17:44:36 +03:00
dAxpeDDa d273518ce9 Process pointer button events 2023-06-02 12:41:35 +02:00
dAxpeDDa 2ade772ab0 Bump console_log to v1 2023-06-01 17:19:30 +02:00
John Nunley 4ac2006cbc
Replace mio with calloop in the X11 backend 2023-05-31 19:44:42 +03:00
dAxpeDDa ba5ad3be13 On Web, fix no-op for Window::set_fullscreen 2023-05-31 15:25:15 +02:00
dAxpeDDa 8092fa2440 Fix changelog 2023-05-31 13:47:34 +02:00
Toniman575 8bb004a1d9
Rename DeviceEventFilter to DeviceEvents
The use of `Filter` was confusing so it was removed inverting the 
behavior of the enum and methods using it.

Co-authored-by: Kirill Chibisov <contact@kchibisov.com>
2023-05-30 22:32:31 +03:00
Simon Hausmann de5327477a web: Fix position of touch events to be relative to the canvas
Use the same logic as for mouse events when not captured.
2023-05-30 21:21:41 +02:00