Skip to content

Commit

Permalink
clipboard, filesystem, gamepad
Browse files Browse the repository at this point in the history
  • Loading branch information
revmischa committed Oct 15, 2024
1 parent 0bd2ad6 commit b02321c
Show file tree
Hide file tree
Showing 3 changed files with 160 additions and 180 deletions.
10 changes: 5 additions & 5 deletions src/sdl3/clipboard.rs
Original file line number Diff line number Diff line change
Expand Up @@ -33,9 +33,9 @@ impl ClipboardUtil {
pub fn set_clipboard_text(&self, text: &str) -> Result<(), String> {
unsafe {
let text = CString::new(text).unwrap();
let result = sys::SDL_SetClipboardText(text.as_ptr() as *const c_char);
let result = sys::clipboard::SDL_SetClipboardText(text.as_ptr() as *const c_char);

if result != 0 {
if result {
Err(get_error())
} else {
Ok(())
Expand All @@ -46,20 +46,20 @@ impl ClipboardUtil {
#[doc(alias = "SDL_GetClipboardText")]
pub fn clipboard_text(&self) -> Result<String, String> {
unsafe {
let buf = sys::SDL_GetClipboardText();
let buf = sys::clipboard::SDL_GetClipboardText();

if buf.is_null() {
Err(get_error())
} else {
let s = CStr::from_ptr(buf as *const _).to_str().unwrap().to_owned();
sys::SDL_free(buf as *mut c_void);
sys::stdinc::SDL_free(buf as *mut c_void);
Ok(s)
}
}
}

#[doc(alias = "SDL_HasClipboardText")]
pub fn has_clipboard_text(&self) -> bool {
unsafe { sys::SDL_HasClipboardText() == sys::SDL_bool::SDL_TRUE }
unsafe { sys::clipboard::SDL_HasClipboardText() == true }
}
}
6 changes: 3 additions & 3 deletions src/sdl3/filesystem.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,9 +10,9 @@ use crate::sys;
#[doc(alias = "SDL_GetBasePath")]
pub fn base_path() -> Result<String, String> {
let result = unsafe {
let buf = sys::SDL_GetBasePath();
let buf = sys::filesystem::SDL_GetBasePath();
let s = CStr::from_ptr(buf as *const _).to_str().unwrap().to_owned();
sys::SDL_free(buf as *mut c_void);
sys::stdinc::SDL_free(buf as *mut c_void);
s
};

Expand Down Expand Up @@ -70,7 +70,7 @@ pub fn pref_path(org_name: &str, app_name: &str) -> Result<String, PrefPathError
Err(err) => return Err(InvalidApplicationName(err)),
};
let buf =
sys::SDL_GetPrefPath(org.as_ptr() as *const c_char, app.as_ptr() as *const c_char);
sys::filesystem::SDL_GetPrefPath(org.as_ptr() as *const c_char, app.as_ptr() as *const c_char);
CStr::from_ptr(buf as *const _).to_str().unwrap().to_owned()
};

Expand Down
Loading

0 comments on commit b02321c

Please sign in to comment.