Input test kit | Register simultaneous button presses


JSON File: (3.3 KB)

Just finished with another experiment. I wanted to get Pulp to register a simultaneous press of the A and B buttons as something distinct from pressing them individually, a "third button" if you will. I wasn't sure how to to get good feedback on if it was working or not in my game, so I started a new instance and whipped up a test kit.

The test kit

It's more lightweight than Benji's gorgeous Input Tester but I think it might be more capable of giving feedback on forms of input that aren't explicitly supported by the syntax. I've only used it to work out A/B inputs, but if others are interested, I think there's a lot of potential in exploring the repeat configuration options for the D pad.

All it does is play a wave animation on the specified row when it registers the set input (as defined by your code). You call the animation with the following two lines:

wireY = 6
call "closeCircuit"

A + B button press

Now that I have a testing tool, we get to what I did with it. It's all in the JSON file if you want to take a peek, but the meat of it is the following in the Player tile:

on confirm do //check if the A button has been pressed
	ifConfirm = 1

on cancel do //check if the B button has been pressed
	ifCancel = 1

on draw do
	// Simultaneous button press handler
	if ifConfirm==1 then // if Confirm has been pressed
		if ifCancel==1 then // and Cancel has been pressed
			//do something
			ifConfirm = 0 //reset variables
			ifCancel = 0
		else // if ONLY Confirm has been pressed
			//do something else
			ifConfirm = 0 //reset variable
	elseif ifCancel==1 then // if ONLY Cancel has been pressed
		//do yet a different thing
		ifCancel = 0 //reset variable

By setting the Confirm and Cancel functions to only check if the button had been pressed and passing the actual handling of that input to the draw function occurring once every loop I was able to introduce conditionals based on both. In my test kit, I had the "do a thing" comments replaced with calls to the closeCircuit function which allowed me to confirm that the whole thing was working as intended pretty quickly.

Give it a try!