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

Added experimental support for Rival 600 #60

merged 3 commits into from Aug 24, 2018


None yet
2 participants
Copy link

ergor commented Aug 7, 2018

EDIT2: see my other comment below


Added support for sensitivity, polling rate, solid colors for all LEDs and saving for the Rival 600.

Except for udev rules and initial loading of profiles, I have kept all new code inside as to not clutter central code files. This may need some refactoring.

One quirk of the 600 is that it doesn't have separate commands for solid colors and color effects. They are stringed together in one big command, the 0x0500 command.

There are some bytes that I haven't been able to identify their purpose. More experimentation is needed to understand the color protocol fully. I have attached my notes on the protocol:



  • Understand color protocol (maybe pr43 has some clues)
  • Check for side effects as consequence of not fully understanding the color protocol
  • Check if color setting code can be simplified (again, because of not fully understanding the color protocol currently)
  • Add color shift support
  • Add button configuration support
  • Consider if some central code needs modifications to accommodate the 600 and similar mice

EDIT1: although this works for my Rival 600, the code is arguably unrefined. Unsure if this should be considered for merging now as experimental support, or be kept open while refining the code (pr43 has some really interesting insights and similarities) and have discussions regarding this class of mice.


This comment has been minimized.

Copy link
Contributor Author

ergor commented Aug 9, 2018


I have reworked everything by applying knowledge from pr #43

As both the Rival 600 and the Sensei 310 (from #43) and possibly other newer mice use a very similar color protocol, I have formalized the new format and added support for it with a new value_type that I have called "rgbuniversal"

Mice using this protocol can now be configured by defining a "rgbuniversal_format" subdictionary which specifies header field indexes, and then the command subdictionaries need only specify value type as rgbuniversal and an LED index.

The handler for rgbuniversal commands currently support three modes:

  • Single steady color
  • Colorshifting between any number of colors, with cycle time and time proportions for each color
  • Reactive mode, with button trigger mask that selects which buttons triggers the reaction

Usage examples, setting logo color:

Set color to steady blue:
$ rivalcfg -c blue

Set even RGB colorshift with cycle time x (don't care) and triggers x:
$ rivalcfg -c x,x,red,0,green,54,blue,54

Set colorshift with cycle time 30000 ms between cyan (position 0/FF), magenta (pos 80/FF) and yellow (pos A0/FF)
$ rivalcfg -c 30000,x,00FFFF,0,FF00FF,80,FFFF00,20
Note that the color positions are cumulative

Set all buttons to trigger a color cycle from red to blue with cycle time of 1000 ms
$ rivalcfg -c 1000,ff,red,0,blue,50

Below is the protocol details:

|---COLORS---(wValue=0x0300 feature)------------------------------------------------------------------------------------------|
|                                                                                                                             |
|   led_id         led_id                   repeat|triggers  points                                                           |
|cmd--|^^|x?---|y?---|^^|speed|                |^^|^^|        |^^|color1--|color1--|p1|color2--|p2|   |colorN--|pN|color1--|pe|
|05:00:id:__:__:__:__:id:ll:hh:... 14 bytes ...:rp:tr:__:__:__:nn:r1:g1:b1:r1:g1:b1:p1:r2:g2:b2:p2:...:rN:gN:bN:pN:r1:g1:b1:pe|

led_id: the led (0..7)
x, y: looks like the x and y coordinates of the LEDs (little endian), maybe for wave effect?
speed: cycle time in milliseconds (little endian)
repeat: wether the cycle should repeat (0=repeat, 1=don't)
triggers: the trigger button mask, selects which buttons trigger new color cycle
points: number of points (point = color and cumulative proportion of cycle time)
colorX: a color in rr:gg:bb format
pX: a (cumulative) time proportion

note: the offical tool inserts the first color at the end regardless of user choices (color1)
note: the inserted color gets a time proportion (pe) of: 0xFF - sum(p1, p2,...,pN)

This was referenced Aug 9, 2018


This comment has been minimized.

Copy link

flozz commented Aug 15, 2018


Sorry for the time I made to answer, I will review your PR very soon. Thank you for your interest in this project :)

Copy link

flozz left a comment


Your PR is ok except for the fiew things I commented. Sorry for the time I took to review it.

int(string, 16)
return True

This comment has been minimized.


flozz Aug 24, 2018


Please catch only ValueError here :)

for led_id in rgb_format["led_id"]:
header[led_id] = command["led_id"]

a, l = rgb_format["speed"], rgb_format["speed_len"]

This comment has been minimized.


flozz Aug 24, 2018


please rename those variables (maybe speed and speed_len ?)

header[rgb_format["triggers"]] = triggers
header[rgb_format["point_count"]] = len(colors) + 1

""" data segment format:

This comment has been minimized.


flozz Aug 24, 2018


do not add a second docstring:

  • Add this to the main docstring if relevant
  • else just add it as a comment :)

This comment has been minimized.

Copy link
Contributor Author

ergor commented Aug 24, 2018

I have applied the requested changes :) Also:

  • Updated the output example of the Rival600 in the Readme
  • Fixed looming case sensitivity issue in rgbuniversal_handler() for the don't care value

flozz approved these changes Aug 24, 2018

@flozz flozz merged commit da033b2 into flozz:master Aug 24, 2018

1 check passed

continuous-integration/travis-ci/pr The Travis CI build passed

This comment has been minimized.

Copy link

flozz commented Aug 24, 2018

Thank you very much :)

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment