Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
2 changes: 1 addition & 1 deletion .github/workflows/ci.yml
Original file line number Diff line number Diff line change
Expand Up @@ -58,7 +58,7 @@ jobs:
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
npm install --prefix native-hid --omit=dev
npm ci --prefix native-hid --omit=dev
# Trim node-hid's other-platform prebuilt bindings — this archive
# only ever runs on win32-x64.
Get-ChildItem native-hid/node_modules/node-hid/prebuilds -Directory |
Expand Down
6 changes: 3 additions & 3 deletions .github/workflows/release.yml
Original file line number Diff line number Diff line change
Expand Up @@ -42,7 +42,7 @@ jobs:
shell: pwsh
run: |
$ErrorActionPreference = "Stop"
npm install --prefix native-hid --omit=dev
npm ci --prefix native-hid --omit=dev
# Trim node-hid's other-platform prebuilt bindings — this archive
# only ever runs on win32-x64.
Get-ChildItem native-hid/node_modules/node-hid/prebuilds -Directory |
Expand Down Expand Up @@ -84,7 +84,7 @@ jobs:
- name: Prepare native-hid (deps + bundled Node.js runtime)
run: |
set -euo pipefail
npm install --prefix native-hid --omit=dev
npm ci --prefix native-hid --omit=dev
# Trim node-hid's non-macOS prebuilt bindings; keep both Apple
# silicon and Intel since the Bridge binary itself is universal.
find native-hid/node_modules/node-hid/prebuilds -mindepth 1 -maxdepth 1 -type d \
Expand Down Expand Up @@ -131,7 +131,7 @@ jobs:
- name: Prepare native-hid (deps + bundled Node.js runtime)
run: |
set -euo pipefail
npm install --prefix native-hid --omit=dev
npm ci --prefix native-hid --omit=dev
# Trim node-hid's non-Linux prebuilt bindings; this archive only
# ever runs on linux-x64.
find native-hid/node_modules/node-hid/prebuilds -mindepth 1 -maxdepth 1 -type d \
Expand Down
4 changes: 3 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -105,7 +105,9 @@ enumeration details.

## Loopback API

- `GET /v1/status` reports the Bridge version, platform, active games, battery
- `GET /v1/status` reports the Bridge version, platform, active games, the
devices the control panel currently holds open over native HID
(`activeDevices`, most recently opened first), battery levels, battery
threshold, autostart and automatic-update preferences, and whether an
OpenMouse client has completed a recent handshake.
- `PUT /v1/handshake` renews OpenMouse's 20-second connection lease. The client
Expand Down
9 changes: 9 additions & 0 deletions native-hid/package-lock.json

Some generated files are not rendered by default. Learn more about how customized files appear on GitHub.

4 changes: 3 additions & 1 deletion native-hid/package.json
Original file line number Diff line number Diff line change
Expand Up @@ -12,10 +12,12 @@
},
"dependencies": {
"@openmouse/protocol": "github:OpenMouse-Project/mouse-protocol#v0.10.0",
"@openmouse/keyboard-protocol": "file:../../../keyboard-protocol",
"@openmouse/keyboard-protocol": "github:OpenMouse-Project/keyboard-protocol#v1.1.0",
"node-hid": "^3.1.0"
},
"allowScripts": {
"github:OpenMouse-Project/keyboard-protocol#v1.1.0": true,
"github:OpenMouse-Project/keyboard-protocol#cae3d7a74e8256a9a3cc5c7fe2311db1425bb977": true,
"github:OpenMouse-Project/mouse-protocol#v0.10.0": true,
"node-hid@3.4.0": true,
"github:OpenMouse-Project/mouse-protocol#b69cd44b2498dcaaa65fd6f77ba10bf109e49322": true
Expand Down
20 changes: 11 additions & 9 deletions src/desktop.rs
Original file line number Diff line number Diff line change
Expand Up @@ -655,9 +655,15 @@ impl TrayApp {
});
let device_name = snapshot.and_then(|snapshot| {
snapshot
.batteries
.active_devices
.first()
.map(|battery| battery.device_name.clone())
.map(|device| device.name.clone())
.or_else(|| {
snapshot
.batteries
.first()
.map(|battery| battery.device_name.clone())
})
.or_else(|| {
snapshot
.active_profile
Expand Down Expand Up @@ -687,7 +693,6 @@ impl TrayApp {
divider(ui);
match snapshot.map(|snapshot| snapshot.batteries.as_slice()) {
Some(batteries) if !batteries.is_empty() => {
let single = batteries.len() == 1;
for battery in batteries.iter().take(MAX_BATTERY_ROWS) {
let value = if battery.charging {
format!("{}% · Charging", battery.percent)
Expand All @@ -701,12 +706,9 @@ impl TrayApp {
} else {
TEXT
};
let label = if single {
"Battery"
} else {
battery.device_name.as_str()
};
value_row(ui, label, &value, color);
// Battery history can belong to a different mouse than
// the active HID device, even when there is only one row.
value_row(ui, &battery.device_name, &value, color);
divider(ui);
}
}
Expand Down
Loading
Loading