Code Monkey home page Code Monkey logo

dualsenseapiupdateattempt's Introduction

DualSenseAPI (now with hardware accelerated Vectors)

docs workflow status nuget version

A .NET standard API for interacting with DualSense controllers. Full docs and API reference are available at https://badmagic100.github.io/DualSenseAPI/.

Features

  • Basic Input: Analog sticks and triggers, d-pad, and all buttons. Basically any input library you will use can offer this, including DirectInput or similar.
  • Advanced Input: Most of the rest of input features for the DualSense. This includes:
    • 6-axis accelerometer (accelerometer and gyroscope)
    • 2-point multitouch
    • Battery status
  • Output: Most of the full suite of output features for the DualSense. This includes:
    • Haptic motors
    • Adaptive triggers
    • Lightbar color
  • Flexiblility of Control: Supports both synchronous and asynchronous/event-driven IO.

Example

This simple example connects to a DualSense controller using asynchronous polling. The repo contains a more detailed sample and also shows the usage of synchronous polling as well. Check it out here!

static void Main(string[] args)
{
    DualSense ds = DualSense.EnumerateControllers().First();
    ds.Acquire();
    ds.JoystickDeadZone = 0.1f;
    ds.BeginPolling(20, (sender) => {
        DualSenseInputState dss = sender.InputState;
        Console.WriteLine($"LS: ({dss.LeftAnalogStick.X:F2}, {dss.LeftAnalogStick.Y:F2})");
        Console.WriteLine($"RS: ({dss.RightAnalogStick.X:F2}, {dss.RightAnalogStick.Y:F2})");
        Console.WriteLine($"Triggers: ({dss.L2:F2}, {dss.R2:F2})");
        Console.WriteLine($"Touch 1: ({dss.Touchpad1.X}, {dss.Touchpad1.Y}, {dss.Touchpad1.IsDown}, {dss.Touchpad1.Id})");
        Console.WriteLine($"Touch 2: ({dss.Touchpad2.X}, {dss.Touchpad2.Y}, {dss.Touchpad2.IsDown}, {dss.Touchpad2.Id})");
        Console.WriteLine($"Gyro: ({dss.Gyro.X}, {dss.Gyro.Y}, {dss.Gyro.Z})");
        Console.WriteLine($"Accel: ({dss.Accelerometer.X}, {dss.Accelerometer.Y}, {dss.Accelerometer.Z}); m={dss.Accelerometer.Magnitude()}");
        Console.WriteLine($"Headphone: {dss.IsHeadphoneConnected}");
        Console.WriteLine($"Battery: {dss.BatteryStatus.IsCharging}, {dss.BatteryStatus.IsFullyCharged}, {dss.BatteryStatus.Level}");
    });
    Console.ReadKey(true);
    ds.EndPolling();
    ds.Release();
}

dualsenseapiupdateattempt's People

Contributors

badmagic100 avatar erebuswolf avatar bogzxo avatar bogz6969 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.