Browse Source

Add srv::make_ipc_header and use in ir_user

pull/86/head
AzureMarker 1 year ago
parent
commit
208a9171e4
  1. 15
      ctru-rs/src/services/ir_user.rs
  2. 7
      ctru-rs/src/services/srv.rs

15
ctru-rs/src/services/ir_user.rs

@ -11,6 +11,7 @@ @@ -11,6 +11,7 @@
#![doc(alias = "gamepad")]
use crate::error::ResultCode;
use crate::services::srv::make_ipc_header;
use crate::services::ServiceReference;
use crate::Error;
use ctru_sys::{Handle, MEMPERM_READ, MEMPERM_READWRITE};
@ -39,13 +40,13 @@ struct IrUserState { @@ -39,13 +40,13 @@ struct IrUserState {
}
// ir:USER syscall command headers
const REQUIRE_CONNECTION_COMMAND_HEADER: u32 = 0x00060040;
const DISCONNECT_COMMAND_HEADER: u32 = 0x00090000;
const GET_RECEIVE_EVENT_COMMAND_HEADER: u32 = 0x000A0000;
const GET_CONNECTION_STATUS_EVENT_COMMAND_HEADER: u32 = 0x000C0000;
const SEND_IR_NOP_COMMAND_HEADER: u32 = 0x000D0042;
const INITIALIZE_IRNOP_SHARED_COMMAND_HEADER: u32 = 0x00180182;
const RELEASE_RECEIVED_DATA_COMMAND_HEADER: u32 = 0x00190040;
const REQUIRE_CONNECTION_COMMAND_HEADER: u32 = make_ipc_header(6, 1, 0);
const DISCONNECT_COMMAND_HEADER: u32 = make_ipc_header(9, 0, 0);
const GET_RECEIVE_EVENT_COMMAND_HEADER: u32 = make_ipc_header(10, 0, 0);
const GET_CONNECTION_STATUS_EVENT_COMMAND_HEADER: u32 = make_ipc_header(12, 0, 0);
const SEND_IR_NOP_COMMAND_HEADER: u32 = make_ipc_header(13, 1, 2);
const INITIALIZE_IRNOP_SHARED_COMMAND_HEADER: u32 = make_ipc_header(24, 6, 2);
const RELEASE_RECEIVED_DATA_COMMAND_HEADER: u32 = make_ipc_header(25, 1, 0);
// Misc constants
const SHARED_MEM_INFO_SECTIONS_SIZE: usize = 0x30;

7
ctru-rs/src/services/srv.rs

@ -28,3 +28,10 @@ impl HandleExt for Handle { @@ -28,3 +28,10 @@ impl HandleExt for Handle {
Ok(())
}
}
/// Creates a command header to be used for IPC. This is a const fn version of [`ctru_sys::IPC_MakeHeader`].
pub const fn make_ipc_header(command_id: u16, normal_params: u8, translate_params: u8) -> u32 {
((command_id as u32) << 16)
| (((normal_params as u32) & 0x3F) << 6)
| ((translate_params as u32) & 0x3F)
}

Loading…
Cancel
Save