User avatar
ndeselms
Topic Author
Posts: 1
Joined: 26 May 2022, 20:31

Best Way to Add Navigation Input

20 Sep 2022, 20:51

Hello Noesis forums,

I'm looking into adding input so users can navigate through a Noesis interface using a gamepad or external device or whatever they choose to bind for these actions.
I've found the MoveFocusAction class which looks to be what I want, but when I put it in my xaml using the recommended syntax (XAML in https://www.noesisengine.com/docs/App.I ... ction.html) I get the error message: [NOESIS/E] MainWindow.xaml(13): 'Right' is not a valid value for property NoesisGUIExtensions.MoveFocusAction.Direction. I think the tag itself isn't being recognized and the error message is a little misleading.

I'm including <NsApp\MoveFocusAction.h> and registering it Noesis::RegisterComponent<NoesisApp::MoveFocusAction>(). Something else seems to not be right with how the NoesisGUIExtensions are getting read.

Also once I get that figured out, is there a recommended way to trigger the MoveFocusAction? I'd like to use our engine's current control binding infrastructure and call MoveFocusAction when bindings for those movements are called (up, down, left, right, select, etc.).
Nate DeSelms
Software Engineer
iRacing Motorsport Simulations
 
User avatar
sfernandez
Site Admin
Posts: 2664
Joined: 22 Dec 2011, 19:20

Re: Best Way to Add Navigation Input

21 Sep 2022, 20:22

Hello and welcome!

By default Noesis is prepared to work correctly with a gamepad, remote control or similar devices by using keyboard directional navigation. You just need to inject into the View the button presses as KeyDown/KeyUp events and analog axis with the Scroll/HScroll events, as explained in the Integration tutorial.
view->KeyDown(Key_GamepadDown); // for Gamepad D-pad down, or Left analog stick down
view->Scroll(vertical_delta); // for Gamepad Right analog stick
Regarding the MoveFocusAction, it can be used to explictly move the focus from a xaml trigger, for example: when an animation finishes (StoryboardCompletedTrigger), when a property changes (DataTrigger), when an event is fired (EventTrigger), etc. But I don't think this exactly what you need. If you just want to use your current control bindings to manage the UI navigation you can directly inject the converted keys into our View. For example, if you have the 'D' key mapped to the 'Right' action, you can inject 'Key_Right' into our View when the user presses the 'D' key. Is that what you are looking for?

The error loading the xaml you mentioned indicates that the FocusDirection enum converter is not registered in the component factory, could you try to add the following?
#include <NsCore/EnumConverter.h>
...
Noesis::RegisterComponent<Noesis::EnumConverter<NoesisApp::FocusDirection>>()
Hope this helps, cheers.

Who is online

Users browsing this forum: SingingBard and 1 guest