Giter VIP home page Giter VIP logo

piper's Introduction

libratbag

libratbag provides ratbagd, a DBus daemon to configure input devices, mainly gaming mice. The daemon provides a generic way to access the various features exposed by these mice and abstracts away hardware-specific and kernel-specific quirks.

libratbag currently supports devices from Logitech, Etekcity, GSkill, Roccat, Steelseries. See the device files for a complete list of supported devices.

Users interact through a GUI like Piper. For developers, the ratbagctl tool is the prime tool for debugging.

Installing libratbag from system packages

libratbag is packaged for some distributions, you can use your system's package manager to install it. See the wiki for details.

Compiling libratbag

libratbag uses the meson build system which in turn uses ninja to invoke the compiler. Run the following commands to clone libratbag and initialize the build:

git clone https://github.com/libratbag/libratbag.git
cd libratbag
meson builddir
ninja -C builddir
sudo ninja -C builddir install

The default prefix is /usr/local, i.e. it will not overwrite the system installation. For more information, see the wiki.

And to build or re-build after code-changes, run:

ninja -C builddir
sudo ninja -C builddir install

To remove/uninstall simply run:

sudo ninja -C builddir uninstall

Note: builddir is the build output directory and can be changed to any other directory name. To set configure-time options, use e.g.

meson configure builddir -Ddocumentation=false

Run meson configure builddir to list the options.

Running ratbagd as DBus-activated systemd service

To run ratbagd, simply run it as root sudo ratbagd. However, ratbagd is intended to run as dbus-activated systemd service and installs the following files:

/usr/share/dbus-1/system.d/org.freedesktop.ratbag1.conf
/usr/share/dbus-1/system-services/org.freedesktop.ratbag1.conf
/usr/share/systemd/system/ratbagd.service

These files are installed into the prefix by ninja install, see also the configure-time options -Dsystemd-unit-dir and -Ddbus-root-dir. Developers are encouraged to simply symlink to the files in the git repository.

For the files to take effect, you should run

sudo systemctl daemon-reload
sudo systemctl reload dbus.service

And finally, to enable the service:

sudo systemctl enable ratbagd.service

This places the required symlink into the systemd directory so that dbus activation is possible.

The DBus Interface

Full documentation of the DBus interface to interact with devices is available here: ratbagd DBus Interface description.

libratbag Internal Architecture

libratbag has two main components, libratbag and ratbagd. Applications like Piper talk over DBus to ratbagd. ratbagd uses libratbag to access the actual devices.

+-------+    +------+    +---------+    +-----------+
| Piper | -> | DBus | -> | ratbagd | -> | libratbag | -> device
+-------+    +------+    +---------+    +-----------+

Inside libratbag, we have the general frontend and API. Each device is handled by a HW-specific backend. That HW backend is responsible for the device-specific communication (usually some vendor-specific HID protocol).

+---------+    +-----+    +------------+    +----------+
| ratbagd | -> | API | -> | hw backend | -> | protocol | -> device
+---------+    +-----+    +------------+    +----------+

The API layer is HW agnostic. Depend on the HW, the protocol may be part of the driver implementation (e.g. etekcity) or a separate set of files (HID++). Where the protocol is separate, the whole known protocol should be implemented. The HW driver then only accesses the bits required for libratbag. This allows us to optionally export the protocol as separate library in the future, if other projects require it.

Adding Devices to libratbag

libratbag relies on a device database to match a device with the drivers. See the data/devices/ directory for the set of known devices. These files are usually installed into $prefix/$datadir (e.g. /usr/share/libratbag/).

Adding a new device can be as simple as adding a new .device file. This is the case for many devices with a shared protocol (e.g. Logitech's HID++). See the data/devices/device.example file for guidance on what information must be set. Look for existing devices from the same vendor as guidance too.

If the device has a different protocol and doesn't work after adding the device file, you'll have to start reverse-engineering the device-specific protocol. Good luck :)

Source

git clone https://github.com/libratbag/libratbag.git

Bugs

Bugs can be reported in our issue tracker

Mailing list

libratbag discussions happen on the input-tools mailing list hosted on freedesktop.org

Device-specific notes

A number of device-specific notes and observations can be found in our wiki: https://github.com/libratbag/libratbag/wiki/Devices

License

libratbag is licensed under the MIT license.

Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions: [...]

See the COPYING file for the full license information.

piper's People

Contributors

