-
Notifications
You must be signed in to change notification settings - Fork 1.1k
Keyboard Navigation / Gamepad #50
Comments
Hey and thanks for your feedback.
Happy that it can be of use.
I previously thought about gamepad and keyboard only support. The problem is both require knowledge about the total layout (position, size) of a widgets to know what widget/window should be selected next by directional input. Another thing is like you already said the identification of the currently active widget. Some widget already do this like properties and edit widgets, but it would require an ID for every widget which would make the default library case more tedious to use, because every widget needs an unique name. That being said, if the resulting UI is static and not complex it is possible to modify this library and create a custom version to get it to work. A simple version would be to only add IDs to all the widgets you need and add an currently hot item to the internal window struct and do the selecting by having a ID hash table describing the widget layout with widget position and size and use that to control the mouse which then again controls widget behavior. This would be quite hacky but should work. The second and way more complex idea is to add an additional optional layer of abstraction to this library to create a retain mode API (which would also allow things like an UI editor to place widgets). The problem is that imguis are a rather new concept and no one has ever tried something like adding a retain mode API on top and currently at this moment I do not have the time to try and find out if it is something doable or not. So it is not a solution that could be implemented in the near future, but is definitely on my long term todo list. |
wow, that's great thanks for the implementation idea |
Great news, thank you. I see yet another option. It's a bit ad-hoc, but should be easier to implement. Namely emulating keyboard and mouse with gamepad - i.e. writing a filter/translator of gamepad commands/signals into keyboard and mouse ones without changing Zahnrad and without writing any abstraction layer over Zahnrad. So the gamepad would then act as a second keyboard and a second mouse. I didn't try to implement this solution, so there might be (and I'm expecting that) a devil in a detail. |
You already can use gamepads as a mouse by using the analog stick and two gamepad buttons as "mouse" buttons (at least under Linux and X11) if it is that what you mean. But the actual reason why I came up with the growing ID is because I am currently extending zahnrad with something resembling |
Just wondering, do you have the code for that sample readily available? I'd like to play with it |
Yeah sure I upload it here: https://gist.github.com/vurtun/519801825b4ccfad6767. The test uses an older version of zahnrad so I don't know if it will just compile. Also everything is just written in user space to get something done so if there is something you need in the library to get something done just say. It is not perfect but hopefully helps a little bit. |
thanks a lot |
Hey works really well! I didn't really read it lol! I just copy pasted into my program and fixed compilation issues till it worked but it's really neat. I'll try to build on top of this |
@vurtun Do you still have the code for the gamepad/keyboard example? The linked gist no longer exists. It would be great to have for reference. |
@vurtun I am also very interested in a code sample of how to impl gamepad support. Do you still have the code to post? |
Or perhaps @fr500 you have a copy of that code floating around somewhere? |
I linked my code experiments here: |
Hey
First of all, thanks a lot for this toolkit, it's great, I've been looking for a cross platform gui toolkit for a while and this fits the bill correctly and this one does.
I'm implementing zahnrad in RetroArch as a new menu driver (retroarch is a sort of multi system emulator and we have several menu drivers but we don't have a traditional mouse + kb driver).
Now I made a basic implementation on our menu driver and I'm wondering, is it possible to navigate the controls with keyboard only or a gamepad? maybe assign an ID to each control and have a selected property that highlights the selected widget? reacting to the click keyevent should be doable already but I'm not sure about the navigation.
The text was updated successfully, but these errors were encountered: