LinuxQuestions.org

LinuxQuestions.org (/questions/)
-   Linux - Hardware (https://www.linuxquestions.org/questions/linux-hardware-18/)
-   -   Adding USB joystick as 2nd x11 pointer (https://www.linuxquestions.org/questions/linux-hardware-18/adding-usb-joystick-as-2nd-x11-pointer-449434/)

bhepple 05-28-2006 06:53 PM

Adding USB joystick as 2nd x11 pointer
 
Any ideas how to do that? I want to keep my normal mouse but also have use a USB joystick to move the pointer, click etc
How about mapping buttons etc?

I already tried putting this in xorg.conf:


Section "InputDevice"
Identifier "Joystick"
Driver "joystick"
Option "Device" "/dev/input/js0"
Option "SendCoreEvents" "true"
EndSection

and this in the serverlayout:
InputDevice "Joystick" "SendCoreEvents"

... it's on virtual/x11-7.0-r2 (modular Xorg) which I compiled with the (Gentoo) +joystick USE flag. X starts up and the mouse is OK as usual but joystick is dead.

usbview sees the joystick but other than that I'm at sea ...


THanks


BOb

comprookie2000 05-28-2006 08:55 PM

Here is how I get two mouse to work on my laptop
InputDevice "Mouse1" "CorePointer"
InputDevice "Keyboard1" "CoreKeyboard"
InputDevice ""Joystick" "AlwaysCore"
and I would try without;
Option "SendCoreEvents" "true"

bhepple 05-30-2006 04:09 AM

Quote:

Originally Posted by comprookie2000
Here is how I get two mouse to work on my laptop
InputDevice "Mouse1" "CorePointer"
InputDevice "Keyboard1" "CoreKeyboard"
InputDevice ""Joystick" "AlwaysCore"
and I would try without;
Option "SendCoreEvents" "true"

Nope - I just tried it and I still get nada on the joystick.

I might mention that

od </dev/input/js0

_does_ respond to the joystick so I am definitely connected through the USB

bhepple 05-30-2006 04:30 AM

Quote:

Originally Posted by comprookie2000
Here is how I get two mouse to work on my laptop
InputDevice "Mouse1" "CorePointer"
InputDevice "Keyboard1" "CoreKeyboard"
InputDevice ""Joystick" "AlwaysCore"
and I would try without;
Option "SendCoreEvents" "true"

... but the log (/var/log/Xorg20.log - why not Xorg1.log???) says:

(EE) Failed to load module "joystick" (out of memory, 701)

.. so it looks like my driver load failed. Why would that be and how to fix??????

Cheers


Bob

comprookie2000 05-30-2006 05:24 PM

I stole this from a thread on gentoo forums. Looks like you don't want to set it up in xorg.conf. I would check your kernel, that could explain the memory error;
FROM: mike4148
Quote:

If it plugs into a USB port, it will probably work out of the box if you have the right modules compiled into your kernel.

If it plugs in to a gameport or serial port, try the following (all kernel options are in the Input Devices section of the kernel config):

1. Build joystick support into your kernel or as a module.

2. Build the relevant gameport driver into your kernel or as a module. For example, if you have the joystick plugged into an SB Live!'s game port, say 'Y' to "Gameport support" and "SB Live! and Audigy gameport support."

3. Build all non-USB joystick drivers as modules. Note the names of all the modules (they show up in the help screen in the graphical kernel configs).

Build and install the new kernel, and boot into it. Try loading each module with modprobe, one at a time. For each, see if you have /dev/js0 and/or /dev/input/js0. If you do, see if it works (you'll probably need to calibrate it first; search the forum system for info on that). If it does, you're done. If not, rmmod the last driver and modprobe the next on the list.

If none work, then it's likely that there is no driver for your joystick. Search the net to see if anyone has developed one.

bhepple 05-31-2006 03:49 AM

Quote:

Originally Posted by comprookie2000
I stole this from a thread on gentoo forums. Looks like you don't want to set it up in xorg.conf. I would check your kernel, that could explain the memory error;
FROM: mike4148

.... hmmmm. This looks like a method for non-USB or at least to get the /dev/input/js0 file set up.
I already have a working /dev/input/js0 - it's failing because it won't load as a X module... as in
/usr/lib/xorg/modules/input/joystick_drv.so gives an error message when X tried to load it

Just to cover all the bases I checked my kernel build and I have:
CONFIG_INPUT_JOYSTICK=y
CONFIG_JOYSTICK_ADI=m

... and I tried "modprobe adi" but it makes no difference (my joystick is a Logitech)... but then I didn't really expect it to make a difference.

bhepple 05-31-2006 06:52 PM

Quote:

Originally Posted by bhepple
... but the log (/var/log/Xorg20.log - why not Xorg1.log???) says:

(EE) Failed to load module "joystick" (out of memory, 701)

.. so it looks like my driver load failed. Why would that be and how to fix??????

OK - I made _some_ progress and reported this to xorg's bugzilla:

I fixed the obvious bug in src/xf86Jstk.c:
Code:

static pointer
xf86JstkPlug(pointer        module,
            pointer        options,
            int        *errmaj,
            int        *errmin )
{
    LocalDevicePtr        local = NULL;
    JoystickDevPtr        priv = NULL;
    char                *s;

    local = xf86JstkAllocate();

    if (!local || !priv) {
        *errmaj = LDR_NOMEM;
        goto SetupProc_fail;
    }

to:
    if (!local || !local->private) {
    ... }

but I now get:

Quote:

(II) LoadModule: "joystick"
(II) Loading /usr/lib/xorg/modules/input/joystick_drv.so
(II) Module joystick: vendor="X.Org Foundation"
compiled for 7.0.0, module version = 1.0.0
Module class: X.Org XInput Driver
ABI class: X.Org XInput driver, version 0.5
(EE) WACOM: No Device specified.
(II) UnloadModule: "joystick"
(II) Unloading /usr/lib/xorg/modules/input/joystick_drv.so
(EE) Failed to load module "joystick" (invalid argument(s) to LoadModule(), 701)
... but my xorg.conf file says:

Quote:

Section "InputDevice"
Identifier "Joystick"
Driver "joystick"
Option "Device" "/dev/input/js0"
EndSection
I am on gentoo using virtual/x11-7.0-r2 and the joystick source contains this tag:

/* $XFree86: xc/programs/Xserver/hw/xfree86/input/joystick/xf86Jstk.c,v 1.5
2001/11/26 16:25:53 dawes Exp $ */

bhepple 06-01-2006 07:54 PM

Solved
 
Quote:

Originally Posted by bhepple
OK - I made _some_ progress and reported this to xorg's bugzilla:

I fixed the obvious bug in src/xf86Jstk.c:
...

Looks like no-one in their right mind uses the xorg joystick driver. It is so hopelessly broken that it's unusable.

A better approach turns out to be to use some user-space daemons to convert the joystick input stream into mouse-like commands and pump them into X.
These worked for me:

qjoypad
joymouse

Now that I've been able to see the joystick in action it seems it's pretty impractical to use it in place of the mouse - it's just not responsive enough and you have no fine control. I guess the joystick is a gaming device and only useful for thrashing back and forth. Well it was a nice idea!!


Cheers


Bob

marcprice 07-07-2006 06:34 AM

Not so useless though
 
Hi There,

I just wanted to say thank you! You are right, using the joystick as an X pointer is clunky (although, I think configuring the buttons will make it somewhat more usable), but, it is still very useful. I have been looking into accessibility for people who have little or no use of one or more limbs. I have found that the most interactive/usable/cost-effective off-the-shelf interface devices for these people are various devices which have been designed to plug into the controller port of the Sony Playstation2. Using a PS2->PC converter, coupled with X configured for joystick input means that these devices can be used in place of mouse and keyboard to a certain extent.

So, thank you for your help, I can now proceed with my work. :-)

Marc


All times are GMT -5. The time now is 11:38 PM.