Joystick Control

From MythTV Official Wiki
Revision as of 05:22, 7 November 2006 by FishFoot (talk | contribs) (Sample File (Xbox Controller on Xbox))

Jump to: navigation, search

It is possible to control MythTV by using a Joystick. This option is especially useful for Xbox frontends, however, with the versitile USB Xbox 360 controller it may make a great deal of sense to opt for a joystick over a remote control.

For the sample configuration files below I used a standard Xbox controller connected to an Ubuntu Dapper 6.06 installation running mythtv-0.20 which was built from source. I found it incredibly helpful to install a package called jscalibrate by running

sudo apt-get install jscalibrate

This GTK based program will display to you the buttons and axis that are available on your joystick. I found that some of the axis were reversed but the buttons mapped perfectly.

One other small bit to note. It seems that the "chords" that you can define in the config file activate when the second button in the chord is released. This is a little strange but no big deal. In addition, you must release all buttons in the chord and then press them again to re-issue the command defined by the chord.

I found that the analog sticks (axis) will fire only one time with most of the config options found below. That's fine if you're using them as "buttons" but if you want to use them as analog sticks you need to define multiple smaller ranges for the axis. For example:

#Down
       axis   4    -32767  -15000  F10

Sets a single F10 to be issued when the axis is moved down, however this:

#Down 3 times
       axis   4    -20000  -15000  F10
       axis   4    -25000  -20001  F10
       axis   4    -32767  -25001  F10

places 3 ranges in the swing of the axis. Each time the axis passes between a range an F10 is issued. It is important to note: if you swing the axis to the maximum and then let it return to center you will actually issues 6 F10s, one for each range on the way down, one for each range on the way back up. Keep this in mind when deciding how many and how big to make the ranges.

Xbox vs PC Configuration

For this example I've used an XBOX controller. Strangely the controller is handled slightly differently by the PC Driver than the Xbox's native driver. Most noticably the D-Pad is seen as a set of axis on the PC but it is a set of buttons on the XBox. This actually makes some "chords" possible that otherwise were not on the PC. Please note the 2 configuration files below. They do the same thing, one is for the XBox, the other for the PC.


Configuration Files

MythTV joystick control is accomplished by defining a plain text document called joystickmenurc in the ~/.mythtv directory for the user that launches your mythfrontend.


Formatting

button num keystring
Send 'keystring' when button 'num' is released
chord cnum bnum keystring
If button cnum is down, and button 'bnum' is released, send keystring
axis num from to keystring
If axis num goes into the range of from-to send keystring


Sample File (Xbox Controller on PC)

# ~/.mythtv/joystickmenurc
# Joystick menu config file
#  Place in /media/.mythtv/
#
#   Format:
#       devicename <devname>        Specify name of joystick device to use
#                                   (e.g. /dev/js0)
#       button num keystring        Send 'keystring' when button 'num' is released
#       chord cnum bnum keystring   If button cnum is down, and button 'bnum'
#                                   is released, send keystring
#       axis num from to keystring  If axis num goes into the range of from-to
#                                   send keystring


devicename /dev/input/js0



######################################################################
#
#       Stick/Pad Configuration
#
######################################################################


##############################################
#
#       D-Pad
#
##############################################

#Right
        axis    6       -1      0       Right
#Left
        axis    6       0       1       Left
#Down
        axis    7       -1      0       Down
#Up
        axis    7       0       1       Up


##############################################
#
#       Left Stick
#
#       Slow Mo Controls
#
##############################################
#Left Analog stick
#Left
        axis   0    -32767  -10000  U
#Right
        axis   0     10000   32767  J
#Down
#       axis   1    -32767  -15000  Down
#Up
#       axis   1     15000   32767  Up
#Button
#       button  7       Enter


##############################################
#
#       Right Stick
#
#
#
##############################################
#Right Analog stick
#Left
#       axis   3    -32767  -10000  U
#Right
#       axis   3     10000   32767  J


#####
#
#  Add 3 ranges to the Up/Down of the stick
#  Used for volume
#  Does about a 10% Jump tick.
#  Hits when moving the stick and when the stick returns to center
#    causing an extra set of presses.  This can be used for finess
#    a smaller push can hit once, a medium 3 or 4, and a full all 6
#
#####
#Down
#       axis   4    -32767  -15000  F10
        axis   4    -20000  -15000  F10
        axis   4    -25000  -20001  F10
        axis   4    -32767  -25001  F10

#Up
#       axis   4     15000   32767  F11
        axis   4     15000   20000  F11
        axis   4     20000   25000  F11
        axis   4     25001   32767  F11

#Button
#       button  8       Enter




