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

controllerly

v0.0.3

Published

Optimized Smartphone Gamepad Enabling Your Local Multiplayer Games.

Downloads

11

Readme

npm version Build Status dependencies Status devDependencies Status NPM

Controllerly

Optimized Smartphone Gamepad Enabling Your Local Multiplayer Games.

Easy integration into your new and existing games.

Add to HTML

<script src="https://cdn.jsdelivr.net/npm/controllerly@latest">
    // Controllery is exposed as a global variable
    console.log(Controllerly.version);
    // you can map certain gamepad keys to keyboard events
    Controllerly.putKeyboardMapping(0, { // '0' is the first controller
        left: 'A',
        right: 'D',
        start: 'ENTER',
        a: 'Q',
        b: 'W'
    });
    // preview the connection code with an alert
    // the alert dismisses automatically if a client connects
    Controllerly.showConnectionCodeAlert();
</script>

You can also directly map to the native WebGamepad API. However, you should not provide keyboard mappings and use the GamepadAPI at the same time.

// map onto native Gamepad API
Controllerly.enableGamepadAPI();

Install via npm

For a direct game integration you can add Controllerly directly to your project or game.

npm install controllerly

Use with Typescript

// import Controllerly instance
// the same instance is available globally
import Controllerly from 'controllerly';

Gamepad Layout Templates

Use unique gamepad layouts that fit your game or project.

Controllerly.changeLayout('classic');

Layouts define ids for the input controls like buttons. For the classic layout they are:

left, right
start, select
a, b

TODO insert pic

The left and right area are the major areas. On small devices the user has the option to hide the center (green). He then has to open the center through an extra button.

Using Advanced Input Events

To get the most out of your smartphone controlled gamepad, Controllerly provides the option to react to double taps or swipes.

You have the following options:

// taps
tap (default)
doubleTap
longPress

// swipes
swipeUp
swipeLeft
swipeRight
swipeDown

In your code you can then listen by writing

Controllerly.on('b_doubleTap');

If you map keyboard events you extend the button name with the input action.

Controllerly.putKeyboardMapping(0, {
    left_tap: 'A',
    right_doubleTap: 'D',
    start_longPress: 'ENTER',
    a: 'E',
    a_swipeUp: 'Q'
});

FAQ

How do I create my own Controllerly instance?

// if you prefer creating your own instance use
import { ControllerlyAPI } from 'controllerly/lib/Controllerly';
let controllerly = new ControllerlyAPI();
// however, this is not recommended because Controllerly creates
// one new WebRTC connection for each instance

Three Controllerly Packages

The project addresses three main concerns regarding remote smartphone gamepads through WebRTC:

Controllerly Packages

Server

Core

Client