bentiss avatar christiangnrd avatar domheadroom avatar doomsdayrs avatar ffy00 avatar funeoz avatar hjdskes avatar isantop avatar k1ngjulien avatar kyokenn avatar muzena avatar nl-tch avatar owendaprile avatar phomes avatar piotrdrag avatar qjammer avatar redbusters avatar s8321414 avatar sketchbuch avatar staticssleever668 avatar stephanlachnit avatar stephengeorgewest avatar t-8ch avatar themarix avatar vistaus avatar whot avatar xinayder avatar xoascf avatar xvitaly avatar z-ww447 avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

piper's Issues

displaying the scale for changing the resolution can be masked

Clicking on resolution 4, at the end of the list often pops up the resolution scale to interact outside of the current view.

The user needs to scroll down to access it, which is counter intuitive.

We need to make sure the scale is always visible after a click by moving all the rest up (with an animation if possible, or @jimmac is going to complain).

ButtonDialog should allow the user to set timeouts

Making this into a separate issue so that I can fix it after #47 is merged, as a feature on its own.

This will probably take the form of a checkbox in the capture page, that will then make the button dialog track the interval within key events.

crash due to lack of compatibility with ratbag

commit ff3730f3fba7dc9e4660fe841097d4f1fe1793e8 in ratbag changed naming convention.

piper/init.py line 172 and line 177 contain description instead of name. Replacing those lines prevents crash if device is not recognized. There might be more examples of such incompatibility in the code.

Confirm before exiting with uncommitted changes

As pointed out by @hadess in #69:

  • Ask the user whether to apply all the settings to the mouse before exiting (same pattern as when you exit gedit with an unsaved file)
  • Add a preference to automatically save to the mouse when exiting (default to yes?)

I definitely want to implement the first; I'm not sure if the second is worth it.

Bindings should share the same DBus connection

From #10:

One thing I did notice is that every Ratbagd* class instantiates a new DBus connection by inheriting from _RatbagdDBus. It seems unnecessary to me to have one DBus connection for each profile, resolution, button, et cetera. Is this design intentional or is this something we can/should improve?

It's not really a problem, just inefficient.

Handle device disconnects

If there are no configurable devices left, display the error perspective saying as such. If there are one or more devices left, display the welcome perspective.

Long time when switching profiles

Playing with the G700 and switching between profiles introduces an ever growing timeout between the actual action on the profile switch button (going from profile0 to profile1) and the update on the screen.

I set the G700 profile 0 to a refresh rate of 125, which outputs an error on piper terminal when we retrieve this profile:

  • at launch (profile 0 selected): 1 "Ooops, rate is 125 and I don't know how to deal with that." is displayed
  • going to profile1 is immediate
  • going back to profile 0, 2 "Ooops..." are displayed
  • going to profile 2 takes few seconds
  • going back to profile 0, 6 "Ooops..." are displayed
  • etc...

Looks like we forget to clean up after a profile has been loaded or we need to use a caching mechanism in piper

Logitech G602 - Piper/libratbag Problem

Installed Piper from Aur, all fine.

Started ratbagd and got this:
ratbagd.service - Daemon to introspect and modify configurable mice
Loaded: loaded (/usr/lib/systemd/system/ratbagd.service; enabled; vendor preset: disabled)
Active: failed (Result: core-dump) since Tue 2017-08-08 18:20:17 CEST; 1min 56s ago
Process: 18686 ExecStart=/usr/bin/ratbagd (code=dumped, signal=SEGV)
Main PID: 18686 (code=dumped, signal=SEGV)

ratbagd.service: Unit entered failed state.
ratbagd.service: Failed with result 'core-dump'.
ratbagd.service: Service hold-off time over, scheduling restart.
Stopped Daemon to introspect and modify configurable mice.
ratbagd.service: Start request repeated too quickly.
Failed to start Daemon to introspect and modify configurable mice.
ratbagd.service: Unit entered failed state.
ratbagd.service: Failed with result 'core-dump'.

After I restarted my computer and got no error. Ratbagd is running. sudo ratbagd and I can see some mouse related infos like battery percent and a few other things:

ratbag debug: Logitech USB Receiver is device '/dev/hidraw3'.
ratbag debug: Logitech USB Receiver is device '/dev/hidraw4'.
ratbag debug: report ID 01
ratbag debug: report ID 03
ratbag debug: report ID 04
ratbag debug: report ID 10
ratbag debug: report ID 11
ratbag debug: report ID 80
ratbag debug: 'Logitech USB Receiver' is using protocol v2.0
ratbag debug: device battery level is 50% (next 20%), status 0
ratbag debug: device has adjustable dpi
ratbag error: HID++ error from the device (1): ERR_INVALID_ADDRESS (02)
ratbag error: Error while requesting resolution: Protocol error (-71)
ratbag debug: device has adjustable report rate
ratbag debug: device has color effects
ratbag error: HID++ error from the device (1): ERR_INVALID_ADDRESS (02)
Speicherzugriffsfehler (Speicherabzug geschrieben)

