Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Gamepad Support! #26

Open
BlizzCrafter opened this issue Apr 4, 2017 · 10 comments
Open

Gamepad Support! #26

BlizzCrafter opened this issue Apr 4, 2017 · 10 comments

Comments

@BlizzCrafter
Copy link

Hello everybody,

the past week I worked on gamepad support for GeonBit.UI. If someone is interested in taking a look then please do: https://github.com/sqrMin1/GeonBit.UI/tree/gamepad

Included is a sample project (GeonBit.UI.Gamepad). You should start it first to get a clue how it works (of course with your Xbox 360 controller plugged in).
Everything should be self-explaining, because I described everything in the sample and in the code.

I didn't make a pull request so far, because I used MonoGame 3.6 Windows DX (through NuGet) and the main GeonBit.UI-repo is using MonoGame 3.5 DesktopGL. But in case you are interested in having this in the main repo @RonenNess then you could create a seperate branch for it (eg. gamepad36) and I will make a PR on this then.

I hope this is helpful.

Cheers,
Marcel

By the way: GeonBit.UI is very awesome! I had a lot of fun using it and I will use it in my main project. Thanks for your hard work!

@RonenNess
Copy link
Owner

Awesome work, thank you for sharing! :)

I'll probably do some GeonBit.UI dev this weekend so I could take a look at this as well as the other PR waiting. I don't have an xbox but I'm sure there are plenty of emulators out there, just hope they play nice with MG.

Will keep you updated once I'm on it.

@smiracle
Copy link

Hello, do you have any plans to move forward with implementing gamepad functionality within the GeonBit UI?

@BlizzCrafter
Copy link
Author

@smiracle I don't know if you mean me or @RonenNess but i'll answer from my perspective, since this is posted in my old issue thread.

I created a repo which shows GeonBit.UI with GamePad support roughly before 2 Years. It seems that much happened since then, because my old repo is 189 commits behind the current master of GeonBit.UI.

I can deffinitley imagine to take a second look and create a clean GamePad support branch based on the current master, but as you can think of this takes much time and preperation (need to figure out all the new features and such). Despite that i'm also busy with different projects.

But yes, this project is really awesome as well as Ronen is and I can imagine to do it. I just can't tell when this will happen, but it will surely take some time.

So, don't expect it to soon (from my side).

@RonenNess
Copy link
Owner

RonenNess commented Oct 1, 2018

Hi @smiracle,

Sorry but currently I have no plans to add gamepad, not even sure I'll work on GeonBit.UI any time soon, but that could change.

You can try and take @sqrmin1's repo and work from there, I'll try to be available and responsive for questions if you have any.

Thanks :)

PS @sqrmin1 apologies for not merging your branch when it was still fresh :/

@BlizzCrafter
Copy link
Author

@RonenNess

Oh, no worries! Everything is fine :)

@smiracle
Copy link

smiracle commented Oct 2, 2018

Happy to hear from you both, I've been spending some time merging the latest UI changes with RonenNess' old gamepad code. So far it seems to be mostly working, although there are some problems with the way entities are selected when tabs are present in the panel (and likely other bugs). I'll likely be looking into this more over the next couple of weeks. Thanks!

@smiracle
Copy link

I went ahead and forked the repo and put all of my changes in a feature branch. There's still a lot of problems to iron out that I've been struggling with (primarily selection between nested panels) but the functionality that sqrMin1 added is all there in conjunction with the latest code and all of the original examples. No extra libraries were added.

Here's the forked branch in case anyone wants to take a look at it:
https://github.com/smiracle/GeonBit.UI/tree/gamepad-support

@BlizzCrafter
Copy link
Author

Thanks @smiracle. I took a look and it's fine to see gamepad functionallity in the newest GeonBit.UI iteration.

But as you said there a some problems which makes my old gamepad code unstable. Espacially when you think of new features like MessageBoxes, where the gamepad didn't even respond to. I'm also receiving crashes here and there.

Nothing special - this is in the end just exactly what I would expect from using pretty old code in a heavenly evolving library like GeonBit.UI.

I think it's neccessary to completly start from scratch again and implement the gamepad support in a clean and fresh (maybe even new) way.

Sure this is a bit of work but we should do it to comply with the high quality of GeonBit.UI!

Anyway thanks for your refreshed sample. It puts me in a positive mood to work on full gamepad support somewhat in the future.

@smiracle
Copy link

@sqrmin1, awesome! I agree, I think maybe taking a more event-driven approach to gamepad input rather than checking for button presses under certain conditions on each update iteration might be worth thinking about.

@BlizzCrafter
Copy link
Author

GeonBit.UI - GamePad-Support

It was about time...

Video
Click on this image to watch the YouTube-Video!

  • Implemented using the Microsoft.Xna.Framework.Input namespace from the MonoGame.Framework!
  • Available on my GamePad-Branch

Hello Com!

4 years after my original GamePad-Implementation for GeonBit.UI, I'm ready to show you my new one. But this time every single
usually interactable entity from the GeonBit.UI library is supported! No mouse-roaming anymore for "complex" entities like SelectList or DropDownButton or even complex UI-Scenarios with nested Panels and complex entities.

How does it work under the hood?

First of all I created the IGamePadInput interface of course and added its functionallity to the DefaultInputProvider. But instead of imitating the regular IMouseInput techniques, I created a specialized, GamePad-Supported version of each usually interactable entity of GeonBit.UI.

To enable the important core events for each entity in relation to the users GamePad-Input, I created an IEntityGamePad interface and traversed specialized GamePad-Events to the original GeonBit.UI-IMouseInput ones. This has the great advantage that I can precisley decide what action on each GamePad-Input-Supported-Entity really has to happen before the input get traversed to its final destination.

This also means that I nearly don't needed to modify the original source code of GeonBit.UI, despite the general GamePad implementation and one single modification.

The one single core-change I did was on this line in the Entity class to make it possible to search in hidden entities (children):
https://github.com/sqrMin1/GeonBit.UI/blob/gamepad/GeonBit.UI/Source/Entities/Entity.cs#L743

The reason for this is that it wasn't possible to find my own custom entites, when they were added to a PanelTabs-Entity, because its internal _panelsPanel (which hosts the added entites), got automatically skipped on Entity.Find() (because they are hidden by default).

However, this change will not break your existing code, because the "skipHidden" parameter automatically sets to false, which is the standard behavier of GeonBit.UI.

Also on board is a GamePadSetup class, which makes it easy to configure the deadzones of your GamePad-Thumbsticks for example, but it also initializes a set of RichParagraphStyleInstruction with original GamePad-Colors from Xbox-Controllers, so that it perfectly integrates with GeonBit.UI.

Where to find?

I know that the GeonBit.UI library is made of high-quality and so it should stay. In the moment you will only find this GamePad-Implementation on my GamePad-Branch.

Feel free to share your (improvment)-suggestions here and if you think that my work could meet the high quality expectations of this library, you could maybe give this post a like and show @RonenNess your interest in an official GamePad-Integration directly into the GeonBit.UI library.

In the case this should ever happen, I am willing to create a "clean" version of my GamePad-Branch which only contains the most important commits and a well integrated sample project.


Thanks for reading and have fun using your GamePad with GeonBit.UI! 😁

Cheers,
Marcel

PS: TRY THE SAMPLE PROJECT!

- Made with ❤ -

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

3 participants