Coder Social home page Coder Social logo

g203-led's Introduction

Logitech G203 Prodigy / G203 LightSync Mouse LED control

Allows you to control the LED lighting of your G203 Prodigy or G203 LightSync Mouse programmatically.
Inspired by and based on g810-led.

Requirements

  • Python 3.5+
  • PyUSB 1.0.2+
  • Root privileges

Installation

  1. Clone the repository: git clone https://github.com/smasty/g203-led.git
  2. Prepare virtualenv: virtualenv ./env
  3. Install dependencies: env/bin/pip install -r requirements.txt
  4. Run (as root): sudo ./g203-led.py solid 00FFFF

Usage

Usage:
    g203-led [lightsync] solid {color} - Solid color mode
    g203-led [lightsync] cycle [{rate} [{brightness}]] - Cycle through all colors
    g203-led [lightsync] breathe {color} [{rate} [{brightness}]] - Single color breathing
    g203-led [lightsync] intro {on|off} - Enable/disable startup effect
    g203-led [lightsync] dpi {dpi} - Set mouse dpi

Arguments:
    Color: RRGGBB (RGB hex value)
    Rate: 100-60000 (Number of milliseconds. Default: 10000ms)
    Brightness: 0-100 (Percentage. Default: 100%)
    DPI: 200-8000 (Prodigy), 50-8000 (Lightsync)

Additional features for G203 LightSync:
    g203-led lightsync triple {color color color} - Sets all 3 colors from left to right.
    g203-led lightsync wave {rate} [{brightness} [{direction}]] - Like cycle but appears to move right or left.
    g203-led lightsync blend [{rate} [{brightness}]] - Like breathe with the side colors changing after some delay.
    
    Direction is either "left" or "right". Default: right).

Note that the lightsync setting will not persist.
There is onboard memory for persistence but it is not used by this script.

g203-led's People

Contributors

smasty 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

g203-led's Issues

Error: Device 046d:c084 not found.

Not sure if I'm doing something wrong? I don't use Python scripts often.

python3.8 --version
Python 3.8.2
virtualenv ./env                                                                                                                                   ๎‚ฒ
created virtual environment CPython3.8.2.final.0-64 in 174ms
  creator CPython3Posix(dest=/home/rob/Downloads/g203-led/env, clear=False, global=False)
  seeder FromAppData(download=False, distro=latest, idna=latest, pip=latest, contextlib2=latest, distlib=latest, setuptools=latest, six=latest, ipaddr=latest, appdirs=latest, requests=latest, pep517=latest, html5lib=latest, pkg_resources=latest, lockfile=latest, wheel=latest, retrying=latest, colorama=latest, packaging=latest, pytoml=latest, chardet=latest, progress=latest, certifi=latest, msgpack=latest, CacheControl=latest, pyparsing=latest, webencodings=latest, urllib3=latest, via=copy, app_data_dir=/home/rob/.local/share/virtualenv/seed-app-data/v1.0.1.debian)
  activators BashActivator,CShellActivator,FishActivator,PowerShellActivator,PythonActivator,XonshActivator
env/bin/pip install -r requirements.txt
Requirement already satisfied: pyusb==1.0.2 in ./env/lib/python3.8/site-packages (from -r requirements.txt (line 1)) (1.0.2)
sudo ./g203-led.py solid 00FFFF
Error: Device 046d:c084 not found.

Would appreciate some help with this.

windows: usb.core.NoBackendError: No backend available

pyusb appears to have issues with windows.
pyusb/pyusb#120

Installing libusb dll into
C:\Windows\SysWOW64 had no effect.
C:\Windows\System32 dll was found, but libusb is not functional.

