Skip to content

A web plugin for the Flutter package "gamepads". Should be considered experimental.

License

Notifications You must be signed in to change notification settings

markvideon/gamepads_web

Folders and files

NameName
Last commit message
Last commit date

Latest commit

 

History

5 Commits
 
 
 
 
 
 
 
 
 
 
 
 

Repository files navigation

gamepads_web

Experimental web implementation of the gamepads package for Flutter. This project is currently on hold. See: flame-engine/gamepads#32.

Getting Started

This plugin is structured to assume the presence of a web worker (as below). The web worker file should be present at the root of your project's web folder. The web worker thread cannot access input APIs, so here it is used only to create a messaging loop.

const millisBetweenChecks = 17;
var checkForInput = true;

addEventListener("message", (event) => {
    switch (event.data) {
        case "STOP":
            stop();
            break;
        case "START":
            start();
            break;
        default:
            break;
    }
});

function callback() {
    if (checkForInput) {
        postMessage("PING");
        setTimeout(callback, millisBetweenChecks);
    }
}

function start() {
    callback();
}

function stop() {
    checkForInput = false;
}

About

A web plugin for the Flutter package "gamepads". Should be considered experimental.

Resources

License

Stars

Watchers

Forks

Releases

No releases published

Packages

No packages published

Languages