aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--Project_Export.toml4
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Generate Bindings.run.xml (renamed from core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Generate Csharp Bindings.run.xml)2
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Run Example.run.xml (renamed from core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Example.run.xml)2
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/NoGamepads_Bindings.csproj1
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/Program.cs58
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/ControllerData.cs19
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/GameArchiveData.cs18
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/GameData.cs33
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/IRawData.cs6
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/ControlMessage.cs158
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/ExitReason.cs28
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/GameMessage.cs104
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Player.cs82
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/NoGamepads_Core.csproj4
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Runtime/ControllerRuntime.cs61
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Runtime/GameRuntime.cs19
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/ServiceType.cs36
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/Tcp/PadTcpClient.cs6
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/Tcp/PadTcpServer.cs6
-rw-r--r--core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Example/Program.cs24
20 files changed, 654 insertions, 17 deletions
diff --git a/Project_Export.toml b/Project_Export.toml
index ba2c27d..e45285b 100644
--- a/Project_Export.toml
+++ b/Project_Export.toml
@@ -56,4 +56,8 @@ c_binding_example_deps_win = { raw = "./", target = "./core/bindings/lang/clang/
csharp_binding_deps_win = { raw = "./", target = "./core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/Native/", files = [
"nogamepads_c.dll",
+] }
+
+csharp_binding_libs_win = { raw = "./", target = "./core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Example/bin/Debug/net6.0/", files = [
+ "nogamepads_c.dll"
] } \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Generate Csharp Bindings.run.xml b/core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Generate Bindings.run.xml
index e70ca09..0e7c565 100644
--- a/core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Generate Csharp Bindings.run.xml
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Generate Bindings.run.xml
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
- <configuration default="false" name="Generate Csharp Bindings" type="DotNetProject" factoryName=".NET Project" folderName="Generate">
+ <configuration default="false" name="Generate Bindings" type="DotNetProject" factoryName=".NET Project" folderName="Run">
<option name="EXE_PATH" value="$PROJECT_DIR$/NoGamepads_Bindings/bin/Debug/net6.0/NoGamepads_Bindings.exe" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/" />
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Example.run.xml b/core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Run Example.run.xml
index 91f4cc3..792c169 100644
--- a/core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Example.run.xml
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/.run/Run Example.run.xml
@@ -1,5 +1,5 @@
<component name="ProjectRunConfigurationManager">
- <configuration default="false" name="Example" type="DotNetProject" factoryName=".NET Project" folderName="Run">
+ <configuration default="false" name="Run Example" type="DotNetProject" factoryName=".NET Project" folderName="Run">
<option name="EXE_PATH" value="$PROJECT_DIR$/NoGamepads_Example/bin/Debug/net6.0/NoGamepads_Example.exe" />
<option name="PROGRAM_PARAMETERS" value="" />
<option name="WORKING_DIRECTORY" value="$PROJECT_DIR$/../Working/" />
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/NoGamepads_Bindings.csproj b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/NoGamepads_Bindings.csproj
index b12992a..aaec264 100644
--- a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/NoGamepads_Bindings.csproj
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/NoGamepads_Bindings.csproj
@@ -15,6 +15,7 @@
</Content>
<PackageReference Include="CppSharp" Version="1.1.5.3168" />
+ <PackageReference Include="Microsoft.CodeAnalysis.CSharp" Version="4.14.0" />
</ItemGroup>
</Project>
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/Program.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/Program.cs
index ebb5f76..f65f182 100644
--- a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/Program.cs
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Bindings/Program.cs
@@ -1,16 +1,63 @@
using CppSharp;
using CppSharp.AST;
+using CppSharp.AST.Extensions;
using CppSharp.Generators;
-using CppSharp.Generators.AST;
-using RecordArgABI = CppSharp.Parser.AST.RecordArgABI;
+using Microsoft.CodeAnalysis;
+using Microsoft.CodeAnalysis.CSharp;
+using Microsoft.CodeAnalysis.CSharp.Syntax;
namespace NoGamepads_Bindings;
internal static class Program
{
- public static void Main(string[] args)
+ public static void Main()
{
ConsoleDriver.Run(new NoGamepadsLibrary());
+ FixRefProperties();
+ }
+
+ private static void FixRefProperties()
+ {
+ var directory = "NoGamepads_Core/Generated";
+ var files = Directory.GetFiles(directory, "*.cs", SearchOption.AllDirectories);
+
+ foreach (var file in files)
+ {
+ var code = File.ReadAllText(file);
+ var tree = CSharpSyntaxTree.ParseText(code);
+ var root = tree.GetRoot();
+
+ var newRoot = root.ReplaceNodes(
+ root.DescendantNodes().OfType<PropertyDeclarationSyntax>(),
+ (prop, _) =>
+ {
+ // internal ref FfiXXXUnion.__Internal __Instance => ref __instance;
+ if (prop.Identifier.Text != "__Instance")
+ return prop;
+
+ if (prop.Type is RefTypeSyntax refType &&
+ prop.ExpressionBody?.Expression is RefExpressionSyntax refExpr &&
+ refType.Type.ToString().EndsWith(".__Internal", StringComparison.Ordinal) &&
+ refExpr.Expression is IdentifierNameSyntax fieldRef &&
+ fieldRef.Identifier.Text == "__instance")
+ {
+ var newType = refType.Type.WithTriviaFrom(refType);
+ var newExpr = fieldRef.WithTriviaFrom(refExpr);
+
+ return prop
+ .WithType(newType)
+ .WithExpressionBody(SyntaxFactory.ArrowExpressionClause(newExpr))
+ .WithSemicolonToken(prop.SemicolonToken);
+ }
+
+ return prop;
+ });
+
+ if (!newRoot.IsEquivalentTo(root))
+ {
+ File.WriteAllText(file, newRoot.ToFullString());
+ }
+ }
}
}
@@ -29,9 +76,10 @@ public class NoGamepadsLibrary : ILibrary
options.OutputDir = "NoGamepads_Core/Generated";
options.GenerateClassTemplates = false;
- var module = options.AddModule("NoGamepads.Native");
+ var module = options.AddModule("nogamepads_c");
module.OutputNamespace = "NoGamepads_Sharp";
module.IncludeDirs.Add("NoGamepads_Bindings/Native");
module.Headers.Add("nogamepads_data.h");
}
-} \ No newline at end of file
+}
+
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/ControllerData.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/ControllerData.cs
new file mode 100644
index 0000000..c2d6391
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/ControllerData.cs
@@ -0,0 +1,19 @@
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Data;
+
+public class ControllerData : IRawData<FfiControllerData>
+{
+ private readonly FfiControllerData _ffi;
+
+ public ControllerData(Player player)
+ {
+ _ffi = nogamepads_data.ControllerDataNew();
+ nogamepads_data.ControllerDataBindPlayer(_ffi, player.GetRawData());
+ }
+
+ public FfiControllerData GetRawData()
+ {
+ return _ffi;
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/GameArchiveData.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/GameArchiveData.cs
new file mode 100644
index 0000000..85b37ac
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/GameArchiveData.cs
@@ -0,0 +1,18 @@
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Data;
+
+public class GameArchiveData : IRawData<FfiGameRuntimeArchive>
+{
+ private readonly FfiGameRuntimeArchive _ffi = nogamepads_data.GameArchiveDataNew();
+
+ public void AddBannedPlayer(Player player)
+ {
+ nogamepads_data.GameArchiveDataAddBanPlayer(_ffi, player.GetRawData());
+ }
+
+ public FfiGameRuntimeArchive GetRawData()
+ {
+ return _ffi;
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/GameData.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/GameData.cs
new file mode 100644
index 0000000..480636b
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/GameData.cs
@@ -0,0 +1,33 @@
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Data;
+
+public class GameData : IRawData<FfiGameData>
+{
+ private readonly FfiGameData _ffi = nogamepads_data.GameDataNew();
+
+ public string Name
+ {
+ set => nogamepads_data.GameDataSetNameInfo(_ffi, value);
+ }
+
+ public string Version
+ {
+ set => nogamepads_data.GameDataSetVersionInfo(_ffi, value);
+ }
+
+ public void EditInfo(string infoName, string value)
+ {
+ nogamepads_data.GameDataAddInfo(_ffi, infoName, value);
+ }
+
+ public void LoadArchive(GameArchiveData gameArchiveData)
+ {
+ nogamepads_data.GameDataLoadArchive(_ffi, gameArchiveData.GetRawData());
+ }
+
+ public FfiGameData GetRawData()
+ {
+ return _ffi;
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/IRawData.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/IRawData.cs
new file mode 100644
index 0000000..a0e72ea
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/IRawData.cs
@@ -0,0 +1,6 @@
+namespace NoGamepads_Core.Data;
+
+public interface IRawData<T>
+{
+ T GetRawData();
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/ControlMessage.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/ControlMessage.cs
new file mode 100644
index 0000000..fb41612
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/ControlMessage.cs
@@ -0,0 +1,158 @@
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Data.Message;
+
+public struct ControlMessage
+{
+ public enum Tag
+ {
+ Message = 0,
+ Pressed = 1,
+ Released = 2,
+ Axis = 3,
+ Direction = 4,
+ Exit = 5,
+ Error = 6,
+ End = 7
+ }
+
+ public Tag MessageTag => _tag;
+
+ private Tag _tag;
+ private string _content;
+ private int _key;
+ private float _x; // Axis or DirectionX
+ private float _y;
+
+ public static ControlMessage Message(string messageContent)
+ {
+ return new ControlMessage
+ {
+ _tag = Tag.Message,
+ _content = messageContent
+ };
+ }
+
+ public static ControlMessage Pressed(int key)
+ {
+ return new ControlMessage
+ {
+ _tag = Tag.Pressed,
+ _key = key
+ };
+ }
+
+ public static ControlMessage Released(int key)
+ {
+ return new ControlMessage
+ {
+ _tag = Tag.Released,
+ _key = key
+ };
+ }
+
+ public static ControlMessage Axis(int key, float x)
+ {
+ return new ControlMessage
+ {
+ _tag = Tag.Axis,
+ _key = key,
+ _x = x
+ };
+ }
+
+ public static ControlMessage Direction(int key, float x, float y)
+ {
+ return new ControlMessage
+ {
+ _tag = Tag.Direction,
+ _key = key,
+ _x = x,
+ _y = y
+ };
+ }
+
+ public static ControlMessage Exit()
+ {
+ return new ControlMessage
+ {
+ _tag = Tag.Exit,
+ };
+ }
+
+ public static ControlMessage Error()
+ {
+ return new ControlMessage
+ {
+ _tag = Tag.Error,
+ };
+ }
+
+ public static ControlMessage End()
+ {
+ return new ControlMessage
+ {
+ _tag = Tag.End,
+ };
+ }
+
+ public FfiControlMessage Parse()
+ {
+ FfiControlMessage controlMessage = new FfiControlMessage();
+ int index = (int) MessageTag;
+ FfiControlMessageTag tag = (FfiControlMessageTag) index;
+ controlMessage.Tag = tag;
+ switch (tag)
+ {
+ case FfiControlMessageTag.CtrlMsg:
+ unsafe { controlMessage.Data = controlMessage.Data with { Message = PtrStringConverter.ToPtr(_content) }; }
+ break;
+ case FfiControlMessageTag.CtrlPressed:
+ controlMessage.Data = controlMessage.Data with { Key = (byte) _key };
+ break;
+ case FfiControlMessageTag.CtrlReleased:
+ controlMessage.Data = controlMessage.Data with { Key = (byte) _key };
+ break;
+ case FfiControlMessageTag.CtrlAxis:
+ FfiKeyAndAxis keyAndAxis = new FfiKeyAndAxis();
+ keyAndAxis.Key = (byte) _key;
+ keyAndAxis.Axis = _x;
+ controlMessage.Data = controlMessage.Data with { KeyAndAxis = keyAndAxis };
+ break;
+ case FfiControlMessageTag.CtrlDir:
+ FfiKeyAndDirection keyAndDirection = new FfiKeyAndDirection();
+ keyAndDirection.Key = (byte) _key;
+ keyAndDirection.X = _x;
+ keyAndDirection.Y = _y;
+ controlMessage.Data = controlMessage.Data with { KeyAndDirection = keyAndDirection };
+ break;
+ }
+ return controlMessage;
+ }
+
+ public static ControlMessage From(FfiControlMessage message)
+ {
+ switch (message.Tag)
+ {
+ case FfiControlMessageTag.CtrlMsg:
+ unsafe { return Message(PtrStringConverter.ToString(message.Data.Message)); }
+ case FfiControlMessageTag.CtrlPressed:
+ return Pressed(message.Data.Key);
+ case FfiControlMessageTag.CtrlReleased:
+ return Released(message.Data.Key);
+ case FfiControlMessageTag.CtrlAxis:
+ FfiKeyAndAxis keyAndAxis = message.Data.KeyAndAxis;
+ return Axis(keyAndAxis.Key, (float) keyAndAxis.Axis);
+ case FfiControlMessageTag.CtrlDir:
+ FfiKeyAndDirection keyAndDirection = message.Data.KeyAndDirection;
+ return Direction(keyAndDirection.Key, (float) keyAndDirection.X, (float) keyAndDirection.Y);
+ case FfiControlMessageTag.CtrlExit:
+ return Exit();
+ case FfiControlMessageTag.CtrlError:
+ return Error();
+ case FfiControlMessageTag.CtrlEnd:
+ return End();
+ }
+ return Error();
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/ExitReason.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/ExitReason.cs
new file mode 100644
index 0000000..0541d7f
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/ExitReason.cs
@@ -0,0 +1,28 @@
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Data.Message;
+
+public enum ExitReason
+{
+ Exit = 0,
+ GameOverReason = 1,
+ ServerClosedReason = 2,
+ YouAreKickedReason = 3,
+ YouAreBannedReason = 4,
+ ErrorReason = 5
+}
+
+public static class ExitReasonConvertor
+{
+ public static ExitReason Convert(this FfiExitReason reason)
+ {
+ int index = (int) reason;
+ return (ExitReason) index;
+ }
+
+ public static FfiExitReason Convert(this ExitReason reason)
+ {
+ int index = (int) reason;
+ return (FfiExitReason) index;
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/GameMessage.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/GameMessage.cs
new file mode 100644
index 0000000..427c674
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Message/GameMessage.cs
@@ -0,0 +1,104 @@
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Data.Message;
+
+public struct GameMessage
+{
+ public enum Tag
+ {
+ EventTrigger = 0,
+ Message = 1,
+ LetExit = 2,
+ Error = 3,
+ End = 4
+ }
+
+ public Tag MessageTag => _tag;
+
+ private Tag _tag;
+ private string _content;
+ private int _key;
+ private ExitReason _exitReason;
+
+ public static GameMessage EventTrigger(int key)
+ {
+ return new GameMessage
+ {
+ _tag = Tag.EventTrigger,
+ _key = key
+ };
+ }
+
+ public static GameMessage Message(string messageContent)
+ {
+ return new GameMessage
+ {
+ _tag = Tag.Message,
+ _content = messageContent
+ };
+ }
+
+ public static GameMessage LetExit(ExitReason exitReason)
+ {
+ return new GameMessage
+ {
+ _tag = Tag.LetExit,
+ _exitReason = exitReason
+ };
+ }
+
+ public static GameMessage Error()
+ {
+ return new GameMessage
+ {
+ _tag = Tag.Error
+ };
+ }
+
+ public static GameMessage End()
+ {
+ return new GameMessage
+ {
+ _tag = Tag.End
+ };
+ }
+
+ public FfiGameMessage Parse()
+ {
+ FfiGameMessage gameMessage = new FfiGameMessage();
+ int index = (int) MessageTag;
+ FfiGameMessageTag tag = (FfiGameMessageTag) index;
+ gameMessage.Tag = tag;
+ switch (tag)
+ {
+ case FfiGameMessageTag.GameEventTrigger:
+ gameMessage.Data = gameMessage.Data with { Key = (byte) _key };
+ break;
+ case FfiGameMessageTag.GameMsg:
+ unsafe { gameMessage.Data = gameMessage.Data with { Message = PtrStringConverter.ToPtr(_content) }; }
+ break;
+ case FfiGameMessageTag.GameLetExit:
+ gameMessage.Data = gameMessage.Data with { ExitReason = _exitReason.Convert()};
+ break;
+ }
+ return gameMessage;
+ }
+
+ public static GameMessage From(FfiGameMessage message)
+ {
+ switch (message.Tag)
+ {
+ case FfiGameMessageTag.GameEventTrigger:
+ return EventTrigger(message.Data.Key);
+ case FfiGameMessageTag.GameMsg:
+ unsafe { return Message(PtrStringConverter.ToString(message.Data.Message)); }
+ case FfiGameMessageTag.GameLetExit:
+ return LetExit(message.Data.ExitReason.Convert());
+ case FfiGameMessageTag.GameError:
+ return Error();
+ case FfiGameMessageTag.GameEnd:
+ return End();
+ }
+ return Error();
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Player.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Player.cs
index a3c3ddd..55280d1 100644
--- a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Player.cs
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Data/Player.cs
@@ -2,18 +2,92 @@ using NoGamepads_Sharp;
namespace NoGamepads_Core.Data;
-public class Player
+public class Player : IRawData<FfiPlayer>
{
- private FfiPlayer _ffi = nogamepads_data.PlayerRegister("Fuck", "AAAAA");
+ private readonly FfiPlayer _ffi;
- public String name
+ public Player(string account, string password)
+ {
+ _ffi = nogamepads_data.PlayerRegister(account, password);
+ }
+
+ public string NickName
+ {
+ get
+ {
+ unsafe
+ {
+ var get = _ffi.Customize;
+ return get == null ? "" : PtrStringConverter.ToString(get.Nickname);
+ }
+ }
+
+ set => nogamepads_data.PlayerSetNickname(_ffi, value);
+ }
+
+ public string Id
+ {
+ get
+ {
+ unsafe
+ {
+ return PtrStringConverter.ToString(_ffi.Account.Id);
+ }
+ }
+ }
+
+ public string Hash
{
get
{
unsafe
{
- return PtrStringConverter.ToString(_ffi.Account.PlayerHash);
+ var get = _ffi.Account.PlayerHash;
+ return PtrStringConverter.ToString(get);
}
}
}
+
+ public int Hue
+ {
+ get => GetHue();
+ set => SetHsv(value, Value, Saturation);
+ }
+
+ public float Value
+ {
+ get => GetValue();
+ set => SetHsv(Hue, value, Saturation);
+ }
+
+ public float Saturation
+ {
+ get => GetSaturation();
+ set => SetHsv(Hue, Value, value);
+ }
+
+ private void SetHsv(int h, float s, float v)
+ {
+ nogamepads_data.PlayerSetHsv(_ffi, h, s, v);
+ }
+
+ private int GetHue()
+ {
+ return _ffi.Customize?.ColorHue ?? 0;
+ }
+
+ private float GetValue()
+ {
+ return (float) (_ffi.Customize?.ColorValue ?? 1f);
+ }
+
+ private float GetSaturation()
+ {
+ return (float) (_ffi.Customize?.ColorSaturation ?? 1f);
+ }
+
+ public FfiPlayer GetRawData()
+ {
+ return _ffi;
+ }
} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/NoGamepads_Core.csproj b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/NoGamepads_Core.csproj
index cdf58f8..82e60e0 100644
--- a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/NoGamepads_Core.csproj
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/NoGamepads_Core.csproj
@@ -11,8 +11,8 @@
<Content Include="Native\**">
<CopyToOutputDirectory>PreserveNewest</CopyToOutputDirectory>
</Content>
- <Folder Include="Runtime\" />
- <Folder Include="Services\" />
+ <Folder Include="Services\Bluetooth\" />
+ <Folder Include="Services\Usb\" />
<ProjectReference Include="..\NoGamepads_Bindings\NoGamepads_Bindings.csproj" />
</ItemGroup>
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Runtime/ControllerRuntime.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Runtime/ControllerRuntime.cs
new file mode 100644
index 0000000..0716c04
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Runtime/ControllerRuntime.cs
@@ -0,0 +1,61 @@
+using NoGamepads_Core.Data;
+using NoGamepads_Core.Data.Message;
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Runtime;
+
+public class ControllerRuntime : IRawData<FfiControllerRuntime>
+{
+ private readonly FfiControllerRuntime _ffi;
+
+ public ControllerRuntime(ControllerData data)
+ {
+ _ffi = nogamepads_data.ControllerDataBuildRuntime(data.GetRawData());
+ }
+
+ public void Close()
+ {
+ nogamepads_data.ControllerRuntimeClose(_ffi);
+ }
+
+ public void Pressed(int key)
+ {
+ nogamepads_data.ControllerRuntimePressAButton(_ffi, (byte)key);
+ }
+
+ public void Released(int key)
+ {
+ nogamepads_data.ControllerRuntimeReleaseAButton(_ffi, (byte)key);
+ }
+
+ public void ChangeAxis(int key, float axis)
+ {
+ nogamepads_data.ControllerRuntimeChangeAxis(_ffi, (byte)key, axis);
+ }
+
+ public void ChangeDirection(int key, float x, float y)
+ {
+ nogamepads_data.ControllerRuntimeChangeDirection(_ffi, (byte)key, x, y);
+ }
+
+ public void SendTextMessage(string message)
+ {
+ nogamepads_data.ControllerRuntimeSendTextMessage(_ffi, message);
+ }
+
+ public void SendMessage(ControlMessage message)
+ {
+ nogamepads_data.ControllerRuntimeSendMessage(_ffi, message.Parse());
+ }
+
+ public GameMessage PopMessage()
+ {
+ var result = nogamepads_data.ControllerRuntimePop(_ffi);
+ return result == null ? GameMessage.Error() : GameMessage.From(result);
+ }
+
+ public FfiControllerRuntime GetRawData()
+ {
+ return _ffi;
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Runtime/GameRuntime.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Runtime/GameRuntime.cs
new file mode 100644
index 0000000..9ba5e14
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Runtime/GameRuntime.cs
@@ -0,0 +1,19 @@
+using NoGamepads_Core.Data;
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Runtime;
+
+public class GameRuntime : IRawData<FfiGameRuntime>
+{
+ private readonly FfiGameRuntime _ffi;
+
+ public GameRuntime(GameData data)
+ {
+ _ffi = nogamepads_data.GameDataBuildRuntime(data.GetRawData());
+ }
+
+ public FfiGameRuntime GetRawData()
+ {
+ return _ffi;
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/ServiceType.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/ServiceType.cs
new file mode 100644
index 0000000..93d7cfa
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/ServiceType.cs
@@ -0,0 +1,36 @@
+using NoGamepads_Sharp;
+
+namespace NoGamepads_Core.Services;
+
+public enum ServiceType
+{
+ Unknown,
+ TcpConnection,
+ BluetoothConnection,
+ UsbConnection,
+}
+
+public static class ServiceTypeConverter
+{
+ public static FfiServiceType Convert(this ServiceType serviceType)
+ {
+ if (serviceType == ServiceType.TcpConnection)
+ return FfiServiceType.TCPConnection;
+ if (serviceType == ServiceType.BluetoothConnection)
+ return FfiServiceType.BlueTooth;
+ if (serviceType == ServiceType.UsbConnection)
+ return FfiServiceType.USB;
+ return FfiServiceType.Unknown;
+ }
+
+ public static ServiceType Convert(this FfiServiceType serviceType)
+ {
+ if (serviceType == FfiServiceType.TCPConnection)
+ return ServiceType.TcpConnection;
+ if (serviceType == FfiServiceType.BlueTooth)
+ return ServiceType.BluetoothConnection;
+ if (serviceType == FfiServiceType.USB)
+ return ServiceType.UsbConnection;
+ return ServiceType.Unknown;
+ }
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/Tcp/PadTcpClient.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/Tcp/PadTcpClient.cs
new file mode 100644
index 0000000..40c9aba
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/Tcp/PadTcpClient.cs
@@ -0,0 +1,6 @@
+namespace NoGamepads_Core.Services.Tcp;
+
+public class PadTcpClient
+{
+
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/Tcp/PadTcpServer.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/Tcp/PadTcpServer.cs
new file mode 100644
index 0000000..bfbef46
--- /dev/null
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Core/Services/Tcp/PadTcpServer.cs
@@ -0,0 +1,6 @@
+namespace NoGamepads_Core.Services.Tcp;
+
+public class PadTcpServer
+{
+
+} \ No newline at end of file
diff --git a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Example/Program.cs b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Example/Program.cs
index 6c450f9..11b0d76 100644
--- a/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Example/Program.cs
+++ b/core/bindings/lang/csharp/NoGamepads_CharpBindings/NoGamepads_Example/Program.cs
@@ -1,7 +1,23 @@
-// See https://aka.ms/new-console-template for more information
+using NoGamepads_Core.Data;
+using NoGamepads_Core.Runtime;
-using NoGamepads_Core.Data;
+namespace NoGamepads_Example;
-Player player = new Player();
+internal class Program
+{
+ public static void Main(string[] args)
+ {
+ Player player = new Player("CatilGrass", "Unknown Password");
-Console.WriteLine(player.name); \ No newline at end of file
+ player.Hue = 200;
+
+ ControllerData data = new ControllerData(player);
+
+ ControllerRuntime runtime = new ControllerRuntime(data);
+
+ runtime.SendTextMessage("Hello World! ");
+ Console.WriteLine(player.Hue + "!");
+
+ // Console.WriteLine(player.Hash);
+ }
+} \ No newline at end of file