summaryrefslogtreecommitdiffstats
path: root/src/core/hle/service/hid
diff options
context:
space:
mode:
authorSubv <subv2112@gmail.com>2015-02-27 03:13:08 +0100
committerSubv <subv2112@gmail.com>2015-03-04 03:48:08 +0100
commit83a8975cb89b908b4737d647a210c19775f25ed7 (patch)
tree53fd0e37dcab9c3a5328338273315b159381d949 /src/core/hle/service/hid
parentMerge pull request #622 from Subv/titles (diff)
downloadyuzu-83a8975cb89b908b4737d647a210c19775f25ed7.tar
yuzu-83a8975cb89b908b4737d647a210c19775f25ed7.tar.gz
yuzu-83a8975cb89b908b4737d647a210c19775f25ed7.tar.bz2
yuzu-83a8975cb89b908b4737d647a210c19775f25ed7.tar.lz
yuzu-83a8975cb89b908b4737d647a210c19775f25ed7.tar.xz
yuzu-83a8975cb89b908b4737d647a210c19775f25ed7.tar.zst
yuzu-83a8975cb89b908b4737d647a210c19775f25ed7.zip
Diffstat (limited to 'src/core/hle/service/hid')
-rw-r--r--src/core/hle/service/hid/hid.cpp32
-rw-r--r--src/core/hle/service/hid/hid.h17
-rw-r--r--src/core/hle/service/hid/hid_spvr.cpp21
-rw-r--r--src/core/hle/service/hid/hid_spvr.h13
-rw-r--r--src/core/hle/service/hid/hid_user.cpp58
-rw-r--r--src/core/hle/service/hid/hid_user.h15
6 files changed, 75 insertions, 81 deletions
diff --git a/src/core/hle/service/hid/hid.cpp b/src/core/hle/service/hid/hid.cpp
index 7cb01729e..e0689be2e 100644
--- a/src/core/hle/service/hid/hid.cpp
+++ b/src/core/hle/service/hid/hid.cpp
@@ -2,7 +2,10 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included.
+#include "core/hle/service/service.h"
#include "core/hle/service/hid/hid.h"
+#include "core/hle/service/hid/hid_spvr.h"
+#include "core/hle/service/hid/hid_user.h"
#include "core/arm/arm_interface.h"
#include "core/hle/kernel/event.h"
@@ -35,6 +38,19 @@ static inline PadData* GetPadData() {
return reinterpret_cast<PadData*>(g_shared_mem->GetPointer().ValueOr(nullptr));
}
+// 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
+
/**
* Circle Pad from keys.
*
@@ -121,9 +137,25 @@ void PadUpdateComplete() {
g_event_pad_or_touch_2->Signal();
}
+void GetIPCHandles(Service::Interface* self) {
+ u32* cmd_buff = Kernel::GetCommandBuffer();
+
+ 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] = 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();
+}
+
void HIDInit() {
using namespace Kernel;
+ AddService(new HID_U_Interface);
+ AddService(new HID_SPVR_Interface);
+
g_shared_mem = SharedMemory::Create("HID:SharedMem");
// Create event handles
diff --git a/src/core/hle/service/hid/hid.h b/src/core/hle/service/hid/hid.h
index fc628f36a..9c6e86f77 100644
--- a/src/core/hle/service/hid/hid.h
+++ b/src/core/hle/service/hid/hid.h
@@ -7,6 +7,7 @@
#include <array>
#include "core/hle/kernel/kernel.h"
+#include "core/hle/service/service.h"
#include "common/bit_field.h"
namespace Kernel {
@@ -123,6 +124,22 @@ const PadState PAD_CIRCLE_LEFT = {{1u << 29}};
const PadState PAD_CIRCLE_UP = {{1u << 30}};
const PadState PAD_CIRCLE_DOWN = {{1u << 31}};
+/**
+ * HID::GetIPCHandles service function
+ * Inputs:
+ * None
+ * Outputs:
+ * 1 : Result of function, 0 on success, otherwise error code
+ * 2 : Unused
+ * 3 : Handle to HID_User shared memory
+ * 4 : Event signaled by HID_User
+ * 5 : Event signaled by HID_User
+ * 6 : Event signaled by HID_User
+ * 7 : Gyroscope event
+ * 8 : Event signaled by HID_User
+ */
+void GetIPCHandles(Interface* self);
+
// Methods for updating the HID module's state
void PadButtonPress(const PadState& pad_state);
void PadButtonRelease(const PadState& pad_state);
diff --git a/src/core/hle/service/hid/hid_spvr.cpp b/src/core/hle/service/hid/hid_spvr.cpp
index 8f06b224d..790dcabbf 100644
--- a/src/core/hle/service/hid/hid_spvr.cpp
+++ b/src/core/hle/service/hid/hid_spvr.cpp
@@ -3,19 +3,14 @@
// Refer to the license.txt file included.
#include "core/hle/hle.h"
+#include "core/hle/service/hid/hid.h"
#include "core/hle/service/hid/hid_spvr.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Namespace HID_SPVR
-
-namespace HID_User {
- extern void GetIPCHandles(Service::Interface* self);
-}
-
-namespace HID_SPVR {
+namespace Service {
+namespace HID {
const Interface::FunctionInfo FunctionTable[] = {
- {0x000A0000, HID_User::GetIPCHandles, "GetIPCHandles"},
+ {0x000A0000, GetIPCHandles, "GetIPCHandles"},
{0x000B0000, nullptr, "StartAnalogStickCalibration"},
{0x000E0000, nullptr, "GetAnalogStickCalibrateParam"},
{0x00110000, nullptr, "EnableAccelerometer"},
@@ -27,11 +22,9 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00170000, nullptr, "GetSoundVolume"},
};
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Interface class
-
-Interface::Interface() {
+HID_SPVR_Interface::HID_SPVR_Interface() {
Register(FunctionTable);
}
-} // namespace
+} // namespace HID
+} // namespace Service
diff --git a/src/core/hle/service/hid/hid_spvr.h b/src/core/hle/service/hid/hid_spvr.h
index 53ddc8569..ba61583d2 100644
--- a/src/core/hle/service/hid/hid_spvr.h
+++ b/src/core/hle/service/hid/hid_spvr.h
@@ -6,18 +6,17 @@
#include "core/hle/service/service.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Namespace HID_SPVR
+namespace Service {
+namespace HID {
-namespace HID_SPVR {
-
-class Interface : public Service::Interface {
+class HID_SPVR_Interface : public Service::Interface {
public:
- Interface();
+ HID_SPVR_Interface();
std::string GetPortName() const override {
return "hid:SPVR";
}
};
-} // namespace
+} // namespace HID
+} // namespace Service \ No newline at end of file
diff --git a/src/core/hle/service/hid/hid_user.cpp b/src/core/hle/service/hid/hid_user.cpp
index 7f464705f..1d0accefe 100644
--- a/src/core/hle/service/hid/hid_user.cpp
+++ b/src/core/hle/service/hid/hid_user.cpp
@@ -6,54 +6,10 @@
#include "core/hle/kernel/event.h"
#include "core/hle/kernel/shared_memory.h"
#include "core/hle/service/hid/hid.h"
-#include "hid_user.h"
+#include "core/hle/service/hid/hid_user.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Namespace HID_User
-
-namespace HID_User {
-
-
-// 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
-
-
-/**
- * HID_User::GetIPCHandles service function
- * Inputs:
- * None
- * Outputs:
- * 1 : Result of function, 0 on success, otherwise error code
- * 2 : Unused
- * 3 : Handle to HID_User shared memory
- * 4 : Event signaled by HID_User
- * 5 : Event signaled by HID_User
- * 6 : Event signaled by HID_User
- * 7 : Gyroscope event
- * 8 : Event signaled by HID_User
- */
-void GetIPCHandles(Service::Interface* self) {
- u32* cmd_buff = Kernel::GetCommandBuffer();
-
- 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] = 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();
-}
+namespace Service {
+namespace HID {
const Interface::FunctionInfo FunctionTable[] = {
{0x000A0000, GetIPCHandles, "GetIPCHandles"},
@@ -66,11 +22,9 @@ const Interface::FunctionInfo FunctionTable[] = {
{0x00170000, nullptr, "GetSoundVolume"},
};
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Interface class
-
-Interface::Interface() {
+HID_U_Interface::HID_U_Interface() {
Register(FunctionTable);
}
-} // namespace
+} // namespace HID
+} // namespace Service
diff --git a/src/core/hle/service/hid/hid_user.h b/src/core/hle/service/hid/hid_user.h
index 1d9929e67..0eeec2c25 100644
--- a/src/core/hle/service/hid/hid_user.h
+++ b/src/core/hle/service/hid/hid_user.h
@@ -6,24 +6,23 @@
#include "core/hle/service/service.h"
-////////////////////////////////////////////////////////////////////////////////////////////////////
-// Namespace HID_User
-
// This service is used for interfacing to physical user controls.
// Uses include game pad controls, touchscreen, accelerometers, gyroscopes, and debug pad.
-namespace HID_User {
-
+namespace Service {
+namespace HID {
+
/**
* HID service interface.
*/
-class Interface : public Service::Interface {
+class HID_U_Interface : public Service::Interface {
public:
- Interface();
+ HID_U_Interface();
std::string GetPortName() const override {
return "hid:USER";
}
};
-} // namespace
+} // namespace HID
+} // namespace Service \ No newline at end of file