Repository navigation
feat(mchose): support the Ace 68 V2 III keyboard #70
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
66de082
3daf1c5
bfcf485
46f1367
551cbbb
4761cab
47b2043
d20c255
b073ed3
8d77666
702bfef
24f3e12
310700f
a75356e
45013c1
b989764
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Large diffs are not rendered by default.
Large diffs are not rendered by default.
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -9,6 +9,7 @@ | |
| import { invoke } from "@tauri-apps/api/core"; | ||
| import { VIA_USAGE, VIA_USAGE_PAGE } from "@openmouse/keyboard-protocol/via"; | ||
| import { WUQUE_FEATURES, wuqueOp } from "./keyboard-wuque"; | ||
| import { isMchoseKeyboardControl, MCHOSE_FEATURES, mchoseOp, mchoseSections, writeMchoseKeyboard } from "./keyboard-mchose"; | ||
| import { DEVICE_DRIVERS, type DeviceDriver } from "@openmouse/keyboard-protocol/drivers/registry"; | ||
| import { SUPPORTED_HID_FILTERS } from "@openmouse/keyboard-protocol/drivers/vendors"; | ||
| import { listHidInterfaces, TauriHidDevice, type HidInterfaceInfo } from "./native-hid/tauri-hid-device"; | ||
|
|
@@ -127,7 +128,7 @@ async function withKeyboard<T>(info: KeyboardInterface, work: (client: any, bran | |
| ]); | ||
| } finally { | ||
| clearTimeout(timer); | ||
| await client.close().catch(() => undefined); | ||
| if (!client.keepOpen) await client.close().catch(() => undefined); | ||
| } | ||
| }); | ||
| } | ||
|
|
@@ -171,7 +172,7 @@ export function describeKeyboard(key: string, brand: string, status: any) { | |
| status: { | ||
| ...status, | ||
| firmware: version ? [version] : status.firmware ?? [], | ||
| keyboardFeatures: brand === "Wuque Studio" ? WUQUE_FEATURES : null, | ||
| keyboardFeatures: brand === "Wuque Studio" ? WUQUE_FEATURES : brand === "MCHOSE" ? MCHOSE_FEATURES : null, | ||
| }, | ||
| controls: null, | ||
| tabs: { | ||
|
|
@@ -189,7 +190,7 @@ export async function connectKeyboard(info: KeyboardInterface) { | |
| const rates = status.logitech ?? await polling(client); | ||
| const sections = status.logitech?.onboardMemory | ||
| ? await logitechKeyboardSections(client, info.key, status.logitech) | ||
| : []; | ||
| : brand === "MCHOSE" ? await mchoseSections(client) : []; | ||
| const readout = describeKeyboard(info.key, brand, { | ||
| ...status, pollingRateHz: rates.pollingRateHz, supportedPollingRates: rates.supportedPollingRates, | ||
| // These controls are offered only after the hardware returns a profile. | ||
|
|
@@ -200,11 +201,12 @@ export async function connectKeyboard(info: KeyboardInterface) { | |
| }); | ||
| } | ||
|
|
||
| /** Keys, actuation and lighting, where this app can change them. */ | ||
| /** Keys, actuation and lighting, where this app can change them (Wuque Studio; MCHOSE lighting). */ | ||
| export async function keyboardOp(info: HidInterfaceInfo, op: string, args: any): Promise<unknown> { | ||
| return withKeyboard(info, async (client, brand) => { | ||
| if (brand !== "Wuque Studio") throw new Error("This app can't change that on this keyboard yet."); | ||
| return wuqueOp(client, op, args); | ||
| if (brand === "Wuque Studio") return wuqueOp(client, op, args); | ||
| if (brand === "MCHOSE") return mchoseOp(client, op, args); | ||
|
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Read calibration status without acquiring the device lock. The status handler reads only in-memory state. This route still acquires the device lock and waits for
|
||
| throw new Error("This app can't change that on this keyboard yet."); | ||
| }); | ||
| } | ||
|
|
||
|
|
@@ -220,6 +222,15 @@ export async function writeKeyboard(info: KeyboardInterface, action: string, val | |
| return { tabs: { ...readout.tabs, advanced: [...sections, ...readout.tabs.advanced] } }; | ||
| }); | ||
| } | ||
| if (isMchoseKeyboardControl(action)) { | ||
| return withKeyboard(info, async (client, brand) => { | ||
| if (brand !== "MCHOSE") throw new Error("This control requires an MCHOSE keyboard."); | ||
| if (await writeMchoseKeyboard(client, action, value) === "rebooted") return -1; | ||
| const status = await client.readStatus(); | ||
|
onyxhq-dev marked this conversation as resolved.
Resolved
coderabbitai[bot] marked this conversation as resolved.
Resolved
|
||
| const readout = describeKeyboard(info.key, brand, status); | ||
| return { tabs: { ...readout.tabs, advanced: [...await mchoseSections(client), ...readout.tabs.advanced] } }; | ||
| }); | ||
| } | ||
| if (action !== "pollingRate") throw new Error("This app can't change that on a keyboard yet."); | ||
| return withKeyboard(info, async (client, brand) => { | ||
| if (brand === "Logitech") { | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.