mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-04-02 11:01:50 -04:00
Merge pull request #16501 from ThirteenAG/master
Input (inc. mouse and keyboard) api for plugins
This commit is contained in:
commit
6c8653762d
7 changed files with 38 additions and 7 deletions
|
@ -275,6 +275,8 @@ typedef enum _keycode_t {
|
|||
NKCODE_EXT_ROTATION_DOWN = 1112,
|
||||
NKCODE_EXT_ROTATION_LEFT = 1113,
|
||||
NKCODE_EXT_ROTATION_RIGHT = 1114,
|
||||
|
||||
NKCODE_MAX
|
||||
} keycode_t;
|
||||
|
||||
enum AndroidJoystickAxis {
|
||||
|
@ -330,5 +332,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
|
||||
};
|
||||
|
|
|
@ -29,6 +29,8 @@
|
|||
#include "Core/HLE/sceKernelModule.h"
|
||||
|
||||
namespace HLEPlugins {
|
||||
float PluginDataAxis[JOYSTICK_AXIS_MAX];
|
||||
std::map<int, uint8_t> PluginDataKeys;
|
||||
|
||||
static bool anyEnabled = false;
|
||||
static std::vector<std::string> prxPlugins;
|
||||
|
|
|
@ -17,6 +17,8 @@
|
|||
|
||||
#pragma once
|
||||
|
||||
#include "Input/KeyCodes.h"
|
||||
|
||||
class PointerWrap;
|
||||
|
||||
namespace HLEPlugins {
|
||||
|
@ -31,4 +33,6 @@ void DoState(PointerWrap &p);
|
|||
|
||||
bool HasEnabled();
|
||||
|
||||
extern float PluginDataAxis[JOYSTICK_AXIS_MAX];
|
||||
extern std::map<int, uint8_t> PluginDataKeys;
|
||||
};
|
||||
|
|
|
@ -71,7 +71,10 @@ extern "C" {
|
|||
// For headless screenshots.
|
||||
#include "Core/HLE/sceDisplay.h"
|
||||
// For EMULATOR_DEVCTL__GET_SCALE
|
||||
#include <System/Display.h>
|
||||
#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;
|
||||
|
@ -1997,8 +2000,8 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
EMULATOR_DEVCTL__TOGGLE_FASTFORWARD = 0x30,
|
||||
EMULATOR_DEVCTL__GET_ASPECT_RATIO,
|
||||
EMULATOR_DEVCTL__GET_SCALE,
|
||||
EMULATOR_DEVCTL__GET_LTRIGGER,
|
||||
EMULATOR_DEVCTL__GET_RTRIGGER
|
||||
EMULATOR_DEVCTL__GET_AXIS,
|
||||
EMULATOR_DEVCTL__GET_VKEY,
|
||||
};
|
||||
|
||||
switch (cmd) {
|
||||
|
@ -2067,11 +2070,15 @@ static u32 sceIoDevctl(const char *name, int cmd, u32 argAddr, int argLen, u32 o
|
|||
Memory::Write_Float(scale, outPtr);
|
||||
}
|
||||
return 0;
|
||||
case EMULATOR_DEVCTL__GET_LTRIGGER:
|
||||
//To-do
|
||||
case EMULATOR_DEVCTL__GET_AXIS:
|
||||
if (Memory::IsValidAddress(outPtr) && (argAddr >= 0 && argAddr < JOYSTICK_AXIS_MAX)) {
|
||||
Memory::Write_Float(HLEPlugins::PluginDataAxis[argAddr], outPtr);
|
||||
}
|
||||
return 0;
|
||||
case EMULATOR_DEVCTL__GET_RTRIGGER:
|
||||
//To-do
|
||||
case EMULATOR_DEVCTL__GET_VKEY:
|
||||
if (Memory::IsValidAddress(outPtr) && (argAddr >= 0 && argAddr < NKCODE_MAX)) {
|
||||
Memory::Write_U8(HLEPlugins::PluginDataKeys[argAddr], outPtr);
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
|
|
|
@ -145,6 +145,8 @@
|
|||
#include "UI/DarwinMemoryStickManager.h"
|
||||
#endif
|
||||
|
||||
#include <Core/HLE/Plugins.h>
|
||||
|
||||
ScreenManager *screenManager;
|
||||
std::string config_filename;
|
||||
|
||||
|
@ -1341,7 +1343,10 @@ bool NativeKey(const KeyInput &key) {
|
|||
#endif
|
||||
bool retval = false;
|
||||
if (screenManager)
|
||||
{
|
||||
HLEPlugins::PluginDataKeys[key.keyCode] = (key.flags & KEY_DOWN) ? 1 : 0;
|
||||
retval = screenManager->key(key);
|
||||
}
|
||||
return retval;
|
||||
}
|
||||
|
||||
|
@ -1361,6 +1366,7 @@ void NativeAxis(const AxisInput &axis) {
|
|||
// only handle tilt events if tilt is enabled.
|
||||
if (g_Config.iTiltInputType == TILT_NULL) {
|
||||
// if tilt events are disabled, then run it through the usual way.
|
||||
HLEPlugins::PluginDataAxis[axis.axisId] = axis.value;
|
||||
screenManager->axis(axis);
|
||||
return;
|
||||
}
|
||||
|
@ -1434,6 +1440,7 @@ void NativeAxis(const AxisInput &axis) {
|
|||
return;
|
||||
|
||||
default:
|
||||
HLEPlugins::PluginDataAxis[axis.axisId] = axis.value;
|
||||
// Don't take over completely!
|
||||
screenManager->axis(axis);
|
||||
return;
|
||||
|
|
|
@ -29,6 +29,7 @@
|
|||
#include "Common/CommonFuncs.h"
|
||||
#include "Common/SysError.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/HLE/Plugins.h"
|
||||
|
||||
#ifndef HID_USAGE_PAGE_GENERIC
|
||||
#define HID_USAGE_PAGE_GENERIC ((USHORT) 0x01)
|
||||
|
@ -320,6 +321,9 @@ namespace WindowsRawInput {
|
|||
g_mouseDeltaX += raw->data.mouse.lLastX;
|
||||
g_mouseDeltaY += raw->data.mouse.lLastY;
|
||||
|
||||
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_X] = g_mouseDeltaX;
|
||||
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = g_mouseDeltaY;
|
||||
|
||||
const int rawInputDownID[5] = {
|
||||
RI_MOUSE_LEFT_BUTTON_DOWN,
|
||||
RI_MOUSE_RIGHT_BUTTON_DOWN,
|
||||
|
|
|
@ -71,6 +71,7 @@
|
|||
|
||||
#include "Windows/main.h"
|
||||
#include "UI/OnScreenDisplay.h"
|
||||
#include <Core/HLE/Plugins.h>
|
||||
|
||||
float g_mouseDeltaX = 0;
|
||||
float g_mouseDeltaY = 0;
|
||||
|
@ -258,6 +259,9 @@ void WindowsHost::PollControllers() {
|
|||
|
||||
g_mouseDeltaX *= g_Config.fMouseSmoothing;
|
||||
g_mouseDeltaY *= g_Config.fMouseSmoothing;
|
||||
|
||||
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_X] = g_mouseDeltaX;
|
||||
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = g_mouseDeltaY;
|
||||
}
|
||||
|
||||
void WindowsHost::BootDone() {
|
||||
|
|
Loading…
Add table
Reference in a new issue