-
Notifications
You must be signed in to change notification settings - Fork 2
InputDeviceManagementService #172
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
InputDeviceManagementService #172
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Pull Request Overview
This is a comprehensive refactoring to introduce a generic input device management system to replace the existing game controller-specific implementation. The changes introduce an InputDeviceManagerService to handle all input device types, with InputDeviceService implementations for specific device types like game controllers.
Key changes:
- Replaced game controller-specific classes with generic input device interfaces and base classes
- Introduced a centralized
InputDeviceManagerServiceto manage all input device types - Renamed events, types, and properties throughout the codebase to use "InputDevice" terminology
- Updated platform-specific implementations (iOS, Android, WinUI) to use the new architecture
Reviewed Changes
Copilot reviewed 53 out of 53 changed files in this pull request and generated 9 comments.
Show a summary per file
| File | Description |
|---|---|
| Various ViewModels and Services | Updated to use new IInputDeviceEventService interface instead of IGameControllerService |
| PlatformServices/InputDevice/ | New generic input device interfaces and base classes |
| PlatformServices/InputDeviceService/ | New service layer for managing input device types |
| InputDeviceManagement/ | New centralized management service and dependency injection setup |
| Platform-specific GameController implementations | Refactored to inherit from generic input device base classes |
| UI and Business Logic | Updated to use new event types and property names |
Tip: Customize your code reviews with copilot-instructions.md. Create the file or learn how to get started.
BrickController2/BrickController2/PlatformServices/InputDevice/InputDeviceChangedEventArgs.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/UI/ViewModels/ControllerTesterPageViewModel.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/UI/ViewModels/ControllerTesterPageViewModel.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/InputDeviceManagement/InputDeviceManagerService.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/InputDeviceManagement/InputDeviceManagerService.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/InputDeviceManagement/InputDeviceManagerService.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/UI/ViewModels/ControllerProfilePageViewModel.cs
Show resolved
Hide resolved
...Controller2/BrickController2/PlatformServices/InputDeviceService/IInputDeviceEventService.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/InputDeviceManagement/InputDeviceManagerService.cs
Outdated
Show resolved
Hide resolved
vicocz
left a comment
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still out of time, therefore left few comments only.
But in general I like Input Device naming. So I guess this will be nice feature to complete, even if it's kind of refactoring only.
BrickController2/BrickController2.iOS/PlatformServices/GameController/GameControllerService.cs
Outdated
Show resolved
Hide resolved
| .OnActivated(e => | ||
| { | ||
| // resolve all registered input device services to trigger their registration | ||
| e.Context.Resolve<IEnumerable<IInputDeviceService>>(); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Why is this needed? Why do we need RegisterInputDeviceService method? What's wrong with resolving IEnumerable<IInputDeviceService> as parameter of InputDeviceManagerService constructor?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Still I need to check this more deeply...
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
IEnumerable as parameter of InputDeviceManagerService constructor?
That was my first attempt and it crashed - it's the chicken-or-egg problem ;)
The InputDeviceService derivations constructor need the InputDeviceManagerService instance as parameter.
So you can't resolve IEnumerable<IInputDeviceService> as parameter of InputDeviceManagerService constructor.
So we first need to create the InputDeviceManagerService instance and then all the registered InputDeviceService types.
51cad4c to
de81671
Compare
|
I've startet renaming all the Controller-stuff (types, methods, etc.) to match the more common "InputDevice"-naming... What do you think? |
No breaking changes from persistence point of view. So JSON related names should be the same. |
It seems, there is a much better solution to instantiate objects at startup: |
Oh, yezzz - much better: builder.RegisterType<GameControllerService>().As<IInputDeviceService>().As<IStartable>().SingleInstance(); // ensure it's started as soon as the container is built in Autofac |
I have identified these types that must retain their name and the names of their properties - they are used in database and sharing context:
I've renamed files and types |
This comment was marked as resolved.
This comment was marked as resolved.
60e3025 to
53bf0e6
Compare
cleanup code: * removed unused properties of IGameController and GamepadControllerBase * removed generic in GameControllerServiceBase; use IGameController
GameController -> InhputDevice
NotifyInputDevicessChangedAction -> NotifyInputDevicesChangedAction
TODOs in * ControllerProfilePageViewModel * ControllerTesterPageViewModel
…support ControllerId now
…lways is true as all inputdevice services support ControllerId now
to ensure InputDeviceService is instantiated and started as soon as the container is built in Autofac
53bf0e6 to
8b8c9e1
Compare
|
Just FYI I plan to start looking this week. |
BrickController2/BrickController2/UI/ViewModels/PlayerPageViewModel.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/UI/ViewModels/GameControllerGroupViewModel.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/UI/ViewModels/GameControllerEventViewModel.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/UI/Services/Dialog/IDialogServer.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/Resources/TranslationResources.resx
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/PlatformServices/InputDevice/InputDeviceEventArgs.cs
Outdated
Show resolved
Hide resolved
BrickController2/BrickController2/InputDeviceManagement/IInputDeviceManagerService.cs
Show resolved
Hide resolved
BrickController2/BrickController2.WinUI/PlatformServices/DI/PlatformServicesModule.cs
Show resolved
Hide resolved
…odel and GameControllerGroupViewModel to InputDeviceGroupViewModel renamed properties from Controller* to InputDevice*
|
Thank you for your contribution :) |
|
You're welcome. Thank you :) |
After many hours of thinking, refactoring, moving and renaming files - here is my suggestion for a generic handling of inputdevices (like gamecontrollers, MCP server,...).
Now, there is one instance of a
InputDeviceManagerServicehandling allInputDeviceServices(all kinds of inputdevice services like GameControllerService, Gyro, whatever) and allInputDevices(gamecontrollers, gyro and so on).The central
InputDeviceManagerServicestill raises inputdevice events on button press, axis movement, channel changes and connection/disconnection inputdevices.An
InputDeviceServicehandles one special kind of inputdevices like gamecontrollers.(In this branch there are only InputDeviceServices for gamecontrollers).
Now there is common base class
InputDevicethat replaces the former "Controller" - there was and still is a lot of renaming to do...All inputdevices are derived from this baseclass.
One interesting part of code is the initialisation of all registered
InputDeviceServicesinInputDeviceManagementModule- perhaps there is a better way...Please take some time and comment.