The wireless G602 should be working. ID 046d:c537 Logitech, Inc, it´s in the hwdb.

Don´t know what´s wrong here.

Running Manjaro and installed from AUR

Add support for translations

There isn't much to translate yet, but we should support for this at one point in time. This comes down to adding the necessary changes in Meson and adding a po directory.

piper crash when ratbagd isn't available

When ratbagd isn't running, piper crashes instead of showing me a nice dialog. This is commit afdadb6 on your buttons branch

$> n install && /opt/libratbag/bin/piper 
[0/1] Installing files.
Installing subdir /home/whot/code/ratbag/piper/piper to /opt/libratbag/lib/python3.6/site-packages
Installing data/piper.gresource to /opt/libratbag/share/piper/piper.gresource
Installing /home/whot/code/ratbag/piper/data/org.freedesktop.Piper.desktop to /opt/libratbag/share/applications
Installing /home/whot/code/ratbag/piper/data/org.freedesktop.Piper.svg to /opt/libratbag/share/icons/hicolor/scalable/apps
Installing /home/whot/code/ratbag/piper/build/piper to /opt/libratbag/bin
Running custom install script '/usr/bin/env sh /home/whot/code/ratbag/piper/meson_install.sh'
gtk-update-icon-cache: Cache file created successfully.
Traceback (most recent call last):
  File "/opt/libratbag/lib/python3.6/site-packages/piper/application.py", line 53, in do_activate
    window = Window(self._ratbag, application=self)
  File "/opt/libratbag/lib/python3.6/site-packages/piper/window.py", line 51, in __init__
    self._device = self._fetch_ratbag_device()
  File "/opt/libratbag/lib/python3.6/site-packages/piper/window.py", line 67, in _fetch_ratbag_device
    if len(self._ratbag.devices) == 0:
AttributeError: 'NoneType' object has no attribute 'devices'

piper crashes when no devices are available

Start ratbagd without any devices plugged in, watch piper crash and burn. What a spectacle! I'll go get popcorn :)

Running from source tree, using local files
Could not find any devices. Do you have anything vaguely mouse-looking plugged in?
Traceback (most recent call last):
  File "/home/whot/code/ratbag/piper/piper/application.py", line 52, in do_activate
    window = Window(self._ratbag, application=self)
  File "/home/whot/code/ratbag/piper/piper/window.py", line 57, in __init__
    capabilities = self._device.capabilities
AttributeError: 'NoneType' object has no attribute 'capabilities'

Drop all indices from the GUI

E.g. "LED X: ", or the number of the resolution in the list, etc. None of this is interesting to the user, except for profiles perhaps because we need the index to differentiate those.

XML error during install

When trying to install piper, ninja gives the following error

XMLLINT not set and xmllint not found in path; skipping xml preprocessing.

Create a Flatpak including libratbag and ratbagd

Hello,

@whot asked me to look into creating a Flatpak of Piper which includes libratbag and ratbagd. This issue is meant to track required items. I will edit this post to add items as I go; other findings will be added as comments.

RUNTIME: we will require GNOME's runtime as we require GLib and GTK+ for Piper. Versions generally don't matter, but we need to see what version of GTK+ we want to use. Newer versions have fancier widgets, but this might limit availability in distributions like Debian when Piper is installed without Flatpak.

TODO:

  • Make libratbag, ratbagd and Piper build systems compliant with the Build API as required for flatpak-builder
    • libratbag
    • ratbagd
    • Piper
  • AppData file for Piper (optional)
  • All files exported from the Flatpak need to have the application ID as their prefix. We can either rename the relevant source files or use flatpak-builder to rename the files at build time. My preference would be the former to keep it simple.
    • Desktop file
    • Application icon
    • ratbagd.service.in (not sure how this works with an org.freedesktop.ratbagd ID in the Flatpak for Piper with org.freedesktop.Piper yet)

Make it possible to run piper from the source tree

./build/piper should just work without any further setup. Since that requires some extra bits to load the module path or at least set up the path, might be easier to just provide a ./build/piper.devel script that mangles everything into place as required.

Handle device connects

