Rigs of Rods 2023.09
Soft-body Physics Simulation
All Data Structures Namespaces Files Functions Variables Typedefs Enumerations Enumerator Friends Macros Modules Pages
Loading...
Searching...
No Matches
OutGauge.h
Go to the documentation of this file.
1/*
2 This source file is part of Rigs of Rods
3 Copyright 2005-2012 Pierre-Michel Ricordel
4 Copyright 2007-2012 Thomas Fischer
5
6 For more information, see http://www.rigsofrods.org/
7
8 Rigs of Rods is free software: you can redistribute it and/or modify
9 it under the terms of the GNU General Public License version 3, as
10 published by the Free Software Foundation.
11
12 Rigs of Rods is distributed in the hope that it will be useful,
13 but WITHOUT ANY WARRANTY; without even the implied warranty of
14 MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
15 GNU General Public License for more details.
16
17 You should have received a copy of the GNU General Public License
18 along with Rigs of Rods. If not, see <http://www.gnu.org/licenses/>.
19*/
20
24
25#pragma once
26
27#include "Application.h"
28
29#ifdef USE_SOCKETW
30#include "SocketW.h"
31#endif //USE_SOCKETW
32
33#ifdef _WIN32
34#include <Ws2tcpip.h>
35#define PACK( __Declaration__ ) __pragma( pack(push, 1) ) __Declaration__ __pragma( pack(pop) )
36#else
37#define PACK( __Declaration__ ) __Declaration__ __attribute__((__packed__))
38#endif // _WIN32
39
40namespace RoR {
41
44
46{
47public:
48
49 OutGauge(void);
50
51 void Connect();
52 bool Update(float dt, ActorPtr truck);
53 void Close();
54
55private:
56
57 bool working;
58 float timer;
59 int sockfd;
60
61
62
63 // from LFS/doc/insim.txt
64 enum
65 {
66 OG_SHIFT = 1, // key
67 OG_CTRL = 2, // key
68 OG_TURBO = 8192, // show turbo gauge
69 OG_KM = 16384, // if not set - user prefers MILES
70 OG_BAR = 32768, // if not set - user prefers PSI
71 };
72
73 enum
74 {
75 DL_SHIFT = BITMASK(1), // bit 0 - shift light
76 DL_FULLBEAM = BITMASK(2), // bit 1 - full beam
77 DL_HANDBRAKE = BITMASK(3), // bit 2 - handbrake
78 DL_PITSPEED = BITMASK(4), // bit 3 - pit speed limiter
79 DL_TC = BITMASK(5), // bit 4 - TC active or switched off
80 DL_SIGNAL_L = BITMASK(6), // bit 5 - left turn signal
81 DL_SIGNAL_R = BITMASK(7), // bit 6 - right turn signal
82 DL_SIGNAL_ANY = BITMASK(8), // bit 7 - shared turn signal
83 DL_OILWARN = BITMASK(9), // bit 8 - oil pressure warning
84 DL_BATTERY = BITMASK(10), // bit 9 - battery warning
85 DL_ABS = BITMASK(11), // bit 10 - ABS active or switched off
86 DL_SPARE = BITMASK(12), // bit 11
87 DL_NUM = BITMASK(13) // bit 14 - end
88 };
89
90 PACK (struct OutGaugePack
91 {
92 unsigned int Time; // time in milliseconds (to check order)
93 char Car[4]; // Car name
94 unsigned short Flags; // Info (see OG_x below)
95 unsigned char Gear; // Reverse:0, Neutral:1, First:2...
96 unsigned char PLID; // Unique ID of viewed player (0 = none)
97 float Speed; // M/S
98 float RPM; // RPM
99 float Turbo; // BAR
100 float EngTemp; // C
101 float Fuel; // 0 to 1
102 float OilPressure; // BAR
103 float OilTemp; // C
104 unsigned int DashLights; // Dash lights available (see DL_x below)
105 unsigned int ShowLights; // Dash lights currently switched on
106 float Throttle; // 0 to 1
107 float Brake; // 0 to 1
108 float Clutch; // 0 to 1
109 char Display1[16]; // Usually Fuel
110 char Display2[16]; // Usually Settings
111 int ID; // optional - only if OutGauge ID is specified
112 });
113};
114
116
117} // namespace RoR
118
Central state/object manager and communications hub.
#define BITMASK(OFFSET)
Definition BitFlags.h:10
void Connect()
Definition OutGauge.cpp:58
PACK(struct OutGaugePack { unsigned int Time;char Car[4];unsigned short Flags;unsigned char Gear;unsigned char PLID;float Speed;float RPM;float Turbo;float EngTemp;float Fuel;float OilPressure;float OilTemp;unsigned int DashLights;unsigned int ShowLights;float Throttle;float Brake;float Clutch;char Display1[16];char Display2[16];int ID;})
bool Update(float dt, ActorPtr truck)
Definition OutGauge.cpp:103
float timer
Definition OutGauge.h:58