-
Notifications
You must be signed in to change notification settings - Fork 34
Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
- Loading branch information
Artur Spirin
committed
Jan 21, 2020
0 parents
commit 342a3b7
Showing
5 changed files
with
438 additions
and
0 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,2 @@ | ||
.idea | ||
*.pyc |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,21 @@ | ||
MIT License | ||
|
||
Copyright (c) 2018 Artur Spirin | ||
|
||
Permission is hereby granted, free of charge, to any person obtaining a copy | ||
of this software and associated documentation files (the "Software"), to deal | ||
in the Software without restriction, including without limitation the rights | ||
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell | ||
copies of the Software, and to permit persons to whom the Software is | ||
furnished to do so, subject to the following conditions: | ||
|
||
The above copyright notice and this permission notice shall be included in all | ||
copies or substantial portions of the Software. | ||
|
||
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR | ||
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, | ||
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE | ||
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER | ||
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, | ||
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE | ||
SOFTWARE. |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,46 @@ | ||
# pyPS4Controller | ||
## | ||
|
||
pyPS4Controller is a light module designed to provide hooks for PS4 Controller using Python on Linux. | ||
|
||
## Installation | ||
`pip install pyPS4Controller` | ||
|
||
## Usage | ||
```python | ||
from pyPS4Controller import Controller | ||
|
||
class MyController(Controller): # create a custom class for your controller and subclass Controller | ||
""" | ||
If we want to bind an action to the X button on the controller, we need to override its respective methods. | ||
Some of the buttons have a binary On/Off state. For example the X, Circle, Square, and Triangle buttons. | ||
When overriding their respective methods there are no args in the function signature. | ||
Some controls like the L2, L3, R2 and R3 have a variable On state. | ||
When overriding their respective method, there is a value argument in the function signature | ||
which indicates the degree of the input. | ||
""" | ||
def on_x_press(self): | ||
# Input any code that you want to run when X is pressed | ||
print("X pressed!") | ||
|
||
def on_x_release(self): | ||
# Input any code that you want to run when X is released | ||
print("X released!") | ||
|
||
def on_L3_up(self, value): | ||
# Input any code that you want to run when left joystick (L3) is pushed up | ||
# value will indicate the degree of how far the joystick is pushed | ||
print(f"L3 pushed up: {value}") | ||
|
||
def on_L3_release(self): | ||
# Input any code that you want to run when left joystick (L3) is back to its resting state | ||
print("L3 at rest!") | ||
|
||
# now make sure the controller is paired over the Bluetooth and turn on the listener | ||
MyController(interface="/dev/input/js0").listen() | ||
``` | ||
|
||
## Pair PS4 Controller with the Raspberry Pi | ||
See detailed instructions [here](https://github.com/macunixs/dualshock4-pi) |
Oops, something went wrong.