Page 1 of 2 12 LastLast
Results 1 to 10 of 20

Thread: usb composite devices ( mouse and gamepad )

  1. #1
    Join Date
    Oct 2007
    Beans
    139

    usb composite devices ( mouse and gamepad )

    So I have a composite device that has a mouse and a joystick in one. The way it works is:

    >gamepad mode, like any normal gamepad
    >mouse mode, with certain settings the mouse cursor will move according to the joystick on the Horizontal axis only. This can be controller on or off.


    On windows 7 it shows up as a mouse but is also listed under game controllers. It works as it should. Its a gamepad by default and the mose mode can be turned on.

    On XP it shows up as a gamepad. It works as it should. Its a gamepad by default and the mose mode can be turned on.

    On Linux joystick(the application) does not see any devices but the joystick controllers the mouse. I know ximput does that intentionally. So that leads me to believe its install as a joystick and working as such. If I removed the device from the virtual pointer in xinput it stops controlling the mouse.

    So if its installed, how can I tell where its installed? I dont really understand this js0 stuff at all. jstest tells me its not there, so where is it? If its capable of controlling the mouse in x, then there is a joystick out there somewhere.

  2. #2
    Join Date
    Oct 2007
    Beans
    139

    Re: usb composite devices ( mouse and gamepad )

    well today I learned about devices

    /proc/bus/input/devices

    and i see my device right there, so why wont joystick(app) find it?

    I: Bus=0003 Vendor=16d0 Product=04fb Version=0110
    N: Name="Sub-Zero Workshop BLISS-BOX"
    P: Phys=usb-0000:00:11.2-2/input0
    S: Sysfs=/devices/pci0000:00/0000:00:11.2/usb4/4-2/4-2:1.0/input/input17
    U: Uniq=
    H: Handlers=mouse0 event5
    B: PROP=0
    B: EV=1f
    B: KEY=ff ffff8000 70001 0 0 0 0 0 0 0 0
    B: REL=3
    B: ABS=ff
    B: MSC=10

    what does "H: Handlers=mouse0 event5" mean?


    I also see in by-id I have

    usb-Sub-Zero_Workshop_BLISS-BOX-event-mouse
    usb-Sub-Zero_Workshop_BLISS-BOX-mouse

    not sure what that means also.
    Last edited by ulao; February 1st, 2012 at 05:32 AM.

  3. #3
    Join Date
    Sep 2007
    Beans
    144

    Re: usb composite devices ( mouse and gamepad )

    Quote Originally Posted by ulao View Post
    what does "H: Handlers=mouse0 event5" mean?
    This means that your device is available as:

    Code:
    /dev/input/mouse0
    /dev/input/event5
    You can access it via (don't think there is a tool to acces mouse0 in a userfriendly way):

    Code:
    evtest /dev/input/event5
    If the device would be a joystick, Linux would show it as:

    Code:
    /dev/input/js0
    And you would be able to test it via:

    Code:
    jstest /dev/input/js0
    As for why it doesn't show up as joystick:

    Try:

    Code:
    modprobe joydev
    or if that doesn't help, run evtest as described above and post the output here.

  4. #4
    Join Date
    Oct 2007
    Beans
    139

    Re: usb composite devices ( mouse and gamepad )

    doing a modprobe joydev just gives me my prompt back.

    I tried to use /dev/input/event5 in my joystick app and it said the given device is not a joystick.

    evtest says:
    Code:
    Input driver version is 1.0.1
    Input device ID: bus 0x3 vendor 0x16d0 product 0x4fb version 0x110
    Input device name: "Sub-Zero Workshop BLISS-BOX"
    Supported events:
      Event type 0 (Sync)
      Event type 1 (Key)
        Event code 256 (Btn0)
        Event code 272 (LeftBtn)
        Event code 273 (RightBtn)
        Event code 274 (MiddleBtn)
        Event code 303 (BtnDead)
        Event code 304 (BtnA)
        Event code 305 (BtnB)
        Event code 306 (BtnC)
        Event code 307 (BtnX)
        Event code 308 (BtnY)
        Event code 309 (BtnZ)
        Event code 310 (BtnTL)
        Event code 311 (BtnTR)
        Event code 312 (BtnTL2)
        Event code 313 (BtnTR2)
        Event code 314 (BtnSelect)
        Event code 315 (BtnStart)
        Event code 316 (BtnMode)
        Event code 317 (BtnThumbL)
        Event code 318 (BtnThumbR)
        Event code 319 (?)
        Event code 320 (ToolPen)
        Event code 321 (ToolRubber)
        Event code 322 (ToolBrush)
        Event code 323 (ToolPencil)
        Event code 324 (ToolAirbrush)
        Event code 325 (ToolFinger)
        Event code 326 (ToolMouse)
        Event code 327 (ToolLens)
      Event type 2 (Relative)
        Event code 0 (X)
        Event code 1 (Y)
      Event type 3 (Absolute)
        Event code 0 (X)
          Value    128
          Min        0
          Max      255
          Flat      15
        Event code 1 (Y)
          Value    128
          Min        0
          Max      255
          Flat      15
        Event code 2 (Z)
          Value    128
          Min        0
          Max      255
          Flat      15
        Event code 3 (Rx)
          Value      0
          Min        0
          Max      255
          Flat      15
        Event code 4 (Ry)
          Value      0
          Min        0
          Max      255
          Flat      15
        Event code 5 (Rz)
          Value    128
          Min        0
          Max      255
          Flat      15
        Event code 6 (Throttle)
          Value      0
          Min        0
          Max      255
          Flat      15
        Event code 7 (Rudder)
          Value      0
          Min        0
          Max      255
          Flat      15
      Event type 4 (Misc)
        Event code 4 (ScanCode)
    Testing ... (interrupt to exit)

  5. #5
    Join Date
    Sep 2007
    Beans
    144

    Re: usb composite devices ( mouse and gamepad )

    Quote Originally Posted by ulao View Post
    doing a modprobe joydev just gives me my prompt back.
    That's what it is supposed to do. But after running it you should have a:

    /dev/input/js0

    Is that not the case?

    I tried to use /dev/input/event5 in my joystick app and it said the given device is not a joystick.
    An evdev (evtest /dev/input/event) is not a joydev (jstest /dev/input/js0), you can't use one in place of the other.

    Code:
    ...
      Event type 3 (Absolute)
        Event code 0 (X)
          Value    128
          Min        0
          Max      255
          Flat      15
    ...
    Hm, as far as I can tell, that should be enough. Any evdev that has a ABS_X (Absolute X) should get a joystick device when joydev is loaded.

    Does evtest output all the events and stuff when you move the stick around?

  6. #6
    Join Date
    Oct 2007
    Beans
    139

    Re: usb composite devices ( mouse and gamepad )

    Does evtest output all the events and stuff when you move the stick around?
    Yes.


    After the mod probe I have

    root@spawnlinux:/dev/input# ls
    by-id event0 event2 event4 event6 mouse0
    by-path event1 event3 event5 mice


    Also the parent dir, I'm told can sometimes have it
    root@spawnlinux:/dev# ls j*
    ls: cannot access j*: No such file or directory


    I also tried

    mknod /dev/input/js0 c 13 0
    then a chmod on it with 666
    then did the modprobe

    but the file remains blank. I read somewhere that a mknod was needed, dont really understand that either.

    Encase this was not mentioned or not clear I want to add that this is a dual device. Its a mouse and a gamepad. In windows both show up under the devices.
    Last edited by ulao; February 8th, 2012 at 08:28 PM.

  7. #7
    Join Date
    Sep 2007
    Beans
    144

    Re: usb composite devices ( mouse and gamepad )

    Encase this was not mentioned or not clear I want to add that this is a dual device. Its a mouse and a gamepad. In windows both show up under the devices.
    Does that mean it reports both joystick and mouse events for the same movements (shouldn't have anything to do with the problem at hand, just wondering)?

    Quote Originally Posted by ulao View Post
    After the mod probe I have

    root@spawnlinux:/dev/input# ls
    by-id event0 event2 event4 event6 mouse0
    by-path event1 event3 event5 mice

    root@spawnlinux:/dev# ls j*
    ls: cannot access j*: No such file or directory
    Ok, guess I found the problem, the joydev module has an extra check to prevent it from grabbing touchpads and tablets as joysticks (linux/drivers/input/joydev.c) and you adapter has one of those buttons it checks for:

    Code:
    static bool joydev_match(struct input_handler *handler, struct input_dev *dev)
    {
            /* Avoid touchpads and touchscreens */
            if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_TOUCH, dev->keybit))
                    return false;
    
            /* Avoid tablets, digitisers and similar devices */
            if (test_bit(EV_KEY, dev->evbit) && test_bit(BTN_DIGI, dev->keybit))
                    return false;
    
            return true;
    }
    Ok, this means you have essentially two options:

    1) Patch your kernel and recompile that module (i.e. make above function always return true)

    2) Use uinput to remap that evdev and have your joystick report different events. To do that you can use xboxdrv. The syntax should be something along the lines of:

    Code:
    ./xboxdrv --ui-clear \
     --evdev /dev/input/event11 \
     --evdev-keymap BTN_A=a,BTN_B=b,BTN_C=x,BTN_X=y \
     --evdev-absmap ABS_X=x1,ABS_Y=y1 \
     \
     --ui-buttonmap a=BTN_A,b=BTN_B,x=BTN_X,y=BTN_Y \
     --ui-axismap x1=ABS_X,y1=ABS_Y
    You have to change the event11 name to where your device is and replace add all the buttons and axis you want to use. Evdev support is xboxdrv 0.8.4 is a bit wonkey, it will be better in the next release, but you should be able to hack something working together with it.

    Quick explanation for how it works (and why it's wonky):

    xboxdrv reads from /dev/input/event and translates the events internally to look like an Xbox360 gamepad (that's --evdev-keymap/absmap). It then outputs the Xbox360-look-alike events to uinput (via --ui-buttonmap/axismap), which makes them available to the kernel and give you a /dev/input/js0.
    Last edited by Grumbel; February 8th, 2012 at 08:49 PM.

  8. #8
    Join Date
    Oct 2007
    Beans
    139

    Re: usb composite devices ( mouse and gamepad )

    Does that mean it reports both joystick and mouse events for the same movements (shouldn't have anything to do with the problem at hand, just wondering)?
    Agreed just wanted to lay it out there. Just means both devices should show up and both are controllable ( not necessarily at once ) by a joystick.


    Being I have yet to try a recompile and I want this to be an option for other Linux users, I'm going to try the second method. I will report back. Your are a saint thus for, thank you.
    Last edited by ulao; February 9th, 2012 at 01:11 AM.

  9. #9
    Join Date
    Oct 2007
    Beans
    139

    Re: usb composite devices ( mouse and gamepad )

    yes this is working. Looks like I have a lot of mapping to do ;P

    Wow man, thx so much!


    -- oh one more thing. How do you get it to stick? Once I run this it works still I cntl break, then its broke. If I run it again I get Device or resource busy

    Also what the best way to get a list of all button I need to map over. I guess I needs a list on each device.

    guessing
    "BTN_A=a "
    BTN_A being my device?
    a being the virtual 360 ?

    I see that up-above its called "BtnA"
    Last edited by ulao; February 9th, 2012 at 01:21 AM.

  10. #10
    Join Date
    Sep 2007
    Beans
    144

    Re: usb composite devices ( mouse and gamepad )

    Quote Originally Posted by ulao View Post
    -- oh one more thing. How do you get it to stick? Once I run this it works still I cntl break, then its broke. If I run it again I get Device or resource busy
    If you Ctrl-c the xboxdrv process, you should be able to simply restart it. If for some reason it ends up floating around in the background, use:

    sudo killall -9 xboxdrv

    To kill it. xboxdrv has to be running the whole time to make this work, so to make this permanent you need to hack together a start script for it or simply start it manually whenever you want to use the controller.

    guessing
    "BTN_A=a "
    BTN_A being my device?
    a being the virtual 360 ?
    Yep, there is an --evdev-debug option that should print all the names and allow you to see which button is named what. evtest uses slightly different names, which can makes things a bit confusing.

Page 1 of 2 12 LastLast

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •