qmk_firmware/assets/feature_userspace.md.DzgyEZm9.js

16 lines
36 KiB
JavaScript
Raw Normal View History

import { _ as _export_sfc, c as createElementBlock, o as openBlock, a8 as createStaticVNode } from "./chunks/framework.B9AX-CPi.js";
const __pageData = JSON.parse('{"title":"Userspace: Sharing Code Between Keymaps","description":"","frontmatter":{},"headers":[],"relativePath":"feature_userspace.md","filePath":"feature_userspace.md"}');
const _sfc_main = { name: "feature_userspace.md" };
const _hoisted_1 = /* @__PURE__ */ createStaticVNode('<h1 id="userspace-sharing-code-between-keymaps" tabindex="-1">Userspace: Sharing Code Between Keymaps <a class="header-anchor" href="#userspace-sharing-code-between-keymaps" aria-label="Permalink to &quot;Userspace: Sharing Code Between Keymaps&quot;"></a></h1><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>Please note, userspace submissions to the upstream <code>qmk/qmk_firmware</code> repository are no longer being accepted. The userspace feature itself remains functional and can be configured locally.</p></div><p>If you use more than one keyboard with a similar keymap, you might see the benefit in being able to share code between them. Create your own folder in <code>users/</code> named the same as your keymap (ideally your GitHub username, <code>&lt;name&gt;</code>) with the following structure:</p><ul><li><code>/users/&lt;name&gt;/</code> (added to the path automatically) <ul><li><code>readme.md</code> (optional, recommended)</li><li><code>rules.mk</code> (included automatically)</li><li><code>config.h</code> (included automatically)</li><li><code>&lt;name&gt;.h</code> (optional)</li><li><code>&lt;name&gt;.c</code> (optional)</li><li><code>cool_rgb_stuff.c</code> (optional)</li><li><code>cool_rgb_stuff.h</code> (optional)</li></ul></li></ul><p>All this only happens when you build a keymap named <code>&lt;name&gt;</code>, like this:</p><pre><code>make planck:&lt;name&gt;\n</code></pre><p>For example,</p><pre><code>make planck:jack\n</code></pre><p>Will include the <code>/users/jack/</code> folder in the path, along with <code>/users/jack/rules.mk</code>.</p><div class="warning custom-block"><p class="custom-block-title">WARNING</p><p>This <code>name</code> can be <a href="#override-default-userspace">overridden</a>, if needed.</p></div><h2 id="rules-mk" tabindex="-1"><code>Rules.mk</code> <a class="header-anchor" href="#rules-mk" aria-label="Permalink to &quot;`Rules.mk`&quot;"></a></h2><p>The <code>rules.mk</code> is one of the two files that gets processed automatically. This is how you add additional source files (such as <code>&lt;name&gt;.c</code>) will be added when compiling.</p><p>It&#39;s highly recommended that you use <code>&lt;name&gt;.c</code> as the default source file to be added. And to add it, you need to add it the SRC in <code>rules.mk</code> like this:</p><pre><code>SRC += &lt;name&gt;.c\n</code></pre><p>Additional files may be added in the same way - it&#39;s recommended you have one named <code>&lt;name&gt;</code>.c/.h to start off with, though.</p><p>The <code>/users/&lt;name&gt;/rules.mk</code> file will be included in the build <em>after</em> the <code>rules.mk</code> from your keymap. This allows you to have features in your userspace <code>rules.mk</code> that depend on individual QMK features that may or may not be available on a specific keyboard.</p><p>For example, if you have RGB control features shared between all your keyboards that support RGB lighting, you can add support for that if the RGBLIGHT feature is enabled:</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:#D73A49;--shiki-dark:#F97583;">ifeq</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;"> (</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">$(</span><span style="--shiki-light:#005CC5;--shiki-dark:#79B8FF;">strip</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;"> $(</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">RGBLIGHT_ENABLE</span><span style="--shiki-light:#032F62;--shiki-dark:#9ECBFF;">))</span><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E8;">, yes)</span></span>\n<span class="line"><span style="--shiki-light:#6A737D;--shiki-dark:#6A737D;"> # Include my fancy rgb functions source here</span></span>\n<span class="line"><span style="--shiki-light:#24292E;--shiki-dark:#E1E4E
const _hoisted_74 = [
_hoisted_1
];
function _sfc_render(_ctx, _cache, $props, $setup, $data, $options) {
return openBlock(), createElementBlock("div", null, _hoisted_74);
}
const feature_userspace = /* @__PURE__ */ _export_sfc(_sfc_main, [["render", _sfc_render]]);
export {
__pageData,
feature_userspace as default
};