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. 8831
      ctru-sys/src/bindings.rs

7
ctr-std/src/panicking.rs

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

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

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

4
ctru-rs/src/console.rs

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

26
ctru-rs/src/gfx.rs

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

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

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

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

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

8831
ctru-sys/src/bindings.rs

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