Shocker is a C++ 17 project made for Linux that allows you to configure the DualShock 4 buttons/triggers/axis as:
- Keyboard Inputs
- Mouse Input
- Macros
- Commands e.g.
firefox https://github.com/raphaelabrantes/Shocker
This types of inputs are called actions. It probably works for other controllers but I haven't tested.
NewShocker is the terminal based application, you can only start the application and quit.
ShockerGUI is the GUI based application using QT-5.15, for now it only creates an SystemTrayIcon and with it you can:
- Start getting the events controller events
- Stop getting the events controller events
- Quit the app
There is plans to used to it to edit or create new profiles (Not yet implemented).
If you are as lazy as I am you know there is a good reason. I wanted to be able to:
- Use the PS4 controller for games that don't have native support ( not perfect but it works ).
- Have a easier way to control stream services from afar without a janky setup.
- Automation of boring tasks.
$ git clone https://github.com/raphaelabrantes/Shocker
or alternatively
$ git clone git@github.com:raphaelabrantes/Shocker.git
First time you will need to execute in the project root:
$ cmake .
After that to build just run the command:
$ cmake --build .
If you want to build only the NewShocker:
$ cmake --build . --target NewShocker
If you want to build only the ShockerGUI:
$ cmake --build . --target ShockerGUI
First you need to install
$ sudo cmake --install .
To run simple execute the command
$ NewShocker
or
$ ShockerGUI
The default profile is in this
path $HOME/.config/shocker/profiles/default.json
, if you want to
run with another profile just run
$ NewShocker <path/to/new/profile/file>
You can and should modify the default profile as what you wish.
Profiles are written in json files following this example.
{
"R2": {
"type": "button",
"value": "ENTER"
},
"R3_MU": {
"type": "mouse",
"value": "MOUSE_Y",
"sensibility": 50,
"positive": false
},
"L1": {
"type": "macro",
"value": [
{
"type": "button",
"value": "H"
},
{
"type": "button",
"value": "E"
},
{
"type": "button",
"value": "L"
},
{
"type": "button",
"value": "L"
},
{
"type": "button",
"value": "O"
}
]
}
}
There is 4 types of actions as talked before.
They all follow the same basic layout.
{
"CONTROLLER_BUTTON": {
"type": type,
"value": value
}
}
Keyboard Input:
{
"CONTROLLER_BUTTON": {
"type": "button",
"value": "KEYBOARD_OR_MOUSE_BUTTON"
}
}
CONTROLLER_BUTTON
being the name of the key in the DualShock button that you want to bind with,
and KEYBOARD_OR_MOUSE_BUTTON
being the name of the keyboard or mouse button you want to press
Mouse Movement Input : For now only work with the directionals (up, right, left, down), triggers and axis of the controller.
{
"CONTROLLER_BUTTON": {
"type": "mouse",
"value": "MOUSE_X"
or
"MOUSE_Y",
"positive": <bollean>,
"sensibility": <int>
}
}
CONTROLLER_BUTTON
being the name of the key in the DualShock button that you want to bind with.
In the mouse
value you can only put or MOUSE_X
or MOUSE_Y
, they are the axis of the mouse movement.
If the positive
value is true that will move the mouse in the positive direction of the axis (up if MOUSE_Y
or right
if MOUSE_X
), if false will move in the negative direction of the axis.
Sensibility is the max amount of pixels that the axis will move in one iteration (20 ms) while the button is being
held.
Macros
{
"CONTROLLER_BUTTON": {
"type": "macro",
"value": [
{
"type": type_of_action,
"value": value_of_action
},
{
"type": type_of_action,
"value": value_of_action
}
]
}
}
CONTROLLER_BUTTON
being the name of the key in the DualShock button that you want to bind with.
The value is an array of actions, can be any type of action, even macros.
Commands It will run any command you can execute in your terminal.
{
"CONTROLLER_BUTTON": {
"type": "command",
"value": "COMMAND"
}
}
CONTROLLER_BUTTON
being the name of the key in the DualShock button that you want to bind with.
COMMAND
being the command you want to execute (It will open a non-blocking thread to execute, but It wont be able to
execute again until the command exit, for safety reasons).
All keyboard and mouse button names can be found in
the key_codes/keys.json
file. ( Except
the MOUSE_X and MOUSE_Y, it wont break but it wont move the mouse )
All controller buttons names can be found in here or in
the profiles/default.json
:
- SQUARE
- TRIANGLE
- CIRCLE
- X
- L1
- L3
- R1
- R3
- OPT
- SHARE
- L2
- R2
- R3_MU ¹
- R3_MR ²
- R3_ML ³
- R3_MD ⁴
- L3_MU ¹
- L3_MR ²
- L3_ML ³
- L3_MD ⁴
- LEFT_BU ¹
- LEFT_BR ²
- LEFT_BL ³
- LEFT_BD ⁴
- PS
¹ UP
² RIGHT
³ LEFT
⁴ DOWN