emscripten-core / emscripten

Emscripten: An LLVM-to-WebAssembly Compiler
Other
25.66k stars 3.29k forks source link

Support for graphic tablet/stylus/pen events? #7278

Open Chemrat opened 5 years ago

Chemrat commented 5 years ago

I've skimmed through C++ HTML5 API and seems like there is API for mouse and touch events, but not for pen events (pointer events with tilt and pressure)

stale[bot] commented 4 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 7 days. Feel free to re-open at any time if this issue is still relevant.

ec1oud commented 4 years ago

Given that browsers do support them, I think emscripten should.

https://www.w3.org/TR/pointerevents2/#dom-pointerevent-pressure

Qt's wasm plugin uses emscripten, and Qt supports pen tablets. So this would potentially pave the way for Qt-based drawing applications to be portable not only between desktop and mobile operating systems, but also to the browser.

stale[bot] commented 3 years ago

This issue has been automatically marked as stale because there has been no activity in the past year. It will be closed automatically if no further activity occurs in the next 30 days. Feel free to re-open at any time if this issue is still relevant.

Lemovision commented 2 years ago

Hi is it possible to have a look at this please? I also very much need this feature for a drawing app

digitalsignalperson commented 5 months ago

SDL3 now has SDL_pen.h as well https://github.com/libsdl-org/SDL/commit/7c80ac6df7001ba8ad37c6cf3ab0dc70b57011dd#diff-8a9cade1c69cd3c5c95378f2b386222c68aa893ea73ae792bb865061b8b9ebf2

icculus commented 1 month ago

SDL3 now has SDL_pen.h as well

It does, and we've just cut this API down dramatically so we could reasonably target lots more platforms, including Emscripten.

What SDL3 needs from Emscripten is access to Pointer Events, and I suppose we could wedge in some Javascript code to hook into the browser via EM_ASM, but it would be nicer if there were an equivalent of emscripten_set_mousedown_callback (etc) for these, as that's what SDL uses for everything else. Among other reasons, the Emscripten functions do a lot of stuff behind the scenes I'm not really qualified to manage, and don't really understand without a background in Emscripten internals magic. :)

Although I suppose that a Pointer Events equivalent would probably be mostly this same code with different details?

icculus commented 1 month ago

I implemented this today in SDL3 using Javascript directly, here, but if would still be nice if this were to have the same Emscripten APIs that mouse/touch already use.

(A demo of the SDL3 implementation is here if you have a stylus/pen that works with your browser.)