@@ -69,14 +69,22 @@ impl SensorSubsystem {
69
69
pub enum SensorType {
70
70
Unknown ,
71
71
Gyroscope ,
72
+ LeftGyroscope ,
73
+ RightGyroscope ,
72
74
Accelerometer ,
75
+ LeftAccelerometer ,
76
+ RightAccelerometer ,
73
77
}
74
78
75
79
impl SensorType {
76
80
pub fn from_ll ( raw : i32 ) -> Self {
77
81
match raw {
78
82
x if x == SDL_SensorType :: SDL_SENSOR_GYRO as i32 => SensorType :: Gyroscope ,
83
+ x if x == SDL_SensorType :: SDL_SENSOR_GYRO_L as i32 => SensorType :: LeftGyroscope ,
84
+ x if x == SDL_SensorType :: SDL_SENSOR_GYRO_R as i32 => SensorType :: RightGyroscope ,
79
85
x if x == SDL_SensorType :: SDL_SENSOR_ACCEL as i32 => SensorType :: Accelerometer ,
86
+ x if x == SDL_SensorType :: SDL_SENSOR_ACCEL_L as i32 => SensorType :: LeftAccelerometer ,
87
+ x if x == SDL_SensorType :: SDL_SENSOR_ACCEL_R as i32 => SensorType :: RightAccelerometer ,
80
88
_ => SensorType :: Unknown ,
81
89
}
82
90
}
@@ -87,7 +95,11 @@ impl From<SensorType> for SDL_SensorType {
87
95
match val {
88
96
SensorType :: Unknown => SDL_SensorType :: SDL_SENSOR_UNKNOWN ,
89
97
SensorType :: Gyroscope => SDL_SensorType :: SDL_SENSOR_GYRO ,
98
+ SensorType :: LeftGyroscope => SDL_SensorType :: SDL_SENSOR_GYRO_L ,
99
+ SensorType :: RightGyroscope => SDL_SensorType :: SDL_SENSOR_GYRO_R ,
90
100
SensorType :: Accelerometer => SDL_SensorType :: SDL_SENSOR_ACCEL ,
101
+ SensorType :: LeftAccelerometer => SDL_SensorType :: SDL_SENSOR_ACCEL_L ,
102
+ SensorType :: RightAccelerometer => SDL_SensorType :: SDL_SENSOR_ACCEL_R ,
91
103
}
92
104
}
93
105
}
@@ -136,7 +148,11 @@ impl Sensor {
136
148
}
137
149
sys:: SDL_SensorType :: SDL_SENSOR_UNKNOWN => SensorType :: Unknown ,
138
150
sys:: SDL_SensorType :: SDL_SENSOR_ACCEL => SensorType :: Accelerometer ,
151
+ sys:: SDL_SensorType :: SDL_SENSOR_ACCEL_L => SensorType :: LeftAccelerometer ,
152
+ sys:: SDL_SensorType :: SDL_SENSOR_ACCEL_R => SensorType :: RightAccelerometer ,
139
153
sys:: SDL_SensorType :: SDL_SENSOR_GYRO => SensorType :: Gyroscope ,
154
+ sys:: SDL_SensorType :: SDL_SENSOR_GYRO_L => SensorType :: LeftGyroscope ,
155
+ sys:: SDL_SensorType :: SDL_SENSOR_GYRO_R => SensorType :: RightGyroscope ,
140
156
}
141
157
}
142
158
@@ -153,7 +169,11 @@ impl Sensor {
153
169
} else {
154
170
Ok ( match self . sensor_type ( ) {
155
171
SensorType :: Gyroscope => SensorData :: Gyro ( [ data[ 0 ] , data[ 1 ] , data[ 2 ] ] ) ,
172
+ SensorType :: LeftGyroscope => SensorData :: Gyro ( [ data[ 0 ] , data[ 1 ] , data[ 2 ] ] ) ,
173
+ SensorType :: RightGyroscope => SensorData :: Gyro ( [ data[ 0 ] , data[ 1 ] , data[ 2 ] ] ) ,
156
174
SensorType :: Accelerometer => SensorData :: Accel ( [ data[ 0 ] , data[ 1 ] , data[ 2 ] ] ) ,
175
+ SensorType :: LeftAccelerometer => SensorData :: Accel ( [ data[ 0 ] , data[ 1 ] , data[ 2 ] ] ) ,
176
+ SensorType :: RightAccelerometer => SensorData :: Accel ( [ data[ 0 ] , data[ 1 ] , data[ 2 ] ] ) ,
157
177
SensorType :: Unknown => SensorData :: Unknown ( data) ,
158
178
} )
159
179
}
0 commit comments