Skip to content

Commit

Permalink
Update explainer.md with changes related to use of -1 (#641)
Browse files Browse the repository at this point in the history
  • Loading branch information
sahirv authored Jun 13, 2023
1 parent c9a640e commit 6c3d08f
Showing 1 changed file with 8 additions and 7 deletions.
15 changes: 8 additions & 7 deletions PointerEventDeviceId/explainer.md
Original file line number Diff line number Diff line change
Expand Up @@ -29,9 +29,10 @@ Microsoft's Surface Hub device supports detection of multiple pen devices intera
## Proposed Solution
The proposed solution is to add a new attribute `deviceId` to `PointerEvent` that has the following characteristics:

1. The attribute will be populated if both the digitizer and the pen support getting a unique hardware ID for the pen.
1. The attribute will be `null` if the digitizer and pen support getting a unique hardware ID, but the ID is not available during the current event due to limitations (see [Limitations of Current Hardware](#limitations-of-current-hardware)).
1. The attribute will be `undefined` if either the digitizer or the pen do not support getting a unique hardware ID.
1. The attribute will be populated if both the digitizer and the pen support getting a unique hardware ID for the pen, with a value of 2 or more.
1. The attribute will be `-1` if the digitizer and pen support getting a unique hardware ID, but the ID is not available during the current event due to limitations (see [Limitations of Current Hardware](#limitations-of-current-hardware)).
1. The attribute will be `-1` if either the digitizer or the pen do not support getting a unique hardware ID.
1. Like pointerId, the attribute will be 1 if the pointer event is generated by mouse.

### Web IDL
The proposed WebIDL for this feature is as follows:
Expand Down Expand Up @@ -63,7 +64,7 @@ This ID allows the developer to assign a different inking color to each unique p
// Listen for a `pointerdown` event and map the deviceId to a color if it exists
// and has not been mapped yet.
canvas.addEventListener('pointerdown', function(e) {
if (e.deviceId && !pen_to_color_map.has(e.deviceId)) {
if (e.deviceId && (e.deviceId > 1) && !pen_to_color_map.has(e.deviceId)) {
pen_to_color_map.set(e.deviceId, COLORS[color_assignment_index]);
// Bump the color assignment index and loop back over if needed
Expand All @@ -90,9 +91,9 @@ The ability to gather a unique hardware ID from the pen is a fairly new capabili

| Scenario | Value of `deviceId` |
| :- | :- |
| Digitizer and Pen support Hardware ID on OS | `unsigned long` |
| Digitizer and Pen support Hardware ID, but not for initial contact | `null` |
| No support for Hardware ID | `undefined` |
| Digitizer and Pen support Hardware ID on OS | `signed long` |
| Digitizer and Pen support Hardware ID, but not for initial contact | `-1` |
| No support for Hardware ID | `-1` |

## Privacy and Security Considerations
### Privacy
Expand Down

0 comments on commit 6c3d08f

Please sign in to comment.