Browse Source

Update bindings for libctru v1.4.0

pull/10/head
Fenrir 7 years ago committed by FenrirWolf
parent
commit
9f5d769afa
  1. 7
      ctr-std/src/panicking.rs
  2. 29
      ctr-std/src/sys/unix/condvar.rs
  3. 4
      ctru-rs/src/console.rs
  4. 26
      ctru-rs/src/gfx.rs
  5. 57
      ctru-rs/src/services/fs.rs
  6. 38
      ctru-rs/src/services/gspgpu.rs
  7. 9033
      ctru-sys/src/bindings.rs

7
ctr-std/src/panicking.rs

@ -431,8 +431,7 @@ fn default_hook(info: &PanicInfo) {
// 3DS-specific code begins here // 3DS-specific code begins here
use libctru::{errorInit, errorText, errorDisp, use libctru::{errorInit, errorText, errorDisp, errorConf};
errorConf, errorType, CFG_Language};
use libc; use libc;
let thread = thread_info::current_thread(); let thread = thread_info::current_thread();
@ -447,8 +446,8 @@ fn default_hook(info: &PanicInfo) {
let mut error_conf: errorConf = mem::uninitialized(); let mut error_conf: errorConf = mem::uninitialized();
errorInit(&mut error_conf, errorInit(&mut error_conf,
errorType::ERROR_TEXT_WORD_WRAP, ::libctru::ERROR_TEXT_WORD_WRAP,
CFG_Language::CFG_LANGUAGE_EN); ::libctru::CFG_LANGUAGE_EN);
errorText(&mut error_conf, error_text.as_ptr() as *const libc::c_char); errorText(&mut error_conf, error_text.as_ptr() as *const libc::c_char);
// Display error // Display error

29
ctr-std/src/sys/unix/condvar.rs

@ -17,11 +17,8 @@ use time::Duration;
use sys::mutex::{self, Mutex}; use sys::mutex::{self, Mutex};
use libctru::{__sync_get_arbiter, LightLock};
use libctru::{svcArbitrateAddress, ArbitrationType};
pub struct Condvar { pub struct Condvar {
lock: UnsafeCell<*mut LightLock>, lock: UnsafeCell<*mut ::libctru::LightLock>,
} }
unsafe impl Send for Condvar {} unsafe impl Send for Condvar {}
@ -42,11 +39,11 @@ impl Condvar {
#[inline] #[inline]
pub fn notify_one(&self) { pub fn notify_one(&self) {
unsafe { unsafe {
let arbiter = __sync_get_arbiter(); let arbiter = ::libctru::__sync_get_arbiter();
svcArbitrateAddress(arbiter, ::libctru::svcArbitrateAddress(arbiter,
*self.lock.get() as u32, *self.lock.get() as u32,
ArbitrationType::ARBITRATION_SIGNAL, ::libctru::ARBITRATION_SIGNAL,
1, 1,
0); 0);
} }
@ -61,11 +58,11 @@ impl Condvar {
return; return;
} }
let arbiter = __sync_get_arbiter(); let arbiter = ::libctru::__sync_get_arbiter();
svcArbitrateAddress(arbiter, ::libctru::svcArbitrateAddress(arbiter,
*self.lock.get() as u32, *self.lock.get() as u32,
ArbitrationType::ARBITRATION_SIGNAL, ::libctru::ARBITRATION_SIGNAL,
-1, -1,
0); 0);
} }
@ -86,11 +83,11 @@ impl Condvar {
mutex.unlock(); mutex.unlock();
let arbiter = __sync_get_arbiter(); let arbiter = ::libctru::__sync_get_arbiter();
svcArbitrateAddress(arbiter, ::libctru::svcArbitrateAddress(arbiter,
*self.lock.get() as u32, *self.lock.get() as u32,
ArbitrationType::ARBITRATION_WAIT_IF_LESS_THAN, ::libctru::ARBITRATION_WAIT_IF_LESS_THAN,
2, 2,
0); 0);
@ -119,11 +116,11 @@ impl Condvar {
mutex.unlock(); mutex.unlock();
let arbiter = __sync_get_arbiter(); let arbiter = ::libctru::__sync_get_arbiter();
svcArbitrateAddress(arbiter, ::libctru::svcArbitrateAddress(arbiter,
*self.lock.get() as u32, *self.lock.get() as u32,
ArbitrationType::ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT, ::libctru::ARBITRATION_WAIT_IF_LESS_THAN_TIMEOUT,
2, 2,
nanos as i64); nanos as i64);

4
ctru-rs/src/console.rs

@ -10,8 +10,8 @@ pub struct Console {
impl Console { impl Console {
pub fn init(screen: Screen) -> Self { pub fn init(screen: Screen) -> Self {
unsafe { unsafe {
let ret = *(::libctru::consoleInit(screen.into(), ptr::null_mut())); let context = ptr::read(::libctru::consoleInit(screen.into(), ptr::null_mut()));
Console { context: ret } Console { context, }
} }
} }

26
ctru-rs/src/gfx.rs

@ -18,49 +18,43 @@ pub enum Side {
} }
impl From<::libctru::gfxScreen_t> for Screen { impl From<::libctru::gfxScreen_t> for Screen {
#[inline]
fn from(g: ::libctru::gfxScreen_t) -> Screen { fn from(g: ::libctru::gfxScreen_t) -> Screen {
use ::libctru::gfxScreen_t::*;
use self::Screen::*; use self::Screen::*;
match g { match g {
GFX_TOP => Top, ::libctru::GFX_TOP => Top,
GFX_BOTTOM => Bottom, ::libctru::GFX_BOTTOM => Bottom,
_ => unreachable!(),
} }
} }
} }
impl From<Screen> for ::libctru::gfxScreen_t { impl From<Screen> for ::libctru::gfxScreen_t {
#[inline]
fn from(g: Screen) -> ::libctru::gfxScreen_t { fn from(g: Screen) -> ::libctru::gfxScreen_t {
use ::libctru::gfxScreen_t::*;
use self::Screen::*; use self::Screen::*;
match g { match g {
Top => GFX_TOP, Top => ::libctru::GFX_TOP,
Bottom => GFX_BOTTOM, Bottom => ::libctru::GFX_BOTTOM,
} }
} }
} }
impl From<::libctru::gfx3dSide_t> for Side { impl From<::libctru::gfx3dSide_t> for Side {
#[inline]
fn from(s: ::libctru::gfx3dSide_t) -> Side { fn from(s: ::libctru::gfx3dSide_t) -> Side {
use ::libctru::gfx3dSide_t::*;
use self::Side::*; use self::Side::*;
match s { match s {
GFX_LEFT => Left, ::libctru::GFX_LEFT => Left,
GFX_RIGHT => Right, ::libctru::GFX_RIGHT => Right,
_ => unreachable!(),
} }
} }
} }
impl From<Side> for ::libctru::gfx3dSide_t { impl From<Side> for ::libctru::gfx3dSide_t {
#[inline]
fn from(s: Side) -> ::libctru::gfx3dSide_t { fn from(s: Side) -> ::libctru::gfx3dSide_t {
use ::libctru::gfx3dSide_t::*;
use self::Side::*; use self::Side::*;
match s { match s {
Left => GFX_LEFT, Left => ::libctru::GFX_LEFT,
Right => GFX_RIGHT, Right => ::libctru::GFX_RIGHT,
} }
} }
} }

57
ctru-rs/src/services/fs.rs

@ -980,13 +980,12 @@ impl Drop for Dir {
impl From<PathType> for ::libctru::FS_PathType { impl From<PathType> for ::libctru::FS_PathType {
fn from(p: PathType) -> Self { fn from(p: PathType) -> Self {
use self::PathType::*; use self::PathType::*;
use ::libctru::FS_PathType::*;
match p { match p {
Invalid => PATH_INVALID, Invalid => ::libctru::PATH_INVALID,
Empty => PATH_EMPTY, Empty => ::libctru::PATH_EMPTY,
Binary => PATH_BINARY, Binary => ::libctru::PATH_BINARY,
ASCII => PATH_ASCII, ASCII => ::libctru::PATH_ASCII,
UTF16 => PATH_UTF16, UTF16 => ::libctru::PATH_UTF16,
} }
} }
} }
@ -994,31 +993,29 @@ impl From<PathType> for ::libctru::FS_PathType {
impl From<ArchiveID> for ::libctru::FS_ArchiveID { impl From<ArchiveID> for ::libctru::FS_ArchiveID {
fn from(a: ArchiveID) -> Self { fn from(a: ArchiveID) -> Self {
use self::ArchiveID::*; use self::ArchiveID::*;
use ::libctru::FS_ArchiveID::*;
match a { match a {
RomFS => ARCHIVE_ROMFS, RomFS => ::libctru::ARCHIVE_ROMFS,
Savedata => ARCHIVE_SAVEDATA, Savedata => ::libctru::ARCHIVE_SAVEDATA,
Extdata => ARCHIVE_EXTDATA, Extdata => ::libctru::ARCHIVE_EXTDATA,
SharedExtdata => ARCHIVE_SHARED_EXTDATA, SharedExtdata => ::libctru::ARCHIVE_SHARED_EXTDATA,
SystemSavedata => ARCHIVE_SYSTEM_SAVEDATA, SystemSavedata => ::libctru::ARCHIVE_SYSTEM_SAVEDATA,
Sdmc => ARCHIVE_SDMC, Sdmc => ::libctru::ARCHIVE_SDMC,
SdmcWriteOnly => ARCHIVE_SDMC_WRITE_ONLY, SdmcWriteOnly => ::libctru::ARCHIVE_SDMC_WRITE_ONLY,
BossExtdata => ARCHIVE_BOSS_EXTDATA, BossExtdata => ::libctru::ARCHIVE_BOSS_EXTDATA,
CardSpiFS => ARCHIVE_CARD_SPIFS, CardSpiFS => ::libctru::ARCHIVE_CARD_SPIFS,
ExtDataAndBossExtdata => ARCHIVE_EXTDATA_AND_BOSS_EXTDATA, ExtDataAndBossExtdata => ::libctru::ARCHIVE_EXTDATA_AND_BOSS_EXTDATA,
SystemSaveData2 => ARCHIVE_SYSTEM_SAVEDATA2, SystemSaveData2 => ::libctru::ARCHIVE_SYSTEM_SAVEDATA2,
NandRW => ARCHIVE_NAND_RW, NandRW => ::libctru::ARCHIVE_NAND_RW,
NandRO => ARCHIVE_NAND_RO, NandRO => ::libctru::ARCHIVE_NAND_RO,
NandROWriteAccess => ARCHIVE_NAND_RO_WRITE_ACCESS, NandROWriteAccess => ::libctru::ARCHIVE_NAND_RO_WRITE_ACCESS,
SaveDataAndContent => ARCHIVE_SAVEDATA_AND_CONTENT, SaveDataAndContent => ::libctru::ARCHIVE_SAVEDATA_AND_CONTENT,
SaveDataAndContent2 => ARCHIVE_SAVEDATA_AND_CONTENT2, SaveDataAndContent2 => ::libctru::ARCHIVE_SAVEDATA_AND_CONTENT2,
NandCtrFS => ARCHIVE_NAND_CTR_FS, NandCtrFS => ::libctru::ARCHIVE_NAND_CTR_FS,
TwlPhoto => ARCHIVE_TWL_PHOTO, TwlPhoto => ::libctru::ARCHIVE_TWL_PHOTO,
NandTwlFS => ARCHIVE_NAND_TWL_FS, NandTwlFS => ::libctru::ARCHIVE_NAND_TWL_FS,
GameCardSavedata => ARCHIVE_GAMECARD_SAVEDATA, GameCardSavedata => ::libctru::ARCHIVE_GAMECARD_SAVEDATA,
UserSavedata => ARCHIVE_USER_SAVEDATA, UserSavedata => ::libctru::ARCHIVE_USER_SAVEDATA,
DemoSavedata => ARCHIVE_DEMO_SAVEDATA, DemoSavedata => ::libctru::ARCHIVE_DEMO_SAVEDATA,
} }
} }
} }

38
ctru-rs/src/services/gspgpu.rs

@ -35,14 +35,14 @@ impl FramebufferFormat {
impl From<::libctru::GSPGPU_FramebufferFormats> for FramebufferFormat { impl From<::libctru::GSPGPU_FramebufferFormats> for FramebufferFormat {
#[inline] #[inline]
fn from(g: ::libctru::GSPGPU_FramebufferFormats) -> FramebufferFormat { fn from(g: ::libctru::GSPGPU_FramebufferFormats) -> FramebufferFormat {
use ::libctru::GSPGPU_FramebufferFormats::*;
use self::FramebufferFormat::*; use self::FramebufferFormat::*;
match g { match g {
GSP_RGBA8_OES => Rgba8, ::libctru::GSP_RGBA8_OES => Rgba8,
GSP_BGR8_OES => Bgr8, ::libctru::GSP_BGR8_OES => Bgr8,
GSP_RGB565_OES => Rgb565, ::libctru::GSP_RGB565_OES => Rgb565,
GSP_RGB5_A1_OES => Rgb5A1, ::libctru::GSP_RGB5_A1_OES => Rgb5A1,
GSP_RGBA4_OES => Rgba4, ::libctru::GSP_RGBA4_OES => Rgba4,
_ => unreachable!(),
} }
} }
} }
@ -50,30 +50,28 @@ impl From<::libctru::GSPGPU_FramebufferFormats> for FramebufferFormat {
impl From<FramebufferFormat> for ::libctru::GSPGPU_FramebufferFormats { impl From<FramebufferFormat> for ::libctru::GSPGPU_FramebufferFormats {
#[inline] #[inline]
fn from(g: FramebufferFormat) -> ::libctru::GSPGPU_FramebufferFormats { fn from(g: FramebufferFormat) -> ::libctru::GSPGPU_FramebufferFormats {
use ::libctru::GSPGPU_FramebufferFormats::*;
use self::FramebufferFormat::*; use self::FramebufferFormat::*;
match g { match g {
Rgba8 => GSP_RGBA8_OES, Rgba8 => ::libctru::GSP_RGBA8_OES,
Bgr8 => GSP_BGR8_OES, Bgr8 => ::libctru::GSP_BGR8_OES,
Rgb565 => GSP_RGB565_OES, Rgb565 => ::libctru::GSP_RGB565_OES,
Rgb5A1 => GSP_RGB5_A1_OES, Rgb5A1 => ::libctru::GSP_RGB5_A1_OES,
Rgba4 => GSP_RGBA4_OES, Rgba4 => ::libctru::GSP_RGBA4_OES,
} }
} }
} }
fn to_raw_event(ev: Event) -> ::libctru::GSPGPU_Event { fn to_raw_event(ev: Event) -> ::libctru::GSPGPU_Event {
use ::libctru::GSPGPU_Event::*;
use self::Event::*; use self::Event::*;
match ev { match ev {
Psc0 => GSPGPU_EVENT_PSC0, Psc0 => ::libctru::GSPGPU_EVENT_PSC0,
Psc1 => GSPGPU_EVENT_PSC1, Psc1 => ::libctru::GSPGPU_EVENT_PSC1,
VBlank0 => GSPGPU_EVENT_VBlank0, VBlank0 => ::libctru::GSPGPU_EVENT_VBlank0,
VBlank1 => GSPGPU_EVENT_VBlank1, VBlank1 => ::libctru::GSPGPU_EVENT_VBlank1,
PPF => GSPGPU_EVENT_PPF, PPF => ::libctru::GSPGPU_EVENT_PPF,
P3D => GSPGPU_EVENT_P3D, P3D => ::libctru::GSPGPU_EVENT_P3D,
DMA => GSPGPU_EVENT_DMA, DMA => ::libctru::GSPGPU_EVENT_DMA,
} }
} }

9033
ctru-sys/src/bindings.rs

File diff suppressed because it is too large Load Diff
Loading…
Cancel
Save