2024-05-30 02:02:10 +00:00
|
|
|
|
import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.DyMmIvSC.js";
|
2024-06-02 02:43:43 +00:00
|
|
|
|
const __pageData = JSON.parse('{"title":"Raw HID","description":"","frontmatter":{},"headers":[],"relativePath":"features/rawhid.md","filePath":"features/rawhid.md"}');
|
|
|
|
|
const _sfc_main = { name: "features/rawhid.md" };
|
2024-05-30 02:02:10 +00:00
|
|
|
|
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="raw-hid" tabindex="-1">Raw HID <a class="header-anchor" href="#raw-hid" aria-label="Permalink to "Raw HID {#raw-hid}""></a></h1><p>The Raw HID feature allows for bidirectional communication between QMK and the host computer over an HID interface. This has many potential use cases, such as switching keymaps on the fly or sending useful metrics like CPU/RAM usage.</p><p>In order to communicate with the keyboard using this feature, you will need to write a program that runs on the host. As such, some basic programming skills are required - more if you intend to implement complex behaviour.</p><h2 id="usage" tabindex="-1">Usage <a class="header-anchor" href="#usage" aria-label="Permalink to "Usage {#usage}""></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;">RAW_ENABLE = yes</span></span></code></pre></div><h2 id="basic-configuration" tabindex="-1">Basic Configuration <a class="header-anchor" href="#basic-configuration" aria-label="Permalink to "Basic Configuration {#basic-configuration}""></a></h2><p>By default, the HID Usage Page and Usage ID for the Raw HID interface are <code>0xFF60</code> and <code>0x61</code>. However, they can be changed if necessary by adding the following to your <code>config.h</code>:</p><table><thead><tr><th>Define</th><th>Default</th><th>Description</th></tr></thead><tbody><tr><td><code>RAW_USAGE_PAGE</code></td><td><code>0xFF60</code></td><td>The usage page of the Raw HID interface</td></tr><tr><td><code>RAW_USAGE_ID</code></td><td><code>0x61</code></td><td>The usage ID of the Raw HID interface</td></tr></tbody></table><h2 id="sending-data-to-the-keyboard" tabindex="-1">Sending Data to the Keyboard <a class="header-anchor" href="#sending-data-to-the-keyboard" aria-label="Permalink to "Sending Data to the Keyboard {#sending-data-to-the-keyboard}""></a></h2><p>To send data to the keyboard, you must first find a library for communicating with HID devices in the programming language of your choice. Here are some examples:</p><ul><li><strong>Node.js:</strong> <a href="https://github.com/node-hid/node-hid" target="_blank" rel="noreferrer">node-hid</a></li><li><strong>C/C++:</strong> <a href="https://github.com/libusb/hidapi" target="_blank" rel="noreferrer">hidapi</a></li><li><strong>Java:</strong> <a href="https://github.com/nyholku/purejavahidapi" target="_blank" rel="noreferrer">purejavahidapi</a> and <a href="https://github.com/gary-rowe/hid4java" target="_blank" rel="noreferrer">hid4java</a></li><li><strong>Python:</strong> <a href="https://pypi.org/project/hid/" target="_blank" rel="noreferrer">pyhidapi</a> and <a href="https://pypi.org/project/pywinusb" target="_blank" rel="noreferrer">pywinusb</a></li></ul><p>Please refer to these libraries' own documentation for instructions on usage. Remember to close the device once you are finished with it!</p><p>Next, you will need to know the USB Vendor and Product IDs of the device. These can easily be found by looking at your keyboard's <code>info.json</code>, under the <code>usb</code> object (alternatively, you can also use Device Manager on Windows, System Information on macOS, or <code>lsusb</code> on Linux). For example, the Vendor ID for the Planck Rev 6 is <code>0x03A8</code>, and the Product ID is <code>0xA4F9</code>.</p><p>It's also a good idea to narrow down the list of potential HID devices the library may give you by filtering on the usage page and usage ID, to avoid accidentally opening the interface on the same device for the keyboard, or mouse, or media keys, etc.</p><p>Once you are able to open the HID device and send reports to it, it's time to handle them on the keyboard side. Implement the following function in your <code>keym
|
|
|
|
|
const _hoisted_38 = [
|
|
|
|
|
_hoisted_1
|
|
|
|
|
];
|
|
|
|
|
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
|
|
|
|
|
return openBlock(), createElementBlock("div", null, _hoisted_38);
|
|
|
|
|
}
|
2024-06-02 02:43:43 +00:00
|
|
|
|
const rawhid = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
|
2024-05-30 02:02:10 +00:00
|
|
|
|
export {
|
|
|
|
|
__pageData,
|
2024-06-02 02:43:43 +00:00
|
|
|
|
rawhid as default
|
2024-05-30 02:02:10 +00:00
|
|
|
|
};
|