Setting up a USB gamepad on FreeBSD

Stuff that plugs in via USB, FireWire, eSATA, PS/2, etc.

Setting up a USB gamepad on FreeBSD

Postby phpwolf » 06 May 2012, 16:56

Hello,

I have a cheap but cool Thrustmaster gamepad and I want to use it for playing games in FreeBSD emulators. I tried to configure it but I really don't now very much about this process. Here is what I've done.

[list=1]
[*]I installed [FILE]xf86-input-joystick[/FILE] and [FILE]uhidd[/FILE] from ports
[*]I added these lines to [FILE]rc.conf[/FILE]:
Code: Select all
uhidd_flags="-kmohs"
uhidd_enable="YES"

[*]When the gamepad is plugged in, the kernel said:
Code: Select all
uhid0: <Mega World USB 2-Axis 8-Button Gamepad, class 0/0, rev 1.10/1.01, addr 3> on usbus1
so it seems like the gamepad is seen by [FILE]uhidd[/FILE]
[*]I added these lines to [FILE]xorg.conf[/FILE]:
Code: Select all
Section "ServerLayout"
   Identifier     "X.org Configured"
   Screen      1  "Screen1" 0 0
   InputDevice    "Mouse0" "CorePointer"
   InputDevice    "Keyboard0" "CoreKeyboard"
   [B]InputDevice    "Joy0" "SendCoreEvents"[/B]
EndSection

Section "InputDevice"
    Identifier     "Joy0"
    Driver         "joystick"
    Option         "Path" "/dev/uhid0"
    Option         "Device" "/dev/uhid0"
    # Right Buttons
    # Button w(Up)/s(Down)
    # Button a(Left)/s(Right)
    Option         "MapAxis1" "mode=accelerated keylow=38 keyhigh=40"
    Option         "MapAxis2" "mode=accelerated keylow=25 keyhigh=39"
    # Right joystick: Like mouse
    Option         "MapAxis3" "mode=relative axis=+1x deadzone=5000"
    Option         "MapAxis4" "mode=relative axis=+1y deadzone=5000"
    # Left joystick:
    # axis X - Left/Right
    # axis Y - Up/Down
    Option "MapAxis5"       "mode=relative deadzone=28000 keylow=100 keyhigh=102 axis=0.15key"
    Option "MapAxis6"       "mode=relative deadzone=28000 keylow=98 keyhigh=104 axis=0.15key"
    #
    Option         "MapButton1" "key=10"
    Option         "MapButton2" "key=11"
    Option         "MapButton3" "key=12"
    Option         "MapButton4" "key=13"
    Option         "MapButton5" "key=14"
    Option         "MapButton6" "key=15"
    # mouse button: left
    Option         "MapButton7" "button=1"
    # mouse button: right
    Option         "MapButton8" "button=3"
    # button "Space"
    Option         "MapButton9" "key=65"
    # button "Enter"
    Option         "MapButton10" "key=36"
EndSection

[/lit]

The current behavior: [FILE]xev[/FILE] doesn't show any event when the gamepad buttons are pressed.

The [FILE]Xorg.0.log[/FILE] joystick part here:

Code: Select all
[    52.975] (II) Using input driver 'joystick' for 'Joy0'
[    52.975] (II) Loading /usr/local/lib/xorg/modules/input/joystick_drv.so
[    52.975] (**) Option "SendCoreEvents"
[    52.975] (**) Joy0: always reports core events
[    52.975] (II) No input driver specified, ignoring this device.
[    52.975] (II) This device may have been added with another device file.
[    52.975] (EE) PreInit returned 11 for "Joy0"
[    52.975] (II) UnloadModule: "joystick"
[    52.975] (II) Unloading joystick


Can you help me, please, to understand what have I done wrong here?

Thank you.
phpwolf
Junior Member
 
Posts: 24
Joined: 16 Feb 2012, 10:49
Location: Romania

Postby phpwolf » 06 May 2012, 19:12

It seems like the gamepad buttons respond to:

[CMD=" "]uhidd -vvv -kmoh /dev/ugen1.3[/CMD]

Here is the result:

