libratbag / libratbag

A DBus daemon to configure input devices, mainly high-end and gaming mice
MIT License
2.11k stars 258 forks source link

Another 258a:1007 SINOWEALTH RGB Mouse #1359

Open DanielMGessel opened 2 years ago

DanielMGessel commented 2 years ago

Is your feature request related to a problem? Please describe. On Ubuntu 22.04.1, locally built libratbag doesn't recognize my Inland GM76 Wired RGB Gaming Mouse.

Describe the solution you'd like Host control over RGB lighting and extra button functionality from Ubuntu 22.04.1 via shell or Python script or C program I could write.

Describe alternatives you've considered I have a Cooler Master MM711 Pixart 3389 mouse on the way, and I'll give that a try. If that works, I'll have more information and a way to use mouse glow for feedback. This Inland mouse is nice & heavy and I like the lighting style. In short, I'd still like to program it.

Additional context lsusb output, to get the ball rolling: Bus 003 Device 002: ID 258a:1007 SINOWEALTH Game Mouse

staticssleever668 commented 2 years ago

@DanielMGessel, hello, there is a slight chance it's already supported, we just need to add some information about it. However after checking it's configuration utility it seems like it's the other kind of Sinowealth mice we don't support. Still, we should try. Could you start ratbagd in verbose mode (sudo ratbagd --verbose) and post the output here? Particularly I'm interested in it's firmware version number.

While you are waiting for my answer after posting it, you can also try adding this at the end of the sinowealth-1007.device device file (probably in /usr/share/libratbag/ or /usr/local/share/libratbag/):

[Driver/sinowealth/devices/InlandGM76_test2]
ButtonCount=8
DeviceName=Inland GM76
FwVersion=2763
LedType=RGB
SensorType=PMW3212

[Driver/sinowealth/devices/InlandGM76_test1]
ButtonCount=8
DeviceName=Inland GM76
# This is the firmware version from the configuration utility.
# As you can see, it's 6 characters long, but there should only be 4 for the driver we have.
FwVersion=FR2763
LedType=RGB
SensorType=PMW3212

Also, see https://github.com/libratbag/libratbag/pull/1312#issuecomment-1203689423, just skip the device file creation step (we already have it for 1007 product ID).

DanielMGessel commented 2 years ago

I did try the _nubwo driver and it doesn't give the errors you see below, but still doesn't work. No luck getting a message about firmware. I undid some the hacks I put in to reduce logging to my SSD, and I see

Nov 01 07:13:10 golden-eagle ratbagd[6444]: ratbag error: Could not set feature report in a write query: -110
Nov 01 07:13:10 golden-eagle ratbagd[6444]: ratbag error: Error while selecting profile: -1

when I startup ratbagd without _nubwo. Point being that I think I successfully undid those hacks and that ratbagd isn't complaining about FwVersion.

Hmmm....

PS did you download the utility and run it to get that FwVersion?

Here's the result of --verbose:

|π•˜π• π•π••π•–π•Ÿ-π•–π•’π•˜π•π•–| ξ‚³β‹…β‹…β‹…β‹…β‹…β‹…β‹…β‹…β‹…β‹…β‹…β‹…ξ‚± (486)ξ‚° sudo ratbagd --verbose
Initializing libratbag
ratbag debug: New device: SINOWEALTH Game Mouse
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: device assigned driver sinowealth
ratbag debug: hidraw info: bus 0x03 vendor 0x258a product 0x1007
ratbag debug: SINOWEALTH Game Mouse is device '/dev/hidraw1'.
ratbag debug: Parsing HID report descriptor
ratbag debug: Parsing HID report descriptor
ratbag debug: hidraw info: bus 0x03 vendor 0x258a product 0x1007
ratbag debug: SINOWEALTH Game Mouse is device '/dev/hidraw3'.
ratbag debug: Parsing HID report descriptor
ratbag debug: Parsing HID report descriptor
ratbag debug: - HID report ID 01
ratbag debug: - HID report ID 02
ratbag debug: - HID report ID 04
ratbag debug: - HID report ID 06
ratbag debug: - HID report ID 07
ratbag debug: - HID report ID 08
ratbag debug: - HID report ID 05
ratbag raw: feature set:   05 02 01 00 00 00
ratbag error: Could not set feature report in a write query: -110
ratbag error: Error while selecting profile: -1
ratbag debug: New device: SINOWEALTH Game Mouse
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: device assigned driver sinowealth
ratbag debug: hidraw info: bus 0x03 vendor 0x258a product 0x1007
ratbag debug: SINOWEALTH Game Mouse is device '/dev/hidraw1'.
ratbag debug: Parsing HID report descriptor
ratbag debug: Parsing HID report descriptor
ratbag debug: hidraw info: bus 0x03 vendor 0x258a product 0x1007
ratbag debug: SINOWEALTH Game Mouse is device '/dev/hidraw3'.
ratbag debug: Parsing HID report descriptor
ratbag debug: Parsing HID report descriptor
ratbag debug: - HID report ID 01
ratbag debug: - HID report ID 02
ratbag debug: - HID report ID 04
ratbag debug: - HID report ID 06
ratbag debug: - HID report ID 07
ratbag debug: - HID report ID 08
ratbag debug: - HID report ID 05
ratbag raw: feature set:   05 02 01 00 00 00
ratbag error: Could not set feature report in a write query: -110
ratbag error: Error while selecting profile: -1
ratbag debug: New device: WACF3233:00 056A:49C4
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: No data file found for 056a:49c4
ratbag debug: New device: DLL0B7F:01 06CB:CE8C
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: No data file found for 06cb:ce8c
DBus server ready
staticssleever668 commented 2 years ago

Thanks for your feedback! Sadly, it's exactly what I thought it was going to be - it's the other kind of Sinowealth mice which we are not compatible with (yet?).

DanielMGessel commented 2 years ago

I’ve done a little coding now and again. I don’t quite get your codebase, but it could be an interesting challenge. It sounds like The protocol is most likely undocumented and that would require reverse engineering with, say, wireshark. Poking around this repository, it also seems the barriers to frying the mouse aren’t that high (if not permanent damage, still requiring a reset, which itself is unknown - so maybe requiring the original SW). Is all that about right?

staticssleever668 commented 2 years ago

Yeah, you got it right. Although I would suggest you making a separate tool first and only then porting it as a libratbag driver to ease your entrance difficulty a bit.

The procedure is basically as follows: 1) You change some settings on the mouse through it's official software while sniffing packets. 2) You inspect the packets.

To capture packets I suggest you either passing your mouse through to a Windows installation in a VM and using usbmon, or doing it in Windows and using USBPcap.

By the way there is some kind of an open source driver already, in the OpenRGB project, see https://github.com/CalcProgrammer1/OpenRGB/blob/f9bacba0379902b679e9f936a2d9e0a74df34fa9/Controllers/SinowealthController/SinowealthController1007.cpp. However, I'm not really fond of neither structure of this specific driver nor their coding style in general. Regarding this driver in particular: they have several structs which they copy onto a buffer before sending it to the mouse - I suggest you making a single structure in the beginning, reading existing configuration into it, and then modifying it and sending back, just like we do in our sinowealth driver.

Also, if you want to see how someone else does this procedure on a different device, this video may come useful to you: https://www.youtube.com/watch?v=is9wVOKeIjQ. You don't really need to know everything explained there about how USB works, but it too may come in handy.

DanielMGessel commented 2 years ago

Thanks! I will dig around a bit and see what I can figure out. My device experience on Linux is limited to some simple bitbanging to twiddle wires on the RPi header or use the I2C interface. USB is a level-up.

Edit: I also got an inexpensive MM711 Mouse for a second machine, which isn't supported by libratbag. It looks like OpenRGB supports it as well, so maybe I'll get both working. Maybe I should get a third cheapo, but supported by libratbag, for reference? It would round out bling for laptop, desktop, and server machines...

Is it okay to leave this issue open so I might ask for a little help in a week or so? It’s fine if you want me to close it to help clear up your inbox!

lepz0r commented 1 year ago

