summaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
Diffstat (limited to '')
-rw-r--r--src/core/hle/service/nfp/nfp.cpp108
1 files changed, 101 insertions, 7 deletions
diff --git a/src/core/hle/service/nfp/nfp.cpp b/src/core/hle/service/nfp/nfp.cpp
index 2af4465de..2a9f84037 100644
--- a/src/core/hle/service/nfp/nfp.cpp
+++ b/src/core/hle/service/nfp/nfp.cpp
@@ -4,6 +4,8 @@
4 4
5#include "common/logging/log.h" 5#include "common/logging/log.h"
6#include "core/hle/ipc_helpers.h" 6#include "core/hle/ipc_helpers.h"
7#include "core/hle/kernel/event.h"
8#include "core/hle/service/hid/hid.h"
7#include "core/hle/service/nfp/nfp.h" 9#include "core/hle/service/nfp/nfp.h"
8#include "core/hle/service/nfp/nfp_user.h" 10#include "core/hle/service/nfp/nfp_user.h"
9 11
@@ -18,7 +20,7 @@ public:
18 static const FunctionInfo functions[] = { 20 static const FunctionInfo functions[] = {
19 {0, &IUser::Initialize, "Initialize"}, 21 {0, &IUser::Initialize, "Initialize"},
20 {1, nullptr, "Finalize"}, 22 {1, nullptr, "Finalize"},
21 {2, nullptr, "ListDevices"}, 23 {2, &IUser::ListDevices, "ListDevices"},
22 {3, nullptr, "StartDetection"}, 24 {3, nullptr, "StartDetection"},
23 {4, nullptr, "StopDetection"}, 25 {4, nullptr, "StopDetection"},
24 {5, nullptr, "Mount"}, 26 {5, nullptr, "Mount"},
@@ -33,24 +35,116 @@ public:
33 {14, nullptr, "GetRegisterInfo"}, 35 {14, nullptr, "GetRegisterInfo"},
34 {15, nullptr, "GetCommonInfo"}, 36 {15, nullptr, "GetCommonInfo"},
35 {16, nullptr, "GetModelInfo"}, 37 {16, nullptr, "GetModelInfo"},
36 {17, nullptr, "AttachActivateEvent"}, 38 {17, &IUser::AttachActivateEvent, "AttachActivateEvent"},
37 {18, nullptr, "AttachDeactivateEvent"}, 39 {18, &IUser::AttachDeactivateEvent, "AttachDeactivateEvent"},
38 {19, nullptr, "GetState"}, 40 {19, &IUser::GetState, "GetState"},
39 {20, nullptr, "GetDeviceState"}, 41 {20, &IUser::GetDeviceState, "GetDeviceState"},
40 {21, nullptr, "GetNpadId"}, 42 {21, &IUser::GetNpadId, "GetNpadId"},
41 {22, nullptr, "GetApplicationArea2"}, 43 {22, nullptr, "GetApplicationArea2"},
42 {23, nullptr, "AttachAvailabilityChangeEvent"}, 44 {23, &IUser::AttachAvailabilityChangeEvent, "AttachAvailabilityChangeEvent"},
43 {24, nullptr, "RecreateApplicationArea"}, 45 {24, nullptr, "RecreateApplicationArea"},
44 }; 46 };
45 RegisterHandlers(functions); 47 RegisterHandlers(functions);
48
49 activate_event = Kernel::Event::Create(Kernel::ResetType::OneShot, "IUser:ActivateEvent");
50 deactivate_event =
51 Kernel::Event::Create(Kernel::ResetType::OneShot, "IUser:DeactivateEvent");
52 availability_change_event =
53 Kernel::Event::Create(Kernel::ResetType::OneShot, "IUser:AvailabilityChangeEvent");
46 } 54 }
47 55
48private: 56private:
57 enum class State : u32 {
58 NonInitialized = 0,
59 Initialized = 1,
60 };
61
62 enum class DeviceState : u32 {
63 Initialized = 0,
64 };
65
49 void Initialize(Kernel::HLERequestContext& ctx) { 66 void Initialize(Kernel::HLERequestContext& ctx) {
50 NGLOG_WARNING(Service_NFP, "(STUBBED) called"); 67 NGLOG_WARNING(Service_NFP, "(STUBBED) called");
68
69 state = State::Initialized;
70
51 IPC::ResponseBuilder rb{ctx, 2}; 71 IPC::ResponseBuilder rb{ctx, 2};
52 rb.Push(RESULT_SUCCESS); 72 rb.Push(RESULT_SUCCESS);
53 } 73 }
74
75 void ListDevices(Kernel::HLERequestContext& ctx) {
76 IPC::RequestParser rp{ctx};
77 const u32 array_size = rp.Pop<u32>();
78
79 ctx.WriteBuffer(&device_handle, sizeof(device_handle));
80
81 NGLOG_WARNING(Service_NFP, "(STUBBED) called, array_size={}", array_size);
82
83 IPC::ResponseBuilder rb{ctx, 3};
84 rb.Push(RESULT_SUCCESS);
85 rb.Push<u32>(0);
86 }
87
88 void AttachActivateEvent(Kernel::HLERequestContext& ctx) {
89 IPC::RequestParser rp{ctx};
90 const u64 dev_handle = rp.Pop<u64>();
91 NGLOG_WARNING(Service_NFP, "(STUBBED) called, dev_handle=0x{:X}", dev_handle);
92
93 IPC::ResponseBuilder rb{ctx, 2, 1};
94 rb.Push(RESULT_SUCCESS);
95 rb.PushCopyObjects(activate_event);
96 }
97
98 void AttachDeactivateEvent(Kernel::HLERequestContext& ctx) {
99 IPC::RequestParser rp{ctx};
100 const u64 dev_handle = rp.Pop<u64>();
101 NGLOG_WARNING(Service_NFP, "(STUBBED) called, dev_handle=0x{:X}", dev_handle);
102
103 IPC::ResponseBuilder rb{ctx, 2, 1};
104 rb.Push(RESULT_SUCCESS);
105 rb.PushCopyObjects(deactivate_event);
106 }
107
108 void GetState(Kernel::HLERequestContext& ctx) {
109 NGLOG_WARNING(Service_NFP, "(STUBBED) called");
110 IPC::ResponseBuilder rb{ctx, 3};
111 rb.Push(RESULT_SUCCESS);
112 rb.Push<u32>(static_cast<u32>(state));
113 }
114
115 void GetDeviceState(Kernel::HLERequestContext& ctx) {
116 NGLOG_WARNING(Service_NFP, "(STUBBED) called");
117 IPC::ResponseBuilder rb{ctx, 3};
118 rb.Push(RESULT_SUCCESS);
119 rb.Push<u32>(static_cast<u32>(device_state));
120 }
121
122 void GetNpadId(Kernel::HLERequestContext& ctx) {
123 IPC::RequestParser rp{ctx};
124 const u64 dev_handle = rp.Pop<u64>();
125 NGLOG_WARNING(Service_NFP, "(STUBBED) called, dev_handle=0x{:X}", dev_handle);
126 IPC::ResponseBuilder rb{ctx, 3};
127 rb.Push(RESULT_SUCCESS);
128 rb.Push<u32>(npad_id);
129 }
130
131 void AttachAvailabilityChangeEvent(Kernel::HLERequestContext& ctx) {
132 IPC::RequestParser rp{ctx};
133 const u64 dev_handle = rp.Pop<u64>();
134 NGLOG_WARNING(Service_NFP, "(STUBBED) called, dev_handle=0x{:X}", dev_handle);
135
136 IPC::ResponseBuilder rb{ctx, 2, 1};
137 rb.Push(RESULT_SUCCESS);
138 rb.PushCopyObjects(availability_change_event);
139 }
140
141 const u64 device_handle{0xDEAD};
142 const HID::ControllerID npad_id{HID::Controller_Player1};
143 State state{State::NonInitialized};
144 DeviceState device_state{DeviceState::Initialized};
145 Kernel::SharedPtr<Kernel::Event> activate_event;
146 Kernel::SharedPtr<Kernel::Event> deactivate_event;
147 Kernel::SharedPtr<Kernel::Event> availability_change_event;
54}; 148};
55 149
56void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) { 150void Module::Interface::CreateUserInterface(Kernel::HLERequestContext& ctx) {