range checks

This commit is contained in:
Sergey P 2023-02-01 13:26:17 +03:00
parent 6ed017ac89
commit 64f1e5ed61
4 changed files with 10 additions and 4 deletions

View file

@ -269,6 +269,8 @@ typedef enum _keycode_t {
NKCODE_EXT_MOTION_LEFT = 1103,
NKCODE_EXT_MOTION_RIGHT = 1104,
NKCODE_EXT_MOTION_FORWARD = 1105,
NKCODE_MAX
} keycode_t;
enum AndroidJoystickAxis {
@ -324,5 +326,6 @@ enum AndroidJoystickAxis {
JOYSTICK_AXIS_ACCELEROMETER_Y = 41,
JOYSTICK_AXIS_ACCELEROMETER_Z = 42,
// The numbers must NOT be changed, only additions are allowed
JOYSTICK_AXIS_MAX = 44
};

View file

@ -29,7 +29,7 @@
#include "Core/HLE/sceKernelModule.h"
namespace HLEPlugins {
std::map<int, float> PluginDataAxis;
float PluginDataAxis[JOYSTICK_AXIS_MAX];
std::map<int, uint8_t> PluginDataKeys;
static bool anyEnabled = false;

View file

@ -17,6 +17,8 @@
#pragma once
#include "Input/KeyCodes.h"
class PointerWrap;
namespace HLEPlugins {
@ -31,6 +33,6 @@ void DoState(PointerWrap &p);
bool HasEnabled();
extern std::map<int, float> PluginDataAxis;
extern float PluginDataAxis[JOYSTICK_AXIS_MAX];
extern std::map<int, uint8_t> PluginDataKeys;
};

View file

@ -74,6 +74,7 @@ extern "C" {
#include "System/Display.h"
// For EMULATOR_DEVCTL__GET_AXIS/VKEY
#include "Core/HLE/Plugins.h"
#include "Input/KeyCodes.h"
static const int ERROR_ERRNO_IO_ERROR = 0x80010005;
static const int ERROR_MEMSTICK_DEVCTL_BAD_PARAMS = 0x80220081;
@ -2070,12 +2071,12 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
}
return 0;
case EMULATOR_DEVCTL__GET_AXIS:
if (Memory::IsValidAddress(outPtr)) {
if (Memory::IsValidAddress(outPtr) && (argAddr >= 0 && argAddr < JOYSTICK_AXIS_MAX)) {
Memory::Write_Float(HLEPlugins::PluginDataAxis[argAddr], outPtr);
}
return 0;
case EMULATOR_DEVCTL__GET_VKEY:
if (Memory::IsValidAddress(outPtr)) {
if (Memory::IsValidAddress(outPtr) && (argAddr >= 0 && argAddr < NKCODE_MAX)) {
Memory::Write_U8(HLEPlugins::PluginDataKeys[argAddr], outPtr);
}
return 0;