Skip to content

voltaney/TouchSenderInterpreter

Repository files navigation

TouchSenderInterpreter

License: MIT NuGet Version CI dotnet Version dotnet Version

Parser library for data sent from the mobile application Touch Sender.

Usage

Example of receiving data from Touch Sender via UDP and parsing its contents to display touch states.

using System.Net;
using System.Net.Sockets;
using TouchSenderInterpreter;

namespace ConsoleApp1;

class Program
{
    static void Main(string[] args)
    {
        int port = 50000;
        IPEndPoint? senderEP = null;

        // Ctrl + C to quit
        using (var udpClient = new UdpClient(port))
        {
            while (true)
            {
                var recievedData = udpClient.Receive(ref senderEP);
                // parse recieved data of Touch Sender
                var result = Interpreter.Read(recievedData);
                if (result.IsSuccess)
                {
                    // print SingleTouchRatio
                    Console.WriteLine(result.Payload?.SingleTouchRatio);
                }
                else
                {
                    Console.WriteLine("Failed to parse Touch Sender data");
                    Console.WriteLine(result.ErrorMessage);
                }
            }
        }
    }
}

Result Structure

If the JSON data is successfully parsed, a result object with the following structure is obtained.

{
  "Payload": {
    "Id": 538,
    "DeviceInfo": {
      "Width": 360,
      "Height": 800
    },
    "SingleTouch": {
      "X": 248.33333333333334,
      "Y": 387
    }
  },
  "IsSuccess": true,
  "ErrorMessage": null
}

Deployment

  • Create a new release based on release-drafter.
  • When the version tag (e.g., v1.0.0) is added, the GitHub Actions workflow for the release is triggered.
  • The workflow builds the package (e.g., .nupkg file) and attaches it to the release.

About

A library for parsing data received from the application "Touch Sender".

Topics

Resources

License

Stars

Watchers

Forks

Packages

No packages published

Languages