There is no guarantees the current value of dpi_index will be correct.
On my G502 the profiles are read in reverse order meaning that setting the
dpi_index can be applied to a wrong value.
Look for the correct libratbag dpi index before setting it.
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
Where a profile name is not UTF8 compatible, let's try to convert it from
latin-1. If that fails, we just escape anything that's not ascii and move on.
Fixes#617
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
For two dicts x and y the merged dict can be created as {**x, **y}. We use
that to take the enum names and covert them to lowercase with hyphens instead
of underscores.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Rough update but headed in the right direction
* Simplified silhouette of bag
* Reduced number of rats inside the Rat Bag to two
* Eyes are still small and potentially still not printable at small scale
* Introduced rough stylized logotype based on Google's Sedgwick Ave Display font
* Reduced total file size by a heap
Instead of multiple entry points for different values, make the button mapping
a single entry point that takes the mapping type and a variant for the value.
The ratbagd.py bindings are basically left as-is.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
GObject silently catches exceptions and logs it to stderr without ever passing
on the exceptions. Avoid oversight by checking stderr in the tests.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
No longer needed now that the ReportRate is in the profile
(bf127d4c68) and the separate
x/y resolution capability is implied by the Resolution value
(8e9dd6f392)
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
We don't have mice that can do report rates per resolutions, so let's not
commit to that.
This is a DBus API break but also a break in ratbagd, piper will need to
update to fetch the rate/rates from the profile object now.
It's a ratbagctl break as well, ratbagctl info changes slightly and the
resolution is not argument anymore for the rate.
Fixes#645
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Since 2607114709 we returned the second parser
to handle everything after the device argument. That parser didn't have the
various options we handled in the original one, causing --keepalive to stop
working. Restore this by passing the existing namespace down to the parser.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Instead of a fixed (uu) with an extra capability flag, let's just make this a
variant defined to be a u or a (uu), depending on whether we have a single or
a separate resolution.
In the ratbagd.py bindings we return a tuple for both, but a simple len()
check will tell us which one it is.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
If the specific name isn't the list (e.g. howling-woodrat) do a basic string
search on all the device names. For the normal case where users have only one
or maybe two devices and they have unique model names, they can do
ratbagctl "Logitech G303" info
Which is something we can easily support forever as sensible API.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
This seems like a convenience thing, possibly dating back to when we thought
ratbagctl will be the primary libratbag interaction. Either way, for the
limited number of commands we have here it's better to be very strict in what
we accept to avoid accidental typos making it into the API.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
ratbagd uses GObjects and properties so we also make use of notify() a
fair bit. Make sure we don't crash out in ratbagc for that, just add an empty
noop function named notify()
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Take the first 4 bytes of the device id (a sha), parse them as two 2-byte hex
values and mod them by the length of a pre-determined array of rodents and
their vocalisation methods. This gives us an index and a device name
assignement like this:
wailing-squirrel: Logitech G500s Laser Gaming Mouse
warbling-groundhog: Logitech MX Anywhere 2S
humming-hutia: Logitech Gaming Mouse G303
This relies on the sha's first 4 bytes to be unique enough that they don't add
up to the same 2 values. Which is probably safe enough.
This does not affect ratbag-command which still uses the hidraw nodes
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The Device is an object on DBus, there is no need for another opaque ID, we
can just emulate this in the client. In our case by using the object
path and generating a sha1 from it.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Having the device node last makes it easy for us to test the same line
on various devices. That is not the most common use-case - normally we'd
expect our users to have one mouse and run several commands on it
(that's the case during debugging as well).
So let's change the device node to be the first argument, it makes for
easier typing/copy-paste, etc.
Plus it makes it a lot more obvious which one the full command is
(`dpi set 800` in this example)
```
$ ratbagctl hidraw4 dpi set 800
```
Fixes: #635
Signed-off-by: Benjamin Tissoires <benjamin.tissoires@gmail.com>
See the earlier commit "Drop the SVG handling from libratbag" for an
explanation, this commit merely removes the actual files from git.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The SVGs must not be part of any stable API, there is too much behavior
implied that we cannot/do not specify. So it's perfectly likely that a future
change in the SVGs or rendering libraries breaks things in some detail. But
then we cannot update the SVGs without risking breaking other clients that
rely on the current behavior.
Besides: we only have one theme, called "gnome" because a push
towards having SVGs for other themes never happened.
And that theme isn't gnome-specific, it merely looks GNOMEy. The theme is very
much piper-specific in that it requires certain elements that piper cares
about. Currently anyway, if we make this part of our API, piper cannot change
that behavior ever without breaking others.
So let's drop SVG handling completely and rely on the clients to sort it out
for themselves.
For now the SVGs are left in the tree to make it easier to copy to Piper. Once
that's done, we will remove those too.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
When the SVGs need to be maintained elsewhere, we need something reliable to
match devices with SVGs. The easiest is to provide a unique model string,
usually composed from the usb/bluetooth information.
A string format was chosen to make it more flexible for the glorious future
where we have something other than usb or bluetooth devices. Meanwhile, the
format is the well-known "usb:1234:56ef:0" string (bus, vid, pid, version).
The version in this string is a future-proof safeguard for libratbag. It will
be used where libratbag supports two devices with the same VID/PID and where
this is not otherwise differentiable. We don't have any such devices yet, so
libratbag just returns a hardcoded 0.
The format is currently defined for usb and bluetooth, in the future we may
have other strings.
The base guarantee is that this is a reliable identifier for the model that
will never change for that model. IOW this is what piper can use to map
devices to their SVGs.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The led type was the physical led type to describe where the LED sits.
This property is basically unused and of questionable use anyway. GUI
applications would need to rely on drawings of the mouse anyway. Scripts don't
really care because ratbagctl uses the led index anyway. The only time this
matters is when we're looking at (human) device discovery. But even then just
trying to set the LED is enough to figure out which one is which.
So let's drop this API on the assumption that it's not really needed and
maintaining and extending that enum forever is not necessary.
This is not a full purge, merely the DBus API that gets dropped.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
The button type was the physical button type, not the logically assigned
button number.
This property is basically unused and of questionable use anyway. GUI
applications would need to rely on drawings of the mouse anyway. Scripts don't
really care because ratbagctl uses the button index anyway. The only time this
matters is when we're looking at (human) device discovery. But often clicking
around is enough to figure out the index.
So let's drop this API on the assumption that it's not really needed and
maintaining and extending that enum forever is not necessary.
This is not a full purge, merely the DBus API that gets dropped.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>
Make this implict - if the profile has a name, it's writable. Otherwise it's
not and you'll have to rely on the index or make up your own naming.
Signed-off-by: Peter Hutterer <peter.hutterer@who-t.net>