import struct
FORZA_DATA_FORMAT = '<iIfffffffffffffffffffffffffffiiiiffffffffffffffffffffiiiiifffffffffffffffffHBBBBBBbbbffffi'


def unpackData(unpackedData):
    carData = {
        "IsRaceOn":unpackedData[0], #// = 1 when race is on. = 0 when in menus/race stopped …
        #// Can overflow to 0 eventually
        "TimestampMS": unpackedData[1],
        "EngineMaxRpm": unpackedData[2],
        "EngineIdleRpm": unpackedData[3],
        "CurrentEngineRpm": unpackedData[4],
        #// In the car's local space; X = right, Y = up, Z = forward
        "AccelerationX": unpackedData[5],
        "AccelerationY": unpackedData[6],
        "AccelerationZ": unpackedData[7],
        #// In the car's local space; X = right, Y = up, Z = forward
        "VelocityX": unpackedData[8],
        "VelocityY": unpackedData[9],
        "VelocityZ": unpackedData[10],
        #// In the car's local space; X = pitch, Y = yaw, Z = roll
        "AngularVelocityX": unpackedData[11],
        "AngularVelocityY": unpackedData[12],
        "AngularVelocityZ": unpackedData[13],
        "Yaw": unpackedData[14],
        "Pitch": unpackedData[15],
        "Roll": unpackedData[16],
        #// Suspension travel normalized: 0.0f = max stretch; 1.0 = max compression
        "NormalizedSuspensionTravelFrontLeft": unpackedData[17],
        "NormalizedSuspensionTravelFrontRight": unpackedData[18],
        "NormalizedSuspensionTravelRearLeft": unpackedData[19],
        "NormalizedSuspensionTravelRearRight": unpackedData[20],
        #// Tire normalized slip ratio, = 0 means 100% grip and |ratio| > 1.0 means loss of grip.
        "TireSlipRatioFrontLeft": unpackedData[21],
        "TireSlipRatioFrontRight": unpackedData[22],
        "TireSlipRatioRearLeft": unpackedData[23],
        "TireSlipRatioRearRight": unpackedData[24],
        #// Wheels rotation speed radians/sec.
        "WheelRotationSpeedFrontLeft": unpackedData[25],
        "WheelRotationSpeedFrontRight": unpackedData[26],
        "WheelRotationSpeedRearLeft": unpackedData[27],
        "WheelRotationSpeedRearRight": unpackedData[28],
        #// = 1 when wheel is on rumble strip, = 0 when off.
        "WheelOnRumbleStripFrontLeft": unpackedData[29],
        "WheelOnRumbleStripFrontRight": unpackedData[30],
        "WheelOnRumbleStripRearLeft": unpackedData[31],
        "WheelOnRumbleStripRearRight": unpackedData[32],
        #// = from 0 to 1, where 1 is the deepest puddle
        "WheelInPuddleDepthFrontLeft": unpackedData[33],
        "WheelInPuddleDepthFrontRight": unpackedData[34],
        "WheelInPuddleDepthRearLeft": unpackedData[35],
        "WheelInPuddleDepthRearRight": unpackedData[36],
        #// Non-dimensional surface rumble values passed to controller force feedback
        "SurfaceRumbleFrontLeft": unpackedData[37],
        "SurfaceRumbleFrontRight": unpackedData[38],
        "SurfaceRumbleRearLeft": unpackedData[39],
        "SurfaceRumbleRearRight": unpackedData[40],
        #// Tire normalized slip angle, = 0 means 100% grip and |angle| > 1.0 means loss of grip.
        "TireSlipAngleFrontLeft": unpackedData[41],
        "TireSlipAngleFrontRight": unpackedData[42],
        "TireSlipAngleRearLeft": unpackedData[43],
        "TireSlipAngleRearRight": unpackedData[44],
        #// Tire normalized combined slip, = 0 means 100% grip and |slip| > 1.0 means loss of grip.
        "TireCombinedSlipFrontLeft": unpackedData[45],
        "TireCombinedSlipFrontRight": unpackedData[46],
        "TireCombinedSlipRearLeft": unpackedData[47],
        "TireCombinedSlipRearRight": unpackedData[48],
        #// Actual suspension travel in meters
        "SuspensionTravelMetersFrontLeft": unpackedData[49],
        "SuspensionTravelMetersFrontRight": unpackedData[50],
        "SuspensionTravelMetersRearLeft": unpackedData[51],
        "SuspensionTravelMetersRearRight": unpackedData[52],
        #// Unique ID of the car make/model
        "CarOrdinal": unpackedData[53],
        #// Between 0 (D -- worst cars) and 7 (X class -- best cars) inclusive         
        "CarClass": unpackedData[54],
        #// Between 100 (worst car) and 999 (best car) inclusive
        "CarPerformanceIndex": unpackedData[55],
        #// 0 = FWD, 1 = RWD, 2 = AWD
        "DrivetrainType": unpackedData[56],
        #// Number of cylinders in the engine
        "NumCylinders": unpackedData[57],
        "PositionX": unpackedData[58],
        "PositionY": unpackedData[59],
        "PositionZ": unpackedData[60],
        "Speed": unpackedData[61],
        "Power": unpackedData[62],
        "Torque": unpackedData[63],
        "TireTempFrontLeft": unpackedData[64],
        "TireTempFrontRight": unpackedData[65],
        "TireTempRearLeft": unpackedData[66],
        "TireTempRearRight": unpackedData[67],
        "Boost": unpackedData[68],
        "Fuel": unpackedData[69],
        "DistanceTraveled": unpackedData[70],
        "BestLap": unpackedData[71],
        "LastLap": unpackedData[72],
        "CurrentLap": unpackedData[73],
        "CurrentRaceTime": unpackedData[74],
        "LapNumber": unpackedData[75],
        "RacePosition": unpackedData[76],
        "Accel": unpackedData[77],
        "Brake": unpackedData[78],
        "Clutch": unpackedData[79],
        "HandBrake": unpackedData[80],
        "Gear": unpackedData[81],
        "Steer": unpackedData[82],
        "NormalizedDrivingLine": unpackedData[83],
        "NormalizedAIBrakeDifference": unpackedData[84],
        "TireWearFrontLeft": unpackedData[85],
        "TireWearFrontRight": unpackedData[86],
        "TireWearRearLeft": unpackedData[87],
        "TireWearRearRight": unpackedData[88],
        #// ID for track
        "TrackOrdinal": unpackedData[89]
    }
    return carData