本文整理汇总了C++中kernel::SharedPtr类的典型用法代码示例。如果您正苦于以下问题:C++ SharedPtr类的具体用法?C++ SharedPtr怎么用?C++ SharedPtr使用的例子?那么恭喜您, 这里精选的类代码示例或许可以为您提供帮助。
在下文中一共展示了SharedPtr类的20个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于我们的系统推荐出更棒的C++代码示例。
示例1: GetProcessInfo
static ResultCode GetProcessInfo(s64* out, Handle process_handle, u32 type) {
LOG_TRACE(Kernel_SVC, "called process=0x%08X type=%u", process_handle, type);
using Kernel::Process;
Kernel::SharedPtr<Process> process = Kernel::g_handle_table.Get<Process>(process_handle);
if (process == nullptr)
return ERR_INVALID_HANDLE;
switch (type) {
case 0:
case 2:
// TODO(yuriks): Type 0 returns a slightly higher number than type 2, but I'm not sure
// what's the difference between them.
*out = process->heap_used + process->linear_heap_used + process->misc_memory_used;
if(*out % Memory::PAGE_SIZE != 0) {
LOG_ERROR(Kernel_SVC, "called, memory size not page-aligned");
return ERR_MISALIGNED_SIZE;
}
break;
case 1:
case 3:
case 4:
case 5:
case 6:
case 7:
case 8:
// These are valid, but not implemented yet
LOG_ERROR(Kernel_SVC, "unimplemented GetProcessInfo type=%u", type);
break;
case 20:
*out = Memory::FCRAM_PADDR - process->GetLinearHeapBase();
break;
default:
LOG_ERROR(Kernel_SVC, "unknown GetProcessInfo type=%u", type);
if (type >= 21 && type <= 23) {
return ResultCode( // 0xE0E01BF4
ErrorDescription::NotImplemented, ErrorModule::OS,
ErrorSummary::InvalidArgument, ErrorLevel::Usage);
} else {
return ResultCode( // 0xD8E007ED
ErrorDescription::InvalidEnumValue, ErrorModule::Kernel,
ErrorSummary::InvalidArgument, ErrorLevel::Permanent);
}
break;
}
return RESULT_SUCCESS;
}
开发者ID:14923523,项目名称:citra,代码行数:49,代码来源:svc.cpp
示例2: GetHandles
namespace IR {
static Kernel::SharedPtr<Kernel::Event> handle_event;
static Kernel::SharedPtr<Kernel::Event> conn_status_event;
static Kernel::SharedPtr<Kernel::SharedMemory> shared_memory;
static Kernel::SharedPtr<Kernel::SharedMemory> transfer_shared_memory;
void GetHandles(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = 0x4000000;
cmd_buff[3] = Kernel::g_handle_table.Create(Service::IR::shared_memory).MoveFrom();
cmd_buff[4] = Kernel::g_handle_table.Create(Service::IR::handle_event).MoveFrom();
}
void InitializeIrNopShared(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 transfer_buff_size = cmd_buff[1];
u32 recv_buff_size = cmd_buff[2];
u32 unk1 = cmd_buff[3];
u32 send_buff_size = cmd_buff[4];
u32 unk2 = cmd_buff[5];
u8 baud_rate = cmd_buff[6] & 0xFF;
Handle handle = cmd_buff[8];
if(Kernel::g_handle_table.IsValid(handle)) {
transfer_shared_memory = Kernel::g_handle_table.Get<Kernel::SharedMemory>(handle);
transfer_shared_memory->name = "IR:TransferSharedMemory";
}
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_IR, "(STUBBED) called, transfer_buff_size=%d, recv_buff_size=%d, "
"unk1=%d, send_buff_size=%d, unk2=%d, baud_rate=%u, handle=0x%08X",
transfer_buff_size, recv_buff_size, unk1, send_buff_size, unk2, baud_rate, handle);
}
void RequireConnection(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conn_status_event->Signal();
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_IR, "(STUBBED) called");
}
void Disconnect(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_IR, "(STUBBED) called");
}
void GetConnectionStatusEvent(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[3] = Kernel::g_handle_table.Create(Service::IR::conn_status_event).MoveFrom();
LOG_WARNING(Service_IR, "(STUBBED) called");
}
void FinalizeIrNop(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_IR, "(STUBBED) called");
}
void Init() {
using namespace Kernel;
AddService(new IR_RST_Interface);
AddService(new IR_U_Interface);
AddService(new IR_User_Interface);
using Kernel::MemoryPermission;
shared_memory = SharedMemory::Create(0x1000, Kernel::MemoryPermission::ReadWrite,
Kernel::MemoryPermission::ReadWrite, "IR:SharedMemory");
transfer_shared_memory = nullptr;
// Create event handle(s)
handle_event = Event::Create(RESETTYPE_ONESHOT, "IR:HandleEvent");
conn_status_event = Event::Create(RESETTYPE_ONESHOT, "IR:ConnectionStatusEvent");
}
void Shutdown() {
transfer_shared_memory = nullptr;
shared_memory = nullptr;
handle_event = nullptr;
conn_status_event = nullptr;
}
} // namespace IR
开发者ID:IwantToPlaySo-iMergeToFork,项目名称:citra,代码行数:99,代码来源:ir.cpp
示例3: GetStickDirectionState
namespace HID {
// Handle to shared memory region designated to HID_User service
static Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
// Event handles
static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_1;
static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_2;
static Kernel::SharedPtr<Kernel::Event> event_accelerometer;
static Kernel::SharedPtr<Kernel::Event> event_gyroscope;
static Kernel::SharedPtr<Kernel::Event> event_debug_pad;
static u32 next_pad_index;
static u32 next_touch_index;
static u32 next_accelerometer_index;
static u32 next_gyroscope_index;
static int enable_accelerometer_count; // positive means enabled
static int enable_gyroscope_count; // positive means enabled
static int pad_update_event;
static int accelerometer_update_event;
static int gyroscope_update_event;
// Updating period for each HID device. These empirical values are measured from a 11.2 3DS.
constexpr u64 pad_update_ticks = BASE_CLOCK_RATE_ARM11 / 234;
constexpr u64 accelerometer_update_ticks = BASE_CLOCK_RATE_ARM11 / 104;
constexpr u64 gyroscope_update_ticks = BASE_CLOCK_RATE_ARM11 / 101;
constexpr float accelerometer_coef = 512.0f; // measured from hw test result
constexpr float gyroscope_coef = 14.375f; // got from hwtest GetGyroscopeLowRawToDpsCoefficient call
static std::atomic<bool> is_device_reload_pending;
static std::array<std::unique_ptr<Input::ButtonDevice>, Settings::NativeButton::NUM_BUTTONS_HID>
buttons;
static std::unique_ptr<Input::AnalogDevice> circle_pad;
static std::unique_ptr<Input::MotionDevice> motion_device;
static std::unique_ptr<Input::TouchDevice> touch_device;
DirectionState GetStickDirectionState(s16 circle_pad_x, s16 circle_pad_y) {
// 30 degree and 60 degree are angular thresholds for directions
constexpr float TAN30 = 0.577350269f;
constexpr float TAN60 = 1 / TAN30;
// a circle pad radius greater than 40 will trigger circle pad direction
constexpr int CIRCLE_PAD_THRESHOLD_SQUARE = 40 * 40;
DirectionState state{false, false, false, false};
if (circle_pad_x * circle_pad_x + circle_pad_y * circle_pad_y > CIRCLE_PAD_THRESHOLD_SQUARE) {
float t = std::abs(static_cast<float>(circle_pad_y) / circle_pad_x);
if (circle_pad_x != 0 && t < TAN60) {
if (circle_pad_x > 0)
state.right = true;
else
state.left = true;
}
if (circle_pad_x == 0 || t > TAN30) {
if (circle_pad_y > 0)
state.up = true;
else
state.down = true;
}
}
return state;
}
static void LoadInputDevices() {
std::transform(Settings::values.buttons.begin() + Settings::NativeButton::BUTTON_HID_BEGIN,
Settings::values.buttons.begin() + Settings::NativeButton::BUTTON_HID_END,
buttons.begin(), Input::CreateDevice<Input::ButtonDevice>);
circle_pad = Input::CreateDevice<Input::AnalogDevice>(
Settings::values.analogs[Settings::NativeAnalog::CirclePad]);
motion_device = Input::CreateDevice<Input::MotionDevice>(Settings::values.motion_device);
touch_device = Input::CreateDevice<Input::TouchDevice>(Settings::values.touch_device);
}
static void UnloadInputDevices() {
for (auto& button : buttons) {
button.reset();
}
circle_pad.reset();
motion_device.reset();
touch_device.reset();
}
static void UpdatePadCallback(u64 userdata, int cycles_late) {
SharedMem* mem = reinterpret_cast<SharedMem*>(shared_mem->GetPointer());
if (is_device_reload_pending.exchange(false))
LoadInputDevices();
PadState state;
using namespace Settings::NativeButton;
state.a.Assign(buttons[A - BUTTON_HID_BEGIN]->GetStatus());
state.b.Assign(buttons[B - BUTTON_HID_BEGIN]->GetStatus());
state.x.Assign(buttons[X - BUTTON_HID_BEGIN]->GetStatus());
state.y.Assign(buttons[Y - BUTTON_HID_BEGIN]->GetStatus());
state.right.Assign(buttons[Right - BUTTON_HID_BEGIN]->GetStatus());
//.........这里部分代码省略.........
开发者ID:JayFoxRox,项目名称:citra,代码行数:101,代码来源:hid.cpp
示例4: SetInputLineWidth
namespace Y2R {
struct ConversionParameters {
InputFormat input_format;
OutputFormat output_format;
Rotation rotation;
BlockAlignment block_alignment;
u16 input_line_width;
u16 input_lines;
StandardCoefficient standard_coefficient;
u8 padding;
u16 alpha;
};
static_assert(sizeof(ConversionParameters) == 12, "ConversionParameters struct has incorrect size");
static Kernel::SharedPtr<Kernel::Event> completion_event;
static ConversionConfiguration conversion;
static DitheringWeightParams dithering_weight_params;
static u32 temporal_dithering_enabled = 0;
static u32 transfer_end_interrupt_enabled = 0;
static u32 spacial_dithering_enabled = 0;
static const CoefficientSet standard_coefficients[4] = {
{{0x100, 0x166, 0xB6, 0x58, 0x1C5, -0x166F, 0x10EE, -0x1C5B}}, // ITU_Rec601
{{0x100, 0x193, 0x77, 0x2F, 0x1DB, -0x1933, 0xA7C, -0x1D51}}, // ITU_Rec709
{{0x12A, 0x198, 0xD0, 0x64, 0x204, -0x1BDE, 0x10F2, -0x229B}}, // ITU_Rec601_Scaling
{{0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421}}, // ITU_Rec709_Scaling
};
ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) {
if (width == 0 || width > 1024 || width % 8 != 0) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
}
// Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of
// 1024 the `camera` module would set the value 0 here, but we don't need to emulate this
// internal detail.
this->input_line_width = width;
return RESULT_SUCCESS;
}
ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
if (lines == 0 || lines > 1024) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
}
// Note: In what appears to be a bug, the `camera` module does not set the hardware register at
// all if `lines` is 1024, so the conversion uses the last value that was set. The intention
// was probably to set it to 0 like in SetInputLineWidth.
if (lines != 1024) {
this->input_lines = lines;
}
return RESULT_SUCCESS;
}
ResultCode ConversionConfiguration::SetStandardCoefficient(
StandardCoefficient standard_coefficient) {
size_t index = static_cast<size_t>(standard_coefficient);
if (index >= ARRAY_SIZE(standard_coefficients)) {
return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
}
std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients));
return RESULT_SUCCESS;
}
static void SetInputFormat(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conversion.input_format = static_cast<InputFormat>(cmd_buff[1]);
cmd_buff[0] = IPC::MakeHeader(0x1, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called input_format=%hhu", conversion.input_format);
}
static void GetInputFormat(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
cmd_buff[0] = IPC::MakeHeader(0x2, 2, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
cmd_buff[2] = static_cast<u32>(conversion.input_format);
LOG_DEBUG(Service_Y2R, "called input_format=%hhu", conversion.input_format);
}
static void SetOutputFormat(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conversion.output_format = static_cast<OutputFormat>(cmd_buff[1]);
cmd_buff[0] = IPC::MakeHeader(0x3, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called output_format=%hhu", conversion.output_format);
}
//.........这里部分代码省略.........
开发者ID:emmauss,项目名称:citra,代码行数:101,代码来源:y2r_u.cpp
示例5: LoadExec
ResultStatus AppLoader_NCCH::LoadExec(Kernel::SharedPtr<Kernel::Process>& process) {
using Kernel::CodeSet;
using Kernel::SharedPtr;
if (!is_loaded)
return ResultStatus::ErrorNotLoaded;
std::vector<u8> code;
u64_le program_id;
if (ResultStatus::Success == ReadCode(code) &&
ResultStatus::Success == ReadProgramId(program_id)) {
std::string process_name = Common::StringFromFixedZeroTerminatedBuffer(
(const char*)overlay_ncch->exheader_header.codeset_info.name, 8);
SharedPtr<CodeSet> codeset = CodeSet::Create(process_name, program_id);
codeset->code.offset = 0;
codeset->code.addr = overlay_ncch->exheader_header.codeset_info.text.address;
codeset->code.size =
overlay_ncch->exheader_header.codeset_info.text.num_max_pages * Memory::PAGE_SIZE;
codeset->rodata.offset = codeset->code.offset + codeset->code.size;
codeset->rodata.addr = overlay_ncch->exheader_header.codeset_info.ro.address;
codeset->rodata.size =
overlay_ncch->exheader_header.codeset_info.ro.num_max_pages * Memory::PAGE_SIZE;
// TODO(yuriks): Not sure if the bss size is added to the page-aligned .data size or just
// to the regular size. Playing it safe for now.
u32 bss_page_size = (overlay_ncch->exheader_header.codeset_info.bss_size + 0xFFF) & ~0xFFF;
code.resize(code.size() + bss_page_size, 0);
codeset->data.offset = codeset->rodata.offset + codeset->rodata.size;
codeset->data.addr = overlay_ncch->exheader_header.codeset_info.data.address;
codeset->data.size =
overlay_ncch->exheader_header.codeset_info.data.num_max_pages * Memory::PAGE_SIZE +
bss_page_size;
codeset->entrypoint = codeset->code.addr;
codeset->memory = std::make_shared<std::vector<u8>>(std::move(code));
process = Kernel::Process::Create(std::move(codeset));
// Attach a resource limit to the process based on the resource limit category
process->resource_limit =
Kernel::ResourceLimit::GetForCategory(static_cast<Kernel::ResourceLimitCategory>(
overlay_ncch->exheader_header.arm11_system_local_caps.resource_limit_category));
// Set the default CPU core for this process
process->ideal_processor =
overlay_ncch->exheader_header.arm11_system_local_caps.ideal_processor;
// Copy data while converting endianness
std::array<u32, ARRAY_SIZE(overlay_ncch->exheader_header.arm11_kernel_caps.descriptors)>
kernel_caps;
std::copy_n(overlay_ncch->exheader_header.arm11_kernel_caps.descriptors, kernel_caps.size(),
begin(kernel_caps));
process->ParseKernelCaps(kernel_caps.data(), kernel_caps.size());
s32 priority = overlay_ncch->exheader_header.arm11_system_local_caps.priority;
u32 stack_size = overlay_ncch->exheader_header.codeset_info.stack_size;
process->Run(priority, stack_size);
return ResultStatus::Success;
}
return ResultStatus::Error;
}
开发者ID:namkazt,项目名称:citra,代码行数:65,代码来源:ncch.cpp
示例6: Update
namespace HID {
static const int MAX_CIRCLEPAD_POS = 0x9C; ///< Max value for a circle pad position
// Handle to shared memory region designated to HID_User service
static Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
// Event handles
static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_1;
static Kernel::SharedPtr<Kernel::Event> event_pad_or_touch_2;
static Kernel::SharedPtr<Kernel::Event> event_accelerometer;
static Kernel::SharedPtr<Kernel::Event> event_gyroscope;
static Kernel::SharedPtr<Kernel::Event> event_debug_pad;
static u32 next_pad_index;
static u32 next_touch_index;
const std::array<Service::HID::PadState, Settings::NativeInput::NUM_INPUTS> pad_mapping = {{
Service::HID::PAD_A, Service::HID::PAD_B, Service::HID::PAD_X, Service::HID::PAD_Y,
Service::HID::PAD_L, Service::HID::PAD_R, Service::HID::PAD_ZL, Service::HID::PAD_ZR,
Service::HID::PAD_START, Service::HID::PAD_SELECT, Service::HID::PAD_NONE,
Service::HID::PAD_UP, Service::HID::PAD_DOWN, Service::HID::PAD_LEFT, Service::HID::PAD_RIGHT,
Service::HID::PAD_CIRCLE_UP, Service::HID::PAD_CIRCLE_DOWN, Service::HID::PAD_CIRCLE_LEFT, Service::HID::PAD_CIRCLE_RIGHT,
Service::HID::PAD_C_UP, Service::HID::PAD_C_DOWN, Service::HID::PAD_C_LEFT, Service::HID::PAD_C_RIGHT
}};
// TODO(peachum):
// Add a method for setting analog input from joystick device for the circle Pad.
//
// This method should:
// * Be called after both PadButton<Press, Release>().
// * Be called before PadUpdateComplete()
// * Set current PadEntry.circle_pad_<axis> using analog data
// * Set PadData.raw_circle_pad_data
// * Set PadData.current_state.circle_right = 1 if current PadEntry.circle_pad_x >= 41
// * Set PadData.current_state.circle_up = 1 if current PadEntry.circle_pad_y >= 41
// * Set PadData.current_state.circle_left = 1 if current PadEntry.circle_pad_x <= -41
// * Set PadData.current_state.circle_right = 1 if current PadEntry.circle_pad_y <= -41
void Update() {
SharedMem* mem = reinterpret_cast<SharedMem*>(shared_mem->GetPointer());
const PadState state = VideoCore::g_emu_window->GetPadState();
if (mem == nullptr) {
LOG_DEBUG(Service_HID, "Cannot update HID prior to mapping shared memory!");
return;
}
mem->pad.current_state.hex = state.hex;
mem->pad.index = next_pad_index;
next_touch_index = (next_touch_index + 1) % mem->pad.entries.size();
// Get the previous Pad state
u32 last_entry_index = (mem->pad.index - 1) % mem->pad.entries.size();
PadState old_state = mem->pad.entries[last_entry_index].current_state;
// Compute bitmask with 1s for bits different from the old state
PadState changed = { { (state.hex ^ old_state.hex) } };
// Get the current Pad entry
PadDataEntry* pad_entry = &mem->pad.entries[mem->pad.index];
// Update entry properties
pad_entry->current_state.hex = state.hex;
pad_entry->delta_additions.hex = changed.hex & state.hex;
pad_entry->delta_removals.hex = changed.hex & old_state.hex;;
// Set circle Pad
pad_entry->circle_pad_x = state.circle_left ? -MAX_CIRCLEPAD_POS :
state.circle_right ? MAX_CIRCLEPAD_POS : 0x0;
pad_entry->circle_pad_y = state.circle_down ? -MAX_CIRCLEPAD_POS :
state.circle_up ? MAX_CIRCLEPAD_POS : 0x0;
// If we just updated index 0, provide a new timestamp
if (mem->pad.index == 0) {
mem->pad.index_reset_ticks_previous = mem->pad.index_reset_ticks;
mem->pad.index_reset_ticks = (s64)CoreTiming::GetTicks();
}
mem->touch.index = next_touch_index;
next_touch_index = (next_touch_index + 1) % mem->touch.entries.size();
// Get the current touch entry
TouchDataEntry* touch_entry = &mem->touch.entries[mem->touch.index];
bool pressed = false;
std::tie(touch_entry->x, touch_entry->y, pressed) = VideoCore::g_emu_window->GetTouchState();
touch_entry->valid = pressed ? 1 : 0;
// TODO(bunnei): We're not doing anything with offset 0xA8 + 0x18 of HID SharedMemory, which
// supposedly is "Touch-screen entry, which contains the raw coordinate data prior to being
// converted to pixel coordinates." (http://3dbrew.org/wiki/HID_Shared_Memory#Offset_0xA8).
// If we just updated index 0, provide a new timestamp
if (mem->touch.index == 0) {
mem->touch.index_reset_ticks_previous = mem->touch.index_reset_ticks;
mem->touch.index_reset_ticks = (s64)CoreTiming::GetTicks();
}
//.........这里部分代码省略.........
开发者ID:ds84182,项目名称:citra,代码行数:101,代码来源:hid.cpp
示例7: SetInputLineWidth
namespace Y2R_U {
struct ConversionParameters {
InputFormat input_format;
OutputFormat output_format;
Rotation rotation;
BlockAlignment block_alignment;
u16 input_line_width;
u16 input_lines;
StandardCoefficient standard_coefficient;
u8 reserved;
u16 alpha;
};
static_assert(sizeof(ConversionParameters) == 12, "ConversionParameters struct has incorrect size");
static Kernel::SharedPtr<Kernel::Event> completion_event;
static ConversionConfiguration conversion;
static const CoefficientSet standard_coefficients[4] = {
{{ 0x100, 0x166, 0xB6, 0x58, 0x1C5, -0x166F, 0x10EE, -0x1C5B }}, // ITU_Rec601
{{ 0x100, 0x193, 0x77, 0x2F, 0x1DB, -0x1933, 0xA7C, -0x1D51 }}, // ITU_Rec709
{{ 0x12A, 0x198, 0xD0, 0x64, 0x204, -0x1BDE, 0x10F2, -0x229B }}, // ITU_Rec601_Scaling
{{ 0x12A, 0x1CA, 0x88, 0x36, 0x21C, -0x1F04, 0x99C, -0x2421 }}, // ITU_Rec709_Scaling
};
ResultCode ConversionConfiguration::SetInputLineWidth(u16 width) {
if (width == 0 || width > 1024 || width % 8 != 0) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
}
// Note: The hardware uses the register value 0 to represent a width of 1024, so for a width of
// 1024 the `camera` module would set the value 0 here, but we don't need to emulate this
// internal detail.
this->input_line_width = width;
return RESULT_SUCCESS;
}
ResultCode ConversionConfiguration::SetInputLines(u16 lines) {
if (lines == 0 || lines > 1024) {
return ResultCode(ErrorDescription::OutOfRange, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053FD
}
// Note: In what appears to be a bug, the `camera` module does not set the hardware register at
// all if `lines` is 1024, so the conversion uses the last value that was set. The intention
// was probably to set it to 0 like in SetInputLineWidth.
if (lines != 1024) {
this->input_lines = lines;
}
return RESULT_SUCCESS;
}
ResultCode ConversionConfiguration::SetStandardCoefficient(StandardCoefficient standard_coefficient) {
size_t index = static_cast<size_t>(standard_coefficient);
if (index >= 4) {
return ResultCode(ErrorDescription::InvalidEnumValue, ErrorModule::CAM,
ErrorSummary::InvalidArgument, ErrorLevel::Usage); // 0xE0E053ED
}
std::memcpy(coefficients.data(), standard_coefficients[index].data(), sizeof(coefficients));
return RESULT_SUCCESS;
}
static void SetInputFormat(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conversion.input_format = static_cast<InputFormat>(cmd_buff[1]);
LOG_DEBUG(Service_Y2R, "called input_format=%hhu", conversion.input_format);
cmd_buff[1] = RESULT_SUCCESS.raw;
}
static void SetOutputFormat(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conversion.output_format = static_cast<OutputFormat>(cmd_buff[1]);
LOG_DEBUG(Service_Y2R, "called output_format=%hhu", conversion.output_format);
cmd_buff[1] = RESULT_SUCCESS.raw;
}
static void SetRotation(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conversion.rotation = static_cast<Rotation>(cmd_buff[1]);
LOG_DEBUG(Service_Y2R, "called rotation=%hhu", conversion.rotation);
cmd_buff[1] = RESULT_SUCCESS.raw;
}
static void SetBlockAlignment(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conversion.block_alignment = static_cast<BlockAlignment>(cmd_buff[1]);
LOG_DEBUG(Service_Y2R, "called alignment=%hhu", conversion.block_alignment);
cmd_buff[1] = RESULT_SUCCESS.raw;
}
//.........这里部分代码省略.........
开发者ID:ajaning,项目名称:citra,代码行数:101,代码来源:y2r_u.cpp
示例8: UpdateGyroscopeCallback
static void UpdateGyroscopeCallback(u64 userdata, int cycles_late) {
SharedMem* mem = reinterpret_cast<SharedMem*>(shared_mem->GetPointer());
mem->gyroscope.index = next_gyroscope_index;
next_gyroscope_index = (next_gyroscope_index + 1) % mem->gyroscope.entries.size();
GyroscopeDataEntry& gyroscope_entry = mem->gyroscope.entries[mem->gyroscope.index];
Math::Vec3<float> gyro;
std::tie(std::ignore, gyro) = motion_device->GetStatus();
double stretch = Core::System::GetInstance().perf_stats.GetLastFrameTimeScale();
gyro *= gyroscope_coef * static_cast<float>(stretch);
gyroscope_entry.x = static_cast<s16>(gyro.x);
gyroscope_entry.y = static_cast<s16>(gyro.y);
gyroscope_entry.z = static_cast<s16>(gyro.z);
// Make up "raw" entry
mem->gyroscope.raw_entry.x = gyroscope_entry.x;
mem->gyroscope.raw_entry.z = -gyroscope_entry.y;
mem->gyroscope.raw_entry.y = gyroscope_entry.z;
// If we just updated index 0, provide a new timestamp
if (mem->gyroscope.index == 0) {
mem->gyroscope.index_reset_ticks_previous = mem->gyroscope.index_reset_ticks;
mem->gyroscope.index_reset_ticks = (s64)CoreTiming::GetTicks();
}
event_gyroscope->Signal();
// Reschedule recurrent event
CoreTiming::ScheduleEvent(gyroscope_update_ticks - cycles_late, gyroscope_update_event);
}
开发者ID:JayFoxRox,项目名称:citra,代码行数:32,代码来源:hid.cpp
示例9: UpdateCallback
static void UpdateCallback(u64 userdata, int cycles_late) {
SharedMem* mem = reinterpret_cast<SharedMem*>(shared_memory->GetPointer());
if (is_device_reload_pending.exchange(false))
LoadInputDevices();
PadState state;
state.zl.Assign(zl_button->GetStatus());
state.zr.Assign(zr_button->GetStatus());
// Get current c-stick position and update c-stick direction
float c_stick_x_f, c_stick_y_f;
std::tie(c_stick_x_f, c_stick_y_f) = c_stick->GetStatus();
constexpr int MAX_CSTICK_RADIUS = 0x9C; // Max value for a c-stick radius
const s16 c_stick_x = static_cast<s16>(c_stick_x_f * MAX_CSTICK_RADIUS);
const s16 c_stick_y = static_cast<s16>(c_stick_y_f * MAX_CSTICK_RADIUS);
if (!raw_c_stick) {
const HID::DirectionState direction = HID::GetStickDirectionState(c_stick_x, c_stick_y);
state.c_stick_up.Assign(direction.up);
state.c_stick_down.Assign(direction.down);
state.c_stick_left.Assign(direction.left);
state.c_stick_right.Assign(direction.right);
}
// TODO (wwylele): implement raw C-stick data for raw_c_stick = true
const u32 last_entry_index = mem->index;
mem->index = next_pad_index;
next_pad_index = (next_pad_index + 1) % mem->entries.size();
// Get the previous Pad state
PadState old_state{mem->entries[last_entry_index].current_state};
// Compute bitmask with 1s for bits different from the old state
PadState changed = {state.hex ^ old_state.hex};
// Get the current Pad entry
PadDataEntry& pad_entry = mem->entries[mem->index];
// Update entry properties
pad_entry.current_state.hex = state.hex;
pad_entry.delta_additions.hex = changed.hex & state.hex;
pad_entry.delta_removals.hex = changed.hex & old_state.hex;
pad_entry.c_stick_x = c_stick_x;
pad_entry.c_stick_y = c_stick_y;
// If we just updated index 0, provide a new timestamp
if (mem->index == 0) {
mem->index_reset_ticks_previous = mem->index_reset_ticks;
mem->index_reset_ticks = CoreTiming::GetTicks();
}
update_event->Signal();
// Reschedule recurrent event
CoreTiming::ScheduleEvent(msToCycles(update_period) - cycles_late, update_callback_id);
}
开发者ID:Subv,项目名称:citra,代码行数:58,代码来源:ir_rst.cpp
示例10: DriverInitialize
static void DriverInitialize(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conversion.input_format = InputFormat::YUV422_Indiv8;
conversion.output_format = OutputFormat::RGBA8;
conversion.rotation = Rotation::None;
conversion.block_alignment = BlockAlignment::Linear;
conversion.coefficients.fill(0);
conversion.SetInputLineWidth(1024);
conversion.SetInputLines(1024);
conversion.alpha = 0;
ConversionBuffer zero_buffer = {};
conversion.src_Y = zero_buffer;
conversion.src_U = zero_buffer;
conversion.src_V = zero_buffer;
conversion.dst = zero_buffer;
completion_event->Clear();
cmd_buff[0] = IPC::MakeHeader(0x2B, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called");
}
开发者ID:emmauss,项目名称:citra,代码行数:25,代码来源:y2r_u.cpp
示例11: NotifyToWait
void NotifyToWait(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1];
// TODO(Subv): Verify this, it seems to get SWKBD and Home Menu further.
start_event->Signal();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_WARNING(Service_APT, "(STUBBED) app_id=%u", app_id);
}
开发者ID:HackerTon,项目名称:citra,代码行数:9,代码来源:apt.cpp
示例12: DisableGyroscopeLow
void DisableGyroscopeLow(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
event_gyroscope->Signal();
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_HID, "(STUBBED) called");
}
开发者ID:ds84182,项目名称:citra,代码行数:9,代码来源:hid.cpp
示例13: EnableAccelerometer
void EnableAccelerometer(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
event_accelerometer->Signal();
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_HID, "(STUBBED) called");
}
开发者ID:ds84182,项目名称:citra,代码行数:9,代码来源:hid.cpp
示例14: RequireConnection
void RequireConnection(Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
conn_status_event->Signal();
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_WARNING(Service_IR, "(STUBBED) called");
}
开发者ID:IwantToPlaySo-iMergeToFork,项目名称:citra,代码行数:9,代码来源:ir.cpp
示例15: Initialize
void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
// TODO(bunnei): Check if these are created in Initialize or on APT process startup.
notification_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Notification");
pause_event = Kernel::Event::Create(RESETTYPE_ONESHOT, "APT_U:Pause");
cmd_buff[3] = Kernel::g_handle_table.Create(notification_event).MoveFrom();
cmd_buff[4] = Kernel::g_handle_table.Create(pause_event).MoveFrom();
// TODO(bunnei): Check if these events are cleared/signaled every time Initialize is called.
notification_event->Clear();
pause_event->Signal(); // Fire start event
ASSERT_MSG((nullptr != lock), "Cannot initialize without lock");
lock->Release();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
}
开发者ID:kevinhartman,项目名称:citra,代码行数:19,代码来源:apt_u.cpp
示例16: SignalInterrupt
void SignalInterrupt() {
// TODO(bunnei): This is just a stub, it does not do anything other than signal to the emulated
// application that a DSP interrupt occurred, without specifying which one. Since we do not
// emulate the DSP yet (and how it works is largely unknown), this is a work around to get games
// that check the DSP interrupt signal event to run. We should figure out the different types of
// DSP interrupts, and trigger them at the appropriate times.
if (interrupt_event != 0)
interrupt_event->Signal();
}
开发者ID:ds84182,项目名称:citra,代码行数:10,代码来源:dsp_dsp.cpp
示例17: Initialize
void Initialize(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
u32 app_id = cmd_buff[1];
u32 flags = cmd_buff[2];
cmd_buff[2] = 0x04000000; // According to 3dbrew, this value should be 0x04000000
cmd_buff[3] = Kernel::g_handle_table.Create(notification_event).MoveFrom();
cmd_buff[4] = Kernel::g_handle_table.Create(start_event).MoveFrom();
// TODO(bunnei): Check if these events are cleared every time Initialize is called.
notification_event->Clear();
start_event->Clear();
ASSERT_MSG((nullptr != lock), "Cannot initialize without lock");
lock->Release();
cmd_buff[1] = RESULT_SUCCESS.raw; // No error
LOG_TRACE(Service_APT, "called app_id=0x%08X, flags=0x%08X", app_id, flags);
}
开发者ID:HackerTon,项目名称:citra,代码行数:20,代码来源:apt.cpp
示例18: UpdateAccelerometerCallback
static void UpdateAccelerometerCallback(u64 userdata, int cycles_late) {
SharedMem* mem = reinterpret_cast<SharedMem*>(shared_mem->GetPointer());
mem->accelerometer.index = next_accelerometer_index;
next_accelerometer_index = (next_accelerometer_index + 1) % mem->accelerometer.entries.size();
Math::Vec3<float> accel;
std::tie(accel, std::ignore) = motion_device->GetStatus();
accel *= accelerometer_coef;
// TODO(wwylele): do a time stretch like the one in UpdateGyroscopeCallback
// The time stretch formula should be like
// stretched_vector = (raw_vector - gravity) * stretch_ratio + gravity
AccelerometerDataEntry& accelerometer_entry =
mem->accelerometer.entries[mem->accelerometer.index];
accelerometer_entry.x = static_cast<s16>(accel.x);
accelerometer_entry.y = static_cast<s16>(accel.y);
accelerometer_entry.z = static_cast<s16>(accel.z);
// Make up "raw" entry
// TODO(wwylele):
// From hardware testing, the raw_entry values are approximately, but not exactly, as twice as
// corresponding entries (or with a minus sign). It may caused by system calibration to the
// accelerometer. Figure out how it works, or, if no game reads raw_entry, the following three
// lines can be removed and leave raw_entry unimplemented.
mem->accelerometer.raw_entry.x = -2 * accelerometer_entry.x;
mem->accelerometer.raw_entry.z = 2 * accelerometer_entry.y;
mem->accelerometer.raw_entry.y = -2 * accelerometer_entry.z;
// If we just updated index 0, provide a new timestamp
if (mem->accelerometer.index == 0) {
mem->accelerometer.index_reset_ticks_previous = mem->accelerometer.index_reset_ticks;
mem->accelerometer.index_reset_ticks = (s64)CoreTiming::GetTicks();
}
event_accelerometer->Signal();
// Reschedule recurrent event
CoreTiming::ScheduleEvent(accelerometer_update_ticks - cycles_late, accelerometer_update_event);
}
开发者ID:JayFoxRox,项目名称:citra,代码行数:41,代码来源:hid.cpp
示例19: StartConversion
static void StartConversion(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
HW::Y2R::PerformConversion(conversion);
// dst_image_size would seem to be perfect for this, but it doesn't include the gap :(
u32 total_output_size = conversion.input_lines *
(conversion.dst.transfer_unit + conversion.dst.gap);
VideoCore::g_renderer->hw_rasterizer->NotifyFlush(
Memory::VirtualToPhysicalAddress(conversion.dst.address), total_output_size);
LOG_DEBUG(Service_Y2R, "called");
completion_event->Signal();
cmd_buff[1] = RESULT_SUCCESS.raw;
}
开发者ID:ajaning,项目名称:citra,代码行数:16,代码来源:y2r_u.cpp
示例20: StartConversion
static void StartConversion(Service::Interface* self) {
u32* cmd_buff = Kernel::GetCommandBuffer();
// dst_image_size would seem to be perfect for this, but it doesn't include the gap :(
u32 total_output_size = conversion.input_lines * (conversion.dst.transfer_unit + conversion.dst.gap);
Memory::RasterizerFlushAndInvalidateRegion(Memory::VirtualToPhysicalAddress(conversion.dst.address), total_output_size);
HW::Y2R::PerformConversion(conversion);
completion_event->Signal();
cmd_buff[0] = IPC::MakeHeader(0x26, 1, 0);
cmd_buff[1] = RESULT_SUCCESS.raw;
LOG_DEBUG(Service_Y2R, "called");
}
开发者ID:14923523,项目名称:citra,代码行数:16,代码来源:y2r_u.cpp
注:本文中的kernel::SharedPtr类示例由纯净天空整理自Github/MSDocs等源码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。 |
请发表评论