Willard21 / MineKhan

Minecraft for Khan Academy
79 stars 53 forks source link

Xbox One Controller support #74

Open ImaginaryNeon opened 2 years ago

ImaginaryNeon commented 2 years ago

Bottom Text

Willard21 commented 2 years ago

I don't own any Bluetooth controllers, so I have no way of working on this. It's definitely something I'd be interested in adding though.

ImaginaryNeon commented 2 years ago

If you have an Xbox 1 controller, you can plug it in btw

Willard21 commented 2 years ago

I have nothing but PS2 and wireless Xbox 360 controllers.

Elite230 commented 2 years ago

Yes, but then your code must be able to find a way of connecting to the controller, + on different operating systems it is different, and not all of us use windows (I don't, using Linux Ubuntu 20.04).

Willard21 commented 2 years ago

It doesn't matter what operating system you use. That's the whole point of the web. I'm on Ubuntu 20.04 too. https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API/Using_the_Gamepad_API has a tutorial. All I'd really need to do is map the controls and add a cursor for the menus, plus a few lines for connecting. But again, I have no way of testing, and trying to code without being able to run the code is futile lol

sauron65 commented 2 years ago

if it connects to something like this then you can use it. but I don't know much about PlayStation or Xbox controllers (even though I have an Xbox controller (don't know if it's Xbox 1, just says "Xbox Wireless controller") that I bought mostly just for use with the Gamepad API)

Willard21 commented 2 years ago

Well the PS2 was released in the year 2000, so it definitely isn't compatible with any computers. Xbox 360 was released in 2005, and their wireless controllers use a "proprietary 2.4 GHz protocol", meaning they won't connect directly to a computer. That's the same frequency as wifi, so it might theoretically be able to connect to the wifi adapter if you had the right drivers, but seeing as I'm already using those adapters to connect to the internet, there's no chance.

Mist-Pompano commented 2 years ago

Hello Willard!

I could beta test this feature due to the fact that I own an Xbox One controller. Even though the one I have is from 2014-ish, it will be able to work with a micro-USB --> USB connector. I think you have seen already that the Mozilla documentation does have a thing or two about Gamepad API and libraries that you can incorporate.

To be fair, I do own Mac and Windows machines, my Mac running on macOS Monterey and my Windows PC running on standard Windows 10.

Just a little inquiry I had, is there any difference between how the Gamepad API is received on Unix-like systems or does it react the same throughout all OS's, whether or not they are Unix-based.

PS4 controllers are a little finicky to connect to a PC, while newer Xbox Controllers (Mine is old, so it doesn't have this feature) will be able to tether to Windows Bluetooth automatically, the only action needed is syncing it using the sync button. I am not sure whether Mozilla and JS environments in general will be finicky towards non-OS based gamepads, but taught is just a matter of testing :)

Hope I didn't barge in completely, but I am a member of KACC so I would be happy to help with anything y'all need lol

Willard21 commented 2 years ago

Yeeeah that wouldn't work. I typically run code dozens of times to figure out what works, print objects to console to explore what values are stored, etc., none of which is possible if I can't run my own code. Having someone else do it would turn 30 minutes of coding into like 12 hours.

harsha7addanki commented 1 year ago

i mean could you show the movement lines maybe someone with a controller like me could try and add support

harsha7addanki commented 1 year ago

I Just Checked They Willard Does Movement And Key Presses woud make it pacticly imposible to have both controller and keyy board support

harsha7addanki commented 4 months ago

I suggest we close this issue and leave it to when we have modding support