Skip to content

Complete typed HID++ feature wrappers#326

Merged
AprilNEA merged 21 commits into
masterfrom
feat/complete-hidpp-api
Jun 27, 2026
Merged

Complete typed HID++ feature wrappers#326
AprilNEA merged 21 commits into
masterfrom
feat/complete-hidpp-api

Conversation

@AprilNEA

Copy link
Copy Markdown
Owner

Summary

Completes typed HID++ wrappers for all documented non-destructive features currently covered by hidpp-docs and wires the HID crate to use the new wrappers where appropriate.

Highlights:

  • Adds typed feature wrappers for mouse pointer/DPI, host switching, keyboard controls, backlight/illumination, lighting effects, audio EQ, persistent remappable actions, crown/touch raw input, and solar keyboard dashboard.
  • Adds the generated 0x1b04 ReprogControls V4/V6 ControlId and TaskId constant tables.
  • Migrates existing HID write paths for SmartShift and lighting onto typed HID++ wrappers.
  • Preserves existing MX Gesture Button semantics documentation from the current branch history.
  • Adds runtime validation for typed wrapper inputs that use reserved sentinels or nibble/range-limited fields.

Validation

  • cargo fmt --check
  • cargo test -p openlogi-hidpp --lib
  • cargo clippy -p openlogi-hidpp --all-targets -- -D warnings
  • cargo check -p openlogi-hid
  • cargo clippy -p openlogi-hid --all-targets -- -D warnings

Notes

Intentionally not included:

  • DFU / firmware-update features
  • Encryption / manufacturing / reset-style destructive features
  • Registry-only entries where no local spec exists

Hardware follow-up: the 0x8070 lighting write migration still needs real-device validation to confirm target firmware ACK behavior for typed send_v20 calls.

@greptile-apps

greptile-apps Bot commented Jun 27, 2026

Copy link
Copy Markdown

Greptile Summary

This PR completes typed HID++ 2.0 feature wrappers for all non-destructive features covered by hidpp-docs, migrates SmartShift and lighting write paths to use the new wrappers, and wires up the new wrappers in the feature registry.

  • Adds 25+ new typed feature modules under openlogi-hidpp (DPI, backlight, EQ, crown, solar, touchpad, reprog controls, etc.) with matching unit tests, plus the generated 0x1b04 ControlId and TaskId constant tables.
  • Migrates openlogi-hid's SmartShift write path from the hand-rolled SmartShiftFeatureV0 to the new SmartShiftEnhancedFeature, and migrates the 0x8070 ColorLedEffects colour-apply path to the typed ColorLedEffectsFeature wrapper (with an explicit 4-zone cap and zero-zone fallback preserved from the old path).
  • Removes the old SmartShiftFeatureV0 struct from openlogi-hid and replaces all its call sites.

Confidence Score: 5/5

Safe to merge; all write paths continue to apply a 4-zone cap and the SmartShift migration correctly handles the function-ID shift between 0x2110 and 0x2111.

The migration preserves the behavioral contract of both lighting and SmartShift write paths. New feature wrappers are well-tested with representative unit tests. The only non-blocking concerns are a missing band-count cap in the Equalizer wrapper and the inherent ambiguity of using a hardcoded zone-effect index for the lighting path — both acknowledged in the PR notes.

crates/openlogi-hid/src/write/lighting.rs (hardcoded zone-effect index needs real-device validation) and crates/openlogi-hidpp/src/feature/equalizer/mod.rs (band-count cap).

Important Files Changed

Filename Overview
crates/openlogi-hid/src/write/lighting.rs Migrates 0x8070 color-apply path to typed ColorLedEffectsFeature; preserves the 4-zone cap and adds a zero-zone fallback; hardcodes zone_effect_index=1 (EFFECT_FIXED) without querying get_zone_effect_info, which needs real-device validation
crates/openlogi-hid/src/write/smartshift.rs Migrates SmartShift Enhanced (0x2111) from the hand-rolled SmartShiftFeatureV0 to the new typed SmartShiftEnhancedFeature; adds set_mode_preserving_status for toggle flows that treats a zero read-back as do-not-change rather than an error
crates/openlogi-hidpp/src/feature/smartshift_enhanced/mod.rs New typed wrapper for 0x2111 SmartShiftWheelEnhanced; uses NonZeroU8 for auto_disengage/tunable_torque to enforce the protocol 0=do-not-change sentinel at the type level
crates/openlogi-hidpp/src/feature/extended_dpi/mod.rs New typed wrapper for 0x2202 ExtendedAdjustableDpi; includes page-bounded DPI range fetching (MAX_RANGE_PAGES=16), echo-byte validation, and event decoding
crates/openlogi-hidpp/src/feature/extended_dpi/types.rs DPI range parser handles fixed values, stepped ranges and page-straddling words; correctly rejects hyphen-without-following-literal and validates range endpoints
crates/openlogi-hidpp/src/feature/equalizer/mod.rs New typed wrapper for 0x8310 Equalizer; get_frequency_gains does not cap band_count at 15, so a device reporting 16+ bands could include a non-gain payload byte in the result
crates/openlogi-hidpp/src/feature/color_led_effects/mod.rs New typed wrapper for 0x8070 ColorLedEffects; validate_single_nv_capability enforces the single-bit NvCapabilities constraint in get_nv_config and set_nv_config
crates/openlogi-hidpp/src/feature/backlight/mod.rs New typed wrapper for 0x1982 Backlight v3; correctly packs the 2-bit mode into bits 3-4 of the options byte and handles the 0xff do-not-change sentinel for the effect field
crates/openlogi-hidpp/src/feature/persistent_remappable_action/mod.rs New typed wrapper for 0x1c00 PersistentRemappableAction; covers all six documented functions with correct payload packing and decoding
crates/openlogi-hidpp/src/feature/registry.rs Wires 25+ new feature IDs to their typed wrapper structs in KNOWN_FEATURES; no pre-existing entries are removed or remapped incorrectly

