From d52d85993683a6948285801ab54d51c79c98afba Mon Sep 17 00:00:00 2001 From: Yuri Kunde Schlesner Date: Fri, 23 Jan 2015 03:11:25 -0200 Subject: Kernel: Convert Event to not use Handles --- src/core/hle/service/hid/hid.cpp | 28 +++++++++++++++------------- src/core/hle/service/hid/hid.h | 11 ++++++----- src/core/hle/service/hid/hid_user.cpp | 11 ++++++----- 3 files changed, 27 insertions(+), 23 deletions(-) (limited to 'src/core/hle/service/hid') diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp index ee2ba7e01..835055af4 100644 --- a/src/core/hle/service/hid/hid.cpp +++ b/src/core/hle/service/hid/hid.cpp @@ -14,11 +14,11 @@ namespace HID { Kernel::SharedPtr g_shared_mem = nullptr; -Handle g_event_pad_or_touch_1 = 0; -Handle g_event_pad_or_touch_2 = 0; -Handle g_event_accelerometer = 0; -Handle g_event_gyroscope = 0; -Handle g_event_debug_pad = 0; +Kernel::SharedPtr g_event_pad_or_touch_1; +Kernel::SharedPtr g_event_pad_or_touch_2; +Kernel::SharedPtr g_event_accelerometer; +Kernel::SharedPtr g_event_gyroscope; +Kernel::SharedPtr g_event_debug_pad; // Next Pad state update information static PadState next_state = {{0}}; @@ -115,19 +115,21 @@ void PadUpdateComplete() { } // Signal both handles when there's an update to Pad or touch - Kernel::SignalEvent(g_event_pad_or_touch_1); - Kernel::SignalEvent(g_event_pad_or_touch_2); + g_event_pad_or_touch_1->Signal(); + g_event_pad_or_touch_2->Signal(); } void HIDInit() { - g_shared_mem = Kernel::SharedMemory::Create("HID:SharedMem").MoveFrom(); + using namespace Kernel; + + g_shared_mem = SharedMemory::Create("HID:SharedMem").MoveFrom(); // Create event handles - g_event_pad_or_touch_1 = Kernel::CreateEvent(RESETTYPE_ONESHOT, "HID:EventPadOrTouch1"); - g_event_pad_or_touch_2 = Kernel::CreateEvent(RESETTYPE_ONESHOT, "HID:EventPadOrTouch2"); - g_event_accelerometer = Kernel::CreateEvent(RESETTYPE_ONESHOT, "HID:EventAccelerometer"); - g_event_gyroscope = Kernel::CreateEvent(RESETTYPE_ONESHOT, "HID:EventGyroscope"); - g_event_debug_pad = Kernel::CreateEvent(RESETTYPE_ONESHOT, "HID:EventDebugPad"); + g_event_pad_or_touch_1 = Event::Create(RESETTYPE_ONESHOT, "HID:EventPadOrTouch1").MoveFrom(); + g_event_pad_or_touch_2 = Event::Create(RESETTYPE_ONESHOT, "HID:EventPadOrTouch2").MoveFrom(); + g_event_accelerometer = Event::Create(RESETTYPE_ONESHOT, "HID:EventAccelerometer").MoveFrom(); + g_event_gyroscope = Event::Create(RESETTYPE_ONESHOT, "HID:EventGyroscope").MoveFrom(); + g_event_debug_pad = Event::Create(RESETTYPE_ONESHOT, "HID:EventDebugPad").MoveFrom(); } void HIDShutdown() { diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h index 5e6236647..2116d2ca3 100644 --- a/src/core/hle/service/hid/hid.h +++ b/src/core/hle/service/hid/hid.h @@ -11,6 +11,7 @@ namespace Kernel { class SharedMemory; + class Event; } namespace Service { @@ -20,11 +21,11 @@ namespace HID { extern Kernel::SharedPtr g_shared_mem; // Event handles -extern Handle g_event_pad_or_touch_1; -extern Handle g_event_pad_or_touch_2; -extern Handle g_event_accelerometer; -extern Handle g_event_gyroscope; -extern Handle g_event_debug_pad; +extern Kernel::SharedPtr g_event_pad_or_touch_1; +extern Kernel::SharedPtr g_event_pad_or_touch_2; +extern Kernel::SharedPtr g_event_accelerometer; +extern Kernel::SharedPtr g_event_gyroscope; +extern Kernel::SharedPtr g_event_debug_pad; /** * Structure of a Pad controller state. diff --git a/src/core/hle/service/hid/hid_user.cpp b/src/core/hle/service/hid/hid_user.cpp index c167927ea..5444aa5ee 100644 --- a/src/core/hle/service/hid/hid_user.cpp +++ b/src/core/hle/service/hid/hid_user.cpp @@ -5,6 +5,7 @@ #include "common/log.h" #include "core/hle/hle.h" +#include "core/hle/kernel/event.h" #include "core/hle/kernel/shared_memory.h" #include "core/hle/service/hid/hid.h" #include "hid_user.h" @@ -49,11 +50,11 @@ void GetIPCHandles(Service::Interface* self) { cmd_buff[1] = 0; // No error // TODO(yuriks): Return error from SendSyncRequest is this fails (part of IPC marshalling) cmd_buff[3] = Kernel::g_handle_table.Create(Service::HID::g_shared_mem).MoveFrom(); - cmd_buff[4] = Service::HID::g_event_pad_or_touch_1; - cmd_buff[5] = Service::HID::g_event_pad_or_touch_2; - cmd_buff[6] = Service::HID::g_event_accelerometer; - cmd_buff[7] = Service::HID::g_event_gyroscope; - cmd_buff[8] = Service::HID::g_event_debug_pad; + cmd_buff[4] = Kernel::g_handle_table.Create(Service::HID::g_event_pad_or_touch_1).MoveFrom(); + cmd_buff[5] = Kernel::g_handle_table.Create(Service::HID::g_event_pad_or_touch_2).MoveFrom(); + cmd_buff[6] = Kernel::g_handle_table.Create(Service::HID::g_event_accelerometer).MoveFrom(); + cmd_buff[7] = Kernel::g_handle_table.Create(Service::HID::g_event_gyroscope).MoveFrom(); + cmd_buff[8] = Kernel::g_handle_table.Create(Service::HID::g_event_debug_pad).MoveFrom(); } const Interface::FunctionInfo FunctionTable[] = { -- cgit v1.2.3