From a92924840b1451250751275d6a1b8a78d5959476 Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Wed, 4 Oct 2023 13:05:21 +0200 Subject: [PATCH 1/7] Support for TUF Gaming M5 Mouse. --- app/Peripherals/Mouse/Models/TUFM5.cs | 170 +++++++++++++++++++++++++ app/Peripherals/PeripheralsProvider.cs | 1 + 2 files changed, 171 insertions(+) create mode 100644 app/Peripherals/Mouse/Models/TUFM5.cs diff --git a/app/Peripherals/Mouse/Models/TUFM5.cs b/app/Peripherals/Mouse/Models/TUFM5.cs new file mode 100644 index 00000000..f1574598 --- /dev/null +++ b/app/Peripherals/Mouse/Models/TUFM5.cs @@ -0,0 +1,170 @@ +namespace GHelper.Peripherals.Mouse.Models +{ + //P304 + public class TUFM5 : AsusMouse + { + public TUFM5() : base(0x0B05, 0x1898, "mi_02", false) + { + } + + public override int DPIProfileCount() + { + return 2; + } + + public override string GetDisplayName() + { + return "TUF GAMING M5"; + } + + + public override PollingRate[] SupportedPollingrates() + { + return new PollingRate[] { + PollingRate.PR125Hz, + PollingRate.PR250Hz, + PollingRate.PR500Hz, + PollingRate.PR1000Hz + }; + } + + //Mouse has React mapped to 0x03 instead of 0x04 like other mice + protected override byte IndexForLightingMode(LightingMode lightingMode) + { + if (lightingMode == LightingMode.React) + { + return 0x03; + } + return ((byte)lightingMode); + } + + //Mouse has React mapped to 0x03 instead of 0x04 like other mice + protected override LightingMode LightingModeForIndex(byte lightingMode) + { + if (lightingMode == 0x03) + { + return LightingMode.React; + } + return base.LightingModeForIndex(lightingMode); + + } + + public override int ProfileCount() + { + return 1; + } + public override int MaxDPI() + { + return 6_200; + } + public override bool HasBattery() + { + return false; + } + + public override bool HasLiftOffSetting() + { + return false; + } + public override LightingZone[] SupportedLightingZones() + { + return new LightingZone[] { LightingZone.Logo }; + } + + public override bool HasRGB() + { + return true; + } + + public override bool HasAngleSnapping() + { + return true; + } + + public override int DPIIncrements() + { + return 100; + } + + public override bool CanChangeDPIProfile() + { + return true; + } + + public override bool HasDebounceSetting() + { + return true; + } + + public override int MaxBrightness() + { + return 4; + } + + public override bool IsLightingModeSupported(LightingMode lightingMode) + { + return lightingMode == LightingMode.Static + || lightingMode == LightingMode.Breathing + || lightingMode == LightingMode.ColorCycle + || lightingMode == LightingMode.React; + } + + + protected override byte[] GetUpdatePollingRatePacket(PollingRate pollingRate) + { + return new byte[] { reportId, 0x51, 0x31, 0x02, 0x00, (byte)pollingRate }; + } + + protected override byte[] GetUpdateAngleSnappingPacket(bool angleSnapping) + { + return new byte[] { reportId, 0x51, 0x31, 0x04, 0x00, (byte)(angleSnapping ? 0x01 : 0x00) }; + } + + protected override PollingRate ParsePollingRate(byte[] packet) + { + + if (packet[1] == 0x12 && packet[2] == 0x04 && packet[3] == 0x00) + { + return (PollingRate)packet[9]; + } + + return PollingRate.PR125Hz; + } + + protected override bool ParseAngleSnapping(byte[] packet) + { + + if (packet[1] == 0x12 && packet[2] == 0x04 && packet[3] == 0x00) + { + return packet[13] == 0x01; + } + + return false; + } + + protected override byte[] GetUpdateDebouncePacket(DebounceTime debounce) + { + return new byte[] { reportId, 0x51, 0x31, 0x03, 0x00, ((byte)debounce) }; + } + + protected override DebounceTime ParseDebounce(byte[] packet) + { + if (packet[1] != 0x12 || packet[2] != 0x04 || packet[3] != 0x00) + { + return DebounceTime.MS12; + } + + if (packet[11] < 0x02) + { + return DebounceTime.MS12; + } + + if (packet[11] > 0x07) + { + return DebounceTime.MS32; + } + + return (DebounceTime)packet[11]; + } + } +} diff --git a/app/Peripherals/PeripheralsProvider.cs b/app/Peripherals/PeripheralsProvider.cs index 781c8207..11b93eae 100644 --- a/app/Peripherals/PeripheralsProvider.cs +++ b/app/Peripherals/PeripheralsProvider.cs @@ -200,6 +200,7 @@ namespace GHelper.Peripherals DetectMouse(new HarpeAceAimLabEditionWired()); DetectMouse(new HarpeAceAimLabEditionOmni()); DetectMouse(new TUFM3()); + DetectMouse(new TUFM5()); DetectMouse(new KerisWirelssAimpoint()); DetectMouse(new KerisWirelssAimpointWired()); DetectMouse(new PugioII()); From a0628ef36895fffc41eb6cddb66870ff22737266 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Wed, 4 Oct 2023 17:32:21 +0200 Subject: [PATCH 2/7] New translations strings.resx (Polish) --- app/Properties/Strings.pl.resx | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/app/Properties/Strings.pl.resx b/app/Properties/Strings.pl.resx index d82875b7..ad8d0c17 100644 --- a/app/Properties/Strings.pl.resx +++ b/app/Properties/Strings.pl.resx @@ -253,7 +253,7 @@ Stan baterii - One time charge to 100% + Jednorazowo naładuj do 100% Aktualizacje BIOS i sterowników From ee90fe4a3dab0828278d42a5691c7d0bf53a846c Mon Sep 17 00:00:00 2001 From: nopeless <38830903+nopeless@users.noreply.github.com> Date: Wed, 4 Oct 2023 10:35:04 -0500 Subject: [PATCH 3/7] feat: allow manual executable build for github (#1415) --- .github/workflows/release.yml | 2 ++ 1 file changed, 2 insertions(+) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index e7531691..3565ce40 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -3,6 +3,8 @@ name: Release on: release: types: [ published ] + workflow_dispatch: + permissions: contents: write From 393cb3300c0d7864c725a91f5984af6a348dfa52 Mon Sep 17 00:00:00 2001 From: nopeless <38830903+nopeless@users.noreply.github.com> Date: Wed, 4 Oct 2023 11:14:31 -0500 Subject: [PATCH 4/7] fix: breaking workflow and upload artifact (#1417) * feat: allow manual executable build for github * fix: manual dispatch behavior * fix: use full sha --- .github/workflows/release.yml | 11 ++++++++++- 1 file changed, 10 insertions(+), 1 deletion(-) diff --git a/.github/workflows/release.yml b/.github/workflows/release.yml index 3565ce40..1acfae9e 100644 --- a/.github/workflows/release.yml +++ b/.github/workflows/release.yml @@ -22,9 +22,18 @@ jobs: - name: Publish run: | dotnet publish app/GHelper.sln --configuration Release --runtime win-x64 -p:PublishSingleFile=true --no-self-contained - powershell Compress-Archive app/bin/x64/Release/net7.0-windows/win-x64/publish/* GHelper.zip + powershell Compress-Archive app/bin/x64/Release/net7.0-windows/win-x64/publish/* GHelper-${{ github.sha }}.zip + - name: Upload + if: github.event_name != 'workflow_dispatch' env: GH_TOKEN: ${{ github.token }} run: | gh release upload ${{ github.ref_name }} GHelper.zip + + - name: Artifact + if: github.event_name == 'workflow_dispatch' + uses: actions/upload-artifact@v3 + with: + name: GHelper-release-${{ github.sha }} + path: GHelper-*.zip From c2ca761d99047a6a7d9fa35a73dbf103c6c41159 Mon Sep 17 00:00:00 2001 From: IceStormNG Date: Thu, 5 Oct 2023 18:21:53 +0200 Subject: [PATCH 5/7] Adds support for the ROG Chakram (P704) --- app/Peripherals/Mouse/Models/Chakram.cs | 209 ++++++++++++++++++++++++ app/Peripherals/PeripheralsProvider.cs | 2 + 2 files changed, 211 insertions(+) create mode 100644 app/Peripherals/Mouse/Models/Chakram.cs diff --git a/app/Peripherals/Mouse/Models/Chakram.cs b/app/Peripherals/Mouse/Models/Chakram.cs new file mode 100644 index 00000000..0fb2ede9 --- /dev/null +++ b/app/Peripherals/Mouse/Models/Chakram.cs @@ -0,0 +1,209 @@ + +namespace GHelper.Peripherals.Mouse.Models +{ + //P704 + public class Chakram : AsusMouse + { + public Chakram() : base(0x0B05, 0x18E5, "mi_00", true) { + + } + + protected Chakram(ushort vendorId, bool wireless) : base(0x0B05, vendorId, "mi_00", wireless) + { + } + public override int DPIProfileCount() + { + return 4; + } + + public override string GetDisplayName() + { + return "ROG Chakram (Wireless)"; + } + + public override PollingRate[] SupportedPollingrates() + { + return new PollingRate[] { + PollingRate.PR125Hz, + PollingRate.PR250Hz, + PollingRate.PR500Hz, + PollingRate.PR1000Hz + }; + } + + + public override int ProfileCount() + { + return 3; + } + public override int MaxDPI() + { + return 16_000; + } + + public override bool HasDebounceSetting() + { + return true; + } + public override bool HasLiftOffSetting() + { + return true; + } + public override int DPIIncrements() + { + return 100; + } + + public override bool HasRGB() + { + return true; + } + public override int MaxBrightness() + { + return 4; + } + + public override LightingZone[] SupportedLightingZones() + { + return new LightingZone[] { LightingZone.Logo, LightingZone.Scrollwheel, LightingZone.Underglow }; + } + + public override bool HasAutoPowerOff() + { + return true; + } + + public override bool HasAngleSnapping() + { + return true; + } + + public override bool HasAngleTuning() + { + return false; + } + + public override bool HasLowBatteryWarning() + { + return true; + } + + public override int LowBatteryWarningStep() + { + return 25; + } + + public override int LowBatteryWarningMax() + { + return 100; + } + + protected override int ParseBattery(byte[] packet) + { + return base.ParseBattery(packet) * 25; + } + protected override int ParseLowBatteryWarning(byte[] packet) + { + return base.ParseLowBatteryWarning(packet) * 25; + } + protected override byte[] GetUpdateEnergySettingsPacket(int lowBatteryWarning, PowerOffSetting powerOff) + { + return base.GetUpdateEnergySettingsPacket(lowBatteryWarning / 25, powerOff); + } + protected override byte[] GetReadLightingModePacket(LightingZone zone) + { + return new byte[] { 0x00, 0x12, 0x03, 0x00 }; + } + + protected LightingSetting? ParseLightingSetting(byte[] packet, LightingZone zone) + { + if (packet[1] != 0x12 || packet[2] != 0x03) + { + return null; + } + + int offset = 5 + (((int)zone) * 5); + + LightingSetting setting = new LightingSetting(); + + setting.LightingMode = LightingModeForIndex(packet[offset + 0]); + setting.Brightness = packet[offset + 1]; + + setting.RGBColor = Color.FromArgb(packet[offset + 2], packet[offset + 3], packet[offset + 4]); + + setting.AnimationDirection = SupportsAnimationDirection(setting.LightingMode) + ? (AnimationDirection)packet[21] + : AnimationDirection.Clockwise; + + if (setting.AnimationDirection != AnimationDirection.Clockwise + && setting.AnimationDirection != AnimationDirection.CounterClockwise) + { + setting.AnimationDirection = AnimationDirection.Clockwise; + } + + setting.RandomColor = SupportsRandomColor(setting.LightingMode) && packet[22] == 0x01; + setting.AnimationSpeed = SupportsAnimationSpeed(setting.LightingMode) + ? (AnimationSpeed)packet[23] + : AnimationSpeed.Medium; + + //If the mouse reports an out of range value, which it does when the current setting has no speed option, chose medium as default + if (setting.AnimationSpeed != AnimationSpeed.Fast + && setting.AnimationSpeed != AnimationSpeed.Medium + && setting.AnimationSpeed != AnimationSpeed.Slow) + { + setting.AnimationSpeed = AnimationSpeed.Medium; + } + return setting; + } + + public override void ReadLightingSetting() + { + if (!HasRGB()) + { + return; + } + //Mouse sends all lighting zones in one response + //21: Direction + //22: Random + //23: Speed + // 20 21 22 23 + //00 12 03 00 00 [03 04 00 00 ff] [03 04 00 00 ff] [03 04 00 00 ff] 00 04 00 00 + //00 12 03 00 00 [05 02 ff 00 ff] [05 02 ff 00 ff] [05 02 ff 00 ff] 00 01 01 00 + //00 12 03 00 00 [03 01 00 00 ff] [03 01 00 00 ff] [03 01 00 00 ff] 00 01 00 01 + byte[]? response = WriteForResponse(GetReadLightingModePacket(LightingZone.All)); + if (response is null) return; + + LightingZone[] lz = SupportedLightingZones(); + for (int i = 0; i < lz.Length; ++i) + { + LightingSetting? ls = ParseLightingSetting(response, lz[i]); + if (ls is null) + { + Logger.WriteLine(GetDisplayName() + ": Failed to read RGB Setting for Zone " + lz[i].ToString()); + continue; + } + + Logger.WriteLine(GetDisplayName() + ": Read RGB Setting for Zone " + lz[i].ToString() + ": " + ls.ToString()); + LightingSetting[i] = ls; + } + } + + public override bool CanChangeDPIProfile() + { + return false; + } + } + + + public class ChakramWired : Chakram + { + public ChakramWired() : base(0x18E3, false) + { + } + + public override string GetDisplayName() + { + return "ROG Chakram (Wired)"; + } + } +} diff --git a/app/Peripherals/PeripheralsProvider.cs b/app/Peripherals/PeripheralsProvider.cs index 11b93eae..ee73be95 100644 --- a/app/Peripherals/PeripheralsProvider.cs +++ b/app/Peripherals/PeripheralsProvider.cs @@ -206,6 +206,8 @@ namespace GHelper.Peripherals DetectMouse(new PugioII()); DetectMouse(new PugioIIWired()); DetectMouse(new StrixImpactII()); + DetectMouse(new Chakram()); + DetectMouse(new ChakramWired()); } public static void DetectMouse(AsusMouse am) From aa327f563fa5a13d9f4dfaadec7386df825fe4d8 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Thu, 5 Oct 2023 19:29:35 +0200 Subject: [PATCH 6/7] New translations strings.resx (Chinese Simplified) --- app/Properties/Strings.zh-CN.resx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/app/Properties/Strings.zh-CN.resx b/app/Properties/Strings.zh-CN.resx index bd27bccc..ef52cfda 100644 --- a/app/Properties/Strings.zh-CN.resx +++ b/app/Properties/Strings.zh-CN.resx @@ -118,7 +118,7 @@ System.Resources.ResXResourceWriter, System.Windows.Forms, Version=4.0.0.0, Culture=neutral, PublicKeyToken=b77a5c561934e089 - Acceleration + 加速 无法连接到ASUS ACPI。 没有它应用程序将无法运行。 请尝试安装Asus System Control Interface驱动。 @@ -223,7 +223,7 @@ 滚轮 - Underglow + 底灯 自动应用 @@ -253,7 +253,7 @@ 电池健康 - One time charge to 100% + 一次性充电至 100% BIOS 和驱动程序更新 @@ -274,7 +274,7 @@ 提高亮度 - Calibrate + 校准 充电中 @@ -289,7 +289,7 @@ 自定义设置 - Deceleration + 减速 默认 @@ -318,7 +318,7 @@ 确定还要继续吗? - NVIDIA 显示模式未设置为自动切换 + NVIDIA 显示模式未设置为 Optimus 电源设置 @@ -342,7 +342,7 @@ GPU 风扇配置文件 - 中等风扇配置 + Mid 风扇配置文件 风扇配置 @@ -465,7 +465,7 @@ 分钟 - 分组 + 分钟 角度校正 From e774f704ddc90fcff713af3610938db1df8a0937 Mon Sep 17 00:00:00 2001 From: Serge <5920850+seerge@users.noreply.github.com> Date: Thu, 5 Oct 2023 21:28:34 +0200 Subject: [PATCH 7/7] New translations strings.resx (Chinese Simplified) --- app/Properties/Strings.zh-CN.resx | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/app/Properties/Strings.zh-CN.resx b/app/Properties/Strings.zh-CN.resx index ef52cfda..bc23c72e 100644 --- a/app/Properties/Strings.zh-CN.resx +++ b/app/Properties/Strings.zh-CN.resx @@ -313,7 +313,7 @@ 集显模式 - 若未在nVIDIA控制面板的混合显示模式中设置为Optimus,关闭独立显卡可能会导致亮度控制在系统重启前都不可用。 + NVIDIA 控制面板中的显示模式未设置为 Optimus 时,通过集显模式禁用独立显卡可能会使亮度控制出现问题,直到下次重启后才能恢复。 确定还要继续吗? @@ -477,7 +477,7 @@ 按键响应 - 静默高度 + 响应高度 低于该电量时警告