Button Matrix Alternative and Navigate Objects with Directional Keys?


I need a suggestion on an alternative to the button matrix object because it does not provide any click feedback when LV_KEY_ENTER is pressed.

What MCU/Processor/Board and compiler are you using?

I’m using a Nintendo Switch homebrew environment with libnx and compiling with DevkitA64.

While the Switch does have a touch screen, the touch input is not available when you dock it with a TV, thus I need a good way to control my UI with the game controllers.

What do you want to achieve?

I’m looking for a button matrix style layout, where you can navigate using D-Pad ( LV_KEY_UP/DOWN/LEFT/RIGHT) but the difference is each button can be focused separately and have proper click feedback using an LV_KEY_ENTER input (mapped to the game controller).

What have you tried so far?

I tried button matrix, but it focuses the entire matrix and doesn’t have individual focus highlight for the buttons inside, so it uses the button pressed style as its “focus”, and that breaks the press feedback for when the button is actually pressed by LV_KEY_ENTER. The keyboard object seems to be the same.

I was considering using the separate buttons approach, but I wasn’t able to find any demo or information on how to set up the buttons in a grid and navigate with the D-Pad/Directional keys. I’ve only seen using a group and navigating with LV_KEY_PREV/NEXT, which is really not ideal in my case.

Screenshot and/or video

The ideal layout should look like this screenshot, using button matrix. (The overlay display on the left.)

However, when applying the controller input device, the whole Matrix gets highlighted in focus style.

The whole thing became purple, which is not the style I set. I could set my own focus style callback to mitigate that, but there still wouldn’t be any button click feedback, so button matrix is out of the question.

I would really appreciate any help and/or suggestions to make this work! Thanks in advance.

I didn’t realize there’s a LV_EVENT_KEY event. I guess I could just set the event callback to handle D Pad navigation. Would there be any conflict if an object already has some default behavior with the LV_KEY_UP/DOWN/LEFT/RIGHT keys?

I ended up writing a PR for btnm

Just for the record, as I’ve mentioned in the Pull request, it will be supported in v7.0.