py-assettocorsa 0.0.1__tar.gz
This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
- py_assettocorsa-0.0.1/LICENSE +21 -0
- py_assettocorsa-0.0.1/PKG-INFO +46 -0
- py_assettocorsa-0.0.1/README.MD +33 -0
- py_assettocorsa-0.0.1/VERSION +1 -0
- py_assettocorsa-0.0.1/ac/__init__.py +3 -0
- py_assettocorsa-0.0.1/ac/memory.py +106 -0
- py_assettocorsa-0.0.1/ac/models/__init__.py +0 -0
- py_assettocorsa-0.0.1/ac/models/enums.py +29 -0
- py_assettocorsa-0.0.1/ac/models/graphics.py +87 -0
- py_assettocorsa-0.0.1/ac/models/physics.py +149 -0
- py_assettocorsa-0.0.1/ac/models/static.py +109 -0
- py_assettocorsa-0.0.1/py_assettocorsa.egg-info/PKG-INFO +46 -0
- py_assettocorsa-0.0.1/py_assettocorsa.egg-info/SOURCES.txt +15 -0
- py_assettocorsa-0.0.1/py_assettocorsa.egg-info/dependency_links.txt +1 -0
- py_assettocorsa-0.0.1/py_assettocorsa.egg-info/top_level.txt +1 -0
- py_assettocorsa-0.0.1/pyproject.toml +25 -0
- py_assettocorsa-0.0.1/setup.cfg +4 -0
|
@@ -0,0 +1,21 @@
|
|
|
1
|
+
MIT License
|
|
2
|
+
|
|
3
|
+
Copyright (c) 2026 Oleh Solomoichenko
|
|
4
|
+
|
|
5
|
+
Permission is hereby granted, free of charge, to any person obtaining a copy
|
|
6
|
+
of this software and associated documentation files (the "Software"), to deal
|
|
7
|
+
in the Software without restriction, including without limitation the rights
|
|
8
|
+
to use, copy, modify, merge, publish, distribute, sublicense, and/or sell
|
|
9
|
+
copies of the Software, and to permit persons to whom the Software is
|
|
10
|
+
furnished to do so, subject to the following conditions:
|
|
11
|
+
|
|
12
|
+
The above copyright notice and this permission notice shall be included in all
|
|
13
|
+
copies or substantial portions of the Software.
|
|
14
|
+
|
|
15
|
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR
|
|
16
|
+
IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY,
|
|
17
|
+
FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE
|
|
18
|
+
AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER
|
|
19
|
+
LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM,
|
|
20
|
+
OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE
|
|
21
|
+
SOFTWARE.
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py-assettocorsa
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Read Assetto Corsa shared memory on Windows.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ooocheckitout/py-assettocorsa
|
|
6
|
+
Project-URL: Repository, https://github.com/ooocheckitout/py-assettocorsa.git
|
|
7
|
+
Project-URL: Issues, https://github.com/ooocheckitout/py-assettocorsa/issues
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# py-assettocorsa
|
|
15
|
+
|
|
16
|
+
The Python library to read shared memory of Assetto Corsa Evo.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install py-assettocorsa
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Example
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from acevo import ACEvoSharedMemory
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
with ACEvoSharedMemory() as memory:
|
|
31
|
+
static, physics, graphics = memory.read_snapshot()
|
|
32
|
+
print(static.session_name, static.track)
|
|
33
|
+
print(physics.speed_kmh, physics.gas, physics.brake)
|
|
34
|
+
print(graphics.current_lap_time_ms, graphics.car_coordinates)
|
|
35
|
+
except FileNotFoundError as error:
|
|
36
|
+
print("The AC Evo shared memory is unavailable. Start a driving session.")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Available Models
|
|
40
|
+
|
|
41
|
+
| Model | Description |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| [Static](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/static.py) | Session, track, and game information. |
|
|
44
|
+
| [Physics](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/physics.py) | Speed, controls, engine, and wheel telemetry. |
|
|
45
|
+
| [Graphics](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/graphics.py) | Timing, positions, tyres, damage, and pit information. |
|
|
46
|
+
| [Enums](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/enums.py) | Named status, session, and flag values. |
|
|
@@ -0,0 +1,33 @@
|
|
|
1
|
+
# py-assettocorsa
|
|
2
|
+
|
|
3
|
+
The Python library to read shared memory of Assetto Corsa Evo.
|
|
4
|
+
|
|
5
|
+
## Install
|
|
6
|
+
|
|
7
|
+
```bash
|
|
8
|
+
pip install py-assettocorsa
|
|
9
|
+
```
|
|
10
|
+
|
|
11
|
+
## Example
|
|
12
|
+
|
|
13
|
+
```python
|
|
14
|
+
from acevo import ACEvoSharedMemory
|
|
15
|
+
|
|
16
|
+
try:
|
|
17
|
+
with ACEvoSharedMemory() as memory:
|
|
18
|
+
static, physics, graphics = memory.read_snapshot()
|
|
19
|
+
print(static.session_name, static.track)
|
|
20
|
+
print(physics.speed_kmh, physics.gas, physics.brake)
|
|
21
|
+
print(graphics.current_lap_time_ms, graphics.car_coordinates)
|
|
22
|
+
except FileNotFoundError as error:
|
|
23
|
+
print("The AC Evo shared memory is unavailable. Start a driving session.")
|
|
24
|
+
```
|
|
25
|
+
|
|
26
|
+
## Available Models
|
|
27
|
+
|
|
28
|
+
| Model | Description |
|
|
29
|
+
| --- | --- |
|
|
30
|
+
| [Static](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/static.py) | Session, track, and game information. |
|
|
31
|
+
| [Physics](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/physics.py) | Speed, controls, engine, and wheel telemetry. |
|
|
32
|
+
| [Graphics](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/graphics.py) | Timing, positions, tyres, damage, and pit information. |
|
|
33
|
+
| [Enums](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/enums.py) | Named status, session, and flag values. |
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
0.0.1
|
|
@@ -0,0 +1,106 @@
|
|
|
1
|
+
from __future__ import annotations
|
|
2
|
+
|
|
3
|
+
import ctypes
|
|
4
|
+
from contextlib import ExitStack
|
|
5
|
+
from ctypes import wintypes
|
|
6
|
+
from types import TracebackType
|
|
7
|
+
from typing import NamedTuple, TypeVar
|
|
8
|
+
|
|
9
|
+
from .models.graphics import GraphicsPage
|
|
10
|
+
from .models.physics import PhysicsPage
|
|
11
|
+
from .models.static import StaticPage
|
|
12
|
+
|
|
13
|
+
Page = TypeVar("Page", bound=ctypes.Structure)
|
|
14
|
+
|
|
15
|
+
_kernel32 = ctypes.WinDLL("kernel32", use_last_error=True)
|
|
16
|
+
_kernel32.OpenFileMappingW.argtypes = (
|
|
17
|
+
wintypes.DWORD,
|
|
18
|
+
wintypes.BOOL,
|
|
19
|
+
wintypes.LPCWSTR,
|
|
20
|
+
)
|
|
21
|
+
_kernel32.OpenFileMappingW.restype = wintypes.HANDLE
|
|
22
|
+
_kernel32.MapViewOfFile.argtypes = (
|
|
23
|
+
wintypes.HANDLE,
|
|
24
|
+
wintypes.DWORD,
|
|
25
|
+
wintypes.DWORD,
|
|
26
|
+
wintypes.DWORD,
|
|
27
|
+
ctypes.c_size_t,
|
|
28
|
+
)
|
|
29
|
+
_kernel32.MapViewOfFile.restype = ctypes.c_void_p
|
|
30
|
+
_kernel32.UnmapViewOfFile.argtypes = (ctypes.c_void_p,)
|
|
31
|
+
_kernel32.UnmapViewOfFile.restype = wintypes.BOOL
|
|
32
|
+
_kernel32.CloseHandle.argtypes = (wintypes.HANDLE,)
|
|
33
|
+
_kernel32.CloseHandle.restype = wintypes.BOOL
|
|
34
|
+
|
|
35
|
+
|
|
36
|
+
class Snapshot(NamedTuple):
|
|
37
|
+
static: StaticPage
|
|
38
|
+
physics: PhysicsPage
|
|
39
|
+
graphics: GraphicsPage
|
|
40
|
+
|
|
41
|
+
|
|
42
|
+
class ACSharedMemory:
|
|
43
|
+
|
|
44
|
+
def __init__(self) -> None:
|
|
45
|
+
self._resources = ExitStack()
|
|
46
|
+
self._pages: dict[type[ctypes.Structure], int] = {}
|
|
47
|
+
|
|
48
|
+
def __enter__(self) -> ACSharedMemory:
|
|
49
|
+
if self._pages:
|
|
50
|
+
raise RuntimeError("Close the reader first.")
|
|
51
|
+
try:
|
|
52
|
+
for name, page_type in (
|
|
53
|
+
("Local\\acpmf_static", StaticPage),
|
|
54
|
+
("Local\\acpmf_physics", PhysicsPage),
|
|
55
|
+
("Local\\acpmf_graphics", GraphicsPage),
|
|
56
|
+
):
|
|
57
|
+
self._pages[page_type] = self._open_page(name, page_type)
|
|
58
|
+
except BaseException:
|
|
59
|
+
self._close()
|
|
60
|
+
raise
|
|
61
|
+
return self
|
|
62
|
+
|
|
63
|
+
def __exit__(
|
|
64
|
+
self,
|
|
65
|
+
exc_type: type[BaseException] | None,
|
|
66
|
+
exc_value: BaseException | None,
|
|
67
|
+
traceback: TracebackType | None,
|
|
68
|
+
) -> None:
|
|
69
|
+
self._close()
|
|
70
|
+
|
|
71
|
+
def _close(self) -> None:
|
|
72
|
+
self._pages.clear()
|
|
73
|
+
self._resources.close()
|
|
74
|
+
|
|
75
|
+
def read_static(self) -> StaticPage:
|
|
76
|
+
return self._read_page(StaticPage)
|
|
77
|
+
|
|
78
|
+
def read_physics(self) -> PhysicsPage:
|
|
79
|
+
return self._read_page(PhysicsPage)
|
|
80
|
+
|
|
81
|
+
def read_graphics(self) -> GraphicsPage:
|
|
82
|
+
return self._read_page(GraphicsPage)
|
|
83
|
+
|
|
84
|
+
def read_snapshot(self) -> Snapshot:
|
|
85
|
+
return Snapshot(self.read_static(), self.read_physics(), self.read_graphics())
|
|
86
|
+
|
|
87
|
+
def _read_page(self, page_type: type[Page]) -> Page:
|
|
88
|
+
return page_type.from_buffer_copy(
|
|
89
|
+
ctypes.string_at(self._pages[page_type], ctypes.sizeof(page_type))
|
|
90
|
+
)
|
|
91
|
+
|
|
92
|
+
def _open_page(self, name: str, page_type: type[Page]) -> int:
|
|
93
|
+
handle = _kernel32.OpenFileMappingW(4, False, name)
|
|
94
|
+
if not handle:
|
|
95
|
+
error = ctypes.get_last_error()
|
|
96
|
+
if error == 2:
|
|
97
|
+
message = "The Assetto Corsa shared memory is unavailable. Start a driving session."
|
|
98
|
+
raise FileNotFoundError(message)
|
|
99
|
+
raise ctypes.WinError(ctypes.get_last_error())
|
|
100
|
+
|
|
101
|
+
self._resources.callback(_kernel32.CloseHandle, handle)
|
|
102
|
+
address = _kernel32.MapViewOfFile(handle, 4, 0, 0, ctypes.sizeof(page_type))
|
|
103
|
+
if not address:
|
|
104
|
+
raise ctypes.WinError(ctypes.get_last_error())
|
|
105
|
+
self._resources.callback(_kernel32.UnmapViewOfFile, address)
|
|
106
|
+
return address
|
|
File without changes
|
|
@@ -0,0 +1,29 @@
|
|
|
1
|
+
from enum import IntEnum
|
|
2
|
+
|
|
3
|
+
|
|
4
|
+
class AC_STATUS(IntEnum):
|
|
5
|
+
AC_OFF = 0
|
|
6
|
+
AC_REPLAY = 1
|
|
7
|
+
AC_LIVE = 2
|
|
8
|
+
AC_PAUSE = 3
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
class AC_SESSION_TYPE(IntEnum):
|
|
12
|
+
AC_UNKNOWN = -1
|
|
13
|
+
AC_PRACTICE = 0
|
|
14
|
+
AC_QUALIFY = 1
|
|
15
|
+
AC_RACE = 2
|
|
16
|
+
AC_HOTLAP = 3
|
|
17
|
+
AC_TIME_ATTACK = 4
|
|
18
|
+
AC_DRIFT = 5
|
|
19
|
+
AC_DRAG = 6
|
|
20
|
+
|
|
21
|
+
|
|
22
|
+
class AC_FLAG_TYPE(IntEnum):
|
|
23
|
+
AC_NO_FLAG = 0
|
|
24
|
+
AC_BLUE_FLAG = 1
|
|
25
|
+
AC_YELLOW_FLAG = 2
|
|
26
|
+
AC_BLACK_FLAG = 3
|
|
27
|
+
AC_WHITE_FLAG = 4
|
|
28
|
+
AC_CHECKERED_FLAG = 5
|
|
29
|
+
AC_PENALTY_FLAG = 6
|
|
@@ -0,0 +1,87 @@
|
|
|
1
|
+
from ctypes import (
|
|
2
|
+
LittleEndianStructure,
|
|
3
|
+
sizeof,
|
|
4
|
+
c_float,
|
|
5
|
+
c_int32,
|
|
6
|
+
c_wchar,
|
|
7
|
+
)
|
|
8
|
+
from collections.abc import Sequence
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
FloatArray = Sequence[float]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class GraphicsPage(LittleEndianStructure):
|
|
15
|
+
_layout_ = "ms"
|
|
16
|
+
_pack_ = 4
|
|
17
|
+
|
|
18
|
+
packet_id: int
|
|
19
|
+
status: int
|
|
20
|
+
session: int
|
|
21
|
+
current_time: str
|
|
22
|
+
last_time: str
|
|
23
|
+
best_time: str
|
|
24
|
+
split: str
|
|
25
|
+
completed_laps: int
|
|
26
|
+
position: int
|
|
27
|
+
i_current_time: int
|
|
28
|
+
i_last_time: int
|
|
29
|
+
i_best_time: int
|
|
30
|
+
session_time_left: float
|
|
31
|
+
distance_traveled: float
|
|
32
|
+
is_in_pit: int
|
|
33
|
+
current_sector_index: int
|
|
34
|
+
last_sector_time: int
|
|
35
|
+
number_of_laps: int
|
|
36
|
+
tyre_compound: str
|
|
37
|
+
replay_time_multiplier: float
|
|
38
|
+
normalized_car_position: float
|
|
39
|
+
car_coordinates: FloatArray
|
|
40
|
+
penalty_time: float
|
|
41
|
+
flag: int
|
|
42
|
+
ideal_line_on: int
|
|
43
|
+
is_in_pit_lane: int
|
|
44
|
+
surface_grip: float
|
|
45
|
+
mandatory_pit_done: int
|
|
46
|
+
wind_speed: float
|
|
47
|
+
wind_direction: float
|
|
48
|
+
is_setup_menu_visible: int
|
|
49
|
+
main_display_index: int
|
|
50
|
+
|
|
51
|
+
_fields_ = [
|
|
52
|
+
("packet_id", c_int32),
|
|
53
|
+
("status", c_int32),
|
|
54
|
+
("session", c_int32),
|
|
55
|
+
("current_time", (c_wchar * 15)),
|
|
56
|
+
("last_time", (c_wchar * 15)),
|
|
57
|
+
("best_time", (c_wchar * 15)),
|
|
58
|
+
("split", (c_wchar * 15)),
|
|
59
|
+
("completed_laps", c_int32),
|
|
60
|
+
("position", c_int32),
|
|
61
|
+
("i_current_time", c_int32),
|
|
62
|
+
("i_last_time", c_int32),
|
|
63
|
+
("i_best_time", c_int32),
|
|
64
|
+
("session_time_left", c_float),
|
|
65
|
+
("distance_traveled", c_float),
|
|
66
|
+
("is_in_pit", c_int32),
|
|
67
|
+
("current_sector_index", c_int32),
|
|
68
|
+
("last_sector_time", c_int32),
|
|
69
|
+
("number_of_laps", c_int32),
|
|
70
|
+
("tyre_compound", (c_wchar * 33)),
|
|
71
|
+
("replay_time_multiplier", c_float),
|
|
72
|
+
("normalized_car_position", c_float),
|
|
73
|
+
("car_coordinates", (c_float * 3)),
|
|
74
|
+
("penalty_time", c_float),
|
|
75
|
+
("flag", c_int32),
|
|
76
|
+
("ideal_line_on", c_int32),
|
|
77
|
+
("is_in_pit_lane", c_int32),
|
|
78
|
+
("surface_grip", c_float),
|
|
79
|
+
("mandatory_pit_done", c_int32),
|
|
80
|
+
("wind_speed", c_float),
|
|
81
|
+
("wind_direction", c_float),
|
|
82
|
+
("is_setup_menu_visible", c_int32),
|
|
83
|
+
("main_display_index", c_int32),
|
|
84
|
+
]
|
|
85
|
+
|
|
86
|
+
|
|
87
|
+
assert sizeof(GraphicsPage) == 304, "GraphicsPage differs from the AC ABI"
|
|
@@ -0,0 +1,149 @@
|
|
|
1
|
+
from ctypes import (
|
|
2
|
+
LittleEndianStructure,
|
|
3
|
+
sizeof,
|
|
4
|
+
c_float,
|
|
5
|
+
c_int32,
|
|
6
|
+
)
|
|
7
|
+
from collections.abc import Sequence
|
|
8
|
+
|
|
9
|
+
|
|
10
|
+
FloatArray = Sequence[float]
|
|
11
|
+
FloatMatrix = Sequence[FloatArray]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class PhysicsPage(LittleEndianStructure):
|
|
15
|
+
_layout_ = "ms"
|
|
16
|
+
_pack_ = 4
|
|
17
|
+
|
|
18
|
+
packet_id: int
|
|
19
|
+
gas: float
|
|
20
|
+
brake: float
|
|
21
|
+
fuel: float
|
|
22
|
+
gear: int
|
|
23
|
+
rpms: int
|
|
24
|
+
steer_angle: float
|
|
25
|
+
speed_kmh: float
|
|
26
|
+
velocity: FloatArray
|
|
27
|
+
acc_g: FloatArray
|
|
28
|
+
wheel_slip: FloatArray
|
|
29
|
+
wheel_load: FloatArray
|
|
30
|
+
wheels_pressure: FloatArray
|
|
31
|
+
wheel_angular_speed: FloatArray
|
|
32
|
+
tyre_wear: FloatArray
|
|
33
|
+
tyre_dirty_level: FloatArray
|
|
34
|
+
tyre_core_temperature: FloatArray
|
|
35
|
+
camber_rad: FloatArray
|
|
36
|
+
suspension_travel: FloatArray
|
|
37
|
+
drs: float
|
|
38
|
+
tc: float
|
|
39
|
+
heading: float
|
|
40
|
+
pitch: float
|
|
41
|
+
roll: float
|
|
42
|
+
cg_height: float
|
|
43
|
+
car_damage: FloatArray
|
|
44
|
+
number_of_tyres_out: int
|
|
45
|
+
pit_limiter_on: int
|
|
46
|
+
abs: float
|
|
47
|
+
kers_charge: float
|
|
48
|
+
kers_input: float
|
|
49
|
+
auto_shifter_on: int
|
|
50
|
+
ride_height: FloatArray
|
|
51
|
+
turbo_boost: float
|
|
52
|
+
ballast: float
|
|
53
|
+
air_density: float
|
|
54
|
+
air_temp: float
|
|
55
|
+
road_temp: float
|
|
56
|
+
local_angular_vel: FloatArray
|
|
57
|
+
final_ff: float
|
|
58
|
+
performance_meter: float
|
|
59
|
+
engine_brake: int
|
|
60
|
+
ers_recovery_level: int
|
|
61
|
+
ers_power_level: int
|
|
62
|
+
ers_heat_charging: int
|
|
63
|
+
ers_is_charging: int
|
|
64
|
+
kers_current_kj: float
|
|
65
|
+
drs_available: int
|
|
66
|
+
drs_enabled: int
|
|
67
|
+
brake_temp: FloatArray
|
|
68
|
+
clutch: float
|
|
69
|
+
tyre_temp_i: FloatArray
|
|
70
|
+
tyre_temp_m: FloatArray
|
|
71
|
+
tyre_temp_o: FloatArray
|
|
72
|
+
is_ai_controlled: int
|
|
73
|
+
tyre_contact_point: FloatMatrix
|
|
74
|
+
tyre_contact_normal: FloatMatrix
|
|
75
|
+
tyre_contact_heading: FloatMatrix
|
|
76
|
+
brake_bias: float
|
|
77
|
+
local_velocity: FloatArray
|
|
78
|
+
p2p_activations: int
|
|
79
|
+
p2p_status: int
|
|
80
|
+
current_max_rpm: int
|
|
81
|
+
|
|
82
|
+
_fields_ = [
|
|
83
|
+
("packet_id", c_int32),
|
|
84
|
+
("gas", c_float),
|
|
85
|
+
("brake", c_float),
|
|
86
|
+
("fuel", c_float),
|
|
87
|
+
("gear", c_int32),
|
|
88
|
+
("rpms", c_int32),
|
|
89
|
+
("steer_angle", c_float),
|
|
90
|
+
("speed_kmh", c_float),
|
|
91
|
+
("velocity", (c_float * 3)),
|
|
92
|
+
("acc_g", (c_float * 3)),
|
|
93
|
+
("wheel_slip", (c_float * 4)),
|
|
94
|
+
("wheel_load", (c_float * 4)),
|
|
95
|
+
("wheels_pressure", (c_float * 4)),
|
|
96
|
+
("wheel_angular_speed", (c_float * 4)),
|
|
97
|
+
("tyre_wear", (c_float * 4)),
|
|
98
|
+
("tyre_dirty_level", (c_float * 4)),
|
|
99
|
+
("tyre_core_temperature", (c_float * 4)),
|
|
100
|
+
("camber_rad", (c_float * 4)),
|
|
101
|
+
("suspension_travel", (c_float * 4)),
|
|
102
|
+
("drs", c_float),
|
|
103
|
+
("tc", c_float),
|
|
104
|
+
("heading", c_float),
|
|
105
|
+
("pitch", c_float),
|
|
106
|
+
("roll", c_float),
|
|
107
|
+
("cg_height", c_float),
|
|
108
|
+
("car_damage", (c_float * 5)),
|
|
109
|
+
("number_of_tyres_out", c_int32),
|
|
110
|
+
("pit_limiter_on", c_int32),
|
|
111
|
+
("abs", c_float),
|
|
112
|
+
("kers_charge", c_float),
|
|
113
|
+
("kers_input", c_float),
|
|
114
|
+
("auto_shifter_on", c_int32),
|
|
115
|
+
("ride_height", (c_float * 2)),
|
|
116
|
+
("turbo_boost", c_float),
|
|
117
|
+
("ballast", c_float),
|
|
118
|
+
("air_density", c_float),
|
|
119
|
+
("air_temp", c_float),
|
|
120
|
+
("road_temp", c_float),
|
|
121
|
+
("local_angular_vel", (c_float * 3)),
|
|
122
|
+
("final_ff", c_float),
|
|
123
|
+
("performance_meter", c_float),
|
|
124
|
+
("engine_brake", c_int32),
|
|
125
|
+
("ers_recovery_level", c_int32),
|
|
126
|
+
("ers_power_level", c_int32),
|
|
127
|
+
("ers_heat_charging", c_int32),
|
|
128
|
+
("ers_is_charging", c_int32),
|
|
129
|
+
("kers_current_kj", c_float),
|
|
130
|
+
("drs_available", c_int32),
|
|
131
|
+
("drs_enabled", c_int32),
|
|
132
|
+
("brake_temp", (c_float * 4)),
|
|
133
|
+
("clutch", c_float),
|
|
134
|
+
("tyre_temp_i", (c_float * 4)),
|
|
135
|
+
("tyre_temp_m", (c_float * 4)),
|
|
136
|
+
("tyre_temp_o", (c_float * 4)),
|
|
137
|
+
("is_ai_controlled", c_int32),
|
|
138
|
+
("tyre_contact_point", ((c_float * 3) * 4)),
|
|
139
|
+
("tyre_contact_normal", ((c_float * 3) * 4)),
|
|
140
|
+
("tyre_contact_heading", ((c_float * 3) * 4)),
|
|
141
|
+
("brake_bias", c_float),
|
|
142
|
+
("local_velocity", (c_float * 3)),
|
|
143
|
+
("p2p_activations", c_int32),
|
|
144
|
+
("p2p_status", c_int32),
|
|
145
|
+
("current_max_rpm", c_int32),
|
|
146
|
+
]
|
|
147
|
+
|
|
148
|
+
|
|
149
|
+
assert sizeof(PhysicsPage) == 592, "PhysicsPage differs from the AC ABI"
|
|
@@ -0,0 +1,109 @@
|
|
|
1
|
+
from ctypes import (
|
|
2
|
+
LittleEndianStructure,
|
|
3
|
+
sizeof,
|
|
4
|
+
c_float,
|
|
5
|
+
c_int32,
|
|
6
|
+
c_wchar,
|
|
7
|
+
)
|
|
8
|
+
from collections.abc import Sequence
|
|
9
|
+
|
|
10
|
+
|
|
11
|
+
FloatArray = Sequence[float]
|
|
12
|
+
|
|
13
|
+
|
|
14
|
+
class StaticPage(LittleEndianStructure):
|
|
15
|
+
_layout_ = "ms"
|
|
16
|
+
_pack_ = 4
|
|
17
|
+
|
|
18
|
+
sm_version: str
|
|
19
|
+
ac_version: str
|
|
20
|
+
number_of_sessions: int
|
|
21
|
+
num_cars: int
|
|
22
|
+
car_model: str
|
|
23
|
+
track: str
|
|
24
|
+
player_name: str
|
|
25
|
+
player_surname: str
|
|
26
|
+
player_nick: str
|
|
27
|
+
sector_count: int
|
|
28
|
+
max_torque: float
|
|
29
|
+
max_power: float
|
|
30
|
+
max_rpm: int
|
|
31
|
+
max_fuel: float
|
|
32
|
+
suspension_max_travel: FloatArray
|
|
33
|
+
tyre_radius: FloatArray
|
|
34
|
+
max_turbo_boost: float
|
|
35
|
+
deprecated_1: float
|
|
36
|
+
deprecated_2: float
|
|
37
|
+
penalties_enabled: int
|
|
38
|
+
aid_fuel_rate: float
|
|
39
|
+
aid_tire_rate: float
|
|
40
|
+
aid_mechanical_damage: float
|
|
41
|
+
aid_allow_tyre_blankets: int
|
|
42
|
+
aid_stability: float
|
|
43
|
+
aid_auto_clutch: int
|
|
44
|
+
aid_auto_blip: int
|
|
45
|
+
has_drs: int
|
|
46
|
+
has_ers: int
|
|
47
|
+
has_kers: int
|
|
48
|
+
kers_max_j: float
|
|
49
|
+
engine_brake_settings_count: int
|
|
50
|
+
ers_power_controller_count: int
|
|
51
|
+
track_spline_length: float
|
|
52
|
+
track_configuration: str
|
|
53
|
+
ers_max_j: float
|
|
54
|
+
is_timed_race: int
|
|
55
|
+
has_extra_lap: int
|
|
56
|
+
car_skin: str
|
|
57
|
+
reversed_grid_positions: int
|
|
58
|
+
pit_window_start: int
|
|
59
|
+
pit_window_end: int
|
|
60
|
+
is_online: int
|
|
61
|
+
|
|
62
|
+
_fields_ = [
|
|
63
|
+
("sm_version", (c_wchar * 15)),
|
|
64
|
+
("ac_version", (c_wchar * 15)),
|
|
65
|
+
("number_of_sessions", c_int32),
|
|
66
|
+
("num_cars", c_int32),
|
|
67
|
+
("car_model", (c_wchar * 33)),
|
|
68
|
+
("track", (c_wchar * 33)),
|
|
69
|
+
("player_name", (c_wchar * 33)),
|
|
70
|
+
("player_surname", (c_wchar * 33)),
|
|
71
|
+
("player_nick", (c_wchar * 33)),
|
|
72
|
+
("sector_count", c_int32),
|
|
73
|
+
("max_torque", c_float),
|
|
74
|
+
("max_power", c_float),
|
|
75
|
+
("max_rpm", c_int32),
|
|
76
|
+
("max_fuel", c_float),
|
|
77
|
+
("suspension_max_travel", (c_float * 4)),
|
|
78
|
+
("tyre_radius", (c_float * 4)),
|
|
79
|
+
("max_turbo_boost", c_float),
|
|
80
|
+
("deprecated_1", c_float),
|
|
81
|
+
("deprecated_2", c_float),
|
|
82
|
+
("penalties_enabled", c_int32),
|
|
83
|
+
("aid_fuel_rate", c_float),
|
|
84
|
+
("aid_tire_rate", c_float),
|
|
85
|
+
("aid_mechanical_damage", c_float),
|
|
86
|
+
("aid_allow_tyre_blankets", c_int32),
|
|
87
|
+
("aid_stability", c_float),
|
|
88
|
+
("aid_auto_clutch", c_int32),
|
|
89
|
+
("aid_auto_blip", c_int32),
|
|
90
|
+
("has_drs", c_int32),
|
|
91
|
+
("has_ers", c_int32),
|
|
92
|
+
("has_kers", c_int32),
|
|
93
|
+
("kers_max_j", c_float),
|
|
94
|
+
("engine_brake_settings_count", c_int32),
|
|
95
|
+
("ers_power_controller_count", c_int32),
|
|
96
|
+
("track_spline_length", c_float),
|
|
97
|
+
("track_configuration", (c_wchar * 33)),
|
|
98
|
+
("ers_max_j", c_float),
|
|
99
|
+
("is_timed_race", c_int32),
|
|
100
|
+
("has_extra_lap", c_int32),
|
|
101
|
+
("car_skin", (c_wchar * 33)),
|
|
102
|
+
("reversed_grid_positions", c_int32),
|
|
103
|
+
("pit_window_start", c_int32),
|
|
104
|
+
("pit_window_end", c_int32),
|
|
105
|
+
("is_online", c_int32),
|
|
106
|
+
]
|
|
107
|
+
|
|
108
|
+
|
|
109
|
+
assert sizeof(StaticPage) == 688, "StaticPage differs from the AC ABI"
|
|
@@ -0,0 +1,46 @@
|
|
|
1
|
+
Metadata-Version: 2.4
|
|
2
|
+
Name: py-assettocorsa
|
|
3
|
+
Version: 0.0.1
|
|
4
|
+
Summary: Read Assetto Corsa shared memory on Windows.
|
|
5
|
+
Project-URL: Homepage, https://github.com/ooocheckitout/py-assettocorsa
|
|
6
|
+
Project-URL: Repository, https://github.com/ooocheckitout/py-assettocorsa.git
|
|
7
|
+
Project-URL: Issues, https://github.com/ooocheckitout/py-assettocorsa/issues
|
|
8
|
+
Classifier: Operating System :: Microsoft :: Windows
|
|
9
|
+
Requires-Python: >=3.9
|
|
10
|
+
Description-Content-Type: text/markdown
|
|
11
|
+
License-File: LICENSE
|
|
12
|
+
Dynamic: license-file
|
|
13
|
+
|
|
14
|
+
# py-assettocorsa
|
|
15
|
+
|
|
16
|
+
The Python library to read shared memory of Assetto Corsa Evo.
|
|
17
|
+
|
|
18
|
+
## Install
|
|
19
|
+
|
|
20
|
+
```bash
|
|
21
|
+
pip install py-assettocorsa
|
|
22
|
+
```
|
|
23
|
+
|
|
24
|
+
## Example
|
|
25
|
+
|
|
26
|
+
```python
|
|
27
|
+
from acevo import ACEvoSharedMemory
|
|
28
|
+
|
|
29
|
+
try:
|
|
30
|
+
with ACEvoSharedMemory() as memory:
|
|
31
|
+
static, physics, graphics = memory.read_snapshot()
|
|
32
|
+
print(static.session_name, static.track)
|
|
33
|
+
print(physics.speed_kmh, physics.gas, physics.brake)
|
|
34
|
+
print(graphics.current_lap_time_ms, graphics.car_coordinates)
|
|
35
|
+
except FileNotFoundError as error:
|
|
36
|
+
print("The AC Evo shared memory is unavailable. Start a driving session.")
|
|
37
|
+
```
|
|
38
|
+
|
|
39
|
+
## Available Models
|
|
40
|
+
|
|
41
|
+
| Model | Description |
|
|
42
|
+
| --- | --- |
|
|
43
|
+
| [Static](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/static.py) | Session, track, and game information. |
|
|
44
|
+
| [Physics](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/physics.py) | Speed, controls, engine, and wheel telemetry. |
|
|
45
|
+
| [Graphics](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/graphics.py) | Timing, positions, tyres, damage, and pit information. |
|
|
46
|
+
| [Enums](https://github.com/ooocheckitout/py-assettocorsa/blob/main/acevo/models/enums.py) | Named status, session, and flag values. |
|
|
@@ -0,0 +1,15 @@
|
|
|
1
|
+
LICENSE
|
|
2
|
+
README.MD
|
|
3
|
+
VERSION
|
|
4
|
+
pyproject.toml
|
|
5
|
+
ac/__init__.py
|
|
6
|
+
ac/memory.py
|
|
7
|
+
ac/models/__init__.py
|
|
8
|
+
ac/models/enums.py
|
|
9
|
+
ac/models/graphics.py
|
|
10
|
+
ac/models/physics.py
|
|
11
|
+
ac/models/static.py
|
|
12
|
+
py_assettocorsa.egg-info/PKG-INFO
|
|
13
|
+
py_assettocorsa.egg-info/SOURCES.txt
|
|
14
|
+
py_assettocorsa.egg-info/dependency_links.txt
|
|
15
|
+
py_assettocorsa.egg-info/top_level.txt
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
|
|
@@ -0,0 +1 @@
|
|
|
1
|
+
ac
|
|
@@ -0,0 +1,25 @@
|
|
|
1
|
+
[build-system]
|
|
2
|
+
requires = ["setuptools >= 77.0.3"]
|
|
3
|
+
build-backend = "setuptools.build_meta"
|
|
4
|
+
|
|
5
|
+
[project]
|
|
6
|
+
name = "py-assettocorsa"
|
|
7
|
+
dynamic = ["version"]
|
|
8
|
+
description = "Read Assetto Corsa shared memory on Windows."
|
|
9
|
+
readme = "README.MD"
|
|
10
|
+
requires-python = ">= 3.9"
|
|
11
|
+
classifiers = ["Operating System :: Microsoft :: Windows"]
|
|
12
|
+
|
|
13
|
+
[dependency-groups]
|
|
14
|
+
dev = ["build", "twine"]
|
|
15
|
+
|
|
16
|
+
[tool.setuptools.packages.find]
|
|
17
|
+
include = ["ac*"]
|
|
18
|
+
|
|
19
|
+
[tool.setuptools.dynamic]
|
|
20
|
+
version = { file = ["VERSION"] }
|
|
21
|
+
|
|
22
|
+
[project.urls]
|
|
23
|
+
Homepage = "https://github.com/ooocheckitout/py-assettocorsa"
|
|
24
|
+
Repository = "https://github.com/ooocheckitout/py-assettocorsa.git"
|
|
25
|
+
Issues = "https://github.com/ooocheckitout/py-assettocorsa/issues"
|