Example

Touchscreen And Gamepad At The Same Time

5

SP4CEBAR 2023-02-18 10:43 (Edited)

412Lop recently discovered that
POKE $FF76,%11
Turns on both gamepad 1 player and gamepad 2 players which resulted in a messed-up looking gamepad (on mobile)

This inspired me to turn on both gamepad 2 players and touchscreen
POKE $FF76,%1001

This is going to be very handy because the touchscreen doesn't allow multiple inputs at the same time, the gamepad does, if you have a game you don't have to choose between touchscreen and gamepad anymore, you can just turn them both on

PC controls

Edit: POKE $FF76,%1010 gives you two gamepad and touchscreen
POKE $FF76,%1011 gives you the messed up gamepad and touchscreen
The following text is untrue, I interpreted my binary numbers in the wrong direction, it works fine:

For some reason, doing both at the same time:  
POKE $FF76,%1101  
Doesn't work and turns on the keyboard instead of the gamepad as if it were:  
POKE $FF76,%0011  

And gamepad 2 players and touchscreen also doesn't work
POKE $FF76,%0101
It turns on the keyboard instead of touchscreen  


SP4CEBAR 2023-02-18 14:56

you can use the mobile d-pad and the touchscreen at the same time


Ericisonit 2023-02-18 19:06

yeah i guess the only thing that's unexpected in LowResNX's behavior here is that if you poke to $ff76 for the FIRST time and you're setting bits 0 and 3, it doesn't give any error; so the input registers will reflect both touch and gamepad input. once the value at $ff76 has been changed to something where bit 0 or bit 3 are set, you can't change it. by default no input is enabled, then once touchpad or gamepad is enabled, you can't disable them or switch between them. and the keyboard will always trump the gamepad when trying to set both. (this is because depending on the device and configuration, e.g. on a PC with no joystick plugged in, the physical keyboard is used for both keyboard and gamepad input, so turning on both at the same time would have unpredictable results.)

this kind of shows how the IO behaves depending on the initial value $ff76 is set to:

_GAMEPAD1 = %00000001
_GAMEPAD2 = %00000010
_KEYBOARD = %00000100
_TOUCHSCR = %00001000
' SET _IO TO ANY BITWISE COMBINATION
' OF THESE FLAGS, RUN, AND TRY ANY IO
' TO SEE ITS EFFECTS ON THE REGISTERS
_IO = _TOUCHSCR OR _KEYBOARD OR _GAMEPAD1

POKE $FF76,_IO

DO
CALL SHOWIO
WAIT VBL
LOOP

SUB SHOWIO
LOCATE 0,0
FOR I=$FF70 TO $FF76
PRINT HEX$(I,4);": ";BIN$(PEEK(I),8)
NEXT I
END SUB


so if you're careful not to let $ff76 change, you can indeed use gamepad and touchscreen simultaneously, which could be of use


SP4CEBAR 2023-02-18 22:00 (Edited)

interpreted my binary numbers in the wrong direction that's why the keyboard popped up unexpectedly, it works fine:
POKE $FF76,%1010 gives you two gamepads and touchscreen
POKE $FF76,%1011 gives you the messed up gamepad and touchscreen


was8bit 2023-02-19 06:16

I “think” the reason why Timo limited it to one or the other was issues with the keyboard controls... have you tested this in the windows version???


SP4CEBAR 2023-02-19 09:11 (Edited)

I have and it works: you can click the screen and use the buttons at the same time


was8bit 2023-02-21 12:45

Cool


Log in to reply.