- From: Alex Kempton via GitHub <sysbot+gh@w3.org>
- Date: Tue, 29 Nov 2022 16:49:17 +0000
- To: public-pointer-events@w3.org
funwithtriangles has just created a new issue for https://github.com/w3c/pointerevents: == API to determine difference between trackpad and mouse events == Currently with web technologies, there is no way of knowing the difference between mouse events and trackpad events. This is creating a lot of challenges for us as developers of 3D applications. To briefly explain our application: - a two-finger drag on a touchpad pans the camera - a scroll on the mouse zooms the camera However, as far as the browser is concerned, these are exactly the same mouse event. In order to tell the difference, we take a sample of deltas from the wheel event and try our best to guess the hardware being used based on our own research of devices. You can see what sort of things we're doing by looking at our tests (below). Some things that I can think of that would be very useful: - A simple flag attached to mouse events (e.g. `isTrackpad`) - Multi-touch data from the trackpad (same as [touchscreens on the web](https://developer.mozilla.org/en-US/docs/Web/API/Touch_events/Multi-touch_interaction)) - A device name attached to mouse events (e.g. `Apple Magic Mouse`, `Logitech XX`) ```js test("Is from wheel if deltas have fractional components", () => { const deltas = [100.5, 100.3, 100.1231] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(true) }) test("Is from wheel if deltas are all the same (absolutely)", () => { const deltas = [100, 100, -100] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(true) }) test("Is NOT from wheel if deltas are all the same but low", () => { const deltas = [1, 1, 1, 1, 1, 1, 1] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(false) }) test("Is NOT from wheel if most the deltas are low", () => { const deltas = [11, 11, 11, 11, 11, 11, 10, 50, 51] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(false) }) test("Is NOT from wheel if most deltas are different, but not all", () => { const deltas = [25, 25, 26, 27, 28] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(false) const deltas2 = [23, 24, 22, 25, 25] const result2 = checkDeltasAreFromWheel(deltas2) expect(result2).toEqual(false) }) test("Is from wheel if deltas have some simple relationship 1.5x / 2x / 3x / 4x / 0.5 / 0.666 / 0.333 / 0.25", () => { const deltas = [150, 300, -450, 150, 450, 300] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(true) }) test("Is not from wheel if simple relationship only happens once in sample", () => { const deltas = [-13, -14, 50, 100, 102, 33] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(false) }) test("Is NOT wheel if deltas are completely different", () => { const deltas = [101, 201, -101, 51, 201] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(false) const deltas2 = [-26, -7, -3, -1] const result2 = checkDeltasAreFromWheel(deltas2) expect(result2).toEqual(false) }) test("Sample of deltas from magic mouse", () => { const deltas = [-13, -14, -48, -20, -21, -74, -29, -32, -105, -35] const result = checkDeltasAreFromWheel(deltas) expect(result).toEqual(false) }) ``` Please view or discuss this issue at https://github.com/w3c/pointerevents/issues/462 using your GitHub account -- Sent via github-notify-ml as configured in https://github.com/w3c/github-notify-ml-config
Received on Tuesday, 29 November 2022 16:49:33 UTC