npm package discovery and stats viewer.

Discover Tips

  • General search

    [free text search, go nuts!]

  • Package details

    pkg:[package-name]

  • User packages

    @[username]

Sponsor

Optimize Toolset

I’ve always been into building performant and accessible sites, but lately I’ve been taking it extremely seriously. So much so that I’ve been building a tool to help me optimize and monitor the sites that I build to make sure that I’m making an attempt to offer the best experience to those who visit them. If you’re into performant, accessible and SEO friendly sites, you might like it too! You can check it out at Optimize Toolset.

About

Hi, 👋, I’m Ryan Hefner  and I built this site for me, and you! The goal of this site was to provide an easy way for me to check the stats on my npm packages, both for prioritizing issues and updates, and to give me a little kick in the pants to keep up on stuff.

As I was building it, I realized that I was actually using the tool to build the tool, and figured I might as well put this out there and hopefully others will find it to be a fast and useful way to search and browse npm packages as I have.

If you’re interested in other things I’m working on, follow me on Twitter or check out the open source projects I’ve been publishing on GitHub.

I am also working on a Twitter bot for this site to tweet the most popular, newest, random packages from npm. Please follow that account now and it will start sending out packages soon–ish.

Open Software & Tools

This site wouldn’t be possible without the immense generosity and tireless efforts from the people who make contributions to the world and share their work via open source initiatives. Thank you 🙏

© 2024 – Pkg Stats / Ryan Hefner

@esc_games/esc-controller-sdk

v1.2.30

Published

## Using the controller SDK:

Downloads

304

Readme

ESC Controller SDK

Using the controller SDK:

Pre-requisites

  • homebrew
brew install npm

Creating a controller using esc-create-controller

In your Unity game project directory (e.g. ~/ToyBox/myGame/), run this command

npx @esc_games/esc-create-controller MyGame
cd controllers

And follow the steps described by the script.

Creating a controller manually

If you are creating a controller manually, start by installing the SDK:

npm install @esc_games/esc-controller-sdk --save

ESC Controller SDK is a React/Redux dependent SDK.
You can use the SDK to make ESC Game controllers, interfacing directly with the ESC API, as well as plugging in a dope controller and user input components made by ESC and our developer community.

Example index.js:

import React, {Component} from 'react';
import ReactDOM from 'react-dom';
import { ESCGameController } from '@esc_games/esc-controller-sdk/';
import './my.css';
import { MyController } from './MyGame';

ReactDOM.render(
    <ESCGameController>
        <MyController/>
    </ESCGameController>,
    document.getElementById('root')
);

Raw User Input

The core user input library from ESC provides access to native User Inputs on the controller device.

  • Accelerometer
  • Screen
  • UserMedia
  • ...

Gestures

The gesture library from ESC provides some concrete implementations of interpreting raw user input into controller events.

  • Shake
  • Flick
  • ...

Here's an example of adding the Shake gesture and the default Shake UI component:

import { ESCManager } from '@esc_games/esc-controller-sdk'
import { Shake, ShakeManager, CONTROLLER_SHAKE } from '@esc_games/esc-controller-sdk/gestures'

ShakeManager.registerEventHandler(CONTROLLER_SHAKE, "A", (message) => {
    ESCManager.networking.sendEventMessage("Shake:");
});

Controls

ESC Controls are easy-to-use drop-in components for common UI Inputs

  • Joystick
  • TattooSelector
  • TattooDisplay
  • ...

Here's how to add a control and subscribe to control events:

import React, {Component} from 'react';
import {Joystick, JoystickManager, CONTROLLER_JOYSTICK_MOTION} from "../esc/controls/joystick";

JoystickManager.registerEventHandler(CONTROLLER_JOYSTICK_MOTION, SEA_OF_FOLKS, (message) => {
    console.log("SENDING ", message);
    ESCManager.networking.sendEventMessage("Joystick:" + message);
});

class MyControllerComponent extends Component {
    render() {
        const joystickStyle = {
            float: "right",
        };

        const tattooStyle = {
            float: "left",
        };


        return <div>
            <div style={joystickStyle}>
                <Joystick/>
                <TattooDisplay/>
            </div>

            <div style={tattooStyle}>
                <TattooSelector/>


                <Shake/>
            </div>
        </div>
    }
}

Creating Reusable Controls

Let's use Joystick as an example - here's a simplified component that we want to change redux state IFF it's showing on the screen:

class JoystickComponent extends Component {
    render() {
        const {id, x, y, skinClassName} = this.props;

        return <div id={id} className={"ESCJoystick " + skinClassName}>
            Joystick
            <pre>
                <pre>
                    {JSON.stringify(this.props, null, 2)}
                </pre>
            </pre>
        </div>
    }
}

This component is made to be simple, and used for debugging. That's why only displaying it's props in a fixed width font.

Here's the reducer for it:

const defaultState = {
    id: "Joystick " + Math.random(),
    x: 0.0,
    y: 0.0,
    skinClassName: "x86-classic"
};

const reducerManager = new ReducerManager({
    [UI_JOYSTICK_MOTION]: (state, action) => {
        return {
            ...state.joystick,
            x: action.value.x,
            y: action.value.y,
        };
    },
    [UI_JOYSTICK_SKIN]: (state, action) => {
        return {
            ...state.joystick,
            skinClassName: action.value
        };
    }
}, defaultState);

Here's how we connect the GameUI, our props displaying React component to ESC's reducer registry:

export const Joystick = JoystickManager.connect(JoystickComponent, [UI_JOYSTICK_MOTION, UI_JOYSTICK_SKIN]);

This connect function should be used instead of redux's connect. The redux actions that should affect state should be listed to ensure that only when/if joystick(s) are showing/in-use do we affect Redux/UI state.