Giter Site home page Giter Site logo

evdev-joystick-calibration's Introduction

Archived, please use https://github.com/nick-l-o3de/evdev-joystick-calibration instead

evdev-joystick-calibration

Run, pick up the gamepad and turn sticks with triggers around.

evdev-joystick-calibration -h
usage: evdev-joystick-calibration [-h] [-l] [-c]

Pick up the gamepad and turn sticks with triggers around

optional arguments:
  -h, --help       show this help message and exit
  -l, --load       load configuration
  -c, --calibrate  calibrate and save configuration

install

kompot@pc:~$ sudo apt install python3-pip git -y
kompot@pc:~$ sudo pip3 install git+https://github.com/Virusmater/evdev-joystick-calibration

example

calibrate

kompot@pc:~$ evdev-joystick-calibration -c
Available devices:
0 Nintendo Wii Remote Classic Controller
2 Nintendo Wii Remote IR
3 Nintendo Wii Remote Accelerometer
4 Wii U GameCube Adapter Port 1
Pick one device for the calibration: 0
Move sticks and triggers of Nintendo Wii Remote Classic Controller to max and min positions.
Press any button to apply.
Configuration for Nintendo Wii Remote Classic Controller
analog: ABS_HAT1Y  min:-28 max:25
analog: ABS_HAT1X  min:-26 max:26
analog: ABS_HAT2X  min:-28 max:24
analog: ABS_HAT2Y  min:-28 max:24
analog: ABS_HAT3X  min:6 max:46
analog: ABS_HAT3Y  min:2 max:40
Configuration for Nintendo Wii Remote Classic Controller saved at /home/kompot/.config/evdev-joystick-calibration/NintendoWiiRemoteClassicController.json

load

kompot@pc:~$ evdev-joystick-calibration -l
Configuration for Nintendo Wii Remote Classic Controller loaded from /home/kompot/.config/evdev-joystick-calibration/NintendoWiiRemoteClassicController.json
Configuration for Nintendo Wii Remote Classic Controller
analog: ABS_HAT1Y  min:-28 max:25
analog: ABS_HAT1X  min:-26 max:26
analog: ABS_HAT2X  min:-28 max:24
analog: ABS_HAT2Y  min:-28 max:24
analog: ABS_HAT3X  min:6 max:46
analog: ABS_HAT3Y  min:2 max:40
Skip Nintendo Wii Remote IR
Skip Nintendo Wii Remote Accelerometer
Skip Wii U GameCube Adapter Port 1

requirements

https://github.com/gvalkov/python-evdev

The user should be able to write to the evdev device. Example of udev rule for Nintendo Wii Remote Classic Controller

kompot@pc:~$ sudo nano /etc/udev/rules.d/99-wiimote.rules 
SUBSYSTEM=="input", ATTRS{name}=="Nintendo Wii Remote Classic Controller", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1", ENV{ID_INPUT_KEY}="0"

auto load configuration on connect

  1. Run calibration as root (unfortunatelly all udev rules are executed under root and there is no way to get current user. if you know how to avoid it - please let me know):
kompot@pc:~$ sudo evdev-joystick-calibration -c
  1. Make new udev rule for add action:
kompot@pc:~$ sudo nano /etc/udev/rules.d/99-wiimote.rules 
SUBSYSTEM=="input", ATTRS{name}=="Nintendo Wii Remote Classic Controller", MODE="0666", ENV{ID_INPUT_JOYSTICK}="1", ENV{ID_INPUT_KEY}="0"
SUBSYSTEM=="input", KERNEL=="event*", ACTION=="add", ATTRS{name}=="Nintendo Wii Remote Classic Controller", RUN+="/bin/sh -c 'evdev-joystick-calibration -l'"
  1. Reload rules:
sudo udevadm control --reload-rules

evdev-joystick-calibration's People

Contributors

virusmater avatar

Stargazers

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

Watchers

 avatar  avatar

Forkers

nick-l-o3de

evdev-joystick-calibration's Issues

cannot actually apply the calibration on old python-evdev versions that satisfy pip dependencies

$ sudo evdev-joystick-calibration
Available devices:
2 Logitech Logitech Extreme 3D
Pick one device for the calibration: 2
Move sticks and triggers of Logitech Logitech Extreme 3D to max and min positions.
Press any button to apply.
Configuration for Logitech Logitech Extreme 3D
analog: ABS_X  min:0 max:1023
Traceback (most recent call last):
  File "/usr/bin/evdev-joystick-calibration", line 33, in <module>
    sys.exit(load_entry_point('evdev-joystick-calibration==0.1', 'console_scripts', 'evdev-joystick-calibration')())
  File "/usr/lib/python3.9/site-packages/evdev_joystick_calibration/__main__.py", line 65, in main
    configuration.apply(device, min_max)
  File "/usr/lib/python3.9/site-packages/evdev_joystick_calibration/configuration.py", line 31, in apply
    dev.set_absinfo(int(conf_code), min=conf[conf_code].minimum, max=conf[conf_code].maximum)
AttributeError: 'InputDevice' object has no attribute 'set_absinfo'

probably since that's only in python-evdev since version 1.3.0 while you don't depend on any specific version.
manually upgrading with pip install -U evdev did the trick, you might wanna update your dependencies

The application is unable to save the settings if the joystick name has any special character.

I have an old joystick and I use rockfire's gameport to usb adapter. And it recognizes the joystick with the following name: "Padix Co. Ltd. 4-axis,4button joystick w/view finder"

When the application saves the settings, the following error occurs "FileNotFoundError: [Errno 2] No such file or directory: '/home/marciocr/.config/evdev-joystick-calibration/PadixCo.Ltd.4-axis,4buttonjoystickw/viewfinder .json'"

I believe that because the device name has "," and "/" the application is not able to save the configuration file.

Request: End calibration by pressing a non-controller key

Hi,
I wanted to use the script to calibrate a device that has two axes only but no buttons. Because of that, I'm unable to end the calibration.
Any chance a "default" non-controller key can be added to end the calibration manually? Enter does already confirm the results for an axis, so maybe the whole behaviour can be changed? E.g.: "E" to exit, "C" confirm", and "R" to restart?

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.