├── third_party
├── lib
│ └── _ctypes.pyd
├── lib64
│ └── _ctypes.pyd
└── sim_info.py
├── README.md
└── Template_Assetto_Corsa_App.py
/third_party/lib/_ctypes.pyd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huntervaners/Template_Assetto_Corsa_App/HEAD/third_party/lib/_ctypes.pyd
--------------------------------------------------------------------------------
/third_party/lib64/_ctypes.pyd:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/huntervaners/Template_Assetto_Corsa_App/HEAD/third_party/lib64/_ctypes.pyd
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # Template Assetto Corsa Python App
2 | ## A Template folder and script for Assetto Corsa Python app
3 |
4 |
5 |
6 | I'm trying to make App developpent in Assetto Corsa easier.
7 | So here's a template folder , and a script that already include :
8 | * __SimInfo__ (for 32 & 64 bits) *by Rombik , modified by me*
9 | * An __acMain()__ function
10 | * that already create an App window
11 | * is link to an OpenGL render function : __appGL()__
12 |
13 | ## Please don't forget to :
14 |
15 | * Place your app folder in :
16 | #### *\assettocorsa\apps\python*
17 |
18 | * Rename your folder :
19 | 
20 |
21 | * And Python script :
22 | 
23 |
24 | * Enable your App in Assetto Corsa or Content manager :
25 | ##### In Assetto Corsa
26 | 
27 | ##### In Content Manager
28 | 
29 |
30 |
31 |
32 | ## You should have something like this :
33 |
34 | 
35 |
36 | 
37 |
38 |
39 |
40 | ### If not :
41 | Please check : \Documents\Assetto Corsa\logs\ __py_log.txt__
42 |
--------------------------------------------------------------------------------
/Template_Assetto_Corsa_App.py:
--------------------------------------------------------------------------------
1 | # AC App Template by Hunter Vaners
2 | # ------------------------------
3 | #
4 | # Don't forget to rename assettocorsa\apps\python\Template_Assetto_Corsa_App
5 | # by assettocorsa\apps\python\[Your_App_Name_Without_Spaces]
6 | # and
7 | # the file Template_Assetto_Corsa_App.py
8 | # by Your_App_Name_Without_Spaces.py
9 | #
10 | # ------------------------------
11 |
12 | import ac
13 | import acsys
14 | from third_party.sim_info import *
15 |
16 |
17 |
18 |
19 | appName = ">YOUR APP NAME HERE<"
20 | width, height = 800 , 800 # width and height of the app's window
21 |
22 | simInfo = SimInfo()
23 |
24 |
25 |
26 | def acMain(ac_version):#----------------------------- App window Init
27 |
28 | # Don't forget to put anything you'll need to update later as a global variables
29 | global appWindow # <- you'll need to update your window in other functions.
30 |
31 | appWindow = ac.newApp(appName)
32 | ac.setTitle(appWindow, appName)
33 | ac.setSize(appWindow, width, height)
34 |
35 | ac.addRenderCallback(appWindow, appGL) # -> links this app's window to an OpenGL render function
36 |
37 | return appName
38 |
39 |
40 |
41 |
42 |
43 | def appGL(deltaT):#-------------------------------- OpenGL UPDATE
44 | """
45 | This is where you redraw your openGL graphics
46 | if you need to use them .
47 | """
48 | pass # -> Delete this line if you do something here !
49 |
50 |
51 |
52 |
53 | def acUpdate(deltaT):#-------------------------------- AC UPDATE
54 | """
55 | This is where you update your app window ( != OpenGL graphics )
56 | such as : labels , listener , ect ...
57 | """
58 | pass # -> Delete this line if you do something here !
59 |
--------------------------------------------------------------------------------
/third_party/sim_info.py:
--------------------------------------------------------------------------------
1 | """
2 | Original sim_info.py by >>> Rombik <<<
3 |
4 | I didn't change much here , beside ctypes import.
5 | -Hunter Vaners-
6 | """
7 |
8 |
9 | import mmap
10 | import functools
11 |
12 |
13 | # ------------------------------------
14 |
15 | # To import ctypes , we need to see if the system is 64 or 32 bits
16 |
17 | import platform
18 | import os
19 | import sys
20 |
21 | if platform.architecture()[0] == "64bit":
22 | libdir = 'lib64'
23 | else:
24 | libdir = 'lib'
25 | sys.path.insert(0, os.path.join(os.path.dirname(__file__), libdir))
26 | os.environ['PATH'] = os.environ['PATH'] + ";."
27 |
28 | import ctypes
29 | from ctypes import c_int32, c_float, c_wchar
30 | # ------------------------------------
31 |
32 |
33 |
34 |
35 |
36 | AC_STATUS = c_int32
37 | AC_OFF = 0
38 | AC_REPLAY = 1
39 | AC_LIVE = 2
40 | AC_PAUSE = 3
41 | AC_SESSION_TYPE = c_int32
42 | AC_UNKNOWN = -1
43 | AC_PRACTICE = 0
44 | AC_QUALIFY = 1
45 | AC_RACE = 2
46 | AC_HOTLAP = 3
47 | AC_TIME_ATTACK = 4
48 | AC_DRIFT = 5
49 | AC_DRAG = 6
50 | AC_FLAG_TYPE = c_int32
51 | AC_NO_FLAG = 0
52 | AC_BLUE_FLAG = 1
53 | AC_YELLOW_FLAG = 2
54 | AC_BLACK_FLAG = 3
55 | AC_WHITE_FLAG = 4
56 | AC_CHECKERED_FLAG = 5
57 | AC_PENALTY_FLAG = 6
58 |
59 | class SPageFilePhysics(ctypes.Structure):
60 | _pack_ = 4
61 | _fields_ = [
62 | ('packetId', c_int32),
63 | ('gas', c_float),
64 | ('brake', c_float),
65 | ('fuel', c_float),
66 | ('gear', c_int32),
67 | ('rpms', c_int32),
68 | ('steerAngle', c_float),
69 | ('speedKmh', c_float),
70 | ('velocity', c_float * 3),
71 | ('accG', c_float * 3),
72 | ('wheelSlip', c_float * 4),
73 | ('wheelLoad', c_float * 4),
74 | ('wheelsPressure', c_float * 4),
75 | ('wheelAngularSpeed', c_float * 4),
76 | ('tyreWear', c_float * 4),
77 | ('tyreDirtyLevel', c_float * 4),
78 | ('tyreCoreTemperature', c_float * 4),
79 | ('camberRAD', c_float * 4),
80 | ('suspensionTravel', c_float * 4),
81 | ('drs', c_float),
82 | ('tc', c_float),
83 | ('heading', c_float),
84 | ('pitch', c_float),
85 | ('roll', c_float),
86 | ('cgHeight', c_float),
87 | ('carDamage', c_float * 5),
88 | ('numberOfTyresOut', c_int32),
89 | ('pitLimiterOn', c_int32),
90 | ('abs', c_float),
91 | ('kersCharge', c_float),
92 | ('kersInput', c_float),
93 | ('autoShifterOn', c_int32),
94 | ('rideHeight', c_float * 2),
95 | ('turboBoost', c_float),
96 | ('ballast', c_float),
97 | ('airDensity', c_float),
98 | ('airTemp', c_float),
99 | ('roadTemp', c_float),
100 | ('localAngularVel', c_float * 3),
101 | ('finalFF', c_float),
102 | ('performanceMeter', c_float),
103 | ('engineBrake', c_int32),
104 | ('ersRecoveryLevel', c_int32),
105 | ('ersPowerLevel', c_int32),
106 | ('ersHeatCharging', c_int32),
107 | ('ersIsCharging', c_int32),
108 | ('kersCurrentKJ', c_float),
109 | ('drsAvailable', c_int32),
110 | ('drsEnabled', c_int32),
111 | ('brakeTemp', c_float * 4),
112 | ('clutch', c_float),
113 | ('tyreTempI', c_float * 4),
114 | ('tyreTempM', c_float * 4),
115 | ('tyreTempO', c_float * 4),
116 | ('isAIControlled', c_int32),
117 | ('tyreContactPoint', c_float * 4 * 3),
118 | ('tyreContactNormal', c_float * 4 * 3),
119 | ('tyreContactHeading', c_float * 4 * 3),
120 | ('brakeBias', c_float),
121 | ('localVelocity', c_float * 3),
122 |
123 | ]
124 |
125 | class SPageFileGraphic(ctypes.Structure):
126 | _pack_ = 4
127 | _fields_ = [
128 | ('packetId', c_int32),
129 | ('status', AC_STATUS),
130 | ('session', AC_SESSION_TYPE),
131 | ('currentTime', c_wchar * 15),
132 | ('lastTime', c_wchar * 15),
133 | ('bestTime', c_wchar * 15),
134 | ('split', c_wchar * 15),
135 | ('completedLaps', c_int32),
136 | ('position', c_int32),
137 | ('iCurrentTime', c_int32),
138 | ('iLastTime', c_int32),
139 | ('iBestTime', c_int32),
140 | ('sessionTimeLeft', c_float),
141 | ('distanceTraveled', c_float),
142 | ('isInPit', c_int32),
143 | ('currentSectorIndex', c_int32),
144 | ('lastSectorTime', c_int32),
145 | ('numberOfLaps', c_int32),
146 | ('tyreCompound', c_wchar * 33),
147 | ('replayTimeMultiplier', c_float),
148 | ('normalizedCarPosition', c_float),
149 | ('carCoordinates', c_float * 3),
150 | ('penaltyTime', c_float),
151 | ('flag', AC_FLAG_TYPE),
152 | ('idealLineOn', c_int32),
153 | ('isInPitLine', c_int32),
154 | ('surfaceGrip', c_float),
155 | ('mandatoryPitDone', c_int32),
156 | ('windSpeed', c_float),
157 | ('windDirection', c_float),
158 |
159 | ]
160 |
161 | class SPageFileStatic(ctypes.Structure):
162 | _pack_ = 4
163 | _fields_ = [
164 | ('_smVersion', c_wchar * 15),
165 | ('_acVersion', c_wchar * 15),
166 | ('numberOfSessions', c_int32),
167 | ('numCars', c_int32),
168 | ('carModel', c_wchar * 33),
169 | ('track', c_wchar * 33),
170 | ('playerName', c_wchar * 33),
171 | ('playerSurname', c_wchar * 33),
172 | ('playerNick', c_wchar * 33),
173 | ('sectorCount', c_int32),
174 | ('maxTorque', c_float),
175 | ('maxPower', c_float),
176 | ('maxRpm', c_int32),
177 | ('maxFuel', c_float),
178 | ('suspensionMaxTravel', c_float * 4),
179 | ('tyreRadius', c_float * 4),
180 | ('maxTurboBoost', c_float),
181 | ('airTemp', c_float),
182 | ('roadTemp', c_float),
183 | ('penaltiesEnabled', c_int32),
184 | ('aidFuelRate', c_float),
185 | ('aidTireRate', c_float),
186 | ('aidMechanicalDamage', c_float),
187 | ('aidAllowTyreBlankets', c_int32),
188 | ('aidStability', c_float),
189 | ('aidAutoClutch', c_int32),
190 | ('aidAutoBlip', c_int32),
191 | ('hasDRS', c_int32),
192 | ('hasERS', c_int32),
193 | ('hasKERS', c_int32),
194 | ('kersMaxJ', c_float),
195 | ('engineBrakeSettingsCount', c_int32),
196 | ('ersPowerControllerCount', c_int32),
197 | ('trackSPlineLength', c_float),
198 | ('trackConfiguration', c_wchar * 33),
199 | ('ersMaxJ', c_float),
200 | ('isTimedRace', c_int32),
201 | ('hasExtraLap', c_int32),
202 | ('carSkin', c_wchar * 33),
203 | ('reversedGridPositions', c_int32),
204 | ('pitWindowStart', c_int32),
205 | ('pitWindowEnd', c_int32),
206 |
207 | ]
208 |
209 | class SimInfo:
210 | def __init__(self):
211 | self._acpmf_physics = mmap.mmap(0, ctypes.sizeof(SPageFilePhysics), "acpmf_physics")
212 | self._acpmf_graphics = mmap.mmap(0, ctypes.sizeof(SPageFileGraphic), "acpmf_graphics")
213 | self._acpmf_static = mmap.mmap(0, ctypes.sizeof(SPageFileStatic), "acpmf_static")
214 | self.physics = SPageFilePhysics.from_buffer(self._acpmf_physics)
215 | self.graphics = SPageFileGraphic.from_buffer(self._acpmf_graphics)
216 | self.static = SPageFileStatic.from_buffer(self._acpmf_static)
217 |
218 | def close(self):
219 | self._acpmf_physics.close()
220 | self._acpmf_graphics.close()
221 | self._acpmf_static.close()
222 |
223 | def __del__(self):
224 | self.close()
225 |
--------------------------------------------------------------------------------