Add more inputs?

im just exploring at the moment, looking at my options - i want to make a tiny little game, but the kind of game i want requires more inputs. i want to make a tiny twin-stick shooter.
obviously it wont work if i wanted to share it with others, but thats doesnt bother me.
is it at all possible to have more button inputs, or analog input?

You could use player 2 buttons but it only works for computers

There are combos too

so there’s no way to add more inputs, even through editing config or source files?

I do not know anything about source file though

On hardware, you can only use button combos if you don’t want to wire anything up. If you want to, you could wire some buttons up and connect them to the pins and read them in software.

If you are going to play using the computer only, you can use player 2’s controls. Press the keyboard button under the simulator while it’s running to see the keys requires to press.

oh!! so it is possible to add more buttons?
ive been trying to read up on the documentation, but i cant find anything that explicitly states i can add more inputs, or how i would even access those inputs;
is it just a matter of defining more GPIO pins as buttons, and then calling those extra buttons in javascript?
like this?



i also see controller.dx, is this for analog input? i can see there’s support for an accelerometer, does that mean MakeCode Arcade can do analog input?
im a fairly technical person, but programming is not my strong suit, and neither is learning new things, so im just having a bit of trouble finding where and how to do the things i want to do :sweat_smile:

controller.dx and controllee.dy should be analog.

For the hardware buttons, you would just define the inputs, and read them in a loop. I don’t really use them that much, but o think there should be events for it. Look in for examples.

And yes, on some hardware, there is support for the accelerometer.

If you add the controller extension to your project, you should get some accelerometer blocks as well as some other random sensors.


Or you can use the keyboard extension and use it with your hardware device.

Yep @CyberPulse, that’s three main choices, 2P controls (PC only, no hardware), Manually wiring new numbers (hardware only) or using the keyboard extension (PC and hardware). I think I know which option is the best, but that’s a choice for you.

If you need four control axes, I think using 2P controls on PC emulator and stick+accelerometer on hardware is worth exploring. It may not be a good fit for a twin-stick shooter though.

One warning - last I checked, reading accelerometer inputs activates an emulated mode that makes other inputs on the Android emulator difficult to use, so you may want to make that a configurable option.

Is there a supported way to feature detect an actual accelerometer to distinguish it from emulation? Based on How can I access the name of my program? - #8 by mmoskal, maybe along the lines of control.getConfigValue(DAL.CFG_ACCELEROMETER_TYPE, 0) ?