scratchfoundation / scratch-vm

Virtual Machine used to represent, run, and maintain the state of programs for Scratch 3.0
http://scratchfoundation.github.io/scratch-vm/
BSD 3-Clause "New" or "Revised" License
1.2k stars 1.5k forks source link

Extension request: Controllers (joysticks) #2128

Open Kenny2github opened 5 years ago

Kenny2github commented 5 years ago

Rationale

Many projects (such as platformers, shooters, or rhythm games) would benefit from using game controller inputs.

Proposal

Here is a rough draft of a set of blocks that could make use of controllers, mostly based off of Pygame's "joystick" framework.

benjiwheeler commented 5 years ago

Do you know any examples of websites that currently take analog controller input? Could be interesting to see how they're doing it. It's unclear to me exactly how that input would appear to the browser; as opposed to binary keypresses, which can just work like keyboard presses.

Kenny2github commented 5 years ago

There's a JavaScript Gamepad API which in retrospect I should have based my proposal off of.

This website is a good sandbox for what controllers report what values.

griffpatch commented 5 years ago

Some kind of touch input control would be very welcome, supporting multi touch for game pad style input.

On Sun, 21 Apr 2019, 06:03 Ken, notifications@github.com wrote:

There's a JavaScript Gamepad API https://developer.mozilla.org/en-US/docs/Web/API/Gamepad_API which in retrospect I should have based my proposal off of.

This https://html5gamepad.com/ website is a good sandbox for what controllers report what values.

— You are receiving this because you are subscribed to this thread. Reply to this email directly, view it on GitHub https://github.com/LLK/scratch-vm/issues/2128#issuecomment-485225175, or mute the thread https://github.com/notifications/unsubscribe-auth/ABTM3PVPGSL3HZSYTPEFDK3PRPYQVANCNFSM4HHI7ZJA .

apple502j commented 5 years ago

@Kenny2github Safari is not on the list so it's hard to implement.

eqot commented 5 years ago

According to Can I use, Gamepad API has been supported by Safari as well. I just verified an example at the website that DualShock4 works in Safari as expected including analog inputs.

Regelink commented 2 years ago

This fork of scratch-vm implements a gamepad extension. You can test it here. After adding the extension, I was able to use one gamepad.