PrefaceThe sixaxis is considered an input device by Linux; more specifically, it's regarded as a joystick. X provides the proper interfaces necessary to use several kinds of input devices including joysticks. What this means for us is that we can tell X to give the sixaxis mouse (and keyboard) functionality
without 3rd party programs such as joy2key or js2mouse.
This should work with either a usb or bluetooth (
http://psubuntu.com/forum/viewtopic.php?t=2408) sixaxis.
Package(s) necessary:-xserver-xorg-input-joystick
Steps:1. Install the xserver-xorg-input-joystick package (on Debian variants such as Ubuntu:
sudo apt-get install xserver-xorg-input-joystick)
2. Open your xorg.conf for modification (
sudo nano -w /etc/X11/xorg.conf).
3. Add the following new "InputDevice" section (I added mine after my mouse's inputdevice section). This section is standalone so it can technically go anywhere in your xorg.conf:
Code:
Section "InputDevice"
Driver "joystick"
Identifier "SIXAXIS"
Option "Device" "/dev/input/js0"
Option "Buttons" "19"
#15 - x
Option "MapButton15" "button=3"
#16 - square
Option "MapButton16" "button=1"
Option "MapAxis1" "mode=relative axis=1.0x deadzone=0"
Option "MapAxis2" "mode=relative axis=1.0y deadzone=0"
EndSection
*Your Option "Device" line may vary depending on the /dev/input/js<n> device your sixaxis is assigned to. A safer setting would probably be /dev/input/by-id/usb-Sony_Bluetooth_Transceiver-joystick4. Scroll to the "ServerLayout" section and add the following entry (again I added this entry after my mouse entry):
Code:
InputDevice "SIXAXIS" "SendCoreEvents"
Your "ServerLayout" section will look something like:
Code:
Section "ServerLayout"
Identifier "Default Layout"
Screen "Default Screen"
InputDevice "Generic Keyboard"
InputDevice "Configured Mouse"
InputDevice "SIXAXIS" "SendCoreEvents"
EndSection
5. Enable your sixaxis (press the PS button) if you haven't already.
6. Restart X (
ctrl+alt+backspace)
Test your left analog stick to see if you have cursor movement. If you do, then you're all set. Square is left click, and X is right click.
Notes:-You can modify the axis sensitivities and deadzones by altering the lines that apply to
MapAxis1 and
MapAxis2. The coefficients are sensitivity multipliers. The deadzone range is anywhere from 0-30000 (default 1000 - I set mine to 0).
-For more information,
man joystick after you have installed the xserver-xorg-input-joystick package.
Advanced usage:The xserver-xorg-input-joystick package also allows keystrokes to be bound to any button. From
man joystick:
Code:
GENERATING KEY EVENTS
Proving a "key=<keycode>[,<keycode>[...]]" option will generate X
Events with the specified keycodes in order, when the joystick button
is pressed. When the button is released, the keys are released in the
reverse order. To lookup keycodes for KeySyms, you can use xmodmap
-pk. You can use unused keycodes and map them to a KeySym of your
choice using xmodmap(1). You can specify up to 4 keycodes per joystick
button.
Examples:
Option "MapButton1" "key=64,23"
will generate Alt_L+Tab when the button is pressed.
With this knowledge, we can map keystrokes intuitively to specific buttons. All mappings go within the "InputDevice" section you added for your sixaxis. For example:
Code:
Section "InputDevice"
Driver "joystick"
Identifier "SIXAXIS"
Option "Device" "/dev/input/js0"
Option "Buttons" "18"
# Say you want to add back / forward functionality to your R1 and L1 buttons so you can use them in Firefox.
# The shortcut for back and forward in Firefox is alt+left arrow and alt+right arrow
#11 - L1
Option "MapButton11" "key=64,100"
#12 - R1
Option "MapButton12" "key=64,102
#15 - x
Option "MapButton15" "button=2"
#16 - square
Option "MapButton16" "button=1"
Option "MapAxis1" "mode=relative axis=1.0x deadzone=0"
Option "MapAxis2" "mode=relative axis=1.0y deadzone=0"
EndSection
64=Left Alt, 100=Left arrow, 102=right arrow. For a more comprehensive listing of keyboard mappings either use
xmodmap -pk or check
http://tldp.org/HOWTO/Intkeyb/x772.html.
If you wish to make your own mappings, I have documented some of the buttons:
#5 - d-pad up
#6 - d-pad right
#7 - d-pad down
#8 - d-pad left
#11 - L1
#12 - R1
#13 - triangle
#14 - circle
#15 - x
#16 - square
Nearly all buttons are pressure sensitive, and as such have their own axis. To map to a specific axis take the button number and add 4. For example, the pressure sensitive axis to L1 is Axis15 (L1 is button 11 therefore 11+4=15).