extensions icon indicating copy to clipboard operation
extensions copied to clipboard

A sensor extension

Open DNin01 opened this issue 1 year ago • 3 comments

Sometimes you want to make games or interactive elements that respond to input other than mouse, keyboard, or touch, and for this, it could be really cool to have an extension that can read various sensors of the device, such as the accelerometer or gyroscope.

We could implement anything that is offered by the Sensor APIs.

Sensing Plus has a block to get accelerometer/gyroscope data but it also has a bunch of other blocks that I don't necessarily want to have to import along. Plus, a dedicated extension would probably be programmed better as sensor access would be the whole point of it.

DNin01 avatar Apr 30 '24 01:04 DNin01

We could also use device orientation events, which are more widely supported.

Keep in mind that the behavior may differ between browsers.

Note that Safari for macOS supports these APIs since version 17, but Safari for iOS has supported them since version 4.2, released in 2010. On that note, seeing that people are probably going to be making mostly mobile games in TurboWarp that utilize these features, we may not even want a motion sensing extension to work on computers.

DNin01 avatar May 02 '24 23:05 DNin01

Some of you developers might like to try https://sensor-js.xyz/demo.html on your mobile devices to test out the features.

DNin01 avatar May 05 '24 03:05 DNin01

I made this https://github.com/Xeltalliv/extensions/blob/generic-sensors/extensions/Vadik1/generic-sensors.js over a year ago, but haven't submitted to any extension gallery

Xeltalliv avatar May 05 '24 16:05 Xeltalliv

Hi, I don't know if I should post this here, but I'm having trouble getting the values for the gyroscope and accelerometer sensors with the sensing+ extension and the generic sensors extension that was posted here. However, in https://sensor-js.xyz/demo.html I am getting the values, I have already tested on two phones.

JuanJose2325 avatar Jan 06 '25 17:01 JuanJose2325

Hi, I don't know if I should post this here, but I'm having trouble getting the values for the gyroscope and accelerometer sensors with the sensing+ extension and the generic sensors extension that was posted here. However, in https://sensor-js.xyz/demo.html I am getting the values, I have already tested on two phones.

Yeah, Sensing+ implements it in a finicky way, I guess. That's the nature of trying to do so many things in the same extension...

DNin01 avatar Jan 06 '25 22:01 DNin01