mirror of
https://github.com/CharaChorder/DeviceManager.git
synced 2026-01-07 02:22:52 +00:00
feat: fetch settings from build meta
This commit is contained in:
@@ -17,6 +17,21 @@
|
||||
import { preference } from "$lib/preferences";
|
||||
import { action } from "$lib/title";
|
||||
import { fly } from "svelte/transition";
|
||||
import type { SettingsItemMeta } from "$lib/meta/types/meta";
|
||||
|
||||
function titlecase(str: string) {
|
||||
return str.charAt(0).toUpperCase() + str.slice(1);
|
||||
}
|
||||
|
||||
function settingValue(value: number, setting: SettingsItemMeta) {
|
||||
if (setting.inverse !== undefined) {
|
||||
return setting.inverse / value;
|
||||
}
|
||||
if (setting.scale !== undefined) {
|
||||
return value * setting.scale;
|
||||
}
|
||||
return value;
|
||||
}
|
||||
</script>
|
||||
|
||||
<svelte:head>
|
||||
@@ -71,15 +86,6 @@
|
||||
/></label
|
||||
>
|
||||
{#if $serialPort}
|
||||
<label
|
||||
>Boot message<input type="checkbox" use:setting={{ id: 0x93 }} /></label
|
||||
>
|
||||
<label
|
||||
>GTM Realtime Feedback<input
|
||||
type="checkbox"
|
||||
use:setting={{ id: 0x92 }}
|
||||
/></label
|
||||
>
|
||||
{#if $deviceMeta?.factoryDefaults?.settings}
|
||||
<button
|
||||
use:action={{ title: "Reset Settings" }}
|
||||
@@ -91,256 +97,63 @@
|
||||
<button class="outline" use:popup={ResetPopup}>Recovery...</button>
|
||||
{/if}
|
||||
</fieldset>
|
||||
|
||||
{#if $serialPort}
|
||||
<fieldset>
|
||||
<legend
|
||||
><label
|
||||
><input type="checkbox" use:setting={{ id: 0x41 }} />Spurring</label
|
||||
></legend
|
||||
>
|
||||
<p>
|
||||
"Chording only" mode which tells your device to output chords on a press
|
||||
rather than a press & release. It also enables you to jump from one
|
||||
chord to another without releasing everything and can be activated in
|
||||
GTM or by chording both mirror keys. It can provide significant speed
|
||||
gains with chording, but also takes away the flexibility of character
|
||||
entry.
|
||||
</p>
|
||||
<p>
|
||||
Spurring also helps new users learn how to chord by eliminating the need
|
||||
to focus on timing.
|
||||
</p>
|
||||
<p>
|
||||
Spurring is toggled by chording <Action display="keys" action={540} /> and
|
||||
<Action display="keys" action={542} /> together.
|
||||
</p>
|
||||
<label
|
||||
>Character Counter Timeout<span class="unit"
|
||||
><input
|
||||
type="number"
|
||||
step="0.001"
|
||||
min="0"
|
||||
max="240"
|
||||
use:setting={{ id: 0x43, scale: 0.001 }}
|
||||
/>s</span
|
||||
></label
|
||||
>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend
|
||||
><label
|
||||
><input
|
||||
type="checkbox"
|
||||
use:setting={{ id: 0x51 }}
|
||||
/>Arpeggiates</label
|
||||
></legend
|
||||
>
|
||||
<p>
|
||||
A quick, single key press and release used to indicate a suffix, prefix,
|
||||
or modifier to be associated with a chord.
|
||||
</p>
|
||||
<p>
|
||||
The following keys have special behavior when arpeggiates are enabled:
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<Action display="keys" action={44} />, <Action
|
||||
display="keys"
|
||||
action={59}
|
||||
/> and <Action display="keys" action={58} /> will be placed before the
|
||||
auto-inserted space
|
||||
</li>
|
||||
<li>
|
||||
<Action display="keys" action={46} />, <Action
|
||||
display="keys"
|
||||
action={63}
|
||||
/> and <Action display="keys" action={33} /> will be placed before the
|
||||
auto-inserted space and capitalize the next word
|
||||
</li>
|
||||
<li>
|
||||
<Action display="keys" action={45} /> and <Action
|
||||
display="keys"
|
||||
action={47}
|
||||
/> will replace the auto-inserted space
|
||||
</li>
|
||||
</ul>
|
||||
<label
|
||||
>Timeout After Chord<span class="unit"
|
||||
><input type="number" step="1" use:setting={{ id: 0x54 }} />ms</span
|
||||
></label
|
||||
>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Chord Modifiers</legend>
|
||||
<p>
|
||||
Chord modifiers change a chord when held with the chord or when pressed
|
||||
after (arpeggiated), <b>provided that arpeggiates are enabled.</b>
|
||||
</p>
|
||||
<ul>
|
||||
<li>
|
||||
<Action display="keys" action={513} /> Capitalizes the first letter of
|
||||
a chord
|
||||
</li>
|
||||
<li>
|
||||
<Action display="keys" action={540} /> Present Tense (supported words only)
|
||||
</li>
|
||||
<li>
|
||||
<Action display="keys" action={542} /> Plural (supported words only)
|
||||
</li>
|
||||
<li>
|
||||
<Action display="keys" action={550} /> Past Tense (supported words only)
|
||||
</li>
|
||||
<li>
|
||||
<Action display="keys" action={551} /> Comparative (supported words only)
|
||||
</li>
|
||||
</ul>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend>Character Entry</legend>
|
||||
{#if $serialPort.device === "LITE"}
|
||||
<label
|
||||
>Swap Keymap 0 and 1<input
|
||||
type="checkbox"
|
||||
use:setting={{ id: 0x13 }}
|
||||
/></label
|
||||
>
|
||||
{/if}
|
||||
<label>
|
||||
Character Entry (chentry)
|
||||
<input type="checkbox" use:setting={{ id: 0x12 }} />
|
||||
</label>
|
||||
<label>
|
||||
Key Scan Rate
|
||||
<span class="unit"
|
||||
><input
|
||||
type="number"
|
||||
use:setting={{ id: 0x14, inverse: 1000 }}
|
||||
/>Hz</span
|
||||
></label
|
||||
>
|
||||
<label>
|
||||
Key Debounce Press<span class="unit"
|
||||
><input type="number" use:setting={{ id: 0x15 }} />ms</span
|
||||
></label
|
||||
>
|
||||
<label
|
||||
>Key Debounce Release<span class="unit"
|
||||
><input type="number" use:setting={{ id: 0x16 }} />ms</span
|
||||
></label
|
||||
>
|
||||
<label
|
||||
>Output Character Delay<span class="unit"
|
||||
><input type="number" use:setting={{ id: 0x17 }} />µs</span
|
||||
></label
|
||||
>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend
|
||||
><label><input type="checkbox" use:setting={{ id: 0x21 }} />Mouse</label
|
||||
></legend
|
||||
>
|
||||
<label
|
||||
>Mouse Speed<input type="number" use:setting={{ id: 0x22 }} /><input
|
||||
type="number"
|
||||
use:setting={{ id: 0x23 }}
|
||||
/></label
|
||||
>
|
||||
<label
|
||||
>Scroll Speed<input type="number" use:setting={{ id: 0x25 }} /></label
|
||||
>
|
||||
<label>
|
||||
<span>
|
||||
Active Mouse
|
||||
<p>Bounces mouse by 1px every 60s if enabled</p></span
|
||||
>
|
||||
<input type="checkbox" use:setting={{ id: 0x24 }} /></label
|
||||
>
|
||||
<label
|
||||
>Poll Rate<span class="unit"
|
||||
><input
|
||||
type="number"
|
||||
use:setting={{ id: 0x26, inverse: 1000 }}
|
||||
/>Hz</span
|
||||
></label
|
||||
>
|
||||
</fieldset>
|
||||
|
||||
<fieldset>
|
||||
<legend
|
||||
><label
|
||||
><input type="checkbox" use:setting={{ id: 0x31 }} />Chording</label
|
||||
></legend
|
||||
>
|
||||
<label
|
||||
>Auto-delete Timeout <span class="unit"
|
||||
><input
|
||||
type="number"
|
||||
min="0"
|
||||
max="25500"
|
||||
step="10"
|
||||
use:setting={{ id: 0x33 }}
|
||||
/>ms</span
|
||||
></label
|
||||
>
|
||||
<label
|
||||
>Press Tolerance<span class="unit"
|
||||
><input
|
||||
type="number"
|
||||
min="1"
|
||||
max="150"
|
||||
step="1"
|
||||
use:setting={{ id: 0x34 }}
|
||||
/>ms</span
|
||||
></label
|
||||
>
|
||||
<label
|
||||
>Release Tolerance<span class="unit"
|
||||
><input
|
||||
type="number"
|
||||
min="1"
|
||||
max="150"
|
||||
step="1"
|
||||
use:setting={{ id: 0x35 }}
|
||||
/>ms</span
|
||||
></label
|
||||
>
|
||||
</fieldset>
|
||||
|
||||
{#if $serialPort.device === "LITE"}
|
||||
{#if $deviceMeta}
|
||||
{#each $deviceMeta.settings as category}
|
||||
<fieldset>
|
||||
<legend
|
||||
><label><input type="checkbox" use:setting={{ id: 0x84 }} />RGB</label
|
||||
></legend
|
||||
>
|
||||
<label
|
||||
>Brightness<input
|
||||
use:setting={{ id: 0x81 }}
|
||||
type="number"
|
||||
min="0"
|
||||
max="50"
|
||||
step="1"
|
||||
/></label
|
||||
>
|
||||
<select use:setting={{ id: 0x82 }}>
|
||||
<option value="0">White</option>
|
||||
<option value="1">Red</option>
|
||||
<option value="2">Orange</option>
|
||||
<option value="3">Yellow</option>
|
||||
<option value="4">Lime</option>
|
||||
<option value="5">Green</option>
|
||||
<option value="7">Cyan</option>
|
||||
<option value="9">Blue</option>
|
||||
<option value="10">Violet</option>
|
||||
<option value="11">Pink</option>
|
||||
<option value="13">Multicolor</option>
|
||||
</select>
|
||||
<legend>
|
||||
{#if category.items[0]?.name === "enable"}
|
||||
<label
|
||||
><input
|
||||
type="checkbox"
|
||||
use:setting={{ id: category.items[0].id }}
|
||||
/>{titlecase(category.name)}</label
|
||||
>
|
||||
{:else}
|
||||
{titlecase(category.name)}
|
||||
{/if}
|
||||
</legend>
|
||||
{#if category.description}
|
||||
<p>{category.description}</p>
|
||||
{/if}
|
||||
{#each category.items as item}
|
||||
{#if item.name !== "enable"}
|
||||
<label
|
||||
>{#if item.enum}
|
||||
<select use:setting={{ id: item.id }}>
|
||||
{#each item.enum as name, value}
|
||||
<option {value}>{titlecase(name)}</option>
|
||||
{/each}
|
||||
</select>
|
||||
{:else if item.range[0] === 0 && item.range[1] === 1}
|
||||
<input type="checkbox" use:setting={{ id: item.id }} />
|
||||
{:else}
|
||||
<span class="unit"
|
||||
><input
|
||||
type="number"
|
||||
min={settingValue(item.range[0], item)}
|
||||
max={settingValue(item.range[1], item)}
|
||||
step={settingValue(item.step, item)}
|
||||
use:setting={{
|
||||
id: item.id,
|
||||
inverse: item.inverse,
|
||||
scale: item.scale,
|
||||
}}
|
||||
/>{item.unit}</span
|
||||
>
|
||||
{/if}
|
||||
{#if item.description}
|
||||
<span
|
||||
>{titlecase(item.name)}
|
||||
<p>{item.description}</p></span
|
||||
>
|
||||
{:else}
|
||||
{titlecase(item.name)}
|
||||
{/if}
|
||||
</label>
|
||||
{/if}
|
||||
{/each}
|
||||
</fieldset>
|
||||
{/if}
|
||||
{/each}
|
||||
{/if}
|
||||
</section>
|
||||
|
||||
|
||||
Reference in New Issue
Block a user