User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Which User Control is the Closest Analog?

08 Mar 2019, 03:10

I'm reaching out to see if anyone might have advice.

Previously, I found great success using a UWP ListView to enable selection of one item in a series. I am not referring to selection mode, but the idea that an end user is able to navigate up and down through a list using keys (or a gamepad) without firing a selection changed event. This is made possible in UWP because focus (i.e. by pressing down on the keyboard or gamepad) does not result in a selection event firing. The end user must then press enter, spacebar, or gamepad 'A' to toggle or fire selection. Based on an understanding of this concept -- which Noesis GUI control would get me closest? Should I try ListBox or ListView?
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Which User Control is the Closest Analog?

08 Mar 2019, 11:20

Unfortunately moving arrow keys in a ListBox/ListView do select the focused item.

Maybe you can play with an ItemsControl that contains Focusable controls as items, and manage selected item in the bound viewmodel using a command triggered when user hits space/enter/gamepad_A.

Could you please give a try and let us know if worked?
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: Which User Control is the Closest Analog?

10 Mar 2019, 17:11

Yes, I'll give it a shot.
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: Which User Control is the Closest Analog?

10 Mar 2019, 19:45

I'm finding success by ignoring selection events and then looking at the UserControl.KeyDown event. One thing that I notice is that I get KeyDown.Space instead of KeyDown.GamepadAccept when I press the 'A' button on an XB1 controller. It seems like I am doing something wrong although I did use the Unity 'accept' input mapping shown in the documentation. Do you know if there is a Unity sample that shows a UI that has functional input mappings, i.e. the A button selects a given menu item?
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: Which User Control is the Closest Analog?

10 Mar 2019, 19:51

OK, this is working for me quite well. I just needed to wrap my head around a few different ways of doing things. No blockers -- clear sailing from here out, I think. Thank you for the help!
 
User avatar
sfernandez
Site Admin
Posts: 2984
Joined: 22 Dec 2011, 19:20

Re: Which User Control is the Closest Analog?

10 Mar 2019, 20:10

I'm finding success by ignoring selection events and then looking at the UserControl.KeyDown event. One thing that I notice is that I get KeyDown.Space instead of KeyDown.GamepadAccept when I press the 'A' button on an XB1 controller. It seems like I am doing something wrong although I did use the Unity 'accept' input mapping shown in the documentation. Do you know if there is a Unity sample that shows a UI that has functional input mappings, i.e. the A button selects a given menu item?
Nothing wrong on your side, we map gamepad buttons to regular keys to share controls implementation with default keyboard.
You can still acccess original key though from event args:
private void OnKeyDown(object sender, const KeyEventArgs e)
{
  if (e.OriginalKey == Key.GamepadAccept) { ... }
}
The mapping is as follows:
GamepadLeft      -> Left
GamepadUp        -> Up
GamepadRight     -> Right
GamepadDown      -> Down
GamepadAccept    -> Space
GamepadCancel    -> Escape
GamepadPageUp    -> PageUp
GamepadPageDown  -> PageDown
GamepadPageLeft  -> PageLeft
GamepadPageRight -> PageRight
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: Which User Control is the Closest Analog?

11 Mar 2019, 02:41

Thank you so much, this is very helpful to know. I didn't realize the original key had it -- perfect. I'm in really good shape. This is truly a great product.
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Which User Control is the Closest Analog?

11 Mar 2019, 12:36

Just an important detail, there is more than a simple mapping from gamepad to keyboard. Gamepad activates focus engagement. So for example, to edit a slider with the pad you need to hit 'A' button. With the keyboard that's not necessary as you have TAB to move the focus.
 
User avatar
stonstad
Topic Author
Posts: 241
Joined: 06 Jun 2016, 18:14
Location: Lesser Magellanic Cloud
Contact:

Re: Which User Control is the Closest Analog?

11 Mar 2019, 15:01

Just an important detail, there is more than a simple mapping from gamepad to keyboard. Gamepad activates focus engagement. So for example, to edit a slider with the pad you need to hit 'A' button. With the keyboard that's not necessary as you have TAB to move the focus.
Thanks, jsantos! I encountered this behavior and I didn't know what it was. Thank you for anticipating and helping!
 
User avatar
jsantos
Site Admin
Posts: 3906
Joined: 20 Jan 2012, 17:18
Contact:

Re: Which User Control is the Closest Analog?

12 Mar 2019, 18:47

Do you know if there is a Unity sample that shows a UI that has functional input mappings, i.e. the A button selects a given menu item?
All our samples in C++ and C# work by default with gamepad. We don't have that in Unity because its input system is quite primitive and you need to store the input mapping at project level, so that cannot be done in the package we are distributing. We could do that in Github, as a separate project. We should definitely do that.

Who is online

Users browsing this forum: Ahrefs [Bot], Google [Bot], Semrush [Bot] and 8 guests