Allow input repeating on A and B buttons

  1. Describe your reason for requesting this feature. What problems are you running into?

I want to add a mechanic where the player holds the A button and an action occurs when they release it. I understand that Pulp doesn't expose input pressed/released events, but I can work around that using the existing functionality and event.frame to count time. Unfortunately, config.inputRepeat only enabled input repeating on udlr as seen in the runtime here:

	if ( LuaTrue( acceptsInput ) ) {
		if ( LuaTrue( justRepeated(Button.UP) ) ) {
			playerMove(0,-1)
		} else if ( LuaTrue( justRepeated(Button.DOWN) ) ) {
			playerMove(0,1)
		} else if ( LuaTrue( justRepeated(Button.LEFT) ) ) {
			playerMove(-1,0)
		} else if ( LuaTrue( justRepeated(Button.RIGHT) ) ) {
			playerMove(1,0)
		}
	
		if ( LuaTrue( justPressed(Button.A) ) ) {
			buttonPressed('confirm')
		}
		if ( LuaTrue( justPressed(Button.B) ) ) {
			buttonPressed('cancel')
		}
	
		if ( LuaTrue( crankAngle.relative!==0 ) ) {
			cranked()
		}
	}

I understand repeating A/B button presses could lead to confusing behavior (like interacting with a sprite multiple times, or skipping through dialog) so maybe it could be behind a separate flag like config.inputButtonRepeat?

  1. How would this request improve your experience with using Pulp?

I would be able to build the mechanic I want.

  1. Include any other details you have relating to this request.

N/A

5 Likes

I would like to propose an alternative to this, which is that as well as the confirm and cancel events triggering when the buttons are pressed, an event variable is also set that tracks whether or not a button is currently held down at any frame.

For example, if you're holding down the confirm button, event.confirmDown would be 1, else it would be 0, and this would update every frame to represent the state of the button. Using this, one could emit an event only when the confirm button is released using the following snippet:

on draw do
  if event.confirmDown==1 then
    holdingConfirm = 1
  elseif holdingConfirm==1 then
    emit "buttonReleased"
    holdingConfirm = 0
  end
end

While it is currently possible to do this by counting frames with the dpad, it might be useful to provide this feature for those buttons too, as it would make programming simple experiences that require holding buttons much easier.

bump. would really love any way to interface with A or B being held down

2 Likes

I think a way to detect held button presses would be a HUGE benefit and open up a lot more possibilities in Pulp game development