VectorLinux

Please login or register.

Login with username, password and session length
Advanced search  

News:

Visit our home page for VL info. For support and documentation, visit the Vector Linux Knowledge Center or search the Knowledge Center and this Forum using the search box above.

Author Topic: Joysticks: "/dev/input/js#" versus "/dev/input/event#" woes.  (Read 4607 times)

Rytz

  • Member
  • *
  • Posts: 64
Joysticks: "/dev/input/js#" versus "/dev/input/event#" woes.
« on: January 26, 2014, 11:25:55 pm »

Greetings:

I'm currently using vector to play some games that require joysticks.

If I calibrate / configure a joystick, both "js#" and "event#" files in "/dev/input" are generated.

Strangely, the games do not pick up new mappings / configurations if the associated "event#" files exist.

However, if I run calibration / configuration, delete the new "event#" files (leaving only the "js#" files), the mappings are picked up by the game correctly.

To summarize, the joystick "/dev/input/event#" files are causing conflicts with the "/dev/input/js#" files.

While I can write a script to just delete the related event files, the generated event files are not created at the same time as the js# files.  They seem to generate about 0.1 second after the js# files are created.  Not a huge deal but I have to use a quick loop to wait for the generation.  It would be preferable if I could stop the generation of the event# files compeltely.

By posting, I'm primarily trying to gain an understanding of the event file creation process.  Can anyone explain the event file creation process?  Which process or resource creates the joystick event# files and why would they conflict with the related js# files?  Am I able to prevent the event# files from being created?

Thanks!
Logged
~ Rytz

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2323
Re: Joysticks: "/dev/input/js#" versus "/dev/input/event#" woes.
« Reply #1 on: January 27, 2014, 04:11:56 am »

Hi Rytz


This is likely a permissions problems. Programs can read and write to the joystick api (the js files) but not to the event api (the files under event directory.) There is a security reason for this, a malicious program could wiretap your keyboard and get your passwords if allowed to read from the event files.
I think your best bet is to write an udev rule for your device, for allowing rw as user from the joystick file descriptors only. Let us know if you need help writing the udev rule.

HTH, Rodrigo
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2323
Re: Joysticks: "/dev/input/js#" versus "/dev/input/event#" woes.
« Reply #2 on: January 27, 2014, 04:15:50 am »

I am guessing that the game uses the newer event api if present but fallbacks to the joystick API if absent. This would explain why the game works if you delete the event control files.
I don't know how to disable one API or the other.
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

Rytz

  • Member
  • *
  • Posts: 64
Re: Joysticks: "/dev/input/js#" versus "/dev/input/event#" woes.
« Reply #3 on: January 27, 2014, 08:39:29 am »

Hi rbistolfi:

I do have a UDEV configuration that includes js* and event*, and that runs a startup script to set standard user ownership of "/dev/input/*".  I haven't had any problems manipulating files in /dev/input as a normal user.  In the past, before I had added a UDEV configuration, the joystick mapper program would be unable to access event# or js# files because of permissions issues.  Adding a valid UDEV config resolved that issue.

Perhaps I need to fix permissions under another location such as /sys/class/input?

I will paste my UDEV configuration later tonight when I get home.
« Last Edit: January 27, 2014, 08:44:36 am by Rytz »
Logged
~ Rytz

Rytz

  • Member
  • *
  • Posts: 64
Re: Joysticks: "/dev/input/js#" versus "/dev/input/event#" woes.
« Reply #4 on: January 27, 2014, 09:41:19 pm »

I rechecked my UDEV rules and everything seems in order.  All ownership and permissions are for the user running the game.  I haven't had any problems deleting or recreating js# or event# files.  Here's my UDEV:

Code: [Select]
KERNEL=="mouse*|mice|event*", MODE="0777" OWNER="gameuser" GROUP="gamegroup" RUN+="/opt/game/permissions_script.sh"
KERNEL=="ts[0-9]*|uinput", MODE="0777" OWNER="gameuser" GROUP="gamegroup" RUN+="/opt/game/permissions_script.sh"
KERNEL=="js[0-9]*", MODE="0777" OWNER="gameuser" GROUP="gamegroup" RUN+="/opt/game/permissions_script.sh"

Anyone know of a way to prevent "/dev/input/event#" files from being generated for joysticks?  Would be nice to stop the generation at the source instead of looping to wait for generation.

Thanks.
Logged
~ Rytz

rbistolfi

  • Packager
  • Vectorian
  • ****
  • Posts: 2323
Re: Joysticks: "/dev/input/js#" versus "/dev/input/event#" woes.
« Reply #5 on: January 28, 2014, 03:48:14 am »

Looks like this is handled by evdev driver from Xorg.  You probably have 2 options. Disable evdev, in which case you will need to be sure your other input devices still work correctly, or maybe adding an entry in xorg.conf for your joystick, setting the driver to "joystick". If you use the joystick driver will prevent evdev from trying to control the device. Also telling xorg to ignore your device seems possible.
Some links:

http://www.x.org/archive/X11R7.5/doc/man/man4/joystick.4.html
http://www.x.org/archive/X11R7.5/doc/man/man4/evdev.4.html
http://www.gentoo.org/proj/en/desktop/x/x11/xorg-server-1.5-upgrade-guide.xml (check the "Without HAL" section at the end, HAL is deprecated but the evdev interface still stands)
https://fedoraproject.org/wiki/Input_device_configuration#Blacklisting_a_device (maybe you can blacklist your device and prevent evdev handling)

HTH
Logged
"There is a concept which corrupts and upsets all others. I refer not to Evil, whose limited realm is that of ethics; I refer to the infinite."
Jorge Luis Borges, Avatars of the Tortoise.

--
Jumalauta!!

Rytz

  • Member
  • *
  • Posts: 64
Re: Joysticks: "/dev/input/js#" versus "/dev/input/event#" woes.
« Reply #6 on: January 28, 2014, 09:38:23 am »

Thanks for the info rbistolfi.
Logged
~ Rytz