Graphic tablet pointer events pointerdown event reporting odd values for width and height, no pressue and incorrect pointer type

余生颓废 提交于 2021-01-29 12:25:01

问题


I am using a Wacom graphics tablet (Intuos PT S CTH-490 if that matters) and I am seeing some weird results with JavaScript pointer events test code that I've devised. The code is pretty much just me listening for pointermove, but here goes for the sake of completeness:

window.addEventListener('load', () => {
  document.documentElement.addEventListener('pointermove', event => {
    let report = '';
    for (const key in event) {
      const value = event[key];
      const type = typeof value;
      if (type === 'function' || value instanceof HTMLElement || MouseEvent[key] !== undefined) {
        continue;
      }

      report += `${key}: ${value}\n`;
    }

    document.body.textContent = report;
  });
});

With this test code, I'm trying a few scenarios, but seeing to me unexpected results (this in in Firefox and on Windows):

Device Scenario                                event.pointerType event.pressure Expected?
Mouse  Hovering around, no buttons pressed     mouse             0              Yes
Mouse  Dragging around, primary button pressed mouse             0.5            Yes
Tablet Sliding around with my finger           mouse (!)         always 0 (!)   No
Tablet Hovering above the tablet with the pen  pen               irrelevant     Yes
Tablet Sliding the pen touching the tablet     touch (!)         always 0 (!)   No

I expected both hovering and sliding with the pen to report a pen move event, not pen on hover and touch on slide - I thought touch on slide would get reported only if I used my finger, not both my finger and the pen.

Also, I am never seeing any pressure values, but when I go to the test page for pressure.js (https://pressurejs.com/) it is able to read the "Targets ONLY Pointer Events (pointer)" value.

Also again, and this is perhaps the most weird (as it looks more like a bug than spotty support issue), the width and height properties of the PointerEvent instance report absolutely meaningless values. Height oscillates between 0 and some large number like 2 billion or something and width is some similarly large number which seems to corelate to the position of the tip on the tablet surface's horizontal axis. This doesn't make any sense to me.

Additionally, when I disabled "Use Windows Ink" in the tablet settings, it is always reported as mouse, not pen by the browser.

I am aware that this might be caused by the tablet driver or bad support in browsers, but I see that the pressure value works on the Pressure.js site, but my simple pointermove handler never reports non-zero pressure when using the pen with the tablet. Is there any commonly known hack that needs to be used for this to work?

BTW I also tried listening to touchmove since touch pointer type is reported when using the pet with the table and sliding it directly on the surface, but this handler was never called for me. For some reason, the pointermove one gets called with pointerType set to touch instead.

Overall my question is whether this is a known issue and I am lacking something obvious to make things behave like I expect (be it using a different driver, browser or tablet) or whether this is indeed wrong and in that case, can other users reproduce this odd behavior (random width/height values, no pressure, pointer type being touch when using pen)?

I played around with the tablet settings in the Wacom Desktop app that comes bundled with the driver installer, but none of the settings seemed to make any difference to the values I was checking except the already mentioned Use Windows Inking one.

来源:https://stackoverflow.com/questions/63102695/graphic-tablet-pointer-events-pointerdown-event-reporting-odd-values-for-width-a

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!