control Sway with a PlayStation gamepad
Find a file
2025-08-19 10:19:16 +12:00
.gitignore add .gitignore 2025-08-19 10:19:16 +12:00
COPYING initial commit 2024-09-17 17:57:12 +12:00
README.md initial commit 2024-09-17 17:57:12 +12:00
swaystick.c initial commit 2024-09-17 17:57:12 +12:00

swaystick

swaystick reads input from a DualSense controller and binds its buttons to actions in the Sway window manager.

Could possibly work with previous DualShock models and perhaps even other gamepads. I've only tested it with a regular DualSense pad.

Uses the limited Linux joystick API. Based on Jason White's joystick demo.

usage

Compile with cc -o swaystick swaystick.c, and start it up with ./swaystick. With one joystick/controller plugged in it should work fine but if it doesn't or if the wrong keys are being picked up, specify a custom joystick device with ./swaystick /dev/input/jsX.

binds

Reference "DualSense wireless controller part names" for the names of any buttons listed here.

Button Action
Left stick Move focused window
Cross Kill focused window
Circle Toggle between tiled windows and floating windows
Triangle Teleport focused window to cursor
Square Toggle whether the focused window is floating
L1 Switch to previous workspace
R1 Switch to next workspace
L2 Focus previous window
R2 Focus next window
Create Collapse all windows
Options Expand all windows
PS Spawn an Emacs window (customizable)