Code: Select all
ugen1.3[0]-> HID interface
ugen1.3[0]-> Report descriptor size = 51
ugen1.3[0]-> Find IN interrupt ep: 0x81 packet_size=0x8
HID APPLICATION COLLECTION (Game Pad) size(51)
  HID REPORT: ID 0
    INPUT:
      POS:0 SIZE:8 COUNT:2 [VARIABLE]
        USAGE X
        USAGE Y
      POS:16 SIZE:1 COUNT:8 [VARIABLE]
        USAGE Button1
        USAGE Button2
        USAGE Button3
        USAGE Button4
        USAGE Button5
        USAGE Button6
        USAGE Button7
        USAGE Button8
ugen1.3[0]-> vhid device created: uvhidctl17
ugen1.3[0]-> HID interface task started
ugen1.3[0]-> vhid device created: uvhidctl17
ugen1.3[0]-> HID interface task started
ugen1.3[0]-> received data(3): -128 -128 04
hid_appcol_recv_data: len(3) 0x80 0x80 0x04
ugen1.3[0]-> uvhidctl17 received data: 128 128 4
ugen1.3[0]-> received data(3): -128 -128 00
hid_appcol_recv_data: len(3) 0x80 0x80 0x00
ugen1.3[0]-> uvhidctl17 received data: 128 128 0
ugen1.3[0]-> received data(3): -128 -128 02
hid_appcol_recv_data: len(3) 0x80 0x80 0x02
ugen1.3[0]-> uvhidctl17 received data: 128 128 2
ugen1.3[0]-> received data(3): -128 -128 00
hid_appcol_recv_data: len(3) 0x80 0x80 0x00
ugen1.3[0]-> uvhidctl17 received data: 128 128 0
ugen1.3[0]-> received data(3): -128 -128 01
hid_appcol_recv_data: len(3) 0x80 0x80 0x01
ugen1.3[0]-> uvhidctl17 received data: 128 128 1
ugen1.3[0]-> received data(3): -128 -128 00
hid_appcol_recv_data: len(3) 0x80 0x80 0x00
ugen1.3[0]-> uvhidctl17 received data: 128 128 0
ugen1.3[0]-> received data(3): -128 00 00
hid_appcol_recv_data: len(3) 0x80 0x00 0x00
ugen1.3[0]-> uvhidctl17 received data: 128 0 0
ugen1.3[0]-> received data(3): -128 -128 00
hid_appcol_recv_data: len(3) 0x80 0x80 0x00
ugen1.3[0]-> uvhidctl17 received data: 128 128 0
ugen1.3[0]-> received data(3): -128 -1 00
hid_appcol_recv_data: len(3) 0x80 0xff 0x00
ugen1.3[0]-> uvhidctl17 received data: 128 255 0
ugen1.3[0]-> received data(3): -128 -128 00
hid_appcol_recv_data: len(3) 0x80 0x80 0x00
ugen1.3[0]-> uvhidctl17 received data: 128 128 0


Now, I created a [FILE]/usr/local/etc/uhidd.conf[/FILE] with this content, to map my gamepad buttons to keyboard buttons:

Code: Select all
# 0x045e is the vendor id and 0x009d is the product id.
# See `uhidd.conf(5)` manual page for details about configuration file.
0x045e:0x009d={
        cc_keymap={
      KEY_C="0x04"
      KEY_X="0x01"
      KEY_D="0x08"
      KEY_S="0x02"
      KEY_Z="0x10"
      KEY_V="0x20"
        }
}


Then restarted the [FILE]uhidd[/FILE] daemon with:

[CMD=" "]/usr/local/etc/rc.d/uhidd stop /dev/ugen1.3[/CMD]

Nothing happens (I suppose after pressing gamepad buttons to see the C, X, D, S, Z and V key typed to the console). Another thing: how can I found the vendor id and the product id for my keyboard?
phpwolf
Junior Member
 
Posts: 24
Joined: 16 Feb 2012, 10:49
Location: Romania

Postby DutchDaemon » 06 May 2012, 20:36

phpwolf, stop dumping unformatted output on these forums!
User avatar
DutchDaemon
Old Fart
 
Posts: 10466
Joined: 16 Nov 2008, 20:17
Location: The Netherlands

Postby phpwolf » 07 May 2012, 07:00

DutchDaemon wrote:phpwolf, stop dumping unformatted output on these forums!


I'm sorry. It was not intentional.
phpwolf
Junior Member
 
Posts: 24
Joined: 16 Feb 2012, 10:49
Location: Romania


Return to Peripheral Hardware

Who is online

Users browsing this forum: No registered users and 1 guest