qmk_firmware/assets/features_digitizer.md.DGIGZFVx.js

16 lines
9.1 KiB
JavaScript
Raw Blame History

This file contains invisible Unicode characters

This file contains invisible Unicode characters that are indistinguishable to humans but may be processed differently by a computer. If you think that this is intentional, you can safely ignore this warning. Use the Escape button to reveal them.

import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.DyMmIvSC.js";
const __pageData = JSON.parse('{"title":"Digitizer","description":"","frontmatter":{},"headers":[],"relativePath":"features/digitizer.md","filePath":"features/digitizer.md"}');
const _sfc_main = { name: "features/digitizer.md" };
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="digitizer" tabindex="-1">Digitizer <a class="header-anchor" href="#digitizer" aria-label="Permalink to &quot;Digitizer {#digitizer}&quot;"></a></h1><p>Digitizers allow the mouse cursor to be placed at absolute coordinates, unlike the <a href="./pointing_device">Pointing Device</a> feature which applies relative displacements.</p><p>This feature implements a stylus device with a tip switch and barrel switch (generally equivalent to the primary and secondary mouse buttons respectively). Tip pressure is not currently implemented.</p><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to &quot;Usage {#usage}&quot;"></a></h2><p>Add the following to your <code>rules.mk</code>:</p><div class="language-make vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">make</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">DIGITIZER_ENABLE = yes</span></span></code></pre></div><h2 id="positioning" tabindex="-1">Positioning <a class="header-anchor" href="#positioning" aria-label="Permalink to &quot;Positioning {#positioning}&quot;"></a></h2><p>The X and Y coordinates are normalized, meaning their value must be set between 0 and 1. For the X component, the value <code>0</code> is the leftmost position, whereas the value <code>1</code> is the rightmost position. Similarly for the Y component, <code>0</code> is at the top and <code>1</code> at the bottom.</p><div class="tip custom-block"><p class="custom-block-title">TIP</p><p>Since there is no display attached, the OS will likely map these coordinates to the virtual desktop. This may be important to know if you have multiple monitors.</p></div><h2 id="examples" tabindex="-1">Examples <a class="header-anchor" href="#examples" aria-label="Permalink to &quot;Examples {#examples}&quot;"></a></h2><p>This example simply places the cursor in the middle of the screen:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">digitizer_in_range_on</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">digitizer_set_position</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, </span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">0.5</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">);</span></span></code></pre></div><p>The &quot;in range&quot; indicator is required to be on for the change in coordinates to be taken. It can then be turned off again to signal the end of the digitizer interaction, but it is not strictly required.</p><p>You can also modify the digitizer state directly, if you need to change multiple fields in a single report:</p><div class="language-c vp-adaptive-theme"><button title="Copy Code" class="copy"></button><span class="lang">c</span><pre class="shiki shiki-themes github-light github-dark vp-code"><code><span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">digitizer_state.in_range </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">digitizer_state.dirty </span><span style="--shiki-light:#D73A49;--shiki-dark:#F97583;">=</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;"> true</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">;</span></span>\n<span class="line"><span style="--shiki-light:#6F42C1;--shiki-dark:#B392F0;">digitizer_flush</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">();</span></span></code></pre></div><p><code>digitizer_state</code> is a struct of type <code>digitizer_t</code>.</p><h2 id="api" tabindex="-1">API <a class="header-anchor" href="#api" aria-label="Permalink to &quot;API {#api}&quot;"></a></h2><h3 id="api-digitizer-t" tabindex="-1"><code>struct digitizer_t</code> <a class="header-anchor" href="#api-digitizer-t" aria-label="Permalink to &quot;`struct digitizer_t` {#api-digitizer-t}&quot;"></a></h3><p>Contains the state of the digitizer.</p><h4 id="api-digitizer-t-members" tabindex="-1">Members <a class="header-anchor" href="#api-digitizer-t-members" aria-label="Permalink to &quot;Members {#api-digitizer-t-members}&quot;"></a></h4><ul><li><code>bool in_range</code><br> Indicates to the host that the contact is within range (ie. close to or in contact with the digitizer surface).</li><li><code>bool tip</code><br> The state of the tip switch.</li><li><code>bool barrel</code><br> The state of the barrel switch.</li><li><code>float x</code><br> The X coordinate of the digitizer contact.</li><li><code>float y</code><br> The Y coordinate of the digitizer contact.</li><li><code>bool dirty</code><br> Whether the current state needs to be sent to the host.</li></ul><hr><h3 id="api-digitizer-flush" tabindex="-1"><code>void digitizer_flush(void)</code> <a class="header-anchor" href="#api-digitizer-flush" aria-label="Permalink to &quot;`void digitizer_flush(void)` {#api-digitizer-flush}&quot;"></a></h3><p>Send the digitizer report to the host if it is marked as dirty.</p><hr><h3 id="api-digitizer-in-range-on" tabindex="-1"><code>void digitizer_in_range_on(void)</code> <a class="header-anchor" href="#api-digitizer-in-range-on" aria-label="Permalink to &quot;`void digitizer_in_range_on(void)` {#api-digitizer-in-range-on}&quot;"></a></h3><p>Assert the &quot;in range&quot; indicator, and flush the report.</p><hr><h3 id="api-digitizer-in-range-off" tabindex="-1"><code>void digitizer_in_range_off(void)</code> <a class="header-anchor" href="#api-digitizer-in-range-off" aria-label="Permalink to &quot;`void digitizer_in_range_off(void)` {#api-digitizer-in-range-off}&quot;"></a></h3><p>Deassert the &quot;in range&quot; indicator, and flush the report.</p><hr><h3 id="api-digitizer-tip-switch-on" tabindex="-1"><code>void digitizer_tip_switch_on(void)</code> <a class="header-anchor" href="#api-digitizer-tip-switch-on" aria-label="Permalink to &quot;`void digitizer_tip_switch_on(void)` {#api-digitizer-tip-switch-on}&quot;"></a></h3><p>Assert the tip switch, and flush the report.</p><hr><h3 id="api-digitizer-tip-switch-off" tabindex="-1"><code>void digitizer_tip_switch_off(void)</code> <a class="header-anchor" href="#api-digitizer-tip-switch-off" aria-label="Permalink to &quot;`void digitizer_tip_switch_off(void)` {#api-digitizer-tip-switch-off}&quot;"></a></h3><p>Deassert the tip switch, and flush the report.</p><hr><h3 id="api-digitizer-barrel-switch-on" tabindex="-1"><code>void digitizer_barrel_switch_on(void)</code> <a class="header-anchor" href="#api-digitizer-barrel-switch-on" aria-label="Permalink to &quot;`void digitizer_barrel_switch_on(void)` {#api-digitizer-barrel-switch-on}&quot;"></a></h3><p>Assert the barrel switch, and flush the report.</p><hr><h3 id="api-digitizer-barrel-switch-off" tabindex="-1"><code>void digitizer_barrel_switch_off(void)</code> <a class="header-anchor" href="#api-digitizer-barrel-switch-off" aria-label="Permalink to &quot;`void digitizer_barrel_switch_off(void)` {#api-digitizer-barrel-switch-off}&quot;"></a></h3><p>Deassert the barrel switch, and flush the report.</p><hr><h3 id="api-digitizer-set-position" tabindex="-1"><code>void digitizer_set_position(float x, float y)</code> <a class="header-anchor" href="#api-digitizer-set-position" aria-label="Permalink to &quot;`void digitizer_set_position(float x, float y)` {#api-digitizer-set-position}&quot;"></a></h3><p>Set the absolute X and Y position of the digitizer contact, and flush the report.</p><h4 id="api-digitizer-set-position-arguments" tabindex="-1">Arguments <a class="header-anchor" href="#api-digitizer-set-position-arguments" aria-label="Permalink to &quot;Arguments {#api-digitizer-set-position-arguments}&quot;"></a></h4><ul><li><code>float x</code><br> The X value of the contact position, from 0 to 1.</li><li><code>float y</code><br> The Y value of the contact position, from 0 to 1.</li></ul>', 47);
const _hoisted_48 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, _hoisted_48);
}
const digitizer = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
__pageData,
digitizer as default
};