Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Use this library to control an external device? #6

Open
jharris1993 opened this issue May 2, 2020 · 1 comment
Open

Use this library to control an external device? #6

jharris1993 opened this issue May 2, 2020 · 1 comment

Comments

@jharris1993
Copy link

Greetings and I hope this finds you safe and well.

My application is a robotic device, (Dexter Industries GoPiGo), that has some example project code that allows you to "drive the robot around" using a virtual joystick, (nipple.js), controlled by your mouse or touchscreen.

The way it works is that when you do something with the mouse in the window that nipple.js is running in, it fires off data to the host/server system, (the robot), via a POST message from the browser.

However, it does this in a very complicated way because it also shows a "nipple" on the screen, (which fades in and out, and is animated based on how you move your mouse or finger), as it is primarily intended for touch-screen applications. The "nipple" graphic shows it has detected the touch and shows how you are moving with respect to that touch.

I have researched using a real joystick in a browser based application, but everything I find assumes that you are developing a browser-based game and all the logic and events are contained within the browser instance the game is running within.

I, myself, don't care about game frame loops, or frame-rates, or anything like that. All I need is for the script to detect the presence of a game controller and fire off events when the controller does something.

My questions for you, if I may:

  1. Do you know of a JavaScript library that will do what I want.
  2. Assuming that this does not exist, what would be the best way to send joystick axis/button events to the host server using your application?

Thanks again for all your help!

Jim "JR"

@ArunMichaelDsouza
Copy link
Owner

Hi @jharris1993,
I am well, thank you. Hope the same for you.

As long as the browser is involved and there is a need to use a gamepad with it, joypad.js can work well. It can detect the presence of a gamepad in the browser (since it's built on top of the web gamepad API) and can fire off events when the user performs an action (button press or axis movement).

You can use something like socket.io to publish real-time gamepad event data to the host server. Hope that helps!

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants