Skip to content

Commit

Permalink
Add Logitech MX Ink component docs and rename buttons to match Logite…
Browse files Browse the repository at this point in the history
…ch docs
  • Loading branch information
dmarcos committed Nov 9, 2024
1 parent 8e504a8 commit 1f6300a
Show file tree
Hide file tree
Showing 2 changed files with 72 additions and 5 deletions.
66 changes: 66 additions & 0 deletions docs/components/logitech-mx-ink-controls.md
Original file line number Diff line number Diff line change
@@ -0,0 +1,66 @@
---
title: logiteck-mx-ink-controls
type: components
layout: docs
parent_section: components
source_code: src/components/logiteck-mx-ink-controls.js
examples: []
---

[trackedcontrols]: ./tracked-controls.md

The logiteck-mx-ink-controls component interfaces with the Logitech MX Ink tracked pen. It
wraps the [tracked-controls component][trackedcontrols] while adding button
mappings, events, and a pencil model.

## Example

```html
<a-entity logiteck-mx-ink-controls="hand: left"></a-entity>
<a-entity logiteck-mx-ink-controls="hand: right"></a-entity>
```

## Value

| Property | Description | Default Value |
|----------------------|----------------------------------------------------|----------------------|
| hand | The hand that will be tracked (i.e., right, left). | left |
| model | Whether the Touch controller model is loaded. | true |

## Events

| Event Name | Description |
| ---------- | ----------- |
| tiptouchstart | Tip touched. |
| tiptouchend | Tip no longer touched. |
| tipchanged | Tip changed. |
| frontdown | Front button pressed. |
| frontup | Front button released. |
| frontchanged | Front button changed. |
| reardown | Rear button pressed. |
| rearup | Rear button released. |
| rearchanged | Rear button changed. |

## Read tip changes

Listen to the `tipchanged` event.

```html
<a-entity logiteck-mx-ink-controls="hand: left" tip-logging></a-entity>
<a-entity logiteck-mx-ink-controls="hand: right" tip-logging></a-entity>
```

```javascript
AFRAME.registerComponent('tip-logging',{
init: function () {
this.el.addEventListener('tipchanged', this.tipChanged);
},
tipChanged: function (evt) {
console.log("Pen tip changed");
}
});
```

## Assets

- [Logiteck MX Ink glTF](https://cdn.aframe.io/controllers/logitech/logitech-mx-ink.glb)
11 changes: 6 additions & 5 deletions src/components/logitech-mx-ink-controls.js
Original file line number Diff line number Diff line change
Expand Up @@ -16,17 +16,18 @@ var LOGITECH_MX_INK_MODEL_GLB_BASE_URL = AFRAME_CDN_ROOT + 'controllers/logitech
/**
* Button IDs:
* 0 - trigger
* 1 - grip
* 3 - X / A
* 4 - Y / B
* 1 - squeeze
* 5 - touchpad
* 6 - tip
* 7 - dock
*
*/
var INPUT_MAPPING_WEBXR = {
left: {
buttons: ['trigger', 'squeeze', 'none', 'none', 'touchpad', 'tip', 'dock']
buttons: ['front', 'back', 'none', 'none', 'none', 'tip']
},
right: {
buttons: ['trigger', 'squeeze', 'none', 'none', 'touchpad', 'tip', 'dock']
buttons: ['front', 'back', 'none', 'none', 'none', 'tip']
}
};

Expand Down

0 comments on commit 1f6300a

Please sign in to comment.