Skip to content

Commit

Permalink
Addition of GPD Win 4 2023 (#49)
Browse files Browse the repository at this point in the history
  • Loading branch information
CasperH2O authored Sep 21, 2023
1 parent 52358cd commit 20fdae3
Show file tree
Hide file tree
Showing 3 changed files with 138 additions and 1 deletion.
63 changes: 63 additions & 0 deletions HandheldCompanion/Devices/GPD/GPDWin4-2023-7640U.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using System;
using System.Collections.Generic;
using System.Numerics;
using WindowsInput.Events;

namespace HandheldCompanion.Devices;

public class GPDWin4_2023_7640U : IDevice
{
public GPDWin4_2023_7640U()
{
// device specific settings
ProductIllustration = "device_gpd4";

// https://www.amd.com/en/products/apu/amd-ryzen-5-7640u
nTDP = new double[] { 15, 15, 28 };
cTDP = new double[] { 5, 28 };
GfxClock = new double[] { 200, 2600 };

AngularVelocityAxis = new Vector3(1.0f, 1.0f, -1.0f);
AngularVelocityAxisSwap = new SortedDictionary<char, char>
{
{ 'X', 'Y' },
{ 'Y', 'Z' },
{ 'Z', 'X' }
};

AccelerationAxis = new Vector3(1.0f, 1.0f, 1.0f);
AccelerationAxisSwap = new SortedDictionary<char, char>
{
{ 'X', 'X' },
{ 'Y', 'Z' },
{ 'Z', 'Y' }
};

// Note, OEM1 not configured as this device has it's own Menu button for guide button

// Note, chords need to be manually configured in GPD app first by end user

// GPD Back buttons do not have a "hold", configured buttons are key down and up immediately
// Holding back buttons will result in same key down and up input every 2-3 seconds
// Configured chords in GPD app need unique characters otherwise this leads to a
// "mixed" result when pressing both buttons at the same time
OEMChords.Add(new DeviceChord("Bottom button left",
new List<KeyCode> { KeyCode.F11, KeyCode.L },
new List<KeyCode> { KeyCode.F11, KeyCode.L },
false, ButtonFlags.OEM2
));

OEMChords.Add(new DeviceChord("Bottom button right",
new List<KeyCode> { KeyCode.F12, KeyCode.R },
new List<KeyCode> { KeyCode.F12, KeyCode.R },
false, ButtonFlags.OEM3
));
}

public override void Close()
{
base.Close();
}
}
63 changes: 63 additions & 0 deletions HandheldCompanion/Devices/GPD/GPDWin4-2023-7840U.cs
Original file line number Diff line number Diff line change
@@ -0,0 +1,63 @@
using HandheldCompanion.Inputs;
using HandheldCompanion.Managers;
using System;
using System.Collections.Generic;
using System.Numerics;
using WindowsInput.Events;

namespace HandheldCompanion.Devices;

public class GPDWin4_2023_7840U : IDevice
{
public GPDWin4_2023_7840U()
{
// device specific settings
ProductIllustration = "device_gpd4";

// https://www.amd.com/en/products/apu/amd-ryzen-7-7840u
nTDP = new double[] { 15, 15, 28 };
cTDP = new double[] { 5, 28 };
GfxClock = new double[] { 200, 2700 };

AngularVelocityAxis = new Vector3(1.0f, 1.0f, -1.0f);
AngularVelocityAxisSwap = new SortedDictionary<char, char>
{
{ 'X', 'Y' },
{ 'Y', 'Z' },
{ 'Z', 'X' }
};

AccelerationAxis = new Vector3(1.0f, 1.0f, 1.0f);
AccelerationAxisSwap = new SortedDictionary<char, char>
{
{ 'X', 'X' },
{ 'Y', 'Z' },
{ 'Z', 'Y' }
};

// Note, OEM1 not configured as this device has it's own Menu button for guide button

// Note, chords need to be manually configured in GPD app first by end user

// GPD Back buttons do not have a "hold", configured buttons are key down and up immediately
// Holding back buttons will result in same key down and up input every 2-3 seconds
// Configured chords in GPD app need unique characters otherwise this leads to a
// "mixed" result when pressing both buttons at the same time
OEMChords.Add(new DeviceChord("Bottom button left",
new List<KeyCode> { KeyCode.F11, KeyCode.L },
new List<KeyCode> { KeyCode.F11, KeyCode.L },
false, ButtonFlags.OEM2
));

OEMChords.Add(new DeviceChord("Bottom button right",
new List<KeyCode> { KeyCode.F12, KeyCode.R },
new List<KeyCode> { KeyCode.F12, KeyCode.R },
false, ButtonFlags.OEM3
));
}

public override void Close()
{
base.Close();
}
}
13 changes: 12 additions & 1 deletion HandheldCompanion/Devices/IDevice.cs
Original file line number Diff line number Diff line change
Expand Up @@ -226,7 +226,18 @@ public static IDevice GetDefault()
device = new GPDWin3();
break;
case "G1618-04":
device = new GPDWin4();
switch (Processor)
{
case "AMD Ryzen 7 6800U with Radeon Graphics":
device = new GPDWin4();
break;
case "AMD Ryzen 5 7640U w/ Radeon 760M Graphics":
device = new GPDWin4_2023_7640U();
break;
case "AMD Ryzen 7 7840U w/ Radeon 780M Graphics":
device = new GPDWin4_2023_7840U();
break;
}
break;
case "G1619-03":
device = new GPDWinMax2Intel();
Expand Down

0 comments on commit 20fdae3

Please sign in to comment.