Skip to content

Commit 086a881

Browse files
Implement SDL_JoystickSendEffect and SDL_GameControllerSendEffect
1 parent c028a67 commit 086a881

File tree

2 files changed

+36
-0
lines changed

2 files changed

+36
-0
lines changed

src/sdl2/controller.rs

+18
Original file line numberDiff line numberDiff line change
@@ -571,6 +571,24 @@ impl GameController {
571571
Ok(())
572572
}
573573
}
574+
575+
/// Send a controller specific effect packet.
576+
#[doc(alias = "SDL_GameControllerSendEffect")]
577+
pub fn send_effect(&mut self, data: &[u8]) -> Result<(), IntegerOrSdlError> {
578+
let result = unsafe {
579+
sys::SDL_GameControllerSendEffect(
580+
self.raw,
581+
data.as_ptr() as *const libc::c_void,
582+
data.len() as i32,
583+
)
584+
};
585+
586+
if result != 0 {
587+
Err(IntegerOrSdlError::SdlError(get_error()))
588+
} else {
589+
Ok(())
590+
}
591+
}
574592
}
575593

576594
#[cfg(feature = "hidapi")]

src/sdl2/joystick.rs

+18
Original file line numberDiff line numberDiff line change
@@ -464,6 +464,24 @@ impl Joystick {
464464
Ok(())
465465
}
466466
}
467+
468+
/// Send a joystick specific effect packet.
469+
#[doc(alias = "SDL_JoystickSendEffect")]
470+
pub fn send_effect(&mut self, data: &[u8]) -> Result<(), IntegerOrSdlError> {
471+
let result = unsafe {
472+
sys::SDL_JoystickSendEffect(
473+
self.raw,
474+
data.as_ptr() as *const libc::c_void,
475+
data.len() as i32,
476+
)
477+
};
478+
479+
if result != 0 {
480+
Err(IntegerOrSdlError::SdlError(get_error()))
481+
} else {
482+
Ok(())
483+
}
484+
}
467485
}
468486

469487
impl Drop for Joystick {

0 commit comments

Comments
 (0)