linearmouse icon indicating copy to clipboard operation
linearmouse copied to clipboard

added support for kensington slimblade top buttons

Open fraschm1998 opened this issue 1 year ago • 6 comments

Closes #853

Not sure if another device category should be added for trackballs instead of adding the device to productsToApplySideButtonFixes as they're not really "side buttons"

fraschm1998 avatar Dec 28 '24 22:12 fraschm1998

Thanks for your contribution!

Not sure if another device category should be added for trackballs instead of adding the device to productsToApplySideButtonFixes as they're not really "side buttons"

I agree—it might be more appropriate to create a separate Set<(VendorID, ProductID)> to store the devices requiring this fix. This would help avoid using hardcoded magic numbers directly in the code and improve clarity and maintainability.

lujjjh avatar Dec 29 '24 05:12 lujjjh

@lujjjh should be good now

Edit: Adding the trackball category will now require updated translations.

fraschm1998 avatar Dec 29 '24 17:12 fraschm1998

@lujjjh so far I just have as I don't have any other trackball devices to try. And I'm not sure if I check for productName contains "trackball" will it mess up devices that have only 2 buttons and 2 scroll reverse buttons.

image

       if let vendorID = device.vendorID,
            let productID = device.productID,
            Self.trackballsRequiringReportMonitoring.contains(
                .init(vendorID: vendorID, productID: productID))
        {
            return .trackball
        }

I could do something like:

        if isTrackball {
            return .trackball
        }

  private var isTrackball: Bool {
        // First check our known device list
        if let vendorID = device.vendorID,
           let productID = device.productID,
           Self.trackballsRequiringReportMonitoring.contains(
               .init(vendorID: vendorID, productID: productID))
        {
            return true
        }
        
        // Then check device characteristics
        if device.confirmsTo(kHIDPage_GenericDesktop, kHIDUsage_GD_Mouse) {
            // Check if it explicitly identifies as a trackball in name
            if self.productName?.lowercased().contains("trackball") == true {
                return true
            }
        }
        
        return false
    }

but then again I don't know if it will mess up the trackball "mice"

fraschm1998 avatar Dec 29 '24 18:12 fraschm1998

Thank you for your effort, and Happy New Year!

After giving it some thought, I wonder if parsing the device's report descriptor might be worth exploring. It could potentially handle extra button recognition for a broader range of devices more effectively. Your work here has provided a great starting point, and I might look into this approach over the weekend or when I have some time.

lujjjh avatar Jan 03 '25 09:01 lujjjh

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar Mar 05 '25 00:03 github-actions[bot]

This PR is stale because it has been open 60 days with no activity. Remove stale label or comment or this will be closed in 10 days.

github-actions[bot] avatar May 13 '25 00:05 github-actions[bot]