more stuff for plugins

This commit is contained in:
ThirteenAG 2022-12-04 23:46:01 +03:00
parent a349e2b85b
commit 6e03de35cf
2 changed files with 46 additions and 3 deletions

View File

@ -1996,7 +1996,9 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
EMULATOR_DEVCTL__GET_ASPECT_RATIO,
EMULATOR_DEVCTL__GET_SCALE,
EMULATOR_DEVCTL__GET_LTRIGGER,
EMULATOR_DEVCTL__GET_RTRIGGER
EMULATOR_DEVCTL__GET_RTRIGGER,
EMULATOR_DEVCTL__GET_VKEY,
EMULATOR_DEVCTL__GET_MOUSE
};
switch (cmd) {
@ -2066,10 +2068,30 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
}
return 0;
case EMULATOR_DEVCTL__GET_LTRIGGER:
//To-do
if (Memory::IsValidAddress(outPtr)) {
extern float PluginDataLT;
Memory::Write_Float(PluginDataLT, outPtr);
}
return 0;
case EMULATOR_DEVCTL__GET_RTRIGGER:
//To-do
if (Memory::IsValidAddress(outPtr)) {
extern float PluginDataRT;
Memory::Write_Float(PluginDataRT, outPtr);
}
return 0;
case EMULATOR_DEVCTL__GET_VKEY:
if (Memory::IsValidAddress(outPtr)) {
extern std::map<int, uint8_t> PluginDataKeys;
Memory::Write_U8(PluginDataKeys[argAddr], outPtr);
}
return 0;
case EMULATOR_DEVCTL__GET_MOUSE:
if (Memory::IsValidAddress(outPtr)) {
extern float g_mouseDeltaX;
extern float g_mouseDeltaY;
Memory::Write_Float(g_mouseDeltaX, outPtr);
Memory::Write_Float(g_mouseDeltaY, outPtr + 4);
}
return 0;
}

View File

@ -141,6 +141,12 @@
#include <mach-o/dyld.h>
#endif
float PluginDataLT;
float PluginDataRT;
float PluginDataMouseX;
float PluginDataMouseY;
std::map<int, uint8_t> PluginDataKeys;
ScreenManager *screenManager;
std::string config_filename;
@ -1334,7 +1340,13 @@ bool NativeKey(const KeyInput &key) {
#endif
bool retval = false;
if (screenManager)
{
if (key.deviceId == DEVICE_ID_KEYBOARD || key.deviceId == DEVICE_ID_MOUSE)
{
PluginDataKeys[key.keyCode] = (key.flags & KEY_DOWN) ? 1 : 0;
}
retval = screenManager->key(key);
}
return retval;
}
@ -1355,6 +1367,11 @@ bool NativeAxis(const AxisInput &axis) {
if (g_Config.iTiltInputType == TILT_NULL) {
// if tilt events are disabled, then run it through the usual way.
if (screenManager) {
if (axis.axisId == JOYSTICK_AXIS_LTRIGGER)
PluginDataLT = axis.value;
else if (axis.axisId == JOYSTICK_AXIS_RTRIGGER)
PluginDataRT = axis.value;
return screenManager->axis(axis);
} else {
return false;
@ -1430,6 +1447,10 @@ bool NativeAxis(const AxisInput &axis) {
return false;
default:
if (axis.axisId == JOYSTICK_AXIS_LTRIGGER)
PluginDataLT = axis.value;
else if (axis.axisId == JOYSTICK_AXIS_RTRIGGER)
PluginDataRT = axis.value;
// Don't take over completely!
return screenManager->axis(axis);
}