######################################################################
#
#       Trigger Configuration  Configuration
#
######################################################################


#Left trigger pull      Rewind (Repeat to speed up)
        axis   2        100     255     <
#Right trigger pull     Fastforward (Repeat to speed up)
        axis   5        100     255     >




######################################################################
#
#       Button Configuration
#
######################################################################


##############################################
#
#       Baseline Buttons
#
##############################################

#Back -=- Escape
        button  9       Escape
#Start Button -=- Pause
        button  6       P

#A Button -=- Enter
        button  0       Enter
#B Button -=- On Screen Menu
        button  1       M
#X Button
#       button  3
#Y Button
#       button  4       E
#Wht Button
#       button  5
#Blk Button
#       button  2






######################################################################
#
#       Function Specific Configuration
#
######################################################################

#####################################
# Edit Mode Controls
#
# Y to Enter/Exit
# Start = Shift
#       Z   = LoadCut
#       Wht = PrevCut
#       Blk = NextCut
#       X   = Transcode
#
#####################################

#Y Button -=- Enter Edit Mode
button  4       E
#Start + Y -=- Load CutpointsHOWTO
chord   6       4       Z
#Start + Blk -=- Jump Next Cutpoint
chord   6       2       PgDown
#Start + White -=- Jump Previous Cutpoint
chord   6       5       PgUp
#Start + X -=- Queue for Transcode
chord   6       3       X

Sample File (Xbox Controller on Xbox)

  1. ~/.mythtv/joystickmenurc
  2. Joystick menu config file
  3. Place in /media/.mythtv/
  4. Format:
  5. devicename <devname> Specify name of joystick device to use
  6. (e.g. /dev/js0)
  7. button num keystring Send 'keystring' when button 'num' is released
  8. chord cnum bnum keystring If button cnum is down, and button 'bnum'
  9. is released, send keystring
  10. axis num from to keystring If axis num goes into the range of from-to
  11. send keystring


devicename /dev/input/js0


  1. Stick/Pad Configuration


  1. D-Pad
  1. Down

button 11 Down

  1. Up

button 9 Up

  1. Down

button 12 Left

  1. Right

button 10 Right

  1. Left Stick
  2. Slow Mo Controls
  3. Left Analog stick
  4. Left
       axis   0    -32767  -10000  U
  1. Right
       axis   0     10000   32767  J
  1. Down
  2. axis 1 -32767 -15000 Down
  3. Up
  4. axis 1 15000 32767 Up
  5. Button
  6. button 7 Enter


  1. Right Stick
  2. Right Analog stick
  3. Left
  4. axis 3 -32767 -10000 U
  5. Right
  6. axis 3 10000 32767 J


  1. Add 3 ranges to the Up/Down of the stick
  2. Used for volume
  3. Does about a 10% Jump tick.
  4. Hits when moving the stick and when the stick returns to center
  5. causing an extra set of presses. This can be used for finess
  6. a smaller push can hit once, a medium 3 or 4, and a full all 6
  7. Down
  8. axis 4 -32767 -15000 F10
       axis   4    -20000  -15000  F10
       axis   4    -25000  -20001  F10
       axis   4    -32767  -25001  F10
  1. Up
  2. axis 4 15000 32767 F11
       axis   4     15000   20000  F11
       axis   4     20000   25000  F11
       axis   4     25001   32767  F11
  1. Button
  2. button 8 Enter



  1. Trigger Configuration Configuration


  1. Left trigger pull Rewind (Repeat to speed up)
       axis   2        100     255     <
  1. Right trigger pull Fastforward (Repeat to speed up)
       axis   5        100     255     >



  1. Button Configuration


  1. Baseline Buttons
  1. Back -=- Escape
       button  13       Escape
  1. Start Button -=- Pause
       button  6       P
  1. A Button -=- Enter
       button  0       Enter
  1. B Button -=- On Screen Menu
       button  1       M
  1. X Button
  2. button 3
  3. Y Button
  4. button 4 E
  5. Wht Button
  6. button 5
  7. Blk Button
  8. button 2




  1. Function Specific Configuration
  1. Edit Mode Controls
  2. Y to Enter/Exit
  3. Start = Shift
  4. Z = LoadCut
  5. Wht = PrevCut
  6. Blk = NextCut
  7. X = Transcode
  1. Y Button -=- Enter Edit Mode

button 4 E

  1. Start + Y -=- Load CutpointsHOWTO

chord 6 4 Z

  1. Start + Blk -=- Jump Next Cutpoint

chord 6 2 PgDown

  1. Start + White -=- Jump Previous Cutpoint

chord 6 5 PgUp

  1. Start + X -=- Queue for Transcode

chord 6 3 X