update server to implement felica polling

This commit is contained in:
ppc
2025-01-14 15:46:35 +00:00
parent b33670d849
commit 31c56d2449
5 changed files with 93 additions and 56 deletions
+17 -12
View File
@@ -1,5 +1,4 @@
using System;
using System.Linq;
using Windows.Win32;
using Windows.Win32.Foundation;
@@ -10,30 +9,36 @@ internal static class Config
internal const string IOSection = "aimeio";
private const string ConfigFileName = @".\segatools.ini";
/// <summary>
/// Valid physical card identification methods.
/// IDm - uses the idm of the card to generate a 20-digit identifier (also known as the 0008 number)
/// Access - prefer the real access code of the card. if not available (i.e. Suica card), fallback to the IDm.
/// </summary>
private static readonly string[] ValidPhysicalCardIdentifiers = ["idm", "access"];
static Config()
{
GameId = ReadKey(IOSection, "gameId", 4);
ServerName = ReadKey(IOSection, "serverName", 26, Environment.MachineName);
var physicalCardIdentifierPreference = ReadKey(IOSection, "physicalCardIdentifier", 10);
PhysicalCardIdentifierPreference = ValidPhysicalCardIdentifiers.Contains(physicalCardIdentifierPreference) ? physicalCardIdentifierPreference : ValidPhysicalCardIdentifiers[^1];
PhysicalCardUseIDm = PInvoke.GetPrivateProfileInt(IOSection, "usePhysicalCardIdm", 0, ConfigFileName) > 0;
EnableAimeTxt = PInvoke.GetPrivateProfileInt(IOSection, "enableKeyboardMode", 1, ConfigFileName) > 0;
AimeTxtPath = ReadKey("aime", "aimePath", PInvoke.MAX_PATH, @"DEVICE\aime.txt");
}
public static string GameId { get; }
/// <summary>
/// The server name to show on devices. Defaults to the computer name.
/// </summary>
public static string ServerName { get; }
public static string PhysicalCardIdentifierPreference { get; }
/// <summary>
/// Whether physically scanned cards should have their IDm forwarded to the game instead of the access code.
/// </summary>
public static bool PhysicalCardUseIDm { get; }
/// <summary>
/// Whether holding the enter key should trigger a card scan using the code from the aime.txt file
/// </summary>
public static bool EnableAimeTxt { get; }
/// <summary>
/// Path to the aime.txt file. Defaults to .\DEVICE\aime.txt
/// </summary>
public static string AimeTxtPath { get; }
internal static unsafe string ReadKey(string section, string key, uint maxLength, string @default = null)