Files
AnyPS5/core/libs/tests/GuestPad.cpp
T
Adrià FranchandClaude 621c8bea23 feat(libScePad): implement scePadGetHandle and the embedded mic vibration option
scePadOpen now records that the pad is open and scePadClose clears it;
scePadGetHandle returns the handle for a port scePadOpen accepts while
the pad is open, and DEVICE_NO_HANDLE otherwise. No embedded microphone
is emulated, so the option that weakens trigger vibration while it is
in use is accepted with no effect.

Co-Authored-By: Claude <noreply@anthropic.com>
2026-10-01 19:57:32 +02:00

33 lines
1.3 KiB
C++

#include "prx/libScePad/include/Pad.hpp"
#include "prx/libc/include/general/VabiMacros.hpp"
#include <cstdlib>
extern "C" {
int APS5_VABI scePadOpen_nid_postfix(int, int, int, const void*);
int APS5_VABI scePadClose_nid_postfix(int);
int APS5_VABI scePadGetHandle(int, int, int);
int APS5_VABI scePadSetVibrationTriggerEffectWeakWhileEmbeddedMicInUse(bool);
}
static void Require(bool value) { if (!value) std::abort(); }
int main() {
constexpr int noHandle = static_cast<int>(0x80920008);
constexpr int user = 0x10000000;
Require(scePadGetHandle(user, 0, 0) == noHandle);
Require(scePadOpen_nid_postfix(user, 1, 0, nullptr) == PAD_ERROR_INVALID_ARG);
Require(scePadOpen_nid_postfix(user, 0, 1, nullptr) == PAD_ERROR_INVALID_ARG);
Require(scePadGetHandle(user, 0, 0) == noHandle);
const int handle = scePadOpen_nid_postfix(user, 0, 0, nullptr);
Require(handle > 0);
Require(scePadGetHandle(user, 0, 0) == handle);
Require(scePadGetHandle(user, 2, 0) == handle);
Require(scePadGetHandle(0xff, 16, 0) == handle);
Require(scePadGetHandle(user, 16, 0) == noHandle);
Require(scePadGetHandle(user, 0, 1) == noHandle);
Require(scePadClose_nid_postfix(handle) == 0);
Require(scePadGetHandle(user, 0, 0) == noHandle);
Require(scePadSetVibrationTriggerEffectWeakWhileEmbeddedMicInUse(true) == 0);
}