From 8182ff9c657c7979fd73cdb2e12681c306ab1d91 Mon Sep 17 00:00:00 2001 From: aus4000 <9aus4000@gmail.com> Date: Sat, 3 Jan 2015 22:05:03 -0700 Subject: [PATCH] Add raw multitouch as default profile Ref: #51, #157. --- ds4drv.conf | 2 +- ds4drv/actions/input.py | 6 ++++- ds4drv/uinput.py | 54 +++++++++++++++++++++++++++++++++++++++++ 3 files changed, 60 insertions(+), 2 deletions(-) diff --git a/ds4drv.conf b/ds4drv.conf index de4dc43..a08bf72 100644 --- a/ds4drv.conf +++ b/ds4drv.conf @@ -21,7 +21,7 @@ ## # Controller settings # -# This is the default profile for each controller. +# This is the default profile for each controller. It is created before the other profiles as "default". # Multiple controllers slots are defined by increasing the number. # # Controller sections contain: diff --git a/ds4drv/actions/input.py b/ds4drv/actions/input.py index bcf09a2..f198421 100644 --- a/ds4drv/actions/input.py +++ b/ds4drv/actions/input.py @@ -12,6 +12,8 @@ ReportAction.add_option("--emulate-xpad-wireless", action="store_true", help="Emulates the same joystick layout as a wireless " "Xbox 360 controller used via the xpad module") +ReportAction.add_option("--emulate-kernel", action="store_true", + help="Emulates the same joystick layout as the default kernel driver.") ReportAction.add_option("--ignored-buttons", metavar="button(s)", type=buttoncombo(","), default=[], help="A comma-separated list of buttons to never send " @@ -62,8 +64,10 @@ def load_options(self, options): joystick_layout = "xpad" elif options.emulate_xpad_wireless: joystick_layout = "xpad_wireless" - else: + elif options.emulate_kernel: joystick_layout = "ds4" + else: + joystick_layout = "ds4drv" if not self.mouse and options.trackpad_mouse: self.mouse = create_uinput_device("mouse") diff --git a/ds4drv/uinput.py b/ds4drv/uinput.py index 8bbf5f5..2123758 100644 --- a/ds4drv/uinput.py +++ b/ds4drv/uinput.py @@ -54,6 +54,57 @@ def create_mapping(name, description, bustype=0, vendor=0, product=0, # Pre-configued mappings +create_mapping( + "ds4drv", "Sony Computer Entertainment Wireless Controller (Userspace)", + # Bus type, vendor, product, version + ecodes.BUS_USB, 1356, 1476, 273, + # Axes + { + "ABS_X": "left_analog_x", + "ABS_Y": "left_analog_y", + "ABS_RX": "right_analog_x", + "ABS_RY": "right_analog_y", + "ABS_Z": "l2_analog", + "ABS_RZ": "r2_analog", + "ABS_THROTTLE": "orientation_roll", + "ABS_RUDDER": "orientation_pitch", + "ABS_WHEEL": "orientation_yaw", + "ABS_DISTANCE": "motion_z", + "ABS_TILT_X": "motion_x", + "ABS_TILT_Y": "motion_y", + }, + # Axes options + { + "ABS_THROTTLE": (-16385, 16384, 0, 0), + "ABS_RUDDER": (-16385, 16384, 0, 0), + "ABS_WHEEL": (-16385, 16384, 0, 0), + "ABS_DISTANCE": (-32768, 32767, 0, 10), + "ABS_TILT_X": (-32768, 32767, 0, 10), + "ABS_TILT_Y": (-32768, 32767, 0, 10), + }, + # Buttons + { + "BTN_START": "button_options", + "BTN_MODE": "button_ps", + "BTN_SELECT": "button_share", + "BTN_A": "button_cross", + "BTN_B": "button_circle", + "BTN_X": "button_square", + "BTN_Y": "button_triangle", + "BTN_TL": "button_l1", + "BTN_TR": "button_r1", + "BTN_THUMBL": "button_l3", + "BTN_THUMBR": "button_r3", + }, + + # Hats + { + "ABS_HAT0X": ("dpad_left", "dpad_right"), + "ABS_HAT0Y": ("dpad_up", "dpad_down") + }, +) + +# Emulate the way the kernel does it create_mapping( "ds4", "Sony Computer Entertainment Wireless Controller", # Bus type, vendor, product, version @@ -106,6 +157,7 @@ def create_mapping(name, description, bustype=0, vendor=0, product=0, } ) +# Emulate xboxdrv's button assignments. create_mapping( "xboxdrv", "Xbox Gamepad (userspace driver)", # Bus type, vendor, product, version @@ -142,6 +194,7 @@ def create_mapping(name, description, bustype=0, vendor=0, product=0, } ) +# Emulate the way the kernel does Xbox 360/Xbone controllers with xpad create_mapping( "xpad", "Microsoft X-Box 360 pad", # Bus type, vendor, product, version @@ -178,6 +231,7 @@ def create_mapping(name, description, bustype=0, vendor=0, product=0, } ) +# Emulate the way the kernel does Xbox 360 Wireless controllers with xpad create_mapping( "xpad_wireless", "Xbox 360 Wireless Receiver", # Bus type, vendor, product, version