Flowchart

%%{init: {'theme': 'neutral'}}%%
flowchart TD
    A[Agent: set_keyboard_color] --> B{LightingMethod?}
    B -->|Auto / ColorLedEffects| C[set_color_effects]
    B -->|PerKey| D[set_color_per_key]
    C --> E[open_feature ColorLedEffectsFeature 0x8070]
    E --> F[get_info zone_count]
    F --> G{zone_count == 0?}
    G -->|yes| H[fallback: zones_to_write = 4]
    G -->|no| I[zones_to_write = zone_count.min 4]
    H --> J[loop: set_zone_effect EFFECT_FIXED Volatile]
    I --> J
    J --> K[sleep FRAME_GAP 8ms per zone]
    D --> L[resolve_feature_index 0x8080]
    L --> M[raw HID++ writes]
    N[Agent: set_smartshift] --> O[SmartShift::open]
    O --> P{0x2111 present?}
    P -->|yes| Q[SmartShiftEnhancedFeature]
    P -->|no| R[SmartShiftFeature 0x2110]
    Q --> S[set_ratchet_control_mode]
    R --> T[set_ratchet_control_mode]
Loading
%%{init: {'theme': 'base', 'themeVariables': {"darkMode": true, "background": "#0d1117", "primaryColor": "#21262d", "primaryTextColor": "#e6edf3", "primaryBorderColor": "#8b949e", "lineColor": "#8b949e", "textColor": "#e6edf3", "edgeLabelBackground": "#161b22", "actorBkg": "#21262d", "actorBorder": "#8b949e", "actorTextColor": "#e6edf3", "actorLineColor": "#8b949e", "signalColor": "#8b949e", "signalTextColor": "#e6edf3", "noteBkgColor": "#373320", "noteBorderColor": "#d4a72c", "noteTextColor": "#f0e6c0", "labelBoxBkgColor": "#21262d", "labelBoxBorderColor": "#8b949e", "labelTextColor": "#e6edf3", "loopTextColor": "#e6edf3", "activationBkgColor": "#30363d", "activationBorderColor": "#8b949e"}}}%%
flowchart TD
    A[Agent: set_keyboard_color] --> B{LightingMethod?}
    B -->|Auto / ColorLedEffects| C[set_color_effects]
    B -->|PerKey| D[set_color_per_key]
    C --> E[open_feature ColorLedEffectsFeature 0x8070]
    E --> F[get_info zone_count]
    F --> G{zone_count == 0?}
    G -->|yes| H[fallback: zones_to_write = 4]
    G -->|no| I[zones_to_write = zone_count.min 4]
    H --> J[loop: set_zone_effect EFFECT_FIXED Volatile]
    I --> J
    J --> K[sleep FRAME_GAP 8ms per zone]
    D --> L[resolve_feature_index 0x8080]
    L --> M[raw HID++ writes]
    N[Agent: set_smartshift] --> O[SmartShift::open]
    O --> P{0x2111 present?}
    P -->|yes| Q[SmartShiftEnhancedFeature]
    P -->|no| R[SmartShiftFeature 0x2110]
    Q --> S[set_ratchet_control_mode]
    R --> T[set_ratchet_control_mode]
Loading

Reviews (4): Last reviewed commit: "fix(hidpp): correct multi-host fn invers..." | Re-trigger Greptile

Comment thread crates/openlogi-hid/src/write/lighting.rs
Comment thread crates/openlogi-hidpp/src/feature/smartshift_enhanced/mod.rs
Comment thread crates/openlogi-hidpp/src/feature/color_led_effects/mod.rs
@AprilNEA AprilNEA merged commit 6ff5689 into master Jun 27, 2026
9 checks passed
@AprilNEA AprilNEA deleted the feat/complete-hidpp-api branch June 27, 2026 14:05
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant