mirror of
https://github.com/yuzu-emu/yuzu.git
synced 2024-12-26 04:10:06 +00:00
hid: Make Hid service accessible and add GetPressState
This commit is contained in:
parent
abbcc8e61e
commit
621b25b6be
@ -410,6 +410,8 @@ void Controller_NPad::OnUpdate(u8* data, std::size_t data_len) {
|
|||||||
libnx_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
libnx_entry.pad.pad_states.raw = pad_state.pad_states.raw;
|
||||||
libnx_entry.pad.l_stick = pad_state.l_stick;
|
libnx_entry.pad.l_stick = pad_state.l_stick;
|
||||||
libnx_entry.pad.r_stick = pad_state.r_stick;
|
libnx_entry.pad.r_stick = pad_state.r_stick;
|
||||||
|
|
||||||
|
press_state |= static_cast<u32>(pad_state.pad_states.raw);
|
||||||
}
|
}
|
||||||
std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(),
|
std::memcpy(data + NPAD_OFFSET, shared_memory_entries.data(),
|
||||||
shared_memory_entries.size() * sizeof(NPadEntry));
|
shared_memory_entries.size() * sizeof(NPadEntry));
|
||||||
@ -636,6 +638,12 @@ void Controller_NPad::ClearAllControllers() {
|
|||||||
});
|
});
|
||||||
}
|
}
|
||||||
|
|
||||||
|
u32 Controller_NPad::GetPressState() {
|
||||||
|
const auto res = press_state;
|
||||||
|
press_state = 0;
|
||||||
|
return res;
|
||||||
|
}
|
||||||
|
|
||||||
bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const {
|
bool Controller_NPad::IsControllerSupported(NPadControllerType controller) const {
|
||||||
const bool support_handheld =
|
const bool support_handheld =
|
||||||
std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(), NPAD_HANDHELD) !=
|
std::find(supported_npad_id_types.begin(), supported_npad_id_types.end(), NPAD_HANDHELD) !=
|
||||||
|
@ -124,6 +124,10 @@ public:
|
|||||||
void ConnectAllDisconnectedControllers();
|
void ConnectAllDisconnectedControllers();
|
||||||
void ClearAllControllers();
|
void ClearAllControllers();
|
||||||
|
|
||||||
|
// Logical OR for all buttons presses on all controllers
|
||||||
|
// Specifically for cheat engine and other features.
|
||||||
|
u32 GetPressState();
|
||||||
|
|
||||||
static std::size_t NPadIdToIndex(u32 npad_id);
|
static std::size_t NPadIdToIndex(u32 npad_id);
|
||||||
static u32 IndexToNPad(std::size_t index);
|
static u32 IndexToNPad(std::size_t index);
|
||||||
|
|
||||||
@ -292,6 +296,8 @@ private:
|
|||||||
bool is_connected;
|
bool is_connected;
|
||||||
};
|
};
|
||||||
|
|
||||||
|
u32 press_state{};
|
||||||
|
|
||||||
NPadType style{};
|
NPadType style{};
|
||||||
std::array<NPadEntry, 10> shared_memory_entries{};
|
std::array<NPadEntry, 10> shared_memory_entries{};
|
||||||
std::array<
|
std::array<
|
||||||
|
File diff suppressed because it is too large
Load Diff
@ -3,6 +3,15 @@
|
|||||||
// Refer to the license.txt file included.
|
// Refer to the license.txt file included.
|
||||||
|
|
||||||
#pragma once
|
#pragma once
|
||||||
|
#include "core/hle/service/service.h"
|
||||||
|
|
||||||
|
namespace CoreTiming {
|
||||||
|
struct EventType;
|
||||||
|
}
|
||||||
|
|
||||||
|
namespace Kernel {
|
||||||
|
class SharedMemory;
|
||||||
|
}
|
||||||
|
|
||||||
namespace SM {
|
namespace SM {
|
||||||
class ServiceManager;
|
class ServiceManager;
|
||||||
@ -10,6 +19,107 @@ class ServiceManager;
|
|||||||
|
|
||||||
namespace Service::HID {
|
namespace Service::HID {
|
||||||
|
|
||||||
|
class ControllerBase;
|
||||||
|
|
||||||
|
enum class HidController : std::size_t {
|
||||||
|
DebugPad,
|
||||||
|
Touchscreen,
|
||||||
|
Mouse,
|
||||||
|
Keyboard,
|
||||||
|
XPad,
|
||||||
|
Unknown1,
|
||||||
|
Unknown2,
|
||||||
|
Unknown3,
|
||||||
|
SixAxisSensor,
|
||||||
|
NPad,
|
||||||
|
Gesture,
|
||||||
|
|
||||||
|
MaxControllers,
|
||||||
|
};
|
||||||
|
|
||||||
|
class IAppletResource final : public ServiceFramework<IAppletResource> {
|
||||||
|
public:
|
||||||
|
IAppletResource();
|
||||||
|
~IAppletResource() override;
|
||||||
|
|
||||||
|
void ActivateController(HidController controller);
|
||||||
|
void DeactivateController(HidController controller);
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
T& GetController(HidController controller) {
|
||||||
|
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
template <typename T>
|
||||||
|
const T& GetController(HidController controller) const {
|
||||||
|
return static_cast<T&>(*controllers[static_cast<size_t>(controller)]);
|
||||||
|
}
|
||||||
|
|
||||||
|
private:
|
||||||
|
template <typename T>
|
||||||
|
void MakeController(HidController controller) {
|
||||||
|
controllers[static_cast<std::size_t>(controller)] = std::make_unique<T>();
|
||||||
|
}
|
||||||
|
|
||||||
|
void GetSharedMemoryHandle(Kernel::HLERequestContext& ctx);
|
||||||
|
void UpdateControllers(u64 userdata, int cycles_late);
|
||||||
|
|
||||||
|
Kernel::SharedPtr<Kernel::SharedMemory> shared_mem;
|
||||||
|
|
||||||
|
CoreTiming::EventType* pad_update_event;
|
||||||
|
|
||||||
|
std::array<std::unique_ptr<ControllerBase>, static_cast<size_t>(HidController::MaxControllers)>
|
||||||
|
controllers{};
|
||||||
|
};
|
||||||
|
|
||||||
|
class Hid final : public ServiceFramework<Hid> {
|
||||||
|
public:
|
||||||
|
Hid();
|
||||||
|
~Hid() override;
|
||||||
|
|
||||||
|
std::shared_ptr<IAppletResource> GetAppletResource();
|
||||||
|
|
||||||
|
private:
|
||||||
|
void CreateAppletResource(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateXpad(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateDebugPad(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateTouchScreen(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateMouse(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateKeyboard(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateGesture(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateNpadWithRevision(Kernel::HLERequestContext& ctx);
|
||||||
|
void StartSixAxisSensor(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetGyroscopeZeroDriftMode(Kernel::HLERequestContext& ctx);
|
||||||
|
void IsSixAxisSensorAtRest(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
||||||
|
void GetSupportedNpadStyleSet(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetSupportedNpadIdType(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateNpad(Kernel::HLERequestContext& ctx);
|
||||||
|
void AcquireNpadStyleSetUpdateEventHandle(Kernel::HLERequestContext& ctx);
|
||||||
|
void DisconnectNpad(Kernel::HLERequestContext& ctx);
|
||||||
|
void GetPlayerLedPattern(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetNpadJoyHoldType(Kernel::HLERequestContext& ctx);
|
||||||
|
void GetNpadJoyHoldType(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetNpadJoyAssignmentModeSingleByDefault(Kernel::HLERequestContext& ctx);
|
||||||
|
void BeginPermitVibrationSession(Kernel::HLERequestContext& ctx);
|
||||||
|
void EndPermitVibrationSession(Kernel::HLERequestContext& ctx);
|
||||||
|
void SendVibrationValue(Kernel::HLERequestContext& ctx);
|
||||||
|
void SendVibrationValues(Kernel::HLERequestContext& ctx);
|
||||||
|
void GetActualVibrationValue(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetNpadJoyAssignmentModeDual(Kernel::HLERequestContext& ctx);
|
||||||
|
void MergeSingleJoyAsDualJoy(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetNpadHandheldActivationMode(Kernel::HLERequestContext& ctx);
|
||||||
|
void GetVibrationDeviceInfo(Kernel::HLERequestContext& ctx);
|
||||||
|
void CreateActiveVibrationDeviceList(Kernel::HLERequestContext& ctx);
|
||||||
|
void ActivateConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
||||||
|
void StartConsoleSixAxisSensor(Kernel::HLERequestContext& ctx);
|
||||||
|
void StopSixAxisSensor(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetIsPalmaAllConnectable(Kernel::HLERequestContext& ctx);
|
||||||
|
void SetPalmaBoostMode(Kernel::HLERequestContext& ctx);
|
||||||
|
|
||||||
|
std::shared_ptr<IAppletResource> applet_resource;
|
||||||
|
};
|
||||||
|
|
||||||
/// Reload input devices. Used when input configuration changed
|
/// Reload input devices. Used when input configuration changed
|
||||||
void ReloadInputDevices();
|
void ReloadInputDevices();
|
||||||
|
|
||||||
|
Loading…
Reference in New Issue
Block a user