-
Notifications
You must be signed in to change notification settings - Fork 90
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
EA to public #1025
EA to public #1025
Conversation
WalkthroughThe project has undergone a significant overhaul, encompassing improvements in bug tracking, feature requests, and the Handheld Companion application. Changes range from label adjustments for better organization to extensive modifications in setup scripts for enhanced dependency management and system integration. Noteworthy updates include refined device handling, especially for AYANEO products, alongside enhancements in UI and backend for improved user interaction and data processing. Changes
Thank you for using CodeRabbit. We offer it for free to the OSS community and would appreciate your support in helping us grow. If you find it useful, would you consider giving us a shout-out on your favorite social media? TipsChatThere are 3 ways to chat with CodeRabbit:
Note: Be mindful of the bot's finite context window. It's strongly recommended to break down tasks such as reading entire modules into smaller chunks. For a focused discussion, use review comments to chat about specific files and their changes, instead of using the PR comments. CodeRabbit Commands (invoked as PR comments)
Additionally, you can add CodeRabbit Configration File (
|
* restore Legion Go FanControl ability (requires BIOS v29) * Implement Sapientia function getUSBVerify() * Implement WMI class (wip) * implement new functions - GetFanFullSpeedAsync - SetFanFullSpeedAsync - SetFanTable - SetSmartFanMode * implement SetCPUPowerLimit()
…#158) * Start implementing IGCL (wip) * More work - Implemented GPUManager - Implemented GPU-specific classes (AMDGPU, IntelGPU) - Implemented IGCLBackend (wip) - SystemManager renamed to MultimediaManager - PowerManager renamed to SystemManager * more work on IGCL * prevent crash on null MainThread * prevent useless SetResolution() calls * more work on IGCL * add missing sharpness check * implement ctl_device_adapter_properties_t (wip) * what if the issue was deviceIdx all along... * Update IGCL_Wrapper.dll * fix remaining implementations * implement IntegerScalingType (Intel only) * make sure to use defaultGPU (idx: 0) We need to find a proper way to guess which one is used for 3D rendering I guess or linked to main screen.. * fix ctl_device_adapter_properties_t Marshalling * implemented some form of logic to pick the first available external GPU (if any) * improve GPUManager - add support for Manufacturer: "Advanced Micro Devices, Inc." - improve GPUManager and GPU Start() and Stop() logics - prevent Task Execution within Tasks on AMDGPU * fix a crash when UpdateTimer is null
* Implement new UI classes - UISounds to manage UI sounds on interaction. - UIGamepad to manage gamepad interactions. - Audio files from https://kenney.nl/assets/ui-audio. - Add support for TextBox and RepeatButton selection via gamepad. * Update HandheldCompanion/UI/UISounds.cs Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com> * fix PlayOggFile refs * removed unused audio files * Add UI Sounds toggle on SettingsPage (default Off) --------- Co-authored-by: coderabbitai[bot] <136622811+coderabbitai[bot]@users.noreply.github.com>
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.
Actionable comments posted: 8
Review Status
Configuration used: CodeRabbit UI
Files ignored due to path filters (16)
HandheldCompanion/ADLX_3DSettings.dll
is excluded by!**/*.dll
HandheldCompanion/ADLX_DisplaySettings.dll
is excluded by!**/*.dll
HandheldCompanion/ADLX_Wrapper.dll
is excluded by!**/*.dll
HandheldCompanion/GamepadMotion.dll
is excluded by!**/*.dll
HandheldCompanion/IGCL_Wrapper.dll
is excluded by!**/*.dll
HandheldCompanion/Resources/device_aya_slide.png
is excluded by!**/*.png
HandheldCompanion/Resources/device_gpd_winmini.png
is excluded by!**/*.png
HandheldCompanion/Resources/device_msi_claw.png
is excluded by!**/*.png
HandheldCompanion/SapientiaUsb.dll
is excluded by!**/*.dll
HandheldCompanion/UI/Audio/bong_001.ogg
is excluded by!**/*.ogg
HandheldCompanion/UI/Audio/drop_001.ogg
is excluded by!**/*.ogg
HandheldCompanion/UI/Audio/drop_002.ogg
is excluded by!**/*.ogg
HandheldCompanion/UI/Audio/glitch_004.ogg
is excluded by!**/*.ogg
HandheldCompanion/UI/Audio/switch_004.ogg
is excluded by!**/*.ogg
HandheldCompanion/UI/Audio/switch_005.ogg
is excluded by!**/*.ogg
HandheldCompanion/UI/Audio/switch_007.ogg
is excluded by!**/*.ogg
Files selected for processing (54)
- .github/ISSUE_TEMPLATE/bug_report.md (2 hunks)
- .github/ISSUE_TEMPLATE/feature_request.md (1 hunks)
- HandheldCompanion.iss (12 hunks)
- HandheldCompanion/ADLX/ADLXBackend.cs (1 hunks)
- HandheldCompanion/Actions/GyroActions.cs (1 hunks)
- HandheldCompanion/App.config (2 hunks)
- HandheldCompanion/App.xaml (1 hunks)
- HandheldCompanion/App.xaml.cs (2 hunks)
- HandheldCompanion/Controllers/DInputController.cs (2 hunks)
- HandheldCompanion/Controllers/DS4Controller.cs (6 hunks)
- HandheldCompanion/Controllers/DualSenseController.cs (4 hunks)
- HandheldCompanion/Controllers/GordonController.cs (6 hunks)
- HandheldCompanion/Controllers/IController.xaml (4 hunks)
- HandheldCompanion/Controllers/IController.xaml.cs (12 hunks)
- HandheldCompanion/Controllers/JSController.cs (6 hunks)
- HandheldCompanion/Controllers/LegionController.cs (1 hunks)
- HandheldCompanion/Controllers/NeptuneController.cs (7 hunks)
- HandheldCompanion/Controllers/ProController.cs (1 hunks)
- HandheldCompanion/Controllers/SteamController.cs (2 hunks)
- HandheldCompanion/Controllers/XInputController.cs (4 hunks)
- HandheldCompanion/Controls/Hints/Hint_AMD_IntegerScalingCheck.cs (3 hunks)
- HandheldCompanion/Controls/Hints/Hint_CoreIsolationCheck.cs (3 hunks)
- HandheldCompanion/Controls/Hints/Hint_LegionGoLegionSpace.cs (4 hunks)
- HandheldCompanion/Controls/Hints/Hint_MSIClawCenter.cs (1 hunks)
- HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs (5 hunks)
- HandheldCompanion/Controls/Hints/Hint_SteamNeptuneDesktop.cs (1 hunks)
- HandheldCompanion/Controls/Hints/Hint_SteamXboxDrivers.cs (1 hunks)
- HandheldCompanion/Controls/ProcessEx.cs (1 hunks)
- HandheldCompanion/Converters/InverseBooleanToVisibilityConverter.cs (1 hunks)
- HandheldCompanion/Converters/InvertPercentageConverter.cs (1 hunks)
- HandheldCompanion/Converters/IsNullConverter.cs (1 hunks)
- HandheldCompanion/DSU/DSUServer.cs (2 hunks)
- HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs (1 hunks)
- HandheldCompanion/Devices/ASUS/ROGAlly.cs (5 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEO2.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEO2021.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEO2021Pro.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEO2S.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIR.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIR1S.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRLite.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlus.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusAMD.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusAMDMendocino.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusIntel.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPro.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEODevice.cs (3 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEODeviceCEc.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEODeviceCEii.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOKUN.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEONEXT.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEONEXTLite.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEONEXTLite4500U.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOSLIDE.cs (1 hunks)
Files not processed due to max files limit (52)
- HandheldCompanion/Devices/Ayn/AynLoki.cs
- HandheldCompanion/Devices/DefaultDevice.cs
- HandheldCompanion/Devices/GPD/GPDWin4-2023-7840U.cs
- HandheldCompanion/Devices/GPD/GPDWin4.cs
- HandheldCompanion/Devices/GPD/GPDWinMax2AMD.cs
- HandheldCompanion/Devices/GPD/GPDWinMax2Intel.cs
- HandheldCompanion/Devices/GPD/GPDWinMini-7640U.cs
- HandheldCompanion/Devices/GPD/GPDWinMini-7840U.cs
- HandheldCompanion/Devices/IDevice.cs
- HandheldCompanion/Devices/Lenovo/LegionGo.cs
- HandheldCompanion/Devices/Lenovo/SapientiaUsb.cs
- HandheldCompanion/Devices/MSI/ClawA1M.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayer2.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniAMD.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniIntel.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerOneXFly.cs
- HandheldCompanion/Extensions/GlyphExtensions.cs
- HandheldCompanion/Extensions/ManagementObjectSearcherExtensions.cs
- HandheldCompanion/Extensions/UIThreadExtensions.cs
- HandheldCompanion/GraphicsProcessingUnit/AMDGPU.cs
- HandheldCompanion/GraphicsProcessingUnit/GPU.cs
- HandheldCompanion/GraphicsProcessingUnit/IntelGPU.cs
- HandheldCompanion/HandheldCompanion.csproj
- HandheldCompanion/HandheldCompanion.json
- HandheldCompanion/Helpers/GamepadMotion.cs
- HandheldCompanion/IGCL/IGCLBackend.cs
- HandheldCompanion/Inputs/AxisState.cs
- HandheldCompanion/Inputs/ButtonState.cs
- HandheldCompanion/Inputs/GyroState.cs
- HandheldCompanion/Managers/ControllerManager.cs
- HandheldCompanion/Managers/Desktop/DesktopScreen.cs
- HandheldCompanion/Managers/DeviceManager.cs
- HandheldCompanion/Managers/DynamicLightingManager.cs
- HandheldCompanion/Managers/GPUManager.cs
- HandheldCompanion/Managers/Hotkeys/Hotkey.cs
- HandheldCompanion/Managers/Hotkeys/InputsHotkey.cs
- HandheldCompanion/Managers/HotkeysManager.cs
- HandheldCompanion/Managers/InputsManager.cs
- HandheldCompanion/Managers/LayoutManager.cs
- HandheldCompanion/Managers/MotionManager.cs
- HandheldCompanion/Managers/MultimediaManager.cs
- HandheldCompanion/Managers/OSDManager.cs
- HandheldCompanion/Managers/PerformanceManager.cs
- HandheldCompanion/Managers/PlatformManager.cs
- HandheldCompanion/Managers/PowerManager.cs
- HandheldCompanion/Managers/PowerProfileManager.cs
- HandheldCompanion/Managers/ProcessManager.cs
- HandheldCompanion/Managers/ProfileManager.cs
- HandheldCompanion/Managers/SensorsManager.cs
- HandheldCompanion/Managers/SettingsManager.cs
Files skipped from review due to trivial changes (1)
- .github/ISSUE_TEMPLATE/feature_request.md
Additional comments not posted (145)
HandheldCompanion/Devices/AYANEO/AYANEO2S.cs (1)
8-11
: Usingthis
for member variable access enhances readability and disambiguates member variables from local variables. Good practice.HandheldCompanion/Devices/AYANEO/AYANEOAIRLite.cs (1)
8-11
: Consistent use ofthis
for member variables is noted across device classes, enhancing code readability and maintainability.HandheldCompanion/Devices/AYANEO/AYANEOAIRPro.cs (1)
8-11
: The explicit use ofthis
for member variables in the constructor maintains consistency and clarity in the codebase. Well done.HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusAMD.cs (1)
8-11
: The use ofthis
for member variables is consistent with the rest of the device classes, contributing to the overall readability and maintainability of the code.HandheldCompanion/Devices/AYANEO/AYANEONEXTLite4500U.cs (1)
8-9
: Adhering to the consistent use ofthis
for member variable access in constructors across device classes enhances code clarity.HandheldCompanion/Devices/AYANEO/AYANEO2021Pro.cs (1)
8-11
: The consistent application ofthis
for member variable access across device classes is a good practice, enhancing code readability.HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusAMDMendocino.cs (1)
8-13
: The use ofthis
for member variables is consistent with other device classes. Additionally, the new assignment toECDetails.AddressFanDuty
is a notable enhancement. Ensure this new value aligns with device specifications and intended behavior.HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusIntel.cs (1)
8-13
: Consistent use ofthis
for member variables is observed. The addition of a new assignment toECDetails.AddressFanDuty
should be verified for correctness according to device specifications.HandheldCompanion/Converters/InvertPercentageConverter.cs (2)
9-11
: Consider adding input type checking and error handling inConvert
method to ensure robustness.
14-16
: Consider adding input type checking and error handling inConvertBack
method to ensure robustness.HandheldCompanion/Devices/AYANEO/AYANEO2.cs (2)
3-3
: Inheritance change toAYANEO.AYANEODeviceCEc
looks appropriate forAYANEO2
.
5-15
: Explicit use ofthis
keyword in the constructor enhances readability and avoids ambiguity. Good practice!HandheldCompanion/Devices/AYANEO/AYANEONEXTLite.cs (1)
5-15
: Constructor initialization of device-specific settings using thethis
keyword is clear and consistent with best practices.HandheldCompanion/Converters/IsNullConverter.cs (2)
9-14
: The use of pattern matching in theConvert
method enhances readability and is a good use of modern C# features.
17-19
: Correct use ofInvalidOperationException
inConvertBack
method to indicate one-way conversion only.HandheldCompanion/Devices/AYANEO/AYANEOSLIDE.cs (1)
7-21
: Constructor initialization of device-specific settings and axis configurations is clear and consistent with best practices. Good use ofVector3
for gyrometer and accelerometer axes..github/ISSUE_TEMPLATE/bug_report.md (2)
5-5
: Label naming convention update to "Bug" and addition of "LENOVO" align with the PR objectives. Good attention to detail.
23-23
: Correction of "Handheld Companinion Version" to "Handheld Companion Version" fixes a typographical error. Well done.HandheldCompanion/Devices/AYANEO/AYANEOAIRPlus.cs (1)
7-29
: Updates to device-specific settings and axes configurations are appropriate. The use ofSortedDictionary
for axis swap configurations is a good choice. Refactoring efforts to improve LED control functionality are commendable.HandheldCompanion/Actions/GyroActions.cs (1)
10-10
: Change ofMotionInput
property toMotionInput.LocalSpace
aligns with the PR's objectives of refining input handling. Good update.HandheldCompanion/Controls/Hints/Hint_SteamXboxDrivers.cs (1)
37-37
: Switching fromBeginInvoke
toInvoke
ensures that the UI update is executed immediately on the UI thread, which can be beneficial for critical updates. However, be mindful of potential performance impacts if the operation is time-consuming, as it could block the UI thread.HandheldCompanion/Devices/AYANEO/AYANEOAIR1S.cs (1)
12-37
: Addingthis.
to instance member references enhances clarity and consistency, making it easier to distinguish between local variables and instance members. Good practice!HandheldCompanion/Controllers/DInputController.cs (1)
45-47
: Adding afloat delta
parameter toUpdateInputs
allows for time-based input handling, which is crucial for smooth and consistent input processing across different frame rates. Ensure all calls toUpdateInputs
are updated accordingly.HandheldCompanion/Converters/InverseBooleanToVisibilityConverter.cs (1)
8-47
: TheInverseBooleanToVisibilityConverter
is correctly implemented to inversely convert between boolean values andVisibility
. This is a useful utility for UI binding scenarios where the visibility of an element needs to be the opposite of a boolean condition. Well done!HandheldCompanion/Devices/AYANEO/AYANEOKUN.cs (1)
7-50
: The refactoring and updates inAYANEOKUN
, including theMapColorValues
method, enhance device-specific settings and improve the handling of OEM chords. Ensure that the color mapping logic inMapColorValues
is tested across all zones for accuracy.HandheldCompanion/Devices/AYANEO/AYANEOAIR.cs (1)
7-44
: The updates inAYANEOAIR
, including adjustments to gyrometer and accelerometer axes and the redefinition ofOEMChords
, are well-implemented. These changes enhance device-specific configurations and input handling. Ensure that the new configurations are tested on actual devices for accuracy and responsiveness.HandheldCompanion/Devices/AYANEO/AYANEONEXT.cs (1)
8-63
: The updates inAYANEONEXT
, including the introduction ofVector3
properties for gyrometer and accelerometer axes and the modification of theGetGlyph
method, are correctly implemented. These changes enhance device-specific settings and input handling. Ensure that the new configurations are tested on actual devices for accuracy and responsiveness.HandheldCompanion/Controls/Hints/Hint_SteamNeptuneDesktop.cs (1)
31-31
: ReplacingBeginInvoke
withInvoke
inSteam_Updated
ensures that the UI update is executed immediately on the UI thread, which can be beneficial for critical updates. However, be mindful of potential performance impacts if the operation is time-consuming, as it could block the UI thread.HandheldCompanion/Devices/AYANEO/AYANEO2021.cs (2)
22-36
: Consider using a constant or a configuration file for the gyrometer and accelerometer axis values to enhance maintainability.
61-73
: Ensure thatdefaultGlyph
is defined and has a meaningful default value for glyphs not covered by the switch cases.HandheldCompanion/Controllers/ProController.cs (2)
16-16
: Ensure thatSourceButtons
andSourceAxis
are properly initialized before adding elements to avoid potential null reference exceptions.
23-33
: Adding adelta
parameter toUpdateInputs
improves the method's flexibility but ensure that all callers of this method are updated accordingly.Verification successful
The verification process confirms that all relevant calls to
UpdateInputs
within the context of theProController.cs
change and its related classes have been updated to include thedelta
parameter. This ensures that the method's flexibility is maintained across the codebase as intended.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Verify that all calls to UpdateInputs include the delta parameter. rg 'UpdateInputs\(' --type csLength of output: 4120
HandheldCompanion/Controls/Hints/Hint_AMD_IntegerScalingCheck.cs (2)
45-45
: UsingInvoke
ensures that UI updates are performed on the UI thread, but consider the potential impact on UI responsiveness for long-running operations.
55-66
: UsingTask
for dialog handling is a good practice for asynchronous operations. Ensure that all dialog interactions are tested for correct behavior.HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs (3)
27-27
: UsingIDevice.GetCurrent()
for device checks is a more flexible approach than accessing a specific property directly. Good improvement.
79-79
: Correctly usingInvoke
for UI thread operations. Ensure that this change does not introduce any performance issues in the UI.
104-104
: Adding null safety withserviceTimer?.Stop()
is a good practice to avoid potential null reference exceptions.HandheldCompanion/Devices/AYANEO/AYANEODevice.cs (3)
9-14
: Introduction of theLEDGroup
enum with a new valueAYA
enhances the clarity and extensibility of LED group handling.
27-45
: Ensure thatdefaultGlyph
is properly defined and provides a meaningful default for glyphs not covered by the switch cases.
73-94
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [60-91]
The updated power status change handling uses
this
references consistently, improving readability and maintainability.HandheldCompanion/Controls/Hints/Hint_MSIClawCenter.cs (2)
101-104
: Correct use ofInvoke
for UI thread operations. Verify that this does not negatively impact UI responsiveness.
115-115
: Properly adding null safety withwatcherTimer?.Stop()
to avoid potential null reference exceptions.HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs (2)
21-21
: SettingCpuClock
to 4700 aligns with the device's specifications. Ensure this value is accurate and reflects the device's capabilities.
23-31
: Initialization ofGyrometerAxis
andAccelerometerAxis
vectors with specific values. Consider externalizing these configurations for easier adjustments.HandheldCompanion/Controls/Hints/Hint_LegionGoLegionSpace.cs (3)
33-33
: UsingIDevice.GetCurrent()
for device checks is a consistent and flexible approach. Good improvement.
85-85
: Correct use ofInvoke
for UI thread operations. Verify that this does not negatively impact UI responsiveness.
123-123
: Properly adding null safety withserviceTimer?.Stop()
to avoid potential null reference exceptions.HandheldCompanion/Devices/AYANEO/AYANEODeviceCEii.cs (7)
26-40
: Ensure gyrometer and accelerometer axis configurations are correct for all AYANEO devices using the CEii protocol.
42-61
: Validate the custom key configurations for OEM chords to ensure they match the intended hardware buttons.
64-74
: Ensure the calculation forduty
inSetFanDuty
correctly maps the percentage to the fan's operational range.
78-87
: Verify that theenable
parameter inSetFanControl
correctly enables or disables the fan as intended.
91-99
: Confirm the LED group addresses and commands inCEcControl_RgbI2cWrite
are accurate for all AYANEO devices using the CEii protocol.
102-104
: EnsureCEiiEcHelper_RgbStart
correctly initializes the RGB control for the device.
107-110
: Validate theECRamDirectWrite
method's logic, especially the conversion ofaddress
andoffset
toushort
.HandheldCompanion/App.xaml.cs (3)
48-66
: Ensure the logic for handling multiple instances of the application is correct and does not inadvertently terminate the wrong process.
113-116
: Verify that logging for inner exceptions provides sufficient detail for troubleshooting without exposing sensitive information.
124-127
: Confirm that enhanced logging for unhandled exceptions in the domain does not introduce performance issues or excessive logging.HandheldCompanion/Controls/Hints/Hint_CoreIsolationCheck.cs (2)
62-62
: Ensure the dispatcher invocation method change does not affect UI thread synchronization.
73-82
: Confirm that the asynchronous dialog handling logic correctly waits for the dialog result before proceeding.HandheldCompanion/App.xaml (1)
66-72
: Ensure the newly added converters (InverseBooleanToVisibilityConverter
,InvertPercentageConverter
,IsNullConverter
) are correctly implemented and used where necessary.HandheldCompanion/Controllers/DS4Controller.cs (3)
12-12
: Ensure the empty constructor is necessary and does not interfere with controller initialization.
18-27
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [23-33]
Confirm that the
InitializeInputOutput
method correctly sets up the controller's input and output configurations.
40-52
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [43-87]
Verify that the
UpdateInputs
method correctly processes inputs, especially with the newdelta
parameter's inclusion.HandheldCompanion/Controllers/DualSenseController.cs (3)
12-12
: Ensure the empty constructor is necessary and does not interfere with controller initialization.
14-20
: Confirm that the UI color settings for buttons are correctly applied and match the intended design.
40-52
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [43-87]
Verify that the
UpdateInputs
method correctly processes inputs, especially with the newdelta
parameter's inclusion.HandheldCompanion/Controls/ProcessEx.cs (7)
49-67
: Ensure the constructor correctly initializes theProcessEx
instance, especially the process icon extraction logic.
69-78
: Confirm thatGetAppCompatFlags
accurately retrieves application compatibility flags from the registry.
81-106
: Verify thatSetAppCompatFlag
correctly modifies application compatibility flags in the registry.
109-117
: Ensure theFullScreenOptimization
property accurately reflects the current state of the full-screen optimization compatibility flag.
119-127
: Confirm that theHighDPIAware
property correctly identifies if the high DPI aware compatibility flag is set.
154-184
: Verify that theRefresh
method correctly updates the process state and handles thread termination appropriately.
187-199
: EnsureRefreshChildProcesses
accurately manages child process IDs, especially in terms of adding new children and removing exited ones.HandheldCompanion/Controllers/JSController.cs (3)
51-53
: Verify that the removal of specific timer logic and UI thread invocation does not negatively impact controller functionality or UI responsiveness.
114-126
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [56-123]
Ensure the updated
UpdateState
method, including the newdelta
parameter and refactored motion data handling, accurately processes controller inputs and motion data.
175-177
: Confirm that the changes to continuous calibration management inAttachJoySettings
do not adversely affect controller accuracy or responsiveness.HandheldCompanion/Controllers/IController.xaml (5)
28-37
: Consider using a resource dictionary forFontIcon
properties to ensure consistency and ease of maintenance.
39-99
: The addition of multipleBorder
elements forUserIndexPanel
is a good approach for indicating user indices. Ensure that theBackground
andCornerRadius
properties align with the application's design guidelines.
110-117
: The buttonContent
property is now directly set, which is a good practice for localization. Ensure all button contents are managed through resource files for easier localization.
124-124
: Thed:Visibility
property is set toVisible
for design-time support, which is a good practice. Ensure runtime visibility is controlled appropriately in the code-behind or view model.
133-141
: ReplacingProgressBarPanel
withProgressBarWarning
and adjusting its properties enhances the user interface. Ensure that theVisibility
property is dynamically controlled based on application state.HandheldCompanion/Controllers/SteamController.cs (3)
2-4
: Addingusing
directives forHandheldCompanion.Managers
andSystem
is necessary for the new functionality introduced. Ensure that these namespaces are used efficiently within the file.
17-18
: Subscribing to theSettingValueChanged
event and callingUpdateSettings
in the constructor ensures that the controller's settings are initialized and dynamically updated. This is a good practice for maintaining state consistency.
31-38
: TheSettingsManager_SettingValueChanged
method efficiently handles setting changes by checking the setting name and applying the new value. This modular approach facilitates easy addition of new settings in the future.HandheldCompanion/Devices/AYANEO/AYANEODeviceCEc.cs (5)
1-8
: Addingusing
directives for necessary namespaces is a good start. Ensure that all used namespaces are necessary for the functionality of this class to avoid unnecessary dependencies.
15-22
: Defining properties for LED control such asledStatus
,ledBrightness
, andledColorSticks
is essential for managing device-specific settings. Ensure these properties are encapsulated properly and accessed safely.
79-99
: The implementation ofSetLedStatus
method with proper locking mechanism ensures thread safety. This is crucial for hardware interaction operations to prevent race conditions.
118-148
: TheSetLedColor
method's switch statement for handling differentLEDLevel
values is a good structure for future expansion. Ensure that all possible LED levels are handled appropriately.
193-195
: TheCEcRgb_GetBrightness
method correctly calculates the brightness based on the color value and the LED brightness setting. This method demonstrates good use of mathematical operations for hardware control.HandheldCompanion/ADLX/ADLXBackend.cs (4)
10-51
: Defining theAdlxTelemetryData
struct to encapsulate telemetry data is a clean and organized way to handle hardware information. Ensure that all fields are necessary and correctly used throughout the application.
54-70
: EnumeratingADLX_RESULT
codes provides a clear and maintainable way to handle various outcomes of ADLX operations. This approach enhances code readability and error handling.
73-125
: The P/Invoke declarations for interacting with the ADLX wrapper DLL are correctly defined. Ensure that the calling conventions and parameter types match those defined in the native DLL to prevent runtime errors.
127-132
: TheGetTelemetryData
method efficiently retrieves telemetry data and encapsulates it within theAdlxTelemetryData
struct. This method simplifies the process of obtaining hardware telemetry.HandheldCompanion/App.config (1)
251-289
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [228-286]
The addition of new settings related to on-screen display levels and configurations is a significant enhancement for user customization. Ensure that these settings are properly documented and validated to prevent invalid configurations.
HandheldCompanion/Controllers/GordonController.cs (4)
23-24
: Adding a parameterless constructor forGordonController
is necessary for instantiation without specific parameters. Ensure that any required initialization is handled appropriately within the constructor.
40-40
: TheInitializeInputOutput
method is crucial for setting up controller-specific input and output configurations. This method enhances modularity and readability by separating configuration logic.
204-227
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [88-224]
Modifying the
UpdateInputs
method to accept an additionalfloat delta
parameter allows for more precise control and processing of inputs, especially for motion data. Ensure that thedelta
parameter is used effectively within the method.
207-214
: Swapping the axes for gyro and accelerometer data processing may be necessary due to hardware specifics. Ensure that these adjustments are documented and tested for accuracy.HandheldCompanion/Controllers/XInputController.cs (3)
54-60
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [57-124]
The addition of the
float delta
parameter toUpdateInputs
is a good enhancement for timing precision. Ensure all calls toUpdateInputs
are updated accordingly.
152-158
: Correctly updated event subscriptions inPlug
andUnplug
methods to include thedelta
parameter. Ensure to test these changes for proper event handling.
201-214
: The newIsWireless
property is a useful addition for distinguishing connection types. Verify its usage across the application to ensure it's leveraged effectively.Verification successful
The usage of the
IsWireless
property across different parts of the application, including in controller management and within the controller hierarchy, has been confirmed. This indicates that the property is leveraged effectively for distinguishing between wireless and wired connections, aligning with the intended purpose of the addition.Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usage of IsWireless property. Expecting relevant results. rg --type cs 'IsWireless'Length of output: 679
HandheldCompanion/Controllers/NeptuneController.cs (4)
31-33
: The addition of a default constructor increases instantiation flexibility. Good for testing or scenarios wherePnPDetails
are not immediately available.
43-49
: Enhanced controller functionality with additional buttons and axes inInitializeInputOutput
. Verify their integration into the application's input handling logic.Verification successful
The integration of the new buttons and axes (ButtonFlags.L4, ButtonFlags.R4, ButtonFlags.L5, ButtonFlags.R5, AxisLayoutFlags.Gyroscope) into the application has been successfully verified. Their usage across Controllers, Views, ViewModels, and Resources confirms a comprehensive integration into the application's functionality and user interaction logic.
Scripts Executed
The following scripts were executed for the analysis:
Script:
#!/bin/bash # Search for usage of new buttons and axes. Expecting relevant results. rg --type cs 'ButtonFlags.L4|ButtonFlags.R4|ButtonFlags.L5|ButtonFlags.R5|AxisLayoutFlags.Gyroscope'Length of output: 8831
232-254
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [80-251]
Significant improvements in
UpdateInputs
with the addition offloat delta
and restructured gyro data processing. Ensure thorough testing of the new motion processing logic for accuracy and responsiveness.
336-343
: RefactoredUnplug
method for more robust rumble thread handling. Verify behavior in scenarios with frequent plug/unplug actions to ensure stability.HandheldCompanion/Controllers/LegionController.cs (4)
84-85
: Consider initializingGyroIndex
in the constructor for clarity.While initializing fields directly is valid, initializing configuration-related fields like
GyroIndex
in the constructor can improve readability and make it easier to manage default values or configurations that might depend on constructor parameters in the future.
104-114
: Ensure proper error handling in the constructor.The constructor makes external calls (
SystemParametersInfo
andUpdateSettings
). Verify that these calls are properly handling potential errors or exceptions to prevent the constructor from failing unexpectedly.
145-149
: Validate settings keys inUpdateSettings
.Ensure that the settings keys
"LegionControllerPassthrough"
and"LegionControllerGyroIndex"
exist and have valid values before using them inSetPassthrough
andSetGyroIndex
. This validation helps prevent runtime errors due to missing or invalid settings.
248-338
: Optimize gyroscopic data processing inUpdateInputs
.The method
UpdateInputs
processes gyroscopic data with repeated code blocks for differentGyroIndex
values. Consider refactoring this logic into a separate method to reduce duplication and improve maintainability.Additionally, verify the correctness of the axis inversion and scaling factors used for accelerometer and gyroscope data processing to ensure accurate motion sensing.
HandheldCompanion/Devices/ASUS/ROGAlly.cs (7)
97-105
: Adjustments to gyrometer and accelerometer axis values and swaps appear to correct orientation issues. Ensure these changes align with hardware specifications.
125-156
: Modifications to power profiles, including CPU boost levels, GUIDs, and TDP override values, aim to optimize power management. Ensure thorough testing on target hardware to validate these settings.
171-178
: Updates to OEM chord key bindings and the introduction of a new byte array for "M1" and "M2" buttons suggest enhancements in input handling. Validate these changes to ensure they work as intended.
674-674
: Dynamic mapping selection based on the 'Remap' flag enhances controller configuration flexibility. Consider adding documentation for clarity on theRemap
flag's usage.
122-159
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-674]
The code is well-organized but lacks comments explaining methods and significant code blocks. Adding comments would improve maintainability and understandability.
122-159
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-674]
Consider enhancing error handling and validation in methods interacting with hardware to improve resilience and reliability.
122-159
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [1-674]
Replace magic numbers and literals with named constants or enumerations to enhance code readability and maintainability.
HandheldCompanion/DSU/DSUServer.cs (8)
425-425
: EnsureudpSock
is not null before callingIOControl
.This null check before calling
IOControl
is a good practice to avoid potential null reference exceptions.
566-566
: Update accelerometer data indexing based onGyroState.SensorState.DSU
.The update to the indexing for accessing accelerometer data ensures that the correct data is being used, aligning with the
GyroState.SensorState.DSU
enum.
569-569
: Update accelerometer data indexing based onGyroState.SensorState.DSU
.Similar to the previous comment, this change ensures that the Y-axis accelerometer data is correctly indexed and used.
572-572
: Update accelerometer data indexing based onGyroState.SensorState.DSU
.This change ensures that the Z-axis accelerometer data is correctly indexed and used, maintaining consistency with the DSU sensor state.
577-577
: Update gyroscope data indexing based onGyroState.SensorState.DSU
.The update to the indexing for accessing gyroscope data on the X-axis aligns with the
GyroState.SensorState.DSU
enum, ensuring accurate data usage.
580-580
: Update gyroscope data indexing based onGyroState.SensorState.DSU
.This change correctly updates the indexing for the Y-axis gyroscope data, including the negation to align with expected values.
583-583
: Update gyroscope data indexing based onGyroState.SensorState.DSU
.Similar to the previous comments, this update ensures that the Z-axis gyroscope data is correctly indexed and negated, aligning with the DSU sensor state.
590-590
: Modify theTick
method signature to include afloat delta
parameter.Adding a
float delta
parameter to theTick
method signature allows for more precise control and handling based on the time delta, which can be crucial for time-sensitive operations.HandheldCompanion.iss (21)
5-11
: Consider guarding#define UseDotNet80
with a more specific condition or configuration flag.This ensures that the directive is only enabled when necessary, potentially avoiding unnecessary dependencies or setup steps for environments that do not require .NET Desktop Runtime 8.0.
26-34
: Ensure versioning and naming conventions are consistent and up-to-date.Verify that the version numbers (
InstallerVersion
,MyAppVersion
) and application details (MyAppSetupName
,MyAppPublisher
, etc.) are current and accurately reflect the application's state. This is crucial for user recognition and version management.
48-52
: Update dependency versions only after thorough testing.Before updating the versions of critical dependencies like .NET, DirectX, ViGem, and others, ensure they have been thoroughly tested with the application. Compatibility issues can arise from minor version changes, impacting the user experience.
57-62
: Validate the integrity of new download links.Ensure the new download links for dependencies are valid and point to the correct versions. It's also a good practice to verify the integrity of downloaded files to prevent tampering or corruption.
73-93
: Review new setup configuration options for potential impacts.The introduction of new setup configuration options, such as
AllowNoIcons
,ArchitecturesInstallIn64BitMode
, andSolidCompression
, should be carefully reviewed to ensure they align with the application's deployment and compatibility requirements.
102-111
: Ensure new file sources and destinations are correctly configured.Verify that the new sources and destinations for files in the setup script are correctly configured and that the files exist at the specified paths. This is crucial to prevent installation errors or missing files during deployment.
124-126
: Confirm the post-installation behavior meets expectations.Ensure that the post-installation behavior, such as automatically starting the application, aligns with user expectations and doesn't introduce any unwanted side effects.
131-133
: Review uninstallation commands for potential issues.Carefully review the uninstallation commands, especially those that involve external utilities or scripts, to ensure they execute correctly and do not leave residual files or configurations.
144-155
: Validate the structure and completeness ofTDependency_Entry
.Ensure that the
TDependency_Entry
record contains all necessary fields for managing dependencies effectively. Consider adding fields for version constraints or platform-specific details if needed.
164-174
: Review the forward declarations for dependency management functions.Verify that the forward declarations for dependency management functions are correctly defined and that the corresponding implementations are provided elsewhere in the script. This ensures that the setup process can manage dependencies effectively.
177-182
: Ensure included utility scripts are up-to-date and compatible.Confirm that the included utility scripts (
CompareVersions.iss
,ApiUtils.iss
, etc.) are up-to-date and compatible with the current version of the setup script. This is crucial for maintaining the integrity and functionality of the setup process.
184-187
: Review the initialization of the wizard and dependency download page.Ensure that the initialization of the wizard and the creation of the
Dependency_DownloadPage
are correctly implemented and that the download page behaves as expected during the setup process.
199-205
: Verify the logic for hiding the run list when a restart is needed.Ensure that the logic for hiding the run list in the finished page of the setup wizard works as intended, especially in scenarios where a restart is required after installation.
208-214
: Review theNeedRestart
function for correct behavior.Confirm that the
NeedRestart
function accurately reflects whether a restart is needed based on the installation of dependencies. This is crucial for ensuring a smooth user experience and system stability.
216-226
: Ensure thePrepareToInstall
function handles restarts correctly.Verify that the
PrepareToInstall
function correctly determines if a restart is needed and handles any exceptions or errors gracefully. This function plays a critical role in the setup process, especially for managing dependencies.
228-231
: Validate the generation of the update ready memo.Ensure that the
Dependency_UpdateReadyMemo
function correctly generates the update ready memo, including all necessary information and formatting. This memo is important for informing users about the installation process and any required actions.
234-290
: Review uninstallation logic for potential improvements or issues.Carefully review the uninstallation logic, especially the conditional deletion of directories and the uninstallation of dependencies like HidHide and ViGem. Ensure that the logic is robust and handles various scenarios correctly.
293-385
: Confirm the setup initialization logic correctly manages dependencies.Verify that the setup initialization logic, including version checks and conditional addition of dependencies, is correctly implemented. This is crucial for ensuring that the application is installed with all necessary dependencies and that updates are handled appropriately.
405-446
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [389-440]
Review the implementation of dependency addition functions.
Ensure that the functions for adding dependencies (
Dependency_Add
andDependency_Add_With_Version
) are correctly implemented and that they accurately manage the list of dependencies. This includes verifying the handling of file existence checks and array manipulation.
485-517
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [443-576]
Validate the dependency installation and restart logic.
Carefully review the logic for installing dependencies and handling restarts in the
Dependency_PrepareToInstall
function. Ensure that the function correctly executes dependency installers, handles errors, and sets the restart flag as needed.
690-750
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [576-749]
Ensure utility functions are correctly implemented and used.
Confirm that utility functions, such as
BoolToStr
,Dependency_IsX64
, and others, are correctly implemented and used throughout the script. These functions play a crucial role in the setup process, especially for handling platform-specific logic and formatting.
protected override void InitializeInputOutput() | ||
{ | ||
// Additional controller specific source buttons | ||
SourceButtons.Add(ButtonFlags.RightPadTouch); | ||
SourceButtons.Add(ButtonFlags.RightPadClick); | ||
SourceButtons.Add(ButtonFlags.RightPadClickDown); | ||
|
||
SourceButtons.Add(ButtonFlags.R4); | ||
SourceButtons.Add(ButtonFlags.R5); | ||
SourceButtons.Add(ButtonFlags.L4); | ||
SourceButtons.Add(ButtonFlags.L5); | ||
|
||
SourceButtons.Add(ButtonFlags.B5); | ||
SourceButtons.Add(ButtonFlags.B6); | ||
SourceButtons.Add(ButtonFlags.B7); | ||
SourceButtons.Add(ButtonFlags.B8); | ||
|
||
// Legion Controllers do not have the Special button | ||
SourceButtons.Remove(ButtonFlags.Special); | ||
|
||
SourceAxis.Add(AxisLayoutFlags.RightPad); | ||
SourceAxis.Add(AxisLayoutFlags.Gyroscope); | ||
} |
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.
Refactor to separate concerns in InitializeInputOutput
.
The method InitializeInputOutput
is responsible for initializing both buttons and axes. Consider refactoring this method to separate the initialization of buttons and axes into distinct methods for improved readability and maintainability.
- protected override void InitializeInputOutput()
+ protected override void InitializeSourceButtons()
+ protected override void InitializeSourceAxis()
Then, call these new methods from InitializeInputOutput
.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
protected override void InitializeInputOutput() | |
{ | |
// Additional controller specific source buttons | |
SourceButtons.Add(ButtonFlags.RightPadTouch); | |
SourceButtons.Add(ButtonFlags.RightPadClick); | |
SourceButtons.Add(ButtonFlags.RightPadClickDown); | |
SourceButtons.Add(ButtonFlags.R4); | |
SourceButtons.Add(ButtonFlags.R5); | |
SourceButtons.Add(ButtonFlags.L4); | |
SourceButtons.Add(ButtonFlags.L5); | |
SourceButtons.Add(ButtonFlags.B5); | |
SourceButtons.Add(ButtonFlags.B6); | |
SourceButtons.Add(ButtonFlags.B7); | |
SourceButtons.Add(ButtonFlags.B8); | |
// Legion Controllers do not have the Special button | |
SourceButtons.Remove(ButtonFlags.Special); | |
SourceAxis.Add(AxisLayoutFlags.RightPad); | |
SourceAxis.Add(AxisLayoutFlags.Gyroscope); | |
} | |
protected override void InitializeSourceButtons() | |
{ | |
// Additional controller specific source buttons | |
SourceButtons.Add(ButtonFlags.RightPadTouch); | |
SourceButtons.Add(ButtonFlags.RightPadClick); | |
SourceButtons.Add(ButtonFlags.RightPadClickDown); | |
SourceButtons.Add(ButtonFlags.R4); | |
SourceButtons.Add(ButtonFlags.R5); | |
SourceButtons.Add(ButtonFlags.L4); | |
SourceButtons.Add(ButtonFlags.L5); | |
SourceButtons.Add(ButtonFlags.B5); | |
SourceButtons.Add(ButtonFlags.B6); | |
SourceButtons.Add(ButtonFlags.B7); | |
SourceButtons.Add(ButtonFlags.B8); | |
// Legion Controllers do not have the Special button | |
SourceButtons.Remove(ButtonFlags.Special); | |
} | |
protected override void InitializeSourceAxis() | |
{ | |
SourceAxis.Add(AxisLayoutFlags.RightPad); | |
SourceAxis.Add(AxisLayoutFlags.Gyroscope); | |
} |
gamepadMotionR = new($"{details.deviceInstanceId}\\{LegionGo.RightJoyconIndex}", CalibrationMode.Manual | CalibrationMode.SensorFusion); | ||
|
||
hidDevice = GetHidDevice(); | ||
if (hidDevice is not null) | ||
hidDevice.OpenDevice(); |
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.
Handle potential exceptions when opening the HID device.
Opening a HID device (hidDevice.OpenDevice()
) can fail due to various reasons, such as permissions issues. Wrap this call in a try-catch block to handle potential exceptions gracefully.
+ try {
hidDevice.OpenDevice();
+ } catch (Exception ex) {
+ LogManager.LogError($"Failed to open HID device: {ex.Message}");
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
gamepadMotionR = new($"{details.deviceInstanceId}\\{LegionGo.RightJoyconIndex}", CalibrationMode.Manual | CalibrationMode.SensorFusion); | |
hidDevice = GetHidDevice(); | |
if (hidDevice is not null) | |
hidDevice.OpenDevice(); | |
gamepadMotionR = new($"{details.deviceInstanceId}\\{LegionGo.RightJoyconIndex}", CalibrationMode.Manual | CalibrationMode.SensorFusion); | |
hidDevice = GetHidDevice(); | |
if (hidDevice is not null) | |
try { | |
hidDevice.OpenDevice(); | |
} catch (Exception ex) { | |
LogManager.LogError($"Failed to open HID device: {ex.Message}"); | |
} |
public override void Plug() | ||
{ | ||
hidDevice = GetHidDevice(); | ||
if (hidDevice is not null && hidDevice.IsConnected) | ||
{ | ||
if (!hidDevice.IsOpen) | ||
hidDevice.OpenDevice(); | ||
|
||
// start data thread | ||
if (dataThread is null) | ||
{ | ||
dataThreadRunning = true; | ||
|
||
dataThread = new Thread(dataThreadLoop); | ||
dataThread.IsBackground = true; | ||
dataThread.Start(); | ||
} | ||
} | ||
|
||
base.Plug(); | ||
} | ||
|
||
public override void Unplug() | ||
} | ||
} |
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.
Ensure thread safety when manipulating dataThread
.
The manipulation of dataThread
and dataThreadRunning
in Plug
method lacks synchronization mechanisms, which could lead to race conditions if accessed from multiple threads. Consider using locking or other synchronization techniques to ensure thread safety.
+ lock (threadLock) {
dataThreadRunning = true;
dataThread = new Thread(dataThreadLoop);
dataThread.IsBackground = true;
dataThread.Start();
+ }
Don't forget to declare a private object threadLock
for locking purposes.
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
public override void Plug() | |
{ | |
hidDevice = GetHidDevice(); | |
if (hidDevice is not null && hidDevice.IsConnected) | |
{ | |
if (!hidDevice.IsOpen) | |
hidDevice.OpenDevice(); | |
// start data thread | |
if (dataThread is null) | |
{ | |
dataThreadRunning = true; | |
dataThread = new Thread(dataThreadLoop); | |
dataThread.IsBackground = true; | |
dataThread.Start(); | |
} | |
} | |
base.Plug(); | |
} | |
public override void Unplug() | |
} | |
} | |
public override void Plug() | |
{ | |
hidDevice = GetHidDevice(); | |
if (hidDevice is not null && hidDevice.IsConnected) | |
{ | |
if (!hidDevice.IsOpen) | |
hidDevice.OpenDevice(); | |
// start data thread | |
if (dataThread is null) | |
{ | |
lock (threadLock) { | |
dataThreadRunning = true; | |
dataThread = new Thread(dataThreadLoop); | |
dataThread.IsBackground = true; | |
dataThread.Start(); | |
} | |
} | |
} |
public override void Unplug() | ||
{ | ||
// kill data thread | ||
// Kill data thread | ||
if (dataThread is not null) | ||
{ | ||
dataThreadRunning = false; | ||
dataThread.Join(); | ||
// Ensure the thread has finished execution | ||
if (dataThread.IsAlive) | ||
dataThread.Join(); | ||
dataThread = null; | ||
} | ||
|
||
if (hidDevice is not null) | ||
{ | ||
if (hidDevice.IsConnected && hidDevice.IsOpen) | ||
} | ||
|
||
if (hidDevice is not null) | ||
{ | ||
if (hidDevice.IsConnected && hidDevice.IsOpen) | ||
hidDevice.CloseDevice(); | ||
|
||
hidDevice.Dispose(); | ||
hidDevice = null; | ||
} | ||
|
||
base.Unplug(); | ||
} | ||
|
||
public override void UpdateInputs(long ticks, bool commit) | ||
{ | ||
// skip if controller isn't connected | ||
if (!IsConnected()) | ||
return; | ||
|
||
base.UpdateInputs(ticks, false); | ||
|
||
FrontEnum frontButton = (FrontEnum)Data[FRONT_IDX]; | ||
Inputs.ButtonState[ButtonFlags.OEM1] = frontButton.HasFlag(FrontEnum.LegionR); | ||
Inputs.ButtonState[ButtonFlags.OEM2] = frontButton.HasFlag(FrontEnum.LegionL); | ||
|
||
BackEnum backButton = (BackEnum)Data[BACK_IDX]; | ||
Inputs.ButtonState[ButtonFlags.R4] = backButton.HasFlag(BackEnum.M3); | ||
Inputs.ButtonState[ButtonFlags.R5] = backButton.HasFlag(BackEnum.Y3); | ||
Inputs.ButtonState[ButtonFlags.L4] = backButton.HasFlag(BackEnum.Y1); | ||
Inputs.ButtonState[ButtonFlags.L5] = backButton.HasFlag(BackEnum.Y2); | ||
Inputs.ButtonState[ButtonFlags.B5] = backButton.HasFlag(BackEnum.M2); | ||
Inputs.ButtonState[ButtonFlags.B6] = Data[20] == 128; // Scroll click | ||
Inputs.ButtonState[ButtonFlags.B7] = Data[24] == 129; // Scroll up | ||
Inputs.ButtonState[ButtonFlags.B8] = Data[24] == 255; // Scroll down | ||
|
||
// Right Pad | ||
ushort TouchpadX = (ushort)((Data[25] << 8) | Data[26]); | ||
ushort TouchpadY = (ushort)((Data[27] << 8) | Data[28]); | ||
|
||
bool touched = (TouchpadX != 0 || TouchpadY != 0); | ||
|
||
Inputs.ButtonState[ButtonFlags.RightPadTouch] = touched; | ||
Inputs.ButtonState[ButtonFlags.RightPadClick] = false; | ||
Inputs.ButtonState[ButtonFlags.RightPadClickDown] = false; | ||
|
||
// handle touchpad if passthrough is off | ||
if (!IsPassthrough) | ||
HandleTouchpadInput(touched, TouchpadX, TouchpadY); | ||
|
||
/* | ||
Inputs.AxisState[AxisFlags.LeftStickX] += (short)InputUtils.MapRange(Data[29], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | ||
Inputs.AxisState[AxisFlags.LeftStickY] -= (short)InputUtils.MapRange(Data[30], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | ||
|
||
Inputs.AxisState[AxisFlags.RightStickX] += (short)InputUtils.MapRange(Data[31], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | ||
Inputs.AxisState[AxisFlags.RightStickY] -= (short)InputUtils.MapRange(Data[32], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | ||
*/ | ||
|
||
base.UpdateInputs(ticks); | ||
} | ||
|
||
private async void dataThreadLoop(object? obj) | ||
{ | ||
// pull latest Data | ||
while (dataThreadRunning) | ||
{ | ||
if (hidDevice is null) | ||
continue; | ||
|
||
hidDevice = null; | ||
} |
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.
Properly handle device disconnection in Unplug
.
The Unplug
method attempts to close and dispose of the hidDevice
without checking if it's already disconnected or disposed. This could lead to exceptions. Add checks to ensure the device is connected and not already disposed before attempting to close or dispose of it.
+ if (hidDevice != null && !hidDevice.IsDisposed && hidDevice.IsConnected) {
if (hidDevice.IsOpen)
hidDevice.CloseDevice();
hidDevice.Dispose();
hidDevice = null;
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
public override void Unplug() | |
{ | |
// kill data thread | |
// Kill data thread | |
if (dataThread is not null) | |
{ | |
dataThreadRunning = false; | |
dataThread.Join(); | |
// Ensure the thread has finished execution | |
if (dataThread.IsAlive) | |
dataThread.Join(); | |
dataThread = null; | |
} | |
if (hidDevice is not null) | |
{ | |
if (hidDevice.IsConnected && hidDevice.IsOpen) | |
} | |
if (hidDevice is not null) | |
{ | |
if (hidDevice.IsConnected && hidDevice.IsOpen) | |
hidDevice.CloseDevice(); | |
hidDevice.Dispose(); | |
hidDevice = null; | |
} | |
base.Unplug(); | |
} | |
public override void UpdateInputs(long ticks, bool commit) | |
{ | |
// skip if controller isn't connected | |
if (!IsConnected()) | |
return; | |
base.UpdateInputs(ticks, false); | |
FrontEnum frontButton = (FrontEnum)Data[FRONT_IDX]; | |
Inputs.ButtonState[ButtonFlags.OEM1] = frontButton.HasFlag(FrontEnum.LegionR); | |
Inputs.ButtonState[ButtonFlags.OEM2] = frontButton.HasFlag(FrontEnum.LegionL); | |
BackEnum backButton = (BackEnum)Data[BACK_IDX]; | |
Inputs.ButtonState[ButtonFlags.R4] = backButton.HasFlag(BackEnum.M3); | |
Inputs.ButtonState[ButtonFlags.R5] = backButton.HasFlag(BackEnum.Y3); | |
Inputs.ButtonState[ButtonFlags.L4] = backButton.HasFlag(BackEnum.Y1); | |
Inputs.ButtonState[ButtonFlags.L5] = backButton.HasFlag(BackEnum.Y2); | |
Inputs.ButtonState[ButtonFlags.B5] = backButton.HasFlag(BackEnum.M2); | |
Inputs.ButtonState[ButtonFlags.B6] = Data[20] == 128; // Scroll click | |
Inputs.ButtonState[ButtonFlags.B7] = Data[24] == 129; // Scroll up | |
Inputs.ButtonState[ButtonFlags.B8] = Data[24] == 255; // Scroll down | |
// Right Pad | |
ushort TouchpadX = (ushort)((Data[25] << 8) | Data[26]); | |
ushort TouchpadY = (ushort)((Data[27] << 8) | Data[28]); | |
bool touched = (TouchpadX != 0 || TouchpadY != 0); | |
Inputs.ButtonState[ButtonFlags.RightPadTouch] = touched; | |
Inputs.ButtonState[ButtonFlags.RightPadClick] = false; | |
Inputs.ButtonState[ButtonFlags.RightPadClickDown] = false; | |
// handle touchpad if passthrough is off | |
if (!IsPassthrough) | |
HandleTouchpadInput(touched, TouchpadX, TouchpadY); | |
/* | |
Inputs.AxisState[AxisFlags.LeftStickX] += (short)InputUtils.MapRange(Data[29], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | |
Inputs.AxisState[AxisFlags.LeftStickY] -= (short)InputUtils.MapRange(Data[30], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | |
Inputs.AxisState[AxisFlags.RightStickX] += (short)InputUtils.MapRange(Data[31], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | |
Inputs.AxisState[AxisFlags.RightStickY] -= (short)InputUtils.MapRange(Data[32], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | |
*/ | |
base.UpdateInputs(ticks); | |
} | |
private async void dataThreadLoop(object? obj) | |
{ | |
// pull latest Data | |
while (dataThreadRunning) | |
{ | |
if (hidDevice is null) | |
continue; | |
hidDevice = null; | |
} | |
public override void Unplug() | |
{ | |
// Kill data thread | |
if (dataThread is not null) | |
{ | |
dataThreadRunning = false; | |
// Ensure the thread has finished execution | |
if (dataThread.IsAlive) | |
dataThread.Join(); | |
dataThread = null; | |
} | |
if (hidDevice != null && !hidDevice.IsDisposed && hidDevice.IsConnected) { | |
if (hidDevice.IsOpen) | |
hidDevice.CloseDevice(); | |
hidDevice.Dispose(); | |
hidDevice = null; | |
} |
protected override async void ui_button_calibrate_Click(object sender, RoutedEventArgs e) | ||
{ | ||
switch (GyroIndex) | ||
{ | ||
default: | ||
case LegionGo.LeftJoyconIndex: | ||
SensorsManager.Calibrate(gamepadMotion); | ||
break; | ||
case LegionGo.RightJoyconIndex: | ||
SensorsManager.Calibrate(gamepadMotionR); | ||
break; | ||
} | ||
} |
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.
Asynchronous method without await in ui_button_calibrate_Click
.
The method ui_button_calibrate_Click
is marked as async
but does not contain any await
calls, which might be an oversight. Ensure that any asynchronous operations within this method are awaited properly to avoid potential runtime issues.
If there are no asynchronous operations, consider removing the async
modifier.
|
||
// If the touchpad was not touched before | ||
if (!touchpadTouched) | ||
{ | ||
// Set the touchpad state variables | ||
touchpadTouched = true; | ||
touchpadPosition = position; | ||
touchpadFirstPosition = position; | ||
touchpadStartTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; | ||
|
||
// Set the right pad touch flag to true | ||
Inputs.ButtonState[ButtonFlags.RightPadTouch] = true; | ||
|
||
long delay = touchpadStartTime - lastTap; | ||
float distance = Vector2.Distance(touchpadFirstPosition, lastTapPosition); | ||
|
||
if (delay < SystemInformation.DoubleClickTime && distance < MaxDistance * 5) | ||
{ | ||
Inputs.ButtonState[ButtonFlags.RightPadClick] = true; | ||
touchpadDoubleTapped = true; | ||
} | ||
} | ||
// If the touchpad was touched before | ||
else | ||
{ | ||
// Update the touchpad position | ||
touchpadPosition = position; | ||
|
||
// If the touchpad has been double tapped | ||
if (touchpadDoubleTapped) | ||
{ | ||
// Keep the right pad click flag to true | ||
Inputs.ButtonState[ButtonFlags.RightPadClick] = true; | ||
} | ||
else | ||
{ | ||
// Calculate the duration and the distance of the touchpad | ||
long duration = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - touchpadStartTime; | ||
float distance = Vector2.Distance(touchpadFirstPosition, touchpadPosition); | ||
|
||
// If the duration is more than the long tap duration and the distance is less than the maximum distance | ||
if (duration >= LongPressTime && duration < (LongPressTime + 100) && distance < MaxDistance) | ||
{ | ||
// If the touchpad has not been long tapped before | ||
if (!touchpadLongTapped) | ||
{ | ||
// Set the right pad click down flag to true | ||
Inputs.ButtonState[ButtonFlags.RightPadClickDown] = true; | ||
|
||
// Set the touchpad long tapped flag to true | ||
touchpadLongTapped = true; | ||
} | ||
} | ||
} | ||
} | ||
} | ||
// If the touchpad is not touched | ||
else | ||
{ | ||
Inputs.AxisState[AxisFlags.RightPadX] = 0; | ||
Inputs.AxisState[AxisFlags.RightPadY] = 0; | ||
|
||
// If the touchpad was touched before | ||
if (touchpadTouched) | ||
{ | ||
// Set the touchpad state variables | ||
touchpadTouched = false; | ||
touchpadEndTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; | ||
|
||
// Set the right pad touch flag to false | ||
Inputs.ButtonState[ButtonFlags.RightPadTouch] = false; | ||
|
||
// Calculate the duration and the distance of the touchpad | ||
long duration = touchpadEndTime - touchpadStartTime; | ||
float distance = Vector2.Distance(touchpadFirstPosition, touchpadPosition); | ||
|
||
// If the duration is less than the short tap duration and the distance is less than the maximum distance | ||
if (duration < SystemInformation.DoubleClickTime && distance < MaxDistance) | ||
{ | ||
// Set the right pad click flag to true | ||
Inputs.ButtonState[ButtonFlags.RightPadClick] = true; | ||
|
||
// Store tap time | ||
lastTap = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; | ||
lastTapPosition = touchpadPosition; | ||
} | ||
|
||
// Set the touchpad long tapped flag to false | ||
touchpadLongTapped = false; | ||
|
||
// Set the touchpad double tapped flag to false | ||
touchpadDoubleTapped = false; | ||
} | ||
} | ||
} | ||
|
||
internal void SetPassthrough(bool enabled) | ||
{ | ||
} | ||
} |
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.
Handle potential null reference in dataThreadLoop
.
In the dataThreadLoop
method, there's a potential for a null reference exception when accessing report.Data
without checking if report
or report.Data
is null. Add null checks to prevent runtime exceptions.
+ if (report != null && report.Data != null && READY_STATES.Contains(report.Data[STATUS_IDX])) {
Data = report.Data;
+ }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
private async void dataThreadLoop(object? obj) | |
{ | |
// pull latest Data | |
while (dataThreadRunning) | |
{ | |
if (hidDevice is null) | |
continue; | |
HidReport report = hidDevice.ReadReport(); | |
if (report is not null) | |
{ | |
// check if packet is safe | |
if (report is not null) | |
{ | |
// check if packet is safe | |
if (READY_STATES.Contains(report.Data[STATUS_IDX])) | |
{ | |
Data = report.Data; | |
} | |
} | |
} | |
} | |
public override string GetGlyph(ButtonFlags button) | |
{ | |
switch (button) | |
{ | |
case ButtonFlags.B5: | |
return "\u2213"; // M2 | |
case ButtonFlags.B6: | |
return "\u2206"; // Scroll click | |
case ButtonFlags.B7: | |
return "\u27F0"; // Scroll up | |
case ButtonFlags.B8: | |
return "\u27F1"; // Scroll down | |
} | |
return base.GetGlyph(button); | |
} | |
public void HandleTouchpadInput(bool touched, ushort x, ushort y) | |
{ | |
// Convert the ushort values to Vector2 | |
Vector2 position = new Vector2(x, y); | |
// If the touchpad is touched | |
if (touched) | |
{ | |
Inputs.AxisState[AxisFlags.RightPadX] = (short)InputUtils.MapRange((short)x, 0, 1000, short.MinValue, short.MaxValue); | |
Inputs.AxisState[AxisFlags.RightPadY] = (short)InputUtils.MapRange((short)-y, 0, 1000, short.MinValue, short.MaxValue); | |
// If the touchpad was not touched before | |
if (!touchpadTouched) | |
{ | |
// Set the touchpad state variables | |
touchpadTouched = true; | |
touchpadPosition = position; | |
touchpadFirstPosition = position; | |
touchpadStartTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; | |
// Set the right pad touch flag to true | |
Inputs.ButtonState[ButtonFlags.RightPadTouch] = true; | |
long delay = touchpadStartTime - lastTap; | |
float distance = Vector2.Distance(touchpadFirstPosition, lastTapPosition); | |
if (delay < SystemInformation.DoubleClickTime && distance < MaxDistance * 5) | |
{ | |
Inputs.ButtonState[ButtonFlags.RightPadClick] = true; | |
touchpadDoubleTapped = true; | |
} | |
} | |
// If the touchpad was touched before | |
else | |
{ | |
// Update the touchpad position | |
touchpadPosition = position; | |
// If the touchpad has been double tapped | |
if (touchpadDoubleTapped) | |
{ | |
// Keep the right pad click flag to true | |
Inputs.ButtonState[ButtonFlags.RightPadClick] = true; | |
} | |
else | |
{ | |
// Calculate the duration and the distance of the touchpad | |
long duration = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond - touchpadStartTime; | |
float distance = Vector2.Distance(touchpadFirstPosition, touchpadPosition); | |
// If the duration is more than the long tap duration and the distance is less than the maximum distance | |
if (duration >= LongPressTime && duration < (LongPressTime + 100) && distance < MaxDistance) | |
{ | |
// If the touchpad has not been long tapped before | |
if (!touchpadLongTapped) | |
{ | |
// Set the right pad click down flag to true | |
Inputs.ButtonState[ButtonFlags.RightPadClickDown] = true; | |
// Set the touchpad long tapped flag to true | |
touchpadLongTapped = true; | |
} | |
} | |
} | |
} | |
} | |
// If the touchpad is not touched | |
else | |
{ | |
Inputs.AxisState[AxisFlags.RightPadX] = 0; | |
Inputs.AxisState[AxisFlags.RightPadY] = 0; | |
// If the touchpad was touched before | |
if (touchpadTouched) | |
{ | |
// Set the touchpad state variables | |
touchpadTouched = false; | |
touchpadEndTime = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; | |
// Set the right pad touch flag to false | |
Inputs.ButtonState[ButtonFlags.RightPadTouch] = false; | |
// Calculate the duration and the distance of the touchpad | |
long duration = touchpadEndTime - touchpadStartTime; | |
float distance = Vector2.Distance(touchpadFirstPosition, touchpadPosition); | |
// If the duration is less than the short tap duration and the distance is less than the maximum distance | |
if (duration < SystemInformation.DoubleClickTime && distance < MaxDistance) | |
{ | |
// Set the right pad click flag to true | |
Inputs.ButtonState[ButtonFlags.RightPadClick] = true; | |
// Store tap time | |
lastTap = DateTime.Now.Ticks / TimeSpan.TicksPerMillisecond; | |
lastTapPosition = touchpadPosition; | |
} | |
// Set the touchpad long tapped flag to false | |
touchpadLongTapped = false; | |
// Set the touchpad double tapped flag to false | |
touchpadDoubleTapped = false; | |
} | |
} | |
} | |
internal void SetPassthrough(bool enabled) | |
{ | |
} | |
} | |
private async void dataThreadLoop(object? obj) | |
{ | |
// pull latest Data | |
while (dataThreadRunning) | |
{ | |
if (hidDevice is null) | |
continue; | |
HidReport report = hidDevice.ReadReport(); | |
if (report != null && report.Data != null && READY_STATES.Contains(report.Data[STATUS_IDX])) { | |
Data = report.Data; | |
} | |
} |
HandheldCompanion.iss
Outdated
procedure CurStepChanged(CurStep: TSetupStep); | ||
begin | ||
if CurStep = ssPostInstall then | ||
begin | ||
//TODO - Add firewall entry | ||
end; |
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.
Consider implementing the TODO item for adding a firewall entry.
It appears there's a TODO comment for adding a firewall entry during the post-installation step. If you need assistance with implementing this feature, I can help or open a GitHub issue to track this task.
// Base class implementing FAN/RGB control for all AYANEO device using the CEii protocol | ||
// AIR Plus AMD, AIR Plus Mendocino, AIR Plus Intel, Slide | ||
public class AYANEODeviceCEii : AYANEODeviceCEc | ||
{ | ||
public AYANEODeviceCEii() | ||
{ | ||
this.ECDetails = new ECDetails | ||
{ | ||
AddressStatusCommandPort = 0x4e, | ||
AddressDataPort = 0x4f, | ||
AddressFanControl = 0xc8, | ||
AddressFanDuty = 0x04, | ||
FanValueMin = 0, | ||
FanValueMax = 255 | ||
}; |
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.
Consider using a constructor initializer for ECDetails
to improve readability.
- this.ECDetails = new ECDetails
+ public AYANEODeviceCEii() : base(new ECDetails
{
AddressStatusCommandPort = 0x4e,
AddressDataPort = 0x4f,
AddressFanControl = 0xc8,
AddressFanDuty = 0x04,
FanValueMin = 0,
FanValueMax = 255
- };
+ }) { }
Committable suggestion
‼️ IMPORTANT
Carefully review the code before committing. Ensure that it accurately replaces the highlighted code, contains no missing lines, and has no issues with indentation.
// Base class implementing FAN/RGB control for all AYANEO device using the CEii protocol | |
// AIR Plus AMD, AIR Plus Mendocino, AIR Plus Intel, Slide | |
public class AYANEODeviceCEii : AYANEODeviceCEc | |
{ | |
public AYANEODeviceCEii() | |
{ | |
this.ECDetails = new ECDetails | |
{ | |
AddressStatusCommandPort = 0x4e, | |
AddressDataPort = 0x4f, | |
AddressFanControl = 0xc8, | |
AddressFanDuty = 0x04, | |
FanValueMin = 0, | |
FanValueMax = 255 | |
}; | |
// Base class implementing FAN/RGB control for all AYANEO device using the CEii protocol | |
// AIR Plus AMD, AIR Plus Mendocino, AIR Plus Intel, Slide | |
public class AYANEODeviceCEii : AYANEODeviceCEc | |
{ | |
public AYANEODeviceCEii() : base(new ECDetails | |
{ | |
AddressStatusCommandPort = 0x4e, | |
AddressDataPort = 0x4f, | |
AddressFanControl = 0xc8, | |
AddressFanDuty = 0x04, | |
FanValueMin = 0, | |
FanValueMax = 255 | |
}) { } |
* SapientiaUsb update * Legion Go - additional settings
- GPUManager should be started before Profile and PowerProfile managers to avoid an IGCL/ADLX calls from being made before they're initialized. - Implemented an IsInitialized check before executing any ADLX/IGCL calls. - Implemented a try{] catch{} on GPU Execute(). - Halt Telemetry timer before closing IGCL/ADLX.
* Log inner exceptions * Update GPU.cs
* Test * more work * misc * Can we actually take advantage of Device_DevNodeStatus? * improve internal/external detection
* implement proper IController virtual bool IsWireless - Used by XInputController - Used by LegionController We might want to implement it for Joyshock controllers * fix IsBusy boolean check on IController * improve compatibility with wireless xbox controllers * Bluetooth controllers are necessarily external * improve the readability of controller messages * add bluetooth icon
…e#186) * early wip * more work * improve DesktopScreen GetResolution() logic * implement GPUManager Hooked event * prevent crash on null gpu variable * improve performance manager locks logic * more work on ADLX - Implemented displayIdx logic - Renamed a few ADLXBackend arguments for clarity - Leveraging WindowsDisplayAPI library to link a display DisplayName with its FriendlyName (which is reported by ADLX - Now storing FriendlyName and DevicePath on DesktopScreen * add new functions to MultimediaManager - GetDisplayFriendlyName() - GetDisplayPath() - GetDisplayTarget()
User will have to update their hotkeys/layouts.
* move a few calls away from MainWindow * improve main window loading experience * halt and resume GPU manager on sleep/resume * suspend/resume LibreHardwareMonitor with system * check IGCL/ADLX status before trying to terminate() * migrate GPU wait to GPUManager * mark GPU as Halting on system stop/sleep Prevents any further ADLX/IGCL calls while GPU is halting * Fixes Valkirie#990 * misc edit to VirtualManager and vTargets * Improved management of controller-specific parameters - Implemented IController UpdateSettings() - Implemented UpdateSettings() supports over LegionController and SteamController * improve lock logic on GPU * revert GPU halting logic I need to learn about Semaphore here to lock and release from different thread. * implement CrossThreadLock class - used by GPU * delay system until we're done ! * fix usage of CrossThreadLock within GPU * fix DesktopScreen GetResolution() That's dirty :'( * Support for Ayaneo Slide Support for Ayaneo Slide --------- Co-authored-by: DevL0rd <[email protected]>
- GyroState is now storing all variants of Gyroscope and Accelerometer using SensorState enum. - DualShock4Target and Xbox360Target will no longer rely on TimerManager but instead wait for VirtualManager UpdateInputs(). - DualShock4Target will no-longer rely on pre-calibrated data from GMH.
* 3D model, update GradientHighlight function. * 3D Model, code cleanup. * 3D Overlay, remove models that are not used often * 3D overlay, HighLightButtons function cleanup and exception commentary * 3D Overlay, define generic UpdateJoystick function * 3D Overlay generic UpdateShouldButtons method * 3D Overlay, minor cleanup. * 3D Overlay, fix default camera and device pose when there is no motion * 3D Overlay, align front of viewport with front of device. * 3D Overlay, separate resting pitch from face camera.
- implemented PowerProfileManager functions: HasDefault(), GetDefault()
* Rewrite standard LED control * Use correct value for turning LED on again * Rename to AYANEODeviceCEc * Add support for CEii family * Some code cleanup * Add some comments * Add FAN support for CEii & formatting * Implement SetFanControl for CEii * Fix swapped offsets * Use override * Fix formatting * Use seperate stick controls, and correct LED offsets * Implement CWinIoX_ECRamWriteDirect * Fix Addresss for FAN duty * Some RGB improvements * Use correct group for confirm * Fix colorAddress correction * Add keyboard RGB support for Slide * Rename AYAButton to AYA * Fix CEii RGB offsets * Improve RGB color changes * Don't use GlobalOff/GlobalOn inside of SetLedColor * Potentially fix RGB weirdness * Simplify more code * Cleanup CEii class * Make secondary unavailable for Slide * Use SlowOff and GlobalOn during color changes * Double loop on AIR CEc devices * Fix my name LOL * Fix IsECReady speed * Remove double loop on Air * Add back double looping * Extreme sleeps to test * Use normal lock * Loop once only * Update isECReady from 100 iterations to 250 msec while --------- Co-authored-by: CasperH2O <[email protected]>
* implement IMUCalibration maxG, maxA * implement GamepadMotion threshold calibration functions * implement threshold calibration * force sensors to use MinimumReportInterval if higher than updateInterval * what's wrong with DSU !? * Sorted * implement SensorReading * implement overflow protection by leveraging GamepadMotion threshold * override threshold for LegionGo (fix overflow)
* Cleanup CEii family * Cleanup CEc family * Cleanup glyphs
* Add support for AYANEO Next Lite * Use inheritance instead of boolean flag
… TimerManager Elapsed deciseconds
- no-longer update UI when virtual manager controller selected event is raised (might be a bad idea but unless we explicitly state the HIDmode was set by a profile, it's bad). - added a threadLock to prevent virtual manager from flooding HIDmode/HIDstatus switch. - virtual manager will wait until controller manager is ready before trying to manipulate the virtual controller. - restore default HID mode when profile is discarded.
- if main sensor is internal/external, swap axis to Yaw. - if main sensor is controller, compare accelZ and accelY to swap axis.
* Change all BeginInvoke to Invoke * for loops should be inside dispatcher, not outside
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.
Actionable comments posted: 2
Review Status
Configuration used: CodeRabbit UI
Files ignored due to path filters (4)
HandheldCompanion/ADLX_Wrapper.dll
is excluded by!**/*.dll
HandheldCompanion/GamepadMotion.dll
is excluded by!**/*.dll
HandheldCompanion/IGCL_Wrapper.dll
is excluded by!**/*.dll
HandheldCompanion/Resources/device_msi_claw.png
is excluded by!**/*.png
Files selected for processing (57)
- .github/ISSUE_TEMPLATE/bug_report.md (2 hunks)
- .github/ISSUE_TEMPLATE/feature_request.md (1 hunks)
- HandheldCompanion.iss (1 hunks)
- HandheldCompanion/ADLX/ADLXBackend.cs (3 hunks)
- HandheldCompanion/Actions/GyroActions.cs (1 hunks)
- HandheldCompanion/App.config (1 hunks)
- HandheldCompanion/App.xaml (1 hunks)
- HandheldCompanion/App.xaml.cs (2 hunks)
- HandheldCompanion/Controllers/DInputController.cs (2 hunks)
- HandheldCompanion/Controllers/DS4Controller.cs (6 hunks)
- HandheldCompanion/Controllers/DualSenseController.cs (4 hunks)
- HandheldCompanion/Controllers/GordonController.cs (6 hunks)
- HandheldCompanion/Controllers/IController.xaml (3 hunks)
- HandheldCompanion/Controllers/IController.xaml.cs (17 hunks)
- HandheldCompanion/Controllers/JSController.cs (6 hunks)
- HandheldCompanion/Controllers/LegionController.cs (3 hunks)
- HandheldCompanion/Controllers/NeptuneController.cs (6 hunks)
- HandheldCompanion/Controllers/ProController.cs (1 hunks)
- HandheldCompanion/Controllers/SteamController.cs (2 hunks)
- HandheldCompanion/Controllers/XInputController.cs (4 hunks)
- HandheldCompanion/Controls/Hints/Hint_AMD_IntegerScalingCheck.cs (3 hunks)
- HandheldCompanion/Controls/Hints/Hint_CoreIsolationCheck.cs (3 hunks)
- HandheldCompanion/Controls/Hints/Hint_LegionGoLegionSpace.cs (4 hunks)
- HandheldCompanion/Controls/Hints/Hint_MSIClawCenter.cs (1 hunks)
- HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs (5 hunks)
- HandheldCompanion/Controls/Hints/Hint_SteamNeptuneDesktop.cs (1 hunks)
- HandheldCompanion/Controls/Hints/Hint_SteamXboxDrivers.cs (1 hunks)
- HandheldCompanion/Controls/ProcessEx.cs (1 hunks)
- HandheldCompanion/Converters/InverseBooleanToVisibilityConverter.cs (1 hunks)
- HandheldCompanion/Converters/IsNullConverter.cs (1 hunks)
- HandheldCompanion/DSU/DSUServer.cs (2 hunks)
- HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs (1 hunks)
- HandheldCompanion/Devices/ASUS/ROGAlly.cs (5 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEO2.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEO2021.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEO2021Pro.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEO2S.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIR.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIR1S.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRLite.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlus.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusAMD.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusAMDMendocino.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusIntel.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPro.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEODeviceCEc.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEODeviceCEii.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOKUN.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEONEXT.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEONEXTLite.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEONEXTLite4500U.cs (1 hunks)
- HandheldCompanion/Devices/AYANEO/AYANEOSLIDE.cs (1 hunks)
- HandheldCompanion/Devices/Ayn/AynLoki.cs (1 hunks)
- HandheldCompanion/Devices/DefaultDevice.cs (1 hunks)
- HandheldCompanion/Devices/GPD/GPDWin4-2023-7840U.cs (1 hunks)
- HandheldCompanion/Devices/GPD/GPDWin4.cs (1 hunks)
- HandheldCompanion/Devices/GPD/GPDWinMax2AMD.cs (1 hunks)
Files not processed due to max files limit (63)
- HandheldCompanion/Devices/GPD/GPDWinMax2Intel.cs
- HandheldCompanion/Devices/GPD/GPDWinMini-7840U.cs
- HandheldCompanion/Devices/IDevice.cs
- HandheldCompanion/Devices/Lenovo/LegionGo.cs
- HandheldCompanion/Devices/Lenovo/SapientiaUsb.cs
- HandheldCompanion/Devices/MSI/ClawA1M.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayer2.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerMini.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniAMD.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniIntel.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerMiniPro.cs
- HandheldCompanion/Devices/OneXPlayer/OneXPlayerOneXFly.cs
- HandheldCompanion/Extensions/GlyphExtensions.cs
- HandheldCompanion/Extensions/UIThreadExtensions.cs
- HandheldCompanion/GraphicsProcessingUnit/AMDGPU.cs
- HandheldCompanion/GraphicsProcessingUnit/GPU.cs
- HandheldCompanion/GraphicsProcessingUnit/IntelGPU.cs
- HandheldCompanion/HandheldCompanion.csproj
- HandheldCompanion/Helpers/GamepadMotion.cs
- HandheldCompanion/IGCL/IGCLBackend.cs
- HandheldCompanion/Inputs/AxisState.cs
- HandheldCompanion/Inputs/ButtonState.cs
- HandheldCompanion/Inputs/GyroState.cs
- HandheldCompanion/Managers/ControllerManager.cs
- HandheldCompanion/Managers/Desktop/DesktopScreen.cs
- HandheldCompanion/Managers/DeviceManager.cs
- HandheldCompanion/Managers/GPUManager.cs
- HandheldCompanion/Managers/Hotkeys/Hotkey.cs
- HandheldCompanion/Managers/HotkeysManager.cs
- HandheldCompanion/Managers/InputsManager.cs
- HandheldCompanion/Managers/LayoutManager.cs
- HandheldCompanion/Managers/MultimediaManager.cs
- HandheldCompanion/Managers/PerformanceManager.cs
- HandheldCompanion/Managers/ProcessManager.cs
- HandheldCompanion/Managers/ProfileManager.cs
- HandheldCompanion/Managers/SensorsManager.cs
- HandheldCompanion/Managers/SettingsManager.cs
- HandheldCompanion/Managers/SystemManager.cs
- HandheldCompanion/Managers/TimerManager.cs
- HandheldCompanion/Managers/UpdateManager.cs
- HandheldCompanion/Managers/VirtualManager.cs
- HandheldCompanion/Misc/Dialog.cs
- HandheldCompanion/Misc/FanProfile.cs
- HandheldCompanion/Misc/FlickStick.cs
- HandheldCompanion/Misc/GlyphIconInfo.cs
- HandheldCompanion/Misc/HidHide.cs
- HandheldCompanion/Misc/Layout.cs
- HandheldCompanion/Misc/MadgwickAHRS.cs
- HandheldCompanion/Misc/MotherboardInfo.cs
- HandheldCompanion/Misc/OneEuroFilter.cs
- HandheldCompanion/Misc/PnPDetails.cs
- HandheldCompanion/Misc/PowerProfile.cs
- HandheldCompanion/Misc/Profile.cs
- HandheldCompanion/Misc/SensorFusion.cs
- HandheldCompanion/Misc/USBDeviceInfo.cs
- HandheldCompanion/Models/AYANEO 2021/L1.obj
- HandheldCompanion/Models/AYANEO 2021/LeftStickClick.obj
- HandheldCompanion/Models/AYANEO 2021/R1.obj
- HandheldCompanion/Models/AYANEO 2021/RightStickClick.obj
- HandheldCompanion/Models/AYANEO NEXT/L1.obj
- HandheldCompanion/Models/AYANEO NEXT/LeftStickClick.obj
- HandheldCompanion/Models/AYANEO NEXT/OEM1.obj
- HandheldCompanion/Models/AYANEO NEXT/OEM2.obj
Files skipped from review as they are similar to previous changes (45)
- .github/ISSUE_TEMPLATE/feature_request.md
- HandheldCompanion.iss
- HandheldCompanion/ADLX/ADLXBackend.cs
- HandheldCompanion/Actions/GyroActions.cs
- HandheldCompanion/App.config
- HandheldCompanion/App.xaml
- HandheldCompanion/App.xaml.cs
- HandheldCompanion/Controllers/DInputController.cs
- HandheldCompanion/Controllers/DS4Controller.cs
- HandheldCompanion/Controllers/DualSenseController.cs
- HandheldCompanion/Controllers/GordonController.cs
- HandheldCompanion/Controllers/IController.xaml
- HandheldCompanion/Controllers/NeptuneController.cs
- HandheldCompanion/Controllers/ProController.cs
- HandheldCompanion/Controllers/SteamController.cs
- HandheldCompanion/Controllers/XInputController.cs
- HandheldCompanion/Controls/Hints/Hint_AMD_IntegerScalingCheck.cs
- HandheldCompanion/Controls/Hints/Hint_CoreIsolationCheck.cs
- HandheldCompanion/Controls/Hints/Hint_LegionGoLegionSpace.cs
- HandheldCompanion/Controls/Hints/Hint_MSIClawCenter.cs
- HandheldCompanion/Controls/Hints/Hint_RogAllyServiceCheck.cs
- HandheldCompanion/Controls/Hints/Hint_SteamNeptuneDesktop.cs
- HandheldCompanion/Controls/Hints/Hint_SteamXboxDrivers.cs
- HandheldCompanion/Controls/ProcessEx.cs
- HandheldCompanion/Converters/InverseBooleanToVisibilityConverter.cs
- HandheldCompanion/Converters/IsNullConverter.cs
- HandheldCompanion/DSU/DSUServer.cs
- HandheldCompanion/Devices/AOKZOE/AOKZOEA1.cs
- HandheldCompanion/Devices/ASUS/ROGAlly.cs
- HandheldCompanion/Devices/AYANEO/AYANEO2.cs
- HandheldCompanion/Devices/AYANEO/AYANEO2021.cs
- HandheldCompanion/Devices/AYANEO/AYANEO2021Pro.cs
- HandheldCompanion/Devices/AYANEO/AYANEO2S.cs
- HandheldCompanion/Devices/AYANEO/AYANEOAIR1S.cs
- HandheldCompanion/Devices/AYANEO/AYANEOAIRLite.cs
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusAMD.cs
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusAMDMendocino.cs
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPlusIntel.cs
- HandheldCompanion/Devices/AYANEO/AYANEOAIRPro.cs
- HandheldCompanion/Devices/AYANEO/AYANEODeviceCEc.cs
- HandheldCompanion/Devices/AYANEO/AYANEODeviceCEii.cs
- HandheldCompanion/Devices/AYANEO/AYANEONEXT.cs
- HandheldCompanion/Devices/AYANEO/AYANEONEXTLite.cs
- HandheldCompanion/Devices/AYANEO/AYANEONEXTLite4500U.cs
- HandheldCompanion/Devices/AYANEO/AYANEOSLIDE.cs
Additional comments not posted (33)
HandheldCompanion/Devices/DefaultDevice.cs (1)
6-6
: Ensure volume control functionality is preserved or appropriately handled elsewhere after removingOEMChords
initialization..github/ISSUE_TEMPLATE/bug_report.md (3)
5-5
: Standardized label naming convention improves clarity. Good change!
15-15
: Adding "LENOVO" as a label expands the template's applicability. Well done!
23-23
: Correcting the typographical error in "Handheld Companion Version" enhances clarity.HandheldCompanion/Devices/GPD/GPDWinMax2AMD.cs (2)
16-16
: Adjusting gyrometer axis values is a precise change. Ensure it's tested on the actual device for accuracy.
24-24
: Similarly, ensure accelerometer axis adjustments are tested on the device to verify the intended effect.HandheldCompanion/Devices/AYANEO/AYANEOAIRPlus.cs (1)
11-29
: Updates to device-specific settings and axes adjustments appear well-considered. Ensure they are tested for accuracy on the actual device.HandheldCompanion/Devices/AYANEO/AYANEOKUN.cs (2)
12-29
: Significant updates to device-specific settings and OEM chords handling. Testing is crucial to ensure these changes enhance functionality as intended.
37-50
: Refactored LED control logic requires thorough testing to verify functionality and compatibility.HandheldCompanion/Devices/AYANEO/AYANEOAIR.cs (1)
11-44
: Significant updates including base class change and axes adjustments. Ensure comprehensive testing on the actual device to confirm improvements.HandheldCompanion/Devices/GPD/GPDWin4-2023-7840U.cs (2)
34-34
: Adjusting gyrometer axis values is a precise change. Ensure it's tested on the actual device for accuracy.
42-42
: Similarly, ensure accelerometer axis adjustments are tested on the device to verify the intended effect.HandheldCompanion/Devices/GPD/GPDWin4.cs (2)
36-36
: Adjusting gyrometer axis values is a precise change. Ensure it's tested on the actual device for accuracy.
44-44
: Adding accelerometer axis initialization is an important update. Ensure this change is tested for accuracy on the device.HandheldCompanion/Devices/Ayn/AynLoki.cs (2)
29-29
: Consider adding a comment explaining the reason for the change inGyrometerAxis
values.
37-37
: Ensure the newAccelerometerAxis
values are tested across all supported orientations.HandheldCompanion/Controllers/JSController.cs (3)
51-53
: Ensure that theUpdateInputs
method correctly utilizes thedelta
parameter for time-sensitive operations.
114-126
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [56-123]
Refactor the
UpdateState
method to improve readability and maintainability, especially with the addition of motion data processing.
175-177
: Verify thatJslResetContinuousCalibration
andJslPauseContinuousCalibration
are correctly managing the calibration state.HandheldCompanion/Controllers/LegionController.cs (4)
121-143
: Refactor to separate concerns inInitializeInputOutput
for improved readability and maintainability.
169-173
: Handle potential exceptions when opening the HID device to ensure graceful error handling.
340-352
: Asynchronous methodui_button_calibrate_Click
lacksawait
calls. Ensure any asynchronous operations are awaited properly.
354-369
: Add null checks indataThreadLoop
to prevent potential null reference exceptions when accessingreport.Data
.HandheldCompanion/Controllers/IController.xaml.cs (10)
80-87
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [83-94]
The introduction of fields such as
gamepadMotion
,VibrationStrength
,_UserIndex
,MaxUserIndex
,workingIdx
,workingThread
, andworkingThreadRunning
significantly enhances the controller's functionality. Ensure that these fields are properly documented, especially regarding their roles in telemetry data handling, vibration control, and thread management. Proper documentation is crucial for maintainability and understanding the codebase by new developers.
100-108
: TheIsBusy
property's logic, which now includes a UI thread invocation to check theIsEnabled
state, introduces a dependency on the UI thread. This could potentially lead to performance issues or deadlocks if not handled carefully. Consider using asynchronous patterns or ensuring that the UI thread will not be blocked by long-running operations.
171-177
: > 📝 NOTEThis review was outside the diff hunks and was mapped to the diff hunk with the greatest overlap. Original lines [174-182]
The method
SetVirtualControllerVisualIndex
uses UI thread invocation to update the visual index. While this is necessary for UI updates, ensure that this method is called judiciously to avoid unnecessary UI thread invocations, which can impact performance, especially in a loop as seen inworkingThreadLoop
.
212-213
: The addition ofInitializeInputOutput
,UpdateSettings
, and the modifications inAttachDetails
method, including the introduction ofgamepadMotion
, are crucial for the controller's functionality. Ensure that these methods are thoroughly tested, especially the interaction with external hardware and the UI updates, to prevent any regressions or unexpected behavior.Also applies to: 217-222, 225-242
251-258
: The introduction of overloadedUpdateInputs
methods and theGetMotionSensor
method enhances the controller's ability to handle input updates and motion sensor data. It's important to ensure that these methods are compatible with the expected data formats and frequencies from the motion sensors to avoid data loss or inaccuracies.Also applies to: 266-269
337-341
: The update to theUpdateUI
method, specifically the conditional visibility of theui_button_calibrate
based on the controller's capabilities, is a thoughtful addition. Ensure that this logic correctly reflects the actual capabilities of the controller, particularly in scenarios where the motion sensor capability might change dynamically.
555-557
: The addition of theCalibrate
method and updates to event handlers likeui_button_calibrate_Click
are crucial for the calibration functionality. Ensure that the calibration process is robust and handles edge cases gracefully, such as calibration failure or unexpected sensor data.Also applies to: 562-569
644-655
: The introduction ofGetGlyphIconInfo
overloads for bothButtonFlags
andAxisLayoutFlags
is a significant improvement for UI customization and consistency. Ensure that these methods are used consistently across the UI to maintain a uniform appearance for controller elements.Also applies to: 657-668
730-748
: The methodsGetTargetButtons
,GetTargetAxis
, andGetTargetTriggers
provide a structured way to retrieve controller targets. It's important to ensure that these methods accurately reflect the controller's capabilities and are updated accordingly if the controller's layout changes.
756-769
: The addition ofHasSourceButton
andHasSourceAxis
overloads enhances the flexibility in checking for the presence of buttons and axes. Ensure that these methods are used efficiently to avoid unnecessary iterations over the lists, especially in performance-critical paths.
public override void UpdateInputs(long ticks, float delta, bool commit) | ||
{ | ||
// skip if controller isn't connected | ||
if (!IsConnected()) | ||
return; | ||
|
||
base.UpdateInputs(ticks, delta, false); | ||
|
||
FrontEnum frontButton = (FrontEnum)Data[FRONT_IDX]; | ||
Inputs.ButtonState[ButtonFlags.OEM1] = frontButton.HasFlag(FrontEnum.LegionR); | ||
Inputs.ButtonState[ButtonFlags.OEM2] = frontButton.HasFlag(FrontEnum.LegionL); | ||
|
||
BackEnum backButton = (BackEnum)Data[BACK_IDX]; | ||
Inputs.ButtonState[ButtonFlags.R4] = backButton.HasFlag(BackEnum.M3); | ||
Inputs.ButtonState[ButtonFlags.R5] = backButton.HasFlag(BackEnum.Y3); | ||
Inputs.ButtonState[ButtonFlags.L4] = backButton.HasFlag(BackEnum.Y1); | ||
Inputs.ButtonState[ButtonFlags.L5] = backButton.HasFlag(BackEnum.Y2); | ||
Inputs.ButtonState[ButtonFlags.B5] = backButton.HasFlag(BackEnum.M2); | ||
Inputs.ButtonState[ButtonFlags.B6] = Data[20] == 128; // Scroll click | ||
Inputs.ButtonState[ButtonFlags.B7] = Data[24] == 129; // Scroll up | ||
Inputs.ButtonState[ButtonFlags.B8] = Data[24] == 255; // Scroll down | ||
|
||
// Right Pad | ||
ushort TouchpadX = (ushort)((Data[25] << 8) | Data[26]); | ||
ushort TouchpadY = (ushort)((Data[27] << 8) | Data[28]); | ||
|
||
bool touched = (TouchpadX != 0 || TouchpadY != 0); | ||
|
||
Inputs.ButtonState[ButtonFlags.RightPadTouch] = touched; | ||
|
||
// handle touchpad if passthrough is off | ||
if (!IsPassthrough) | ||
HandleTouchpadInput(touched, TouchpadX, TouchpadY); | ||
|
||
/* | ||
Inputs.AxisState[AxisFlags.LeftStickX] += (short)InputUtils.MapRange(Data[29], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | ||
Inputs.AxisState[AxisFlags.LeftStickY] -= (short)InputUtils.MapRange(Data[30], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | ||
|
||
Inputs.AxisState[AxisFlags.RightStickX] += (short)InputUtils.MapRange(Data[31], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | ||
Inputs.AxisState[AxisFlags.RightStickY] -= (short)InputUtils.MapRange(Data[32], byte.MinValue, byte.MaxValue, short.MinValue, short.MaxValue); | ||
*/ | ||
|
||
float aX, aZ, aY = 0; | ||
float gX, gZ, gY = 0; | ||
|
||
switch (GyroIndex) | ||
{ | ||
default: | ||
case LegionGo.LeftJoyconIndex: | ||
{ | ||
aX = (short)(Data[34] << 8 | Data[35]) * -(2.0f / short.MaxValue); | ||
aZ = (short)(Data[36] << 8 | Data[37]) * -(2.0f / short.MaxValue); | ||
aY = (short)(Data[38] << 8 | Data[39]) * -(2.0f / short.MaxValue); | ||
|
||
gX = (short)(Data[40] << 8 | Data[41]) * -(2000.0f / short.MaxValue); | ||
gZ = (short)(Data[42] << 8 | Data[43]) * -(2000.0f / short.MaxValue); | ||
gY = (short)(Data[44] << 8 | Data[45]) * -(2000.0f / short.MaxValue); | ||
} | ||
break; | ||
|
||
case LegionGo.RightJoyconIndex: | ||
{ | ||
aX = (short)(Data[49] << 8 | Data[50]) * -(2.0f / short.MaxValue); | ||
aZ = (short)(Data[47] << 8 | Data[48]) * (2.0f / short.MaxValue); | ||
aY = (short)(Data[51] << 8 | Data[52]) * -(2.0f / short.MaxValue); | ||
|
||
gX = (short)(Data[55] << 8 | Data[56]) * -(2000.0f / short.MaxValue); | ||
gZ = (short)(Data[53] << 8 | Data[54]) * (2000.0f / short.MaxValue); | ||
gY = (short)(Data[57] << 8 | Data[58]) * -(2000.0f / short.MaxValue); | ||
} | ||
break; | ||
} | ||
|
||
// store motion | ||
Inputs.GyroState.SetGyroscope(gX, gY, gZ); | ||
Inputs.GyroState.SetAccelerometer(aX, aY, aZ); | ||
|
||
// process motion | ||
switch (GyroIndex) | ||
{ | ||
default: | ||
case LegionGo.LeftJoyconIndex: | ||
gamepadMotion.ProcessMotion(gX, gY, gZ, aX, aY, aZ, delta); | ||
base.UpdateInputs(ticks, delta); | ||
break; | ||
case LegionGo.RightJoyconIndex: | ||
gamepadMotion.ProcessMotion(gX, gY, gZ, aX, aY, aZ, delta); | ||
base.UpdateInputs(ticks, delta, gamepadMotionR); | ||
break; | ||
} |
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.
Consider optimizing the gyroscopic data handling in UpdateInputs
to reduce complexity and improve performance.
protected readonly List<ButtonFlags> TargetButtons = new() | ||
{ | ||
ButtonFlags.B1, ButtonFlags.B2, ButtonFlags.B3, ButtonFlags.B4, | ||
ButtonFlags.None, ButtonFlags.B1, ButtonFlags.B2, ButtonFlags.B3, ButtonFlags.B4, |
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.
Consider encapsulating the TargetButtons
, TargetAxis
, SourceAxis
, and SourceButtons
lists within a separate class or structure to improve modularity and maintainability. This approach can also facilitate future expansions or modifications to the controller mapping logic.
Also applies to: 42-44, 48-52, 57-63
Summary by CodeRabbit
ADLXBackend
.Process
class for advanced process management.DSUServer
to prevent potential crashes.