Merge pull request #890 from alfalfa-star/fix/pad-read-state-invalid-handle
fix(pad): return INVALID_HANDLE from scePadReadState for an unknown handle
This commit is contained in:
commit
df247280db
|
|
@ -150,7 +150,7 @@ int APS5_VABI scePadRead_nid_postfix(int handle, PadData* data, int num) {
|
|||
}
|
||||
|
||||
int APS5_VABI scePadReadState(int handle, PadData* data) {
|
||||
if (handle != 1) APS5_INVALID_ARG_EX;
|
||||
if (handle != PAD_HANDLE) return PAD_ERROR_INVALID_HANDLE;
|
||||
if (data == nullptr) APS5_INVALID_ARG_EX;
|
||||
|
||||
*data = Pad::ReadState();
|
||||
|
|
|
|||
|
|
@ -12,6 +12,8 @@ int APS5_VABI scePadClose_nid_postfix(int);
|
|||
int APS5_VABI scePadGetHandle(int, int, int);
|
||||
int APS5_VABI scePadSetVibrationTriggerEffectWeakWhileEmbeddedMicInUse(bool);
|
||||
int APS5_VABI scePadInit_nid_postfix(void);
|
||||
int APS5_VABI scePadRead_nid_postfix(int, PadData*, int);
|
||||
int APS5_VABI scePadReadState(int, PadData*);
|
||||
int APS5_VABI scePadSetTiltCorrectionState(int, bool);
|
||||
int APS5_VABI scePadResetOrientation(int);
|
||||
int APS5_VABI scePadSetAngularVelocityDeadbandState(int, bool);
|
||||
|
|
@ -57,6 +59,14 @@ static void CheckTouchContact() {
|
|||
Pad::ReadState();
|
||||
}
|
||||
|
||||
static void CheckReadStateHandle(int handle) {
|
||||
PadData data{};
|
||||
Require(scePadReadState(0, &data) == PAD_ERROR_INVALID_HANDLE);
|
||||
Require(scePadReadState(handle + 1, &data) == PAD_ERROR_INVALID_HANDLE);
|
||||
Require(scePadRead_nid_postfix(0, &data, 1) == PAD_ERROR_INVALID_HANDLE);
|
||||
Require(scePadReadState(handle, &data) == PAD_OK);
|
||||
}
|
||||
|
||||
int main() {
|
||||
constexpr int noHandle = static_cast<int>(0x80920008);
|
||||
constexpr int user = 0x10000000;
|
||||
|
|
@ -71,6 +81,7 @@ int main() {
|
|||
Require(scePadGetHandle(user, 2, 0) == handle);
|
||||
CheckTiltCorrection(handle);
|
||||
CheckTouchContact();
|
||||
CheckReadStateHandle(handle);
|
||||
Require(scePadGetHandle(0xff, 16, 0) == handle);
|
||||
Require(scePadGetHandle(user, 16, 0) == noHandle);
|
||||
Require(scePadGetHandle(user, 0, 1) == noHandle);
|
||||
|
|
|
|||
Loading…
Reference in New Issue