I have Marvo G956/Digital Alliance G Premium which also has 258a:1007 but with PMW3360 sensor instead

PCAPNG which I played with DPI color & DPI settings

ratbag log:

Initializing libratbag
ratbag debug: New device: JosefAdamcik Sofle
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: No data file found for fc32:0287
ratbag debug: New device: JosefAdamcik Sofle
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: No data file found for fc32:0287
ratbag debug: New device: JosefAdamcik Sofle
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: No data file found for fc32:0287
ratbag debug: New device: SINOWEALTH Game Mouse
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: device assigned driver sinowealth
ratbag debug: hidraw info: bus 0x03 vendor 0x258a product 0x1007
ratbag debug: SINOWEALTH Game Mouse is device '/dev/hidraw0'.
ratbag debug: Parsing HID report descriptor
ratbag debug: Parsing HID report descriptor
ratbag debug: hidraw info: bus 0x03 vendor 0x258a product 0x1007
ratbag debug: SINOWEALTH Game Mouse is device '/dev/hidraw1'.
ratbag debug: Parsing HID report descriptor
ratbag debug: Parsing HID report descriptor
ratbag debug: - HID report ID 01
ratbag debug: - HID report ID 02
ratbag debug: - HID report ID 04
ratbag debug: - HID report ID 06
ratbag debug: - HID report ID 07
ratbag debug: - HID report ID 08
ratbag debug: - HID report ID 05
ratbag raw: feature set:   05 02 01 00 00 00
ratbag error: Could not set feature report in a write query: -110
ratbag error: Error while selecting profile: -1
ratbag debug: New device: SINOWEALTH Game Mouse
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: device assigned driver sinowealth
ratbag debug: hidraw info: bus 0x03 vendor 0x258a product 0x1007
ratbag debug: SINOWEALTH Game Mouse is device '/dev/hidraw0'.
ratbag debug: Parsing HID report descriptor
ratbag debug: Parsing HID report descriptor
ratbag debug: hidraw info: bus 0x03 vendor 0x258a product 0x1007
ratbag debug: SINOWEALTH Game Mouse is device '/dev/hidraw1'.
ratbag debug: Parsing HID report descriptor
ratbag debug: Parsing HID report descriptor
ratbag debug: - HID report ID 01
ratbag debug: - HID report ID 02
ratbag debug: - HID report ID 04
ratbag debug: - HID report ID 06
ratbag debug: - HID report ID 07
ratbag debug: - HID report ID 08
ratbag debug: - HID report ID 05
ratbag raw: feature set:   05 02 01 00 00 00
ratbag error: Could not set feature report in a write query: -110
ratbag error: Error while selecting profile: -1
ratbag debug: New device: TTGK Technology TTGK Audio
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: No data file found for 3302:33c0
ratbag debug: New device: Logitech USB Optical Mouse
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: No data file found for 046d:c077
ratbag debug: New device: Logitech Logitech USB Keyboard
ratbag debug: Using data directory '/usr/share/libratbag'
ratbag debug: No data file found for 046d:c315
DBus server ready

sinowealth-1007.device:

[Device]
DeviceMatch=usb:258a:1007
Driver=sinowealth
Name=SinoWealth Generic Mouse (1007)

# This does NOT work. See libratbag/libratbag#1296.
# For future: ID of A3050 sensor is 0x2, and maximum DPI is 4000.
#[Driver/sinowealth/devices/AntEsportsGM500]
#ButtonCount=7
#DeviceName=Ant Esports GM500
#FwVersion=0910
#LedType=RBG
#SensorType=A3050

[Driver/sinowealth/devices/MarvoG956]
ButtonCount=7
DeviceName=Marvo G956
FwVersion=YJG184
LedType=RGB
SensorType=PMW3360

EDIT: Detected as ZET Fury Pro by OpenRGB

DanielMGessel commented 1 year ago

Sorry, this kind of fell off my todo list... @lepz0r does this device file work for you?

lepz0r commented 1 year ago

No, because of that I sent my PCAPNG file & my log because I have the same error, maybe related

ratbag error: Could not set feature report in a write query: -110
ratbag error: Error while selecting profile: -1