GithubHelp home page GithubHelp logo

asdlei99 / ps4joystick Goto Github PK

View Code? Open in Web Editor NEW

This project forked from stanfordroboticsclub/ps4joystick

0.0 0.0 0.0 54 KB

Collection of methods of using a PS4 controller with UDPComms

Python 94.27% Shell 5.73%

ps4joystick's Introduction

PS4Joystick

Code allowing the use of a DualShock (PS4 Joystick) over Bluetooth on Linux. Over USB comming soon. mac_joystick.py shows how to emulate something similar on macOS, but without the fancy features.

Note: We have updated from the previous version so make sure you disable ds4drv from running automatically at startup as they will conflict.

This method still requires ds4drv however it doesn't run it as a separate service and then separately pull joystick data using Pygame. Instead it imports ds4drv directly which gives us much more control over the joystick behaviour. Specifically:

  • It will only pair to one joystick allowing us to run multiple robots at a time
  • Allows for launching joystick code via systemd at boot using sudo systemctl enable joystick
  • Can change joystick colors and using rumble directly from Python (can also access the touchpad and IMU!)
  • Is a much nicer interface than using Pygame, as the axes are actually named as opposed to arbitrarly numbered! The axis directions are consistant with Pygame.
  • Doesn't need $DISPLAY hacks to run on headless devices

Usage

Take a look at rover_example.py as it demonstrates most features. To implement this functionality to a new repository (say PupperCommand) you can just call from PS4Joystick import Joystick anywhere once you've installed the module. Replicate joystick.service in that repository.

Install

sudo bash install.sh

macOS

Sadly ds4drv doesn't work on Macs. But you can get some of the functionality by installing Pygame with sudo pip3 install Pygame. Take a look in mac_joystick.py for an example. Note this only works over USB (plug the controller in using a micro usb cable) and the mapping is different than using Pygame with ds4drv

ps4joystick's People

Contributors

mark-bowers avatar mikh3x4 avatar nate711 avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.