-
Notifications
You must be signed in to change notification settings - Fork 217
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Added better default mapping and added basic multi-touch support #51
base: master
Are you sure you want to change the base?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
Original file line number | Diff line number | Diff line change |
---|---|---|
|
@@ -27,7 +27,6 @@ | |
ecodes.REL_WHEELUP = 13 # Unique value for this lib | ||
ecodes.REL_WHEELDOWN = 14 # Ditto | ||
|
||
|
||
def parse_button(attr): | ||
if attr[0] in BUTTON_MODIFIERS: | ||
modifier = attr[0] | ||
|
@@ -52,8 +51,62 @@ def create_mapping(name, description, bustype=0, vendor=0, product=0, | |
mouse_options) | ||
_mappings[name] = mapping | ||
|
||
|
||
# Pre-configued mappings | ||
# Emulate it the (mostly) correct way | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. What is |
||
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 | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Please add a space to these comments. E.g.
|
||
create_mapping( | ||
"ds4", "Sony Computer Entertainment Wireless Controller", | ||
# Bus type, vendor, product, version | ||
|
@@ -104,8 +157,10 @@ def create_mapping(name, description, bustype=0, vendor=0, product=0, | |
"ABS_HAT0X": ("dpad_left", "dpad_right"), | ||
"ABS_HAT0Y": ("dpad_up", "dpad_down") | ||
} | ||
|
||
) | ||
|
||
#Emulate xboxdrv's button assignments. | ||
create_mapping( | ||
"xboxdrv", "Xbox Gamepad (userspace driver)", | ||
# Bus type, vendor, product, version | ||
|
@@ -142,6 +197,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 +234,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 | ||
|
@@ -214,14 +271,20 @@ def create_mapping(name, description, bustype=0, vendor=0, product=0, | |
}, | ||
) | ||
|
||
#Emulate a multi-touch trackpad | ||
create_mapping( | ||
"mouse", "DualShock4 Mouse Emulation", | ||
buttons={ | ||
"BTN_LEFT": "button_trackpad", | ||
"BTN_TOOL_FINGER" : "trackpad_touch0_active", | ||
"BTN_TOOL_DOUBLETAP" : "trackpad_touch1_active" | ||
}, | ||
mouse={ | ||
"REL_X": "trackpad_touch0_x", | ||
"REL_Y": "trackpad_touch0_y" | ||
|
||
"REL_X" : "trackpad_touch0_x", | ||
"REL_Y" : "trackpad_touch0_y", | ||
"REL_RX" : "trackpad_touch1_x", | ||
"REL_RY" : "trackpad_touch1_y" | ||
}, | ||
) | ||
|
||
|
@@ -372,8 +435,9 @@ def emit_mouse(self, report): | |
continue | ||
|
||
sensitivity = self.mouse_analog_sensitivity | ||
self.mouse_rel[name] += accel * sensitivity | ||
self.mouse_rel[name] += accel * sensitivity | ||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. There is a minor white space error here. |
||
|
||
|
||
# Emulate mouse wheel (needs special handling) | ||
if name in (ecodes.REL_WHEELUP, ecodes.REL_WHEELDOWN): | ||
ecode = ecodes.REL_WHEEL # The real event we need to emit | ||
|
@@ -407,6 +471,7 @@ def emit_mouse(self, report): | |
if self._scroll_details.get('direction') == name: | ||
self._scroll_details['last_write'] = 0 | ||
self._scroll_details['count'] = 0 | ||
|
||
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Why is this new line added? |
||
|
||
rel = int(self.mouse_rel[name]) | ||
self.mouse_rel[name] = self.mouse_rel[name] - rel | ||
|
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
White space error.