Coder Social home page Coder Social logo

forzatelemetryreader's Introduction

Nuget Nuget

ForzaTelemetryReader

Library for reading and parsing live telemetry data from Forza video games. Currently Forza Motorsport 7 (in "Sled" and "Dash" mode) and Forza Horizon 4 supported.

Functionality

Both Forza Motorsport 7 and Forza Horizon 4 have a feature called "Data out" that can be enabled via the in-game settings. Enabling this feature will make the game send UDP packets with live telemetry data to a given IP and Port. The game will send a telemetry packet every frame. So if you have the game running at 60fps, the TelemetryReader will receive 60 packets per second.

Hint: According to the official documentation it is not possible to stream data to the machine the game is running on. This not correct, although you have to manually execute a command in order to enable localhost streaming. For more details, see "Installation".

Official documentation from the Forza Motorsport 7 developers .

Installation

This library is published on NuGet as ForzaTelemetryReader. You can simply install it just as any other NuGet package.

Optional: Enable localhost streaming

As mentioned above, the streaming of telemetry data to the machine the game is running on is not officially supported due to restrictions in UWP. These restrictions can however be manually disabled. Simply run the following commands in powershell with admin privileges (Win + X โ†’ Windows Powershell (Administrator)):

Forza Motorsport 7:

CheckNetIsolation.exe LoopbackExempt -a -n="Microsoft.ApolloBaseGame_8wekyb3d8bbwe"

Forza Horizon 4:

CheckNetIsolation.exe LoopbackExempt -a -n="Microsoft.SunriseBaseGame_8wekyb3d8bbwe"

Usage

This library is easy to integrate in just a few lines of code. The telemetry client is running in its own background thread, so you don't have to worry about blocking anything else.

This is a minimal usage example:

using System;
using System.Threading;
using MicrosoftGames.Forza;

namespace Forza_Telemetry_Test
{
    class Program
    {
        private static void Main()
        {
            // the port defined in the in-game settings
            const int port = 5685;

            // initialize a new TelemetryReader with the port
            var telemetryReader = new TelemetryReader(port);

            // start listening to telemetry packages
            telemetryReader.StartListener();

            // listen for one minute
            for(int i = 0; i < 60; i++)
            {
                // print some example data to the console
                Console.SetCursorPosition(0,0);
                Console.WriteLine($"Game: {telemetryReader.TelemetryData.GameTitle}");
                Console.WriteLine($"Timestamp: {telemetryReader.TelemetryData.TimestampMS}");
                Console.WriteLine($"Is in Race: {telemetryReader.TelemetryData.IsRaceOn}");
                Console.WriteLine($"RPM: {(int) telemetryReader.TelemetryData.CurrentEngineRpm}"); // cast from float to int
                Console.WriteLine($"KMH: {(int) (telemetryReader.TelemetryData.Speed * 3.6)}");    // Speed is in m/s, so multiply with 3.6 to get km/h
                Console.WriteLine($"Gear: {telemetryReader.TelemetryData.Gear}");
                
                // the listener wont be affected since it is running in a background thread
                Thread.Sleep(1000);
            }
            
            // stop listening and unblock the port
            telemetryReader.StopListener();
        }
    }
}

forzatelemetryreader's People

Contributors

grimsi avatar

Stargazers

Julio Ramos avatar

Watchers

James Cloos avatar  avatar  avatar

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    ๐Ÿ–– Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. ๐Ÿ“Š๐Ÿ“ˆ๐ŸŽ‰

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google โค๏ธ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.