Results 1 to 3 of 3

Thread: [SOLVED] mplayer - cannot re-assign joystick buttons 1-4

  1. #1
    Join Date
    May 2006
    Beans
    21

    Question [SOLVED] mplayer - cannot re-assign joystick buttons 1-4

    I'm having some issues with using a joystick (specifically a Playstation 2 controller, detected at /dev/input/js0) with mplayer.

    What does work (and steps taken):
    * Joystick works well with other programs (ex: mame, mythtv)
    * jscalibrator picks up the controller, all 16 buttons and axis
    * enabled joystick input in /etc/mplayer/mplayer.conf
    ---> at the very bottom of mplayer.conf looked for:
    Code:
    #Disable joystick support
    #It seems to cause very odd problems on laptops
    #With accelerometers (See LP: #75925)
    nojoystick = yes
    changed "nojoystick = yes" to "nojoystick = no"

    * Created a new file "input.conf" in ~/.mplayer/
    Code:
    ## Triangle 	
    JOY_BTN0 quit
    ## Circle 	
    JOY_BTN1 set_menu main
    ## X		
    JOY_BTN2 speed_set 1.0
    ## Square		
    JOY_BTN3 frame_step +1
    ## L2		
    JOY_BTN4 speed_mult 0.9091
    ## R2		
    JOY_BTN5 speed_mult 1.1
    ## L1		
    JOY_BTN6 seek -600
    ## R1		
    JOY_BTN7 seek 600
    ## Select		
    JOY_BTN8  osd
    ## Start		
    JOY_BTN9 pause
    ## L3		
    JOY_BTN10 sub_select 
    ## R3		
    JOY_BTN11 switch_audio
    ## D-Up	
    JOY_BTN12 seek +60
    ## D-Right		
    JOY_BTN13 seek +10
    ## D-Down		
    JOY_BTN14 seek -60
    ## D-Left  	
    JOY_BTN15 seek -10
    *Verified Buttons 4 through 9 work properly

    *** Problem 1 ***
    Buttons 0 through 3 will not remap to anything other than the defaults. I verified this in the code for mplayer's input.c (snippet below)

    Code:
    326	#ifdef HAVE_JOYSTICK
    327	  { { JOY_AXIS0_PLUS, 0 }, "seek 10" },
    328	  { { JOY_AXIS0_MINUS, 0 }, "seek -10" },
    329	  { { JOY_AXIS1_MINUS, 0 }, "seek 60" },
    330	  { { JOY_AXIS1_PLUS, 0 }, "seek -60" },
    331	  { { JOY_BTN0, 0 }, "pause" },
    332	  { { JOY_BTN1, 0 }, "osd" },
    333	  { { JOY_BTN2, 0 }, "volume 1"},
    334	  { { JOY_BTN3, 0 }, "volume -1"},
    So lines 331 through 334 are setting the default for these joystick buttons, but it seems that nothing I do in ~/mplayer/input.conf can change these. So, anybody know of a way to override these 4 defaults (short of recompiling mplayer).

    *** Problem 2 ***
    Buttons 10 through 15 are not detected by MPlayer as JOY_BTNx, instead when I press one of these I see on the terminal output:
    Code:
    No bind found for key '0x100001a0'.                         7% 1 0 
    No bind found for key '0x100001a1'.                         7% 1 0 
    No bind found for key '0x100001a2'.                         7% 1 0 
    No bind found for key '0x100001a3'.                         7% 1 0 
    No bind found for key '0x1000019e'.                         7% 1 0 
    No bind found for key '0x1000019f'.                         7% 1 0 
    No bind found for key '0x1000019e'.                         8% 1 0 
    No bind found for key '0x1000019f'.                         8% 1 0 
    No bind found for key '0x100001a0'.                         8% 1 0 
    No bind found for key '0x100001a1'.                         8% 1 0 
    No bind found for key '0x100001a2'.                         0.8% 1 0 
    No bind found for key '0x100001a3'.                         0.8% 1 0
    The output above was generated by pressing buttons 10-15 sequentially.

    I did note (again in mplayer's code: input.c) that buttons 10-15 are not defined. However I was wondering is there a way to just input the hex code from the key into the input.conf (again, make it work w/o having to edit the input.c and recompile). I did try to replace the JOY_BTNx w/ the hex code seen above, but that did not work.

    The sections of input.c I'm talking about may be seen below.
    Code:
    	/// The names of the keys as used in input.conf
    140	/// If you add some new keys, you also need to add them here
    141	
    142	static mp_key_name_t key_names[] = {
    143	  { ' ', "SPACE" },
    144	  { KEY_ENTER, "ENTER" },
    145	  { KEY_TAB, "TAB" },
    146	  { KEY_CTRL, "CTRL" },
    147	  { KEY_BACKSPACE, "BS" },
    148	  { KEY_DELETE, "DEL" },
    149	  { KEY_INSERT, "INS" },
    150	  { KEY_HOME, "HOME" },
    151	  { KEY_END, "END" },
    152	  { KEY_PAGE_UP, "PGUP" },
    153	  { KEY_PAGE_DOWN, "PGDWN" },
    154	  { KEY_ESC, "ESC" },
    155	  { KEY_RIGHT, "RIGHT" },
    156	  { KEY_LEFT, "LEFT" },
    157	  { KEY_DOWN, "DOWN" },
    158	  { KEY_UP, "UP" },
    159	  { KEY_F+1, "F1" },
    160	  { KEY_F+2, "F2" },
    161	  { KEY_F+3, "F3" },
    162	  { KEY_F+4, "F4" },
    163	  { KEY_F+5, "F5" },
    164	  { KEY_F+6, "F6" },
    165	  { KEY_F+7, "F7" },
    166	  { KEY_F+8, "F8" },
    167	  { KEY_F+9, "F9" },
    168	  { KEY_F+10, "F10" },
    169	  { KEY_F+11, "F11" },
    170	  { KEY_F+12, "F12" },
    171	  { KEY_KP0, "KP0" },
    172	  { KEY_KP1, "KP1" },
    173	  { KEY_KP2, "KP2" },
    174	  { KEY_KP3, "KP3" },
    175	  { KEY_KP4, "KP4" },
    176	  { KEY_KP5, "KP5" },
    177	  { KEY_KP6, "KP6" },
    178	  { KEY_KP7, "KP7" },
    179	  { KEY_KP8, "KP8" },
    180	  { KEY_KP9, "KP9" },
    181	  { KEY_KPDEL, "KP_DEL" },
    182	  { KEY_KPDEC, "KP_DEC" },
    183	  { KEY_KPINS, "KP_INS" },
    184	  { KEY_KPENTER, "KP_ENTER" },
    185	  { MOUSE_BTN0, "MOUSE_BTN0" },
    186	  { MOUSE_BTN1, "MOUSE_BTN1" },
    187	  { MOUSE_BTN2, "MOUSE_BTN2" },
    188	  { MOUSE_BTN3, "MOUSE_BTN3" },
    189	  { MOUSE_BTN4, "MOUSE_BTN4" },
    190	  { MOUSE_BTN5, "MOUSE_BTN5" },
    191	  { MOUSE_BTN6, "MOUSE_BTN6" },
    192	  { MOUSE_BTN7, "MOUSE_BTN7" },
    193	  { MOUSE_BTN8, "MOUSE_BTN8" },
    194	  { MOUSE_BTN9, "MOUSE_BTN9" },
    195	  { JOY_AXIS1_MINUS, "JOY_UP" },
    196	  { JOY_AXIS1_PLUS, "JOY_DOWN" },
    197	  { JOY_AXIS0_MINUS, "JOY_LEFT" },
    198	  { JOY_AXIS0_PLUS, "JOY_RIGHT" },
    199	
    200	  { JOY_AXIS0_PLUS, "JOY_AXIS0_PLUS" },
    201	  { JOY_AXIS0_MINUS, "JOY_AXIS0_MINUS" },
    202	  { JOY_AXIS1_PLUS, "JOY_AXIS1_PLUS" },
    203	  { JOY_AXIS1_MINUS, "JOY_AXIS1_MINUS" },
    204	  { JOY_AXIS2_PLUS, "JOY_AXIS2_PLUS" },
    205	  { JOY_AXIS2_MINUS, "JOY_AXIS2_MINUS" },
    206	  { JOY_AXIS3_PLUS, "JOY_AXIS3_PLUS" },
    207	  { JOY_AXIS3_MINUS, "JOY_AXIS3_MINUS" },
    208	  { JOY_AXIS4_PLUS, "JOY_AXIS4_PLUS" },
    209	  { JOY_AXIS4_MINUS, "JOY_AXIS4_MINUS" },
    210	  { JOY_AXIS5_PLUS, "JOY_AXIS5_PLUS" },
    211	  { JOY_AXIS5_MINUS, "JOY_AXIS5_MINUS" },
    212	  { JOY_AXIS6_PLUS, "JOY_AXIS6_PLUS" },
    213	  { JOY_AXIS6_MINUS, "JOY_AXIS6_MINUS" },
    214	  { JOY_AXIS7_PLUS, "JOY_AXIS7_PLUS" },
    215	  { JOY_AXIS7_MINUS, "JOY_AXIS7_MINUS" },
    216	  { JOY_AXIS8_PLUS, "JOY_AXIS8_PLUS" },
    217	  { JOY_AXIS8_MINUS, "JOY_AXIS8_MINUS" },
    218	  { JOY_AXIS9_PLUS, "JOY_AXIS9_PLUS" },
    219	  { JOY_AXIS9_MINUS, "JOY_AXIS9_MINUS" },
    220	
    221	  { JOY_BTN0, "JOY_BTN0" },
    222	  { JOY_BTN1, "JOY_BTN1" },
    223	  { JOY_BTN2, "JOY_BTN2" },
    224	  { JOY_BTN3, "JOY_BTN3" },
    225	  { JOY_BTN4, "JOY_BTN4" },
    226	  { JOY_BTN5, "JOY_BTN5" },
    227	  { JOY_BTN6, "JOY_BTN6" },
    228	  { JOY_BTN7, "JOY_BTN7" },
    229	  { JOY_BTN8, "JOY_BTN8" },
    230	  { JOY_BTN9, "JOY_BTN9" },
    231	
    232	  { KEY_XF86_PAUSE, "XF86_PAUSE" },
    233	  { KEY_XF86_STOP, "XF86_STOP" },
    234	  { KEY_XF86_PREV, "XF86_PREV" },
    235	  { KEY_XF86_NEXT, "XF86_NEXT" },
    236	
    237	  { 0, NULL }
    238	};
    239
    As you can see, lines 221 through 230 define JOY_BTN 0 through 9. And to recap, 0-3 seem hard-coded by mplayer and 10+ are undefined.

    Any help and/or hints are greatly appreciated! (Surely I'm not the only one who's tried to do this...

    One last note, the controller analog sticks are not picked up by mplayer (which is fine), the d-pad registers as buttons 12-15 (with other programs, registers as the hex codes above w/ mplayer).
    Last edited by ChiaGod; August 13th, 2008 at 09:21 PM.

  2. #2
    Join Date
    May 2006
    Beans
    21

    Exclamation Re: mplayer - cannot re-assign joystick buttons 1-4

    Well I got it partially resolved. Seems there's another input.conf in /etc/mplayer/ which was taking priority over the input.conf in my home directory (~/.mplayer/). Commenting out the following lines (adding #):
    Code:
    JOY_RIGHT seek 10
    JOY_LEFT seek -10
    JOY_UP seek 60
    JOY_DOWN seek -60
    JOY_BTN0 pause
    JOY_BTN1 osd
    JOY_BTN2 volume 1
    JOY_BTN3 volume -1
    now buttons 1-3 work as intended per my modifications in the input.conf in my home directory. Note that for some reason though, button 0 is still tied to "pause" even though it's commented out in the /etc version and has a different binding in mine. Still no luck with buttons 10 through 15 yet.

    On a side note, when I commented out all these lines, the left analog stick on the PS2 controller is now detected by mplayer and works for seek +/- 60 and +/-10. This is odd considering it's not defined anywhere (except maybe in the mplayer code).

    Oh and in case anybody is wondering, I'm using an EMS "USBII Gun Controller Converter" aka "Dualshooter USB II", detected as "ID 0b43:0003 Play.com, Inc. PS2 Controller Converter". It's simply a grey box with 2 PS2 controller hookups, usb cable (to attach to pc or PS2), and a video cable used to adapt Guncon1 lightguns to Guncon2 games. I ordered this one out of Hong Kong a while back. I'll see if some of the ones I can get locally work as well as this one, if so this would be a really neat way of controlling a MythTV / Linux gaming all-in-one box. 2 player games work, if I can find the 2nd one (I have somewhere), I can test 4 player games.
    Last edited by ChiaGod; August 14th, 2008 at 10:15 PM.

  3. #3
    Join Date
    May 2006
    Beans
    21

    Smile Re: mplayer - cannot re-assign joystick buttons 1-4

    Well I got it working, however I had to resort to putting the non-working button configs in the config file at /etc/mplayer/input.conf
    Code:
    JOY_BTN0 quit
    0x1000019e  sub_select 
    0x1000019f switch_audio
    For some odd reason this worked while these same lines in the user input.conf did nothing. Note that even then hex key/button assignments work in the (root owned) /etc/mplayer/input.conf while the same assigments *do not* work when entered in the user's version in their home directory (at ~/.mplayer/input.conf).

    Also noted that plugging in the ps2 controller adapter first (then the controller) caused some apps to not detect the analog sticks. Plugging in the controllers into the adapter, then the usb connection of the adaptor into the pc resolves this.

    One last thing of course is the red analog light on the PS2 controller needs to be on for the thumbsticks to work (pressing the "ANALOG" button in between them).

    Well that's all with that, the PS2 controllers now do all they need to to in mplayer and along with them working in games and MythTV I'm pretty set! Now to get the right analog stick to control the mouse cursor (for webbrowsing).

    I'll check w/ the mplayer folks to see if this configuration behavior is as intended or a bug.

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
  •