@@ -298,6 +298,8 @@ pub enum EventType {
298
298
ControllerDeviceAdded = SDL_EventType :: SDL_CONTROLLERDEVICEADDED as u32 ,
299
299
ControllerDeviceRemoved = SDL_EventType :: SDL_CONTROLLERDEVICEREMOVED as u32 ,
300
300
ControllerDeviceRemapped = SDL_EventType :: SDL_CONTROLLERDEVICEREMAPPED as u32 ,
301
+ #[ cfg( feature = "hidapi" ) ]
302
+ ControllerSensorUpdated = SDL_EventType :: SDL_CONTROLLERSENSORUPDATE as u32 ,
301
303
302
304
FingerDown = SDL_EventType :: SDL_FINGERDOWN as u32 ,
303
305
FingerUp = SDL_EventType :: SDL_FINGERUP as u32 ,
@@ -366,6 +368,8 @@ impl TryFrom<u32> for EventType {
366
368
SDL_CONTROLLERDEVICEADDED => ControllerDeviceAdded ,
367
369
SDL_CONTROLLERDEVICEREMOVED => ControllerDeviceRemoved ,
368
370
SDL_CONTROLLERDEVICEREMAPPED => ControllerDeviceRemapped ,
371
+ #[ cfg( feature = "hidapi" ) ]
372
+ SDL_CONTROLLERSENSORUPDATE => ControllerSensorUpdated ,
369
373
370
374
SDL_FINGERDOWN => FingerDown ,
371
375
SDL_FINGERUP => FingerUp ,
@@ -674,6 +678,18 @@ pub enum Event {
674
678
which : u32 ,
675
679
} ,
676
680
681
+ /// Triggered when the gyroscope or accelerometer is updated
682
+ #[ cfg( feature = "hidapi" ) ]
683
+ ControllerSensorUpdated {
684
+ timestamp : u32 ,
685
+ which : u32 ,
686
+ sensor : crate :: sensor:: SensorType ,
687
+ /// Data from the sensor.
688
+ ///
689
+ /// See the `sensor` module for more information.
690
+ data : [ f32 ; 3 ] ,
691
+ } ,
692
+
677
693
FingerDown {
678
694
timestamp : u32 ,
679
695
touch_id : i64 ,
@@ -1612,6 +1628,16 @@ impl Event {
1612
1628
which : event. which as u32 ,
1613
1629
}
1614
1630
}
1631
+ #[ cfg( feature = "hidapi" ) ]
1632
+ EventType :: ControllerSensorUpdated => {
1633
+ let event = raw. csensor ;
1634
+ Event :: ControllerSensorUpdated {
1635
+ timestamp : event. timestamp ,
1636
+ which : event. which as u32 ,
1637
+ sensor : crate :: sensor:: SensorType :: from_ll ( event. sensor ) ,
1638
+ data : event. data ,
1639
+ }
1640
+ }
1615
1641
1616
1642
EventType :: FingerDown => {
1617
1643
let event = raw. tfinger ;
@@ -1898,6 +1924,8 @@ impl Event {
1898
1924
| ( Self :: RenderDeviceReset { .. } , Self :: RenderDeviceReset { .. } )
1899
1925
| ( Self :: User { .. } , Self :: User { .. } )
1900
1926
| ( Self :: Unknown { .. } , Self :: Unknown { .. } ) => true ,
1927
+ #[ cfg( feature = "hidapi" ) ]
1928
+ ( Self :: ControllerSensorUpdated { .. } , Self :: ControllerSensorUpdated { .. } ) => true ,
1901
1929
_ => false ,
1902
1930
}
1903
1931
}
@@ -1947,6 +1975,8 @@ impl Event {
1947
1975
Self :: ControllerDeviceAdded { timestamp, .. } => timestamp,
1948
1976
Self :: ControllerDeviceRemoved { timestamp, .. } => timestamp,
1949
1977
Self :: ControllerDeviceRemapped { timestamp, .. } => timestamp,
1978
+ #[ cfg( feature = "hidapi" ) ]
1979
+ Self :: ControllerSensorUpdated { timestamp, .. } => timestamp,
1950
1980
Self :: FingerDown { timestamp, .. } => timestamp,
1951
1981
Self :: FingerUp { timestamp, .. } => timestamp,
1952
1982
Self :: FingerMotion { timestamp, .. } => timestamp,
0 commit comments