Difference between revisions of "Joy2key"

From ArchWiki
Jump to: navigation, search
m (Created page with "**DRAFT** Getting Logitech Cordless RumblePad 2 "hat" (aka d-pad) to work with XBMC. NOTES: XBMC 10 or maybe a recent Arch update broke this. xbmc.log shows 0 hats: 17:00:36 T...")
 
(20 intermediate revisions by 3 users not shown)
Line 1: Line 1:
**DRAFT**
+
[[Category:Input devices]]
 +
===Use a joystick/gamepad to control applications which accept keyboard commands===
 +
{{Note|This solution may not work with XBMC 11.0 and joy2key 1.6.3-1. An alternative and more direct approach is described in the [[Joystick#Joystick_sending_keystrokes|Joystick wiki page]].}}
  
Getting Logitech Cordless RumblePad 2 "hat" (aka d-pad) to work with XBMC.
 
  
NOTES:
+
I use [http://interreality.org/~tetron/technology/joy2key/ joy2key] to work around issues with the Logitech Cordless RumblePad 2 "hat" (a.k.a. d-pad) in [http://xbmc.org/ XBMC].
XBMC 10 or maybe a recent Arch update broke this.
+
  
xbmc.log shows 0 hats:
+
XBMC 10.0 or probably a recent Arch update (SDL?) broke the joystick hat functionality for me.
17:00:36 T:3020363648 M:1703337984  NOTICE: Enabled Joystick: Logitech Logitech Cordless RumblePad 2
+
On XBMC startup, {{ic|xbmc.log}} shows 0 hats and 6 - instead of 4 - axes:
17:00:36 T:3020363648 M:1703337984  NOTICE: Details: Total Axis: 6 Total Hats: 0 Total Buttons: 12
+
17:00:36 T:3020363648 M:1703337984  NOTICE: Enabled Joystick: Logitech Logitech Cordless RumblePad 2
 +
17:00:36 T:3020363648 M:1703337984  NOTICE: Details: Total Axis: 6 Total Hats: 0 Total Buttons: 12
  
SOLUTION:
 
Install joy2key from AUR.
 
  
#
+
My solution was to install {{AUR|joy2key}} from the [[Arch User Repository|AUR]]. Here is my config which could potentially save you hours of frustration or fun, depending on how you look at it:
# ~/.joy2keyrc
+
#
#
+
# ~/.joy2keyrc
 +
#
 +
 +
COMMON
 +
-dev /dev/input/js0
 +
-thresh -16383 16383 -16383 16383 -16383 16383 -16383 16383 -16383 16383 -16383 16383
 +
#-autorepeat 5
 +
#-deadzone 50
 +
 +
START xbmc
 +
-X
 +
# -axis <axis0min> <axis0max> <axis1min> <axis1max> ...
 +
#      0 = left analog stick X-axis
 +
#      1 = left analog stick Y-axis
 +
#      2 = right analog stick X-axis
 +
#      3 = right analog stick Y-axis
 +
#      4 = hat (d-pad) X-axis
 +
#      5 = hat (d-pad) Y-axis
 +
#
 +
# actions: Left/Right/Up/Down (arrow keys) - first letter capital!
 +
#          plus/minus (ASCII characters) - lower case!
 +
#          blank = special
 +
# more info in /usr/include/X11/keysymdef.h
 +
#
 +
# .....0..........1.......2..........3..........4..........5......
 +
#-axis Left Right Up Down minus plus plus minus Left Right Up Down
 +
-axis blank blank blank blank blank blank blank blank Left Right Up Down
 +
 +
# EoF
  
COMMON
 
-dev /dev/input/js0
 
-thresh -16383 16383 -16383 16383 -16383 16383 -16383 16383 -16383 16383 -16383 16383
 
#-autorepeat 5
 
#-deadzone 50
 
  
START xbmc
+
joy2key needs to start '''after''' XBMC to be able to see its window. Here's my XBMC standalone system config:
-X
+
#
# -axis <axis0min> <axis0max> <axis1min> <axis1max> ...
+
# ~/.xinitrc
#       0 = left analog [Left Right]
+
#
#      1 = left analog [Up Down]
+
#       2 = right analog [Left Right]
+
# Enable Ctrl+Alt+Bksp.
#      3 = right analog [Up Down]
+
setxkbmap -option terminate:ctrl_alt_bksp &
#       4 = hat (d-pad) [Left Right]
+
   
#      5 = hat (d-pad) [Up Down]
+
# Start joy2key after XBMC has been detected running. (Function takes arguments, some optional.)
#
+
start_joy2key()
# actions: Left/Right/Up/Down (arrows) - first letter capital!
+
{
#          plus/minus (ASCII characters) - lower case!
+
  for n in $(seq $4 || seq 5)
# ....0..........1.......2..........3..........4..........5......
+
  do
-axis Left Right Up Down Left Right plus minus Left Right Up Down
+
    xwininfo -display :0 -name "$1" >/dev/null 2>&1 && joy2key "$1" -config "$2"
 +
    sleep $3 || sleep 3
 +
  done
 +
}
 +
# syntax: start_joy2key <window name> <config file> [wait # of sec between tries] [repeat # of times]
 +
start_joy2key "XBMC Media Center" xbmc 3 5 &
 +
 +
# Start XBMC.
 +
ck-launch-session xbmc-standalone
 +
 +
# EoF
  
# EoF
 
  
***
+
And here is my joy2key config section for controlling [[Boxee-source]]:
 +
START boxee
 +
-X
 +
-axis blank blank Page_Up Page_Down blank blank plus minus Left Right Up Down
 +
# .......1.2......3......4.5....6.....7...........8............9.0.1.2
 +
-buttons v Return Escape c Left Right bracketleft bracketright i z s h
  
#
 
# ~/.xinitrc
 
#
 
  
# Enable Ctrl+Alt+Bksp.
+
Add this to {{ic|~/.xinitrc}} below the XBMC section to alternate between launching XBMC and Boxee:
setxkbmap -option terminate:ctrl_alt_bksp &
+
start_joy2key Boxee boxee 3 3 &
 +
ck-launch-session /opt/boxee/run-boxee-desktop
  
# After a delay, start joy2key with XBMC config.
 
(sleep 3 && joy2key "XBMC Media Center" -config xbmc) &
 
  
# Start XBMC.
+
This gets respawned over and over from {{ic|/etc/inittab}}:
ck-launch-session xbmc-standalone --nolirc
+
x:5:respawn:/bin/su xbmc -l -c "/bin/bash --login -c /usr/bin/startx >/dev/null 2>&1"
  
# EoF
+
 
 +
References to the sources where I learned about this:
 +
*[http://hans.fugal.net/blog/2007/06/02/joystick-hat-in-x-plane-in-linux/] blog entry: ''Joystick Hat in X-Plane in Linux''
 +
*[http://ubuntuforums.org/showthread.php?t=646564] Ubuntu forum post: ''How to use joy2key for SIXAXIS joypad (or any really!) ''
 +
*[http://wiki.xbmc.org/index.php?title=Installing_XBMC_for_Linux#Autostarting_XBMC] XBMC wiki: ''Installing XBMC for Linux > Autostarting XBMC''

Revision as of 17:35, 21 April 2012

Use a joystick/gamepad to control applications which accept keyboard commands

Note: This solution may not work with XBMC 11.0 and joy2key 1.6.3-1. An alternative and more direct approach is described in the Joystick wiki page.


I use joy2key to work around issues with the Logitech Cordless RumblePad 2 "hat" (a.k.a. d-pad) in XBMC.

XBMC 10.0 or probably a recent Arch update (SDL?) broke the joystick hat functionality for me. On XBMC startup, xbmc.log shows 0 hats and 6 - instead of 4 - axes:

17:00:36 T:3020363648 M:1703337984  NOTICE: Enabled Joystick: Logitech Logitech Cordless RumblePad 2
17:00:36 T:3020363648 M:1703337984  NOTICE: Details: Total Axis: 6 Total Hats: 0 Total Buttons: 12


My solution was to install joy2keyAUR from the AUR. Here is my config which could potentially save you hours of frustration or fun, depending on how you look at it:

#
# ~/.joy2keyrc
#

COMMON
-dev /dev/input/js0
-thresh -16383 16383 -16383 16383 -16383 16383 -16383 16383 -16383 16383 -16383 16383
#-autorepeat 5
#-deadzone 50

START xbmc
-X
# -axis <axis0min> <axis0max> <axis1min> <axis1max> ...
#       0 = left analog stick X-axis
#       1 = left analog stick Y-axis
#       2 = right analog stick X-axis
#       3 = right analog stick Y-axis
#       4 = hat (d-pad) X-axis
#       5 = hat (d-pad) Y-axis
#
# actions: Left/Right/Up/Down (arrow keys) - first letter capital!
#          plus/minus (ASCII characters) - lower case!
#          blank = special
# more info in /usr/include/X11/keysymdef.h
#
# .....0..........1.......2..........3..........4..........5......
#-axis Left Right Up Down minus plus plus minus Left Right Up Down
-axis blank blank blank blank blank blank blank blank Left Right Up Down

# EoF


joy2key needs to start after XBMC to be able to see its window. Here's my XBMC standalone system config:

#
# ~/.xinitrc
#

# Enable Ctrl+Alt+Bksp.
setxkbmap -option terminate:ctrl_alt_bksp &

# Start joy2key after XBMC has been detected running. (Function takes arguments, some optional.)
start_joy2key()
{
  for n in $(seq $4 || seq 5)
  do
    xwininfo -display :0 -name "$1" >/dev/null 2>&1 && joy2key "$1" -config "$2"
    sleep $3 || sleep 3
  done
}
# syntax: start_joy2key <window name> <config file> [wait # of sec between tries] [repeat # of times]
start_joy2key "XBMC Media Center" xbmc 3 5 &

# Start XBMC.
ck-launch-session xbmc-standalone

# EoF


And here is my joy2key config section for controlling Boxee-source:

START boxee
-X
-axis blank blank Page_Up Page_Down blank blank plus minus Left Right Up Down
# .......1.2......3......4.5....6.....7...........8............9.0.1.2
-buttons v Return Escape c Left Right bracketleft bracketright i z s h


Add this to ~/.xinitrc below the XBMC section to alternate between launching XBMC and Boxee:

start_joy2key Boxee boxee 3 3 &
ck-launch-session /opt/boxee/run-boxee-desktop


This gets respawned over and over from /etc/inittab:

x:5:respawn:/bin/su xbmc -l -c "/bin/bash --login -c /usr/bin/startx >/dev/null 2>&1"


References to the sources where I learned about this:

  • [1] blog entry: Joystick Hat in X-Plane in Linux
  • [2] Ubuntu forum post: How to use joy2key for SIXAXIS joypad (or any really!)
  • [3] XBMC wiki: Installing XBMC for Linux > Autostarting XBMC