src/video/emscripten/SDL_emscriptenevents.c


Log

Author Commit Date CI Message
Sam Lantinga b8d85c69 2022-11-30T12:51:59 Update for SDL3 coding style (#6717) I updated .clang-format and ran clang-format 14 over the src and test directories to standardize the code base. In general I let clang-format have it's way, and added markup to prevent formatting of code that would break or be completely unreadable if formatted. The script I ran for the src directory is added as build-scripts/clang-format-src.sh This fixes: #6592 #6593 #6594 (cherry picked from commit 5750bcb174300011b91d1de20edb288fcca70f8c)
Sylvain Becker fb0ce375 2022-11-27T17:38:43 Cleanup add brace (#6545) * Add braces after if conditions * More add braces after if conditions * Add braces after while() conditions * Fix compilation because of macro being modified * Add braces to for loop * Add braces after if/goto * Move comments up * Remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements * More remove extra () in the 'return ...;' statements after merge * Fix inconsistent patterns are xxx == NULL vs !xxx * More "{}" for "if() break;" and "if() continue;" * More "{}" after if() short statement * More "{}" after "if () return;" statement * More fix inconsistent patterns are xxx == NULL vs !xxx * Revert some modificaion on SDL_RLEaccel.c * SDL_RLEaccel: no short statement * Cleanup 'if' where the bracket is in a new line * Cleanup 'while' where the bracket is in a new line * Cleanup 'for' where the bracket is in a new line * Cleanup 'else' where the bracket is in a new line (cherry picked from commit 6a2200823c66e53bd3cda4a25f0206b834392652 to reduce conflicts merging between SDL2 and SDL3)
Ryan C. Gordon b9e1d1b4 2022-10-09T19:49:34 events: Rename SDL_SendKeyboardKeyComplete to SDL_SendKeyboardKeyAndKeycode.+
Ryan C. Gordon 92215481 2022-10-09T19:33:52 emscripten: Make an attempt at correct keyboard scancode/keycodes. This uses a newer browser API to get physical scancodes, but still uses the (deprecated) event field that we were already using for scancodes, but for keycodes instead now, which appears to be more accurate. Since keyboard layout isn't (generally) available to web apps, this adds an internal interface to send key events with both scancode and keycode to SDL's internals, instead of sending just scancodes and expecting SDL to use its own keymap to generate keycodes. Future work in this area would be to use the keyboard layout APIs on browsers that support them, which would allow us to use SDL's usual keymap code and not rely on a deprecated browser API, but until we get there, this patch gives significantly more correct results than we would have before. Fixes #2098.
Charlie Birks 9de97e19 2020-12-01T12:46:59 emscripten: Don't prevent default on filtered key events
Sam Lantinga 120c76c8 2022-01-03T09:40:00 Updated copyright for 2022
Thomas Ballinger 94c1276a 2021-11-07T20:49:32 emscripten: Decrease vertical scroll speed by using deltaMode Reference issue #4623.
Jānis Rūcis 454943cf 2021-04-11T16:44:48 emscripten: Don't flag window fullscreen on external requests Also, the condition was always true.
Stephan Vedder fa367cdd 2020-11-24T10:56:50 emscripten: Fix alt key being a nav key
Charlie Birks edaf3f9c 2020-04-21T15:02:06 emscripten: Extend the "nav key" blacklist Add the F keys and Ctrl/Alt+*. Consistent with other naviagtion disabling. Also, none of these generate keypress events anyway.
Sam Lantinga 9130f7c3 2021-01-02T10:25:38 Updated copyright for 2021
Charlie Birks 258d4106 2020-04-09T15:57:12 emscripten: Add a few keyCode mappings for German keyboards From @sy2002 in https://github.com/emscripten-ports/SDL2/issues/108
Charlie Birks babf010c 2020-04-09T15:01:47 emscripten: Pass canvas id to request_pointer_lock Fixes pointer lock with DISABLE_DEPRECATED_FIND_EVENT_TARGET_BEHAVIOR=1
Daid fb3df3a1 2020-04-09T15:01:41 emscripten: Fix the reported keys for the numpad. See https://github.com/emscripten-ports/SDL2/issues/94
Sylvain Beucler 44716b02 2020-04-09T15:01:37 emscripten: Send SDL_APP_TERMINATING before unload (#88)
Beuc 0380cbd7 2020-04-09T15:01:32 emscripten: Typo
Ryan C. Gordon 8641f6e9 2020-04-07T14:03:13 emscripten: support KaiOS's Left Soft Key and Right Soft Key (thanks, pelya!). Fixes Bugzilla #5027.
Sam Lantinga 2a91f682 2020-03-03T17:56:33 Fixed bug 5012 - KaiOS keycodes support pelya KaiOS is an OS for feature phones, with numeric keypad and non-touch screen, and typically 512 Mb RAM and 4 Gb flash. It is based on Firefox OS, all apps are made with HTML5 and Javascript. SDL can be cross-compiled using emscripten and packaged as native app. This patch adds support for star '*' and pound '#' keys on such phones to generate SDL events.
Sam Lantinga a8780c6a 2020-01-16T20:49:25 Updated copyright date for 2020
Alex Szpakowski d5ec735a 2019-08-01T18:22:12 Add a windowID field to SDL_TouchFingerEvent (bug #4331). This is unimplemented on some platforms and will cause compile errors when building those platform backends for now.
Ryan C. Gordon ba0fc92d 2019-05-11T12:41:21 Patched to compile.
Charlie Birks 6eb05211 2019-05-09T12:09:45 Emscripten: Use EMSCRIPTEN_EVENT_TARGET_*
Charlie Birks 4e5b5cba 2019-05-09T12:09:40 Emscripten: Switch from canvas[XY] to target[XY] Allows mouse/touch events to work on non-default canvases
Charlie Birks 60c48ed7 2019-05-09T12:09:34 Emscripten: Store canvas id in WindowData Also replace all hardcoded uses of "#canvas" or NULL
Sylvain Becker b45abbb2 2019-04-02T17:57:27 Bug 4576: fix warning and compile
Sylvain Becker b086edc9 2019-04-02T17:10:29 Bug 4576: remove touch/mouse duplication for Emscripten
Sebastian Krzyszkowiak 6311c7cf 2019-03-16T19:08:59 emscripten: force resize event when pixel ratio changes Without this, applications can't react to changed canvas size on window zoom.
Charlie Birks 8dab9c95 2019-01-29T12:18:56 Emscripten: Use set_canvas_element_size This will be needed for supporting multiple canvases and set_canvas_size is deprecated anyway.
kichikuou ed66a430 2019-01-29T12:14:54 Emscripten: Do not consume mouseup event outside of the canvas
Sylvain Beucler 2838abb5 2019-01-29T12:14:44 Emscripten: fix duplicate mousebuttonup/mousebuttondown events when touch events are disabled
Charlie Birks 80d690a2 2019-01-29T12:14:33 Emscripten: reset fullscreen_window when leaving fullscreen If the browser left fullscreen mode by the user pressing ESC, the next call to SDL_SetWindowFullscreen(1) will fail as it thinks the window is already fullscreen. (#65)
Sam Lantinga 5e13087b 2019-01-04T22:01:14 Updated copyright for 2019
Alex Szpakowski 5029d50e 2018-11-10T16:15:48 Add SDL_TouchDeviceType enum and SDL_GetTouchDeviceType(SDL_TouchID id). Touch device types include SDL_TOUCH_DEVICE_DIRECT (a touch screen with window-relative coordinates for touches), SDL_TOUCH_DEVICE_INDIRECT_ABSOLUTE (a trackpad-style device with absolute device coordinates), and SDL_TOUCH_DEVICE_INDIRECT_RELATIVE (a trackpad-style device with screen cursor-relative coordinates). Phone screens are an example of a direct device type. Mac trackpads are the indirect-absolute touch device type. The Apple TV remote is an indirect-relative touch device type.
Sam Lantinga e3cc5b2c 2018-01-03T10:03:25 Updated copyright for 2018
Sam Lantinga a4cfa936 2017-08-14T21:28:04 Fixed bug 2293 - Precise scrolling events Martijn Courteaux I implemented precise scrolling events. I have been through all the folders in /src/video/[platform] to implement where possible. This works on OS X, but I can't speak for others. Build farm will figure that out, I guess. I think this patch should introduce precise scrolling on OS X, Wayland, Mir, Windows, Android, Nacl, Windows RT. The way I provide precise scrolling events is by adding two float fields to the SDL_MouseWheelScrollEvent datastructure, called "preciseX" and "preciseY". The old integer fields "x" and "y" are still present. The idea is that every platform specific code normalises the scroll amounts and forwards them to the SDL_SendMouseWheel function. It is this function that will now accumulate these (using a static variable, as I have seen how it was implemented in the Windows specific code) and once we hit a unit size, set the traditional integer "x" and "y" fields. I believe this is pretty solid way of doing it, although I'm not the expert here. There is also a fix in the patch for a typo recently introduced, that might need to be taken away by the time anybody merges this in. There is also a file in Nacl which I have stripped a horrible amount of trailing whitespaces. (Leave that part out if you want).
Ryan C. Gordon 599d9ba1 2017-06-05T21:30:25 emscripten: listen for pointerlockchange events on the #document specifically.
Philipp Wiesemann 75931972 2017-05-26T22:45:40 emscripten: Fixed compiling on C89 compilers.
Charlie Birks 126e5a1d 2017-05-24T14:04:39 Emscripten: Prevent default on arrow keys
Patrick Monaghan f839b209 2017-05-24T14:04:25 Emscripten: fixed incorrect conversion of touch motion events to mouse motion events
Philipp Wiesemann 29222db7 2017-05-13T23:00:35 emscripten: Fixed not removing pointer lock event callback.
Philipp Wiesemann cc5b4f45 2017-05-12T23:01:17 emscripten: Changed internal functions to be static.
Ryan C. Gordon 93a6191c 2017-04-20T13:00:54 emscripten: keep track of pointer lock losses and maybe regrab pointer later. If an Emscripten app is in relative mouse mode and the user presses Escape (or whatever is appropriate), then the pointer lock is broken by the browser. This keeps track of those losses, and next time the user presses a mouse button down on the canvas, if the app is still meant to be in relative mouse mode, we will attempt to regrab the pointer. This makes it much more seamless for things like first-person shooters, and the app doesn't need any manual intervention.
Charlie Birks 613955b4 2017-02-17T10:13:07 Emscripten: only update pixel ratio if HiDPI is enabled
Sam Lantinga 45b774e3 2017-01-01T18:33:28 Updated copyright for 2017
Philipp Wiesemann c3451262 2016-11-18T00:05:28 Emscripten: Fixed handling of deactivated mouse events. SDL_GetEventState() was called with a button state instead of an event type.
Csongor Szabo 01f62736 2016-10-14T17:06:28 emscripten: check if device pixel ratio has changed
Sam Lantinga 00791f3a 2016-09-13T00:09:21 Only prevent the default browser event handling when the specific event types aren't disabled by the user, patch contributed by Jonas Platte
Charlie Birks 993dd835 2016-09-13T00:04:00 Add mapping for media keys
Jukka Jyl?nki 7cf44f1b 2016-09-13T00:03:51 Remove unused variable warning from Emscripten build in Emscripten_HandleFullscreenChange().
Boris Gjenero b54eb82c 2016-09-13T00:03:49 Unpress all keys on blur to avoid stuck keys
Boris Gjenero a0a75f38 2016-09-13T00:03:48 Listen for blur and focus events on window instead of canvas Blur and focus events were not arriving for the canvas in Firefox 35 and Chrome 40.
Boris Gjenero 3e5c4cec 2016-09-13T00:03:46 Mouse events use CSS coordinates, so don't scale by pixel_ratio
Boris Gjenero a20c40c4 2016-09-13T00:03:45 Accumulate subpixel mouse motion so motion is not lost. Previously when the canvas was scaled up and the pointer was locked, motion corresponding to less than one pixel was lost. Therefore, slow mouse motion resulted in no motion. This fixes that.
TelpeNight 443998ff 2016-09-13T00:03:44 Fix of mouse events in browser without pointer locks
Charlie Birks 98ec8443 2016-09-13T00:03:39 send mouse move on enter/leave
Charlie Birks a2ef0db8 2016-09-13T00:03:37 listen for mouse up on document (fixes mouseup outside canvas)
Charlie Birks cd05184f 2016-09-13T00:03:36 use SDL_SetMouseFocus
Sam Lantinga bdca510f 2016-09-13T00:03:28 simplify fullscreen handling using new fullscreen_strategy api, patch contributed by Charlie Birks
Charlie Birks be08cc61 2016-09-12T23:58:08 use css size for touch normalisation
Ryan C. Gordon d05ae194 2016-08-12T19:59:00 emscripten: send fake mouse events for touches, like other targets do. (This really should be handled at the higher level and not in the individual targets, but this fixes the immediate bug.)
Sam Lantinga 42065e78 2016-01-02T10:10:34 Updated copyright to 2016
Philipp Wiesemann 0e45984f 2015-06-21T17:33:46 Fixed crash if initialization of EGL failed but was tried again later. The internal function SDL_EGL_LoadLibrary() did not delete and remove a mostly uninitialized data structure if loading the library first failed. A later try to use EGL then skipped initialization and assumed it was previously successful because the data structure now already existed. This led to at least one crash in the internal function SDL_EGL_ChooseConfig() because a NULL pointer was dereferenced to make a call to eglBindAPI().
Philipp Wiesemann 5d6aa08b 2015-06-09T21:06:29 Emscripten: Fixed SDL_GetTouchDevice() returning 0 for the valid device index. The single touch device gets SDL_TouchID 1 (like on iOS and WinRT).
Sam Lantinga 6e67c949 2015-05-28T12:55:01 Fixed bug 2054 - SDL_GetError: "Unknown touch device" Volumetric The "Unknown touch device" message appears because the initial touch device setup loop uses SDL_GetTouch() as a guard for calling SDL_AddTouch(). SDL_GetTouch() will always report "Unknown touch device" since the device hasn't been added yet. The SDL_GetTouch() call is unnecessary since SDL_AddTouch() calls SDL_GetTouchIndex() to verify that the device hasn't been added yet, and SDL_GetTouchIndex() has the benefit of not reporting an error for a device it can't find.
Sam Lantinga 2c4a6ea0 2015-05-26T06:27:46 Updated the copyright year to 2015
Philipp Wiesemann a54d038b 2015-05-16T21:15:27 Emscripten: Fixed wrong source comment and updated web link.
Philipp Wiesemann 3f51758e 2015-05-06T21:10:48 Emscripten: Fixed touch coordinates not being normalized.
Ryan C. Gordon b72938c8 2015-04-20T12:22:44 Windows: Always set the system timer resolution to 1ms by default. An existing hint lets apps that don't need the timer resolution changed avoid this, to save battery, etc, but this fixes several problems in timing, audio callbacks not firing fast enough, etc. Fixes Bugzilla #2944.
Alex Szpakowski fe6c797c 2015-04-10T23:30:31 Fixed an iOS view orientation issue when SDL_GL_CreateContext or SDL_CreateRenderer is called.
Philipp Wiesemann 8f4c2a8f 2015-03-06T21:29:25 Emscripten: Fixed ignoring return value of internal function. If the function Emscripten_ConvertUTF32toUTF8() failed (should currently not be possible) a not terminated string would have been sent as text input event.
Philipp Wiesemann 1686af72 2015-03-06T21:26:37 Emscripten: Partially fixed not removing key event callbacks if hint was used. The key event callbacks were always removed from the same target although it is possible to set them to different targets using the hint. This is only a partial fix because it assumes that the hint is not changed to a different value later.
Philipp Wiesemann bd2d0146 2015-02-15T21:44:36 Emscripten: Changed return type of callback implementations from int to EM_BOOL. The prototypes are declared with EM_BOOL (which is currently an int) in html5.h.
Edward Rudd b88ca1b4 2015-02-10T16:28:56 the last parameter of XChangeProperty is the number of elements.. and when the element format is 32.. the element is "long" so we have 5 long elements here. Yes this seems confusing as on mac+linux Long is either 32 or 64bits depending on the architecture, but this is how the X11 protocol is defined. Thus 5 is the correct value for the nelts here. Not 5 or 10 depending on the architecture. More info on the confusion https://bugs.freedesktop.org/show_bug.cgi?id=16802
Philipp Wiesemann b48e54aa 2015-01-26T22:00:29 Fixed bug 2802 - [patch] Fix android build compiling in wrong filesystem implementation Jonas Kulla The configure script didn't differentiate between Linux and Android, unconditionally compiling in the unix implementation of SDL_sysfilesystem.c. I'm probably one of the very few people building SDL for android using classic configure + standalone toolchain, so this has gone undetected all along.
Ryan C. Gordon fe40a172 2014-12-18T00:19:52 Initial merge of Emscripten port! With this commit, you can compile SDL2 with Emscripten ( http://emscripten.org/ ), and make your SDL-based C/C++ program into a web app. This port was due to the efforts of several people, including: Charlie Birks, Sathyanarayanan Gunasekaran, Jukka Jyl?nki, Alon Zakai, Edward Rudd, Bruce Mitchener, and Martin Gerhardy. (Thanks, everyone!)