(env) PS C:\Work\g203-led> python g203-led.py solid 00FFFF
Traceback (most recent call last):
  File "g203-led.py", line 301, in <module>
    main()
  File "g203-led.py", line 67, in main
    set_led_solid(process_color(args[2]))
  File "g203-led.py", line 170, in set_led_solid
    return set_led('01', color + '0000000000')
  File "g203-led.py", line 185, in set_led
    send_command(prefix + mode + data + suffix)
  File "g203-led.py", line 251, in send_command
    attach_mouse()
  File "g203-led.py", line 285, in attach_mouse
    if dev.is_kernel_driver_active(wIndex) is True:
  File "C:\Users\home\AppData\Roaming\Python\Python38\site-packages\usb\core.py", line 1062, in is_kernel_driver_active
    return self._ctx.backend.is_kernel_driver_active(
  File "C:\Users\home\AppData\Roaming\Python\Python38\site-packages\usb\backend\libusb1.py", line 897, in is_kernel_driver_active
    return bool(_check(self.lib.libusb_kernel_driver_active(dev_handle.handle,
  File "C:\Users\home\AppData\Roaming\Python\Python38\site-packages\usb\backend\libusb1.py", line 593, in _check
    raise NotImplementedError(_strerror(ret))
NotImplementedError: Operation not supported or unimplemented on this platform

What are the options? I feel like this is a lot of dependency to do a little usb hid wiggling.

Cheers,
Joe

Not working

It seems that the script doesn't work with my Logitech G203. No errors displayed after I corrected the id.
The command is:

sudo ./g203-led.py solid 000000

non-existent command

Hi, I have a problem with your code,
nothings happens when I run the command: sudo ./g203-led.py solid 00FFFF.
The system tell me that the ./g203-led.py command not exist.
I'm new to GNU/Linux, so i don't know how to fixed this problem,
I would like if you could help me.

Thank you and best ragards.
Moreno

PyUSB exception on Mac

Running the application on a Mac (possibly only an ARM Mac?) will produce a NoBackendError: No backend available error from PyUSB as it cannot locate libusb.

While this isn't really an issue with g203-led, you may consider including run instructions for Macs. The following fixed the issue for me (requires Homebrew):

brew install libusb
ln -s /opt/homebrew/lib ~/lib

More info here: https://stackoverflow.com/questions/70729330/python-on-m1-mbp-trying-to-connect-to-usb-devices-nobackenderror-no-backend-a

Changing functionality for dpi button

I have the G203 LIGHTSYNC Gaming Mouse and I'm a huge fan of this repo, thanks!

I wanted to disable the functionality of the DPI button on the mouse, which is possible on Windows in G-HUB (just by deleting all but one DPI slider). On linux I first I tried disabling the extra mouse buttons in the X11/xorg.conf.d/ folder via:

Option "ButtonMapping" "1 2 3 4 5 0 0 0 0 0"

But this didn't work. That led me to check xev for what event the DPI pressing event registered as, but nothing showed up when I pressed the DPI button. That leads me to believe that the DPI button is changing values on the hardware in the mouse itself instead of sending the event to X11 and changing some value there. I searched this repo to see if my intuition was right, but I didn't find any functionality. I'd be happy to code that myself, but I don't have the know-how to reverse engineer hardware and what bytes to send to the mouse. I'd be scared of bricking the mouse somehow.

Is my intuition correct about the DPI button? If so can anyone send me some tips on how I could possibly figure out how to disable it? Is there an guide that Logitech releases that descripts the different bytecodes that are used to interface with the mouse? I could probably code it with that.

Support for multiple devices

Hello,

Thank you. I tested this on a "Logitech G Pro Gaming Mouse" and it works just great.
I just had to change the Product ID from c084 to c085 to match output from lsusb -v

An idea could be to incorporate a check to automatically identify the device. However it might be tricky if multiple Logitech G RGB devices are attached.

Shebang env/bin/python makes no sense

The interpreter specification env/bin/python won't do what it's supposed to on most Unix/GNU/Linux systems, as the path is neither absolute nor does it match a common location for the python binary.

For launching a script with the Python interpreter, the most common specification is:

#!/usr/bin/env python

The line is also listed on the Wikiepdia page: https://en.wikipedia.org/wiki/Shebang_(Unix)#Examples

Please fix this.

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.