Giter Club home page Giter Club logo

aframe-gamepad-controls's Introduction

Hi there πŸ‘‹

In 2D and 3D graphics ecosystems on the web β€” like three.js, React Three Fiber, and A-Frame β€”Β my work lets developers be more productive, makes engines faster and more powerful, and enables artists to enjoy creative and flexible art workflows. If my work is helpful to you, please consider sponsoring me. For technical support, please see my current availability. Thank you!

aframe-gamepad-controls's People

Contributors

andygill avatar donmccurdy avatar rspace avatar

Stargazers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

Watchers

 avatar  avatar  avatar  avatar  avatar  avatar  avatar  avatar

aframe-gamepad-controls's Issues

Request for THIS feature to simulate an onClick event with gamepad-controls in A-Frame.

Because I could not trigger an onClick event with 'gamepadbuttondown:8' from the gamepad controller,
I have the built a work-around that should be easy to implement in the next version of gamepad-controls.

Using a simple lightswitch as an example: https://jsfiddle.net/RonK/vm81ddn7/8/

The onClick event in the is set to onClick="SetSubjectOfFocus('lightswitch')";
This way clicking on the switch object with a normal mouse click sets the object to be effected,
And a fusion-cursor event also sets it, without it being triggered.

Event-listeners are added:
Classroom.addEventListener('gamepadbuttondown:8', function () {
ClickFunctionList('gp8');
});
Classroom.addEventListener('gamepadbuttondown:0', function () {
ClickFunctionList('gp0');
});
Classroom.addEventListener('mouseup', function () {
ClickFunctionList('msu');
});
Classroom.addEventListener('touchend', function () {
ClickFunctionList('tche');
});
Classroom.addEventListener('click', function () {
ClickFunctionList('clk');
});

Each event-listener passes on a nametag for itself in the arguments so that the actual triggering events
can have separate functions enabled in the ClickFunctionList().

        //if gamepad is present (GPP=true or false)
function ClickFunctionList(TriggeredBy){
	if(SubjectOfFocus=='light switch' && TriggeredBy=='gp0'){LightToggle();}
	if(SubjectOfFocus=='light switch' && TriggeredBy=='clk' && GPP==false){LightToggle();}
	if(SubjectOfFocus=='light switch' && TriggeredBy=='tche'){LightToggle();}
	if(SubjectOfFocus=='light switch' && TriggeredBy=='gp8'){SearchSay(LsnVoc,0,'light switch');}
}

Clicking with a mouse works, and touch events on a phone or tablet work.
Clicking with a gamecontroler works.

Adding var GPP will allow you to get different results:
GPP==false: lets cursor-fusion click and trigger the lightswitch if wearing phone in a HMD.
GPP==true: keeps cursor-fusion from activating switch at a glance, requiring a controler-click.

--

If implemented as part of "gamepad-controls", it could absorb the ClickFunctionList invisable to the user.

It could either use the "this" feature in javascript to identify each event (but would require raycaster?)
Or, at runtime the controller.js could use QuerySelector to search the objects in the scene for:
"OnButton1" or similar markers, identifying:
and setting the: if(SubjectOfFocus=='light switch' && TriggeredBy=='gp1'){LightToggle();}
all by itself.

Clicks through entities

Hi,
I am using Windows 10 and Edge 41.16299.371.0 for testing this component (version 0.6.0)

I have a setup in aframe where I have a small box and another bigger box behind the smaller. I am using cursor for pointing. When I point cursor at any box and click, their color changes. The problem is that when I click on small box using my Red Gear gamepad, its and the color of bigger box changes at same time. It means the cursor is able to click through the smaller box when clicking using gamepad. This does not happen when I click using my mouse.
Thanks, if I am missing any detail or not clear please let me know.

invertedEnabled flag

Some old-timers like myself like to play controller games with the lookVector.y reversed. I'll send a pull request after I've tested my changes. I propose adding

invertedEnabled:   { default: false },

to the schema, and the line

if (this.data.invertedEnabled) lookVector.y = -lookVector.y;

just after lookVector is updated.

