shroudedcode / contro Goto Github PK
View Code? Open in Web Editor NEW:video_game: Game controls done right.
Home Page: https://npm.im/contro
License: MIT License
:video_game: Game controls done right.
Home Page: https://npm.im/contro
License: MIT License
While on an Xbox controller the action buttons are called A, B, C, and D, on a PlayStation controller the action buttons are symbols (circle, square, ...). Contro should detect that and display the appropriate label.
These mappings might help.
When a gamepad is connected, Contro should check whether it supports the standard
mapping defined by W3C and only accept it if it does.
my device:
OnePlus 3
Android 8.0.0
Chrome browser
gamepad: XBox controller.
here's the code. It is alerting 'a' in desktop chrome but not on mobile. I verified my gamepad is connected using https://html5gamepad.com/
const { Mouse, Keyboard, Gamepad, or, and } = Contro;
const gamepad = new Gamepad();
const controls = {
a: gamepad.button('a').trigger,
b: gamepad.button('b').trigger,
left: gamepad.button('left').trigger
}
function gameLoop() {
// Query the controls and do something
if (controls.a.query()) {
console.log('a');
alert('a')
}
if (controls.b.query()) {
console.log('b');
}
if (controls.left.query()) {
console.log('left')
alert('left')
}
requestAnimationFrame(gameLoop)
}
requestAnimationFrame(gameLoop)
Many game libraries (like Three.js) have their own 2D vector implementation. Contro should allow developers to use the implementation they like.
for using contro without game loops it might come in handy
please provide the d.ts as part of the release?
Hey it's possible to add detection of more gamepads?
The docs says buttons and sticks can be queried
gamepad.button('A').query()
gamepad.stick('left').query()
but sticks can't, the stick function returns the vector object
gamepad.stick('left')
I've attempted to use the demo with my 8bitdo wireless controller. It doesn't appear to recognize the connection. The button labels don't change when connected, nor do they respond to input from the gamepad. I've tried this on bluetooth and USB using Windows 10, Chrome.
I hate to open an issue for something basic, but I do see input working with the controller using this: https://html5gamepad.com/
Looking at your code, it uses most of the same stuff.
Hi,
I really like this lib, nice work!
I propose an addition to the API/doc - a way to add custom inputs.
This is useful for when having the same game played on mobile.
Hello, whenever I do gamepad.stick("left").query()
I get this error: Uncaught (in promise) TypeError: Cannot read property 'timestamp' of undefined
Why?
Hello, thanks for a great library and extensive tests! I have been using it to allow blind people to play video games with a gamepad.
I ran into a few limitations and after a failed attempt to add some of them to contro
, I ended up writing some code that is similar to contro
but has the following features:
standard
layout
I was not sure if some of those were problems others have run into and if you would be interested in a Pull Request to contro
with those changes. If you are interested, I can create one and add tests.
Also, here is the README for the code.
Again, thanks for such an elegant library!
refs #2
Please, can you add a vibration system for the gamepads?
A declarative, efficient, and flexible JavaScript library for building user interfaces.
๐ Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.
TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
An Open Source Machine Learning Framework for Everyone
The Web framework for perfectionists with deadlines.
A PHP framework for web artisans
Bring data to life with SVG, Canvas and HTML. ๐๐๐
JavaScript (JS) is a lightweight interpreted programming language with first-class functions.
Some thing interesting about web. New door for the world.
A server is a program made to process requests and deliver data to clients.
Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.
Some thing interesting about visualization, use data art
Some thing interesting about game, make everyone happy.
We are working to build community through open source technology. NB: members must have two-factor auth.
Open source projects and samples from Microsoft.
Google โค๏ธ Open Source for everyone.
Alibaba Open Source for everyone
Data-Driven Documents codes.
China tencent open source team.