if the user is in the welcome screen, simply add it to the list. If the user is in the error perspective, switch to the welcome perspective. Otherwise, simply make the back button visible if it wasn't already.

Possibly an in-app notification can be added to tell the user his device has been recognized.

install instructions

Hello

Can you provide some install instructions for ubuntu please?

I've done python setup.py build, python setup.py install.

But I'm getting:

ImportError: No module named 'ratbagd'

When I run it.

Highlighting LEDs changes their z-stacking

Visible with the SVG in libratbag/libratbag#228

In an svg, elements' z stacking order determines whether they are visible and what parts of them are. A common trick for drawings (especially for lazy people) is to simply let something be obscured by another element instead of having to perfectly line up the edges. In the G303 drawing in pull request libratbag/libratbag#228 this is the case for the left LED - the top of it is hidden by the button.

Highlighting that LED seems to change the z-stacking order, causing the element to appear above the button that should otherwise obscure it.

Packaging PIPER as Snap app

I’ve read the comments on the issue #5.
As far as I know, snap packaging system can already overcome those issues.

As the next ubuntu release will ship with gnome and snap apps can be installed in the majority of the distros, I’d suggest to try the snap apps...

Here is an example of a meson app for reference: https://github.com/snapcore/snapcraft/tree/0a62dc065b033e84925198e25fcba775a833e0ba/integration_tests/snaps/meson-hello

And here the interfaces of the snap apps:
https://snapcraft.io/docs/reference/interfaces

Resolutions page needs a way to set a profile's default resolution.

The mockups left this out, so this isn't yet decided.

@whot suggested a check mark next to the delete button (functioning like a radio button, e.g. only one can be selected at any given time) or an "advanced" popup menu that has the check mark in there, and if supported by the device also exposes the scale for the y-resolution. My personal preference would be the former, but let's open a discussion on this.

Don't allow unsetting the left button

If we map current logical left button to anything else, map another button to left instead. Default approach: search for the right button and swap it. Otherwise pick some random button (?).

We don't want to end up without a left button

Profile cycle buttons must apply across all profiles

If we assign a button to profile cycle up or some other profile switching, that mapping must be assigned across all profiles. Otherwise clicking the same button will eventually land you in a profile with no way out.

piper won't start

In Ubuntu Artful i get this error in terminal:

$ piper
Traceback (most recent call last):
File "/usr/bin/piper", line 32, in
from piper.application import Application
ModuleNotFoundError: No module named 'piper'

Improve keyboard support

There is no keyboard support for navigating lists or switching stack pages and the like. We should probably add that at some point, especially in case you mess up your only device and need the keyboard to fix it :)

LED capability check needed

One of the LEDs on my G303 apparently cannot be set to breathing, but piper exposes that option. We should grey out that button if the cap isn't there.

This isn't a piper bug just yet, libratbag doesn't expose this option

Resolution sliders need stops and reasonable ranges

Comment from @hadess during GUADEC when I demoed it: the resolution sliders should have increments and snap to those (e.g. every 50 or 100 dpi).

Also, the resolution range can be capped to a resonable range, if we don't expect anyone to set 12000 dpi, we shouldn't display it.

ButtonsPage displays macros as their integer keycodes

I couldn't test this before, but I just noticed it with the test device from running ratbagd.devel: the buttonspage displays macros using their integer keycodes. This is easily solved by copying the code from KeyStroke::_update_macro, but that results in (unnecessary?) duplication.

I was thinking of adding a (possibly static) method to RatbagdButton to get the human-readable string representation of the macro, if it is mapped to a macro. What are your thoughts on this? Tagging @whot and @bentiss

Save button is not obvious

Comment from @hadess when I showed him piper at GUADEC: the save button to actually write to the mouse is not obvious enough, needs to be differently placed.

Do not crash if ratbagd is not loaded

With the new dbus activation, users are still required to call systemctl enable ratbagd.service before being able to launch piper.
If this step has not been completed, piper crashes with GLib.Error: g-io-error-quark: Error calling StartServiceByName for org.freedesktop.ratbag1: GDBus.Error:org.freedesktop.systemd1.LoadFailed: Unit dbus-org.freedesktop.ratbag1.service failed to load: No such file or directory. (36).

It would be good to catch the exception and present a message to the user that there are some configuration commands that needs to be run.

changing a resolution should not change the active one

When testing a device that has resolution 2 active, changing any other resolution in the Resolution panel and committing to the device changes the active resolution back to the first one (0).

I do not have this behavior with ratbagctl so I guess piper must be overwriting the active resolution...

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.