Services: Moved the PTM and APT services to their own folder
This coincidentally fixes an issue about the PTM service failing to create its SharedExtSaveData archive due to the FS service not being initialized by the time the creating code runs. Ideally I'd like to move each process to its own folder, and have a single file per process that registers the service classes, which would be in their own files inside that folder. Then each service class would just call functions from the process to complete the commands.
This commit is contained in:
parent
44f46254dc
commit
83a8975cb8
40 changed files with 1202 additions and 1110 deletions
|
@ -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
|
||||
|
|
|
@ -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);
|
||||
|
|
|
@ -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
|
||||
|
|
|
@ -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
|
|
@ -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
|
||||
|
|
|
@ -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
|
Loading…
Add table
Add a link
Reference in a new issue