Gamepad works but still shows error: Gamepad #0 not found. Connect controller and press any button to continue.

Hi. Thanks a lot for this component.
I am using Windows 10 and Edge 41.16299.371.0 for testing this component (version 0.6.0)
My gamepad Red Gear works fine (can move around and click) but I am still getting this error in console:

Gamepad #0 not found. Connect controller and press any button to continue.

Besides this there is nothing harmful about this component in this case. Thanks again

Enhacement proposal for enabling proxying of controls over websockets

I recently did a test to stream controls from a host machine to a client over websockets. The latencies I faced on a local network where acceptable and I was able to implement the WASD -controls over websockets using Socket.io running on a simple Node.js server.

My goal is to achieve a platform independent solution for connecting gamepads to webvr/A-Frame -based content. Any interest in an implementation towards this approach? Suggestions?

Controls from all gamepads

Hi ! Thanks for this great project !

As I understand it, currently we can use controls from only one source, chosen by the controller attribute. Would there be a way to indicate that we want the controls to be read from all the controllers?

Thanks !

Update: I currently treated the case by adding multiple=true; in the component and then called gamepad-controls multiple times:

gamepad-controls__0="controller:0;flyEnabled: true;"
gamepad-controls__1="controller:1;flyEnabled: true;"
gamepad-controls__2="controller:2;flyEnabled: true;"
gamepad-controls__3="controller:3;flyEnabled: true;"

Aframe reference:
https://aframe.io/docs/0.7.0/core/component.html#multiple

Demo Enhancements

I want to make the demo more useful for testing gamepad/browser compatibility.

Add now:

  • Live stream of buttons pressed, overlaying the screen (and disappearing after 2-3 seconds).
  • Green/red indicator lit up if a gamepad has been detected.
  • Indicate whether browser supports the Gamepad API.

Add once proxy-controls are functional

  • Indicate whether browser supports WebRTC.
  • Indicate whether browser supports WebSockets.
  • Indicate whether proxy-controls has an active connection.

How can I detect whether a gamepad is connected or not using this component?

Hi,
I am using 0.6.0 version of this component and I am testing it on Windows 10 and Edge 41.16299.371.0 using Red Gear.
I went through README.md and couldn't find a method or someway this component provides using which I can detect whether a gamepad is connected or not. Is there something I am missing? or do I have to use navigator.getGamepads() for this purpose?
Thanks.

Standard gamepad buttons should be referenced by constants

Users should not need to know which button index (0-16) matches a given button on their gamepad.

Proposed implementation:

AFRAME.GamepadControls.GamepadButtons = {
  FACE_1: 0,
  FACE_2: 1,
  FACE_3: 2,
  FACE_4: 3,
  // ...
  R_SHOULDER_1: 7,
  // ... see https://mozvr.github.io/gamepad-plus/
};
var Buttons = AFRAME.GamepadControls.GamepadButtons;

if (gamepadControls.getButton(Buttons.R_SHOULDER_1).pressed) {
  this.el.emit('fire-the-missiles');
}

when HMD of Windows Mixed Reality is connected, cannot do rotation by gamepad's joystick

Hi,
I have been testing this component a lot recently, you must know from previous issues :-)
I am using Windows 10 and Edge 41.16299.371.0 for testing this component (version 0.6.0) along with HP's Window Mixed Reality HMD.
I wanted to confirm a behavior: when HMD of Windows Mixed Reality is connected, cannot do rotation by gamepad's joystick. Of course this is desired behavior for users. My question is: Is it expected behavior of this component? can I rely on this behavior reliably?
Thanks a lot for this component, very useful.

Button mapping issues with SNES-like controller.

Various issues with SNES-like (dpad only) controllers, and button mappings.

Chrome, OS X:

Feature Status
Dpad ok
GamepadButton.FACE_1-4 In the wrong order. Perhaps reversed?

Chrome, Android:

Feature Status
Dpad Not recognized.
GamepadButton.FACE_1-4 ok

Firefox, Android:

Feature Status
Dpad ok
GamepadButton.FACE_1-4 ok

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.