pokerogue icon indicating copy to clipboard operation
pokerogue copied to clipboard

Menu - Gamepad/Keyboard menu

Open Greenlamp2 opened this issue 9 months ago • 24 comments

First iteration of the gamepad menu, for now, there is only the 2 "old" gamepad related entry + the new default gamepad selection.

I don't know if you prefer multiple small working PR with features added in this menu or if you want a big PR with all the gamepad related feature i'd like to implement:

  • Gamepad selection
  • Gamepad rebinding
  • Activate/Deactivate turbo (holding a button to repeat the input)
  • [... will maybe have more idea later ...]

image

screen-capture (1).webm

I've added some hidden mecanism like:

  • There is 2 gamepad, we are using the gamepad2 as the chosen gamepad. if we reload, this is still this gamepad that will be used.

  • There is 2 gamepad, we are using the gamepad2 as the chosen gamepad. if we disconnect the gamepad2, it fallback automatically to the gamepad1

  • There is no gamepad, we plug a new gamepad, at the very first button pressed, this gamepad will be the new chosen gamepad

  • on any event from the gamepads, the list of gamepads in the menu is updated

  • on any event from the gamepads, the chosen gamepad in the menu is updated

  • It's not yet there, but the way it's coded, will allow to have custom binding based on the chosen gamepad

Greenlamp2 avatar May 09 '24 15:05 Greenlamp2

[Main post updated]

What about mobile controls ? if you mean a tab dedicated to it, yes it's possible, if you mean rebinding the touch control, the issue is that the touch control, as it's coded for the moment is a virtual keyboard, we assign a touch event to a key from the keyboard.

in this v1, i'll just do the rebinding of the gamepad, but when it's done, i'm sure it will be easy to adapt the code to the keyboard, and thus, iterate on the mobile version.

Greenlamp2 avatar May 09 '24 15:05 Greenlamp2

and if the worry was about the renaming in the enum of cycle_shiny and cycle_form, don't worry, there is no visual changed image

Greenlamp2 avatar May 09 '24 15:05 Greenlamp2

UI/UX is not always the easiest thing ahah but i progress !

image

Greenlamp2 avatar May 10 '24 13:05 Greenlamp2

image

Greenlamp2 avatar May 10 '24 23:05 Greenlamp2

image

Greenlamp2 avatar May 11 '24 12:05 Greenlamp2

V1 of the key remapping is working !

Greenlamp2 avatar May 11 '24 16:05 Greenlamp2

Gamepad menu is done. the code need some cleanup/refactor/renaming though

Greenlamp2 avatar May 11 '24 23:05 Greenlamp2

Screenshot 2024-05-12 at 21 04 08

Greenlamp2 avatar May 12 '24 19:05 Greenlamp2

image

Greenlamp2 avatar May 13 '24 22:05 Greenlamp2

I've added a lot of test case to be sure everything works fine. maybe there will be more case i did not handle, manual test will be needed so i can replicate them in the unit test.

on the keyboard mapping, you can press DELETE to remove a binding

Greenlamp2 avatar May 14 '24 17:05 Greenlamp2

It's LB & RB to navigate in the manu tabs, F & R by default with keyboard

Greenlamp2 avatar May 14 '24 17:05 Greenlamp2

there is not yet an image to say "No button assigned" so for now, it displays 0

Greenlamp2 avatar May 14 '24 17:05 Greenlamp2

in your tests, if you mess with the mapping: delete in your local storage:

  • customKeyboardMappings for keyboard mapping
  • customMapping for gamepad mapping

Greenlamp2 avatar May 14 '24 17:05 Greenlamp2

you can test here: https://pokerogue.greenlamp.ovh/

username: test password: testtest

Greenlamp2 avatar May 14 '24 17:05 Greenlamp2

on mobile, i've displayed the buttons we had in the starter selection since it's needed to navigate in the menu image

Greenlamp2 avatar May 16 '24 10:05 Greenlamp2

TODO:

  • ~~use the button action to change a bind instead of the button right~~
  • ~~rework the swap to just delete the button source instead of asking to swap both buttons~~
  • ~~add a button to "reset to default"~~
  • ~~prevent the rebind of the main keys like the arrows, escape and enter~~
  • ~~prevent the deletion of the last bind of an action~~
  • ~~display the alt button as an icon if the main bind has been deleted~~
  • ~~add Actions UI to know how to reset & delete~~

Greenlamp2 avatar May 16 '24 20:05 Greenlamp2

test instance: https://pokerogue.greenlamp.ovh/

Greenlamp2 avatar May 17 '24 13:05 Greenlamp2

image

Greenlamp2 avatar May 17 '24 14:05 Greenlamp2

image

Greenlamp2 avatar May 17 '24 15:05 Greenlamp2

TODO:

  • ~~fix the cursor glitch when we scroll + delete~~

Greenlamp2 avatar May 19 '24 01:05 Greenlamp2

Closing this PR to create a cleaner one.

Greenlamp2 avatar May 21 '24 12:05 Greenlamp2