mirror of
https://github.com/hrydgard/ppsspp.git
synced 2025-02-15 11:48:33 +00:00
Preliminary relative mouse mapping. Disabled because it breaks the control mapping UI currently.
Needs tweaking.
This commit is contained in:
parent
16aa636b17
commit
22a05c5e38
@ -424,7 +424,9 @@ const KeyMap_IntStrPair axis_names[] = {
|
||||
{JOYSTICK_AXIS_GAS, "Gas"},
|
||||
{JOYSTICK_AXIS_BRAKE, "Brake"},
|
||||
{JOYSTICK_AXIS_DISTANCE, "Distance"},
|
||||
{JOYSTICK_AXIS_TILT, "Tilt"}
|
||||
{JOYSTICK_AXIS_TILT, "Tilt"},
|
||||
{JOYSTICK_AXIS_MOUSE_REL_X, "MouseDX"},
|
||||
{JOYSTICK_AXIS_MOUSE_REL_Y, "MouseDY"},
|
||||
};
|
||||
|
||||
static std::string unknown_key_name = "??";
|
||||
|
@ -15,6 +15,12 @@
|
||||
// Official git repository and contact information can be found at
|
||||
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
||||
|
||||
#include <algorithm>
|
||||
|
||||
#include "base/NativeApp.h"
|
||||
#include "input/input_state.h"
|
||||
#include "input/keycodes.h"
|
||||
|
||||
#include "Core/Core.h"
|
||||
#include "Core/Config.h"
|
||||
#include "Core/CoreParameter.h"
|
||||
@ -42,6 +48,9 @@
|
||||
|
||||
static PMixer *curMixer;
|
||||
|
||||
float mouseDeltaX = 0;
|
||||
float mouseDeltaY = 0;
|
||||
|
||||
int MyMix(short *buffer, int numSamples, int bits, int rate, int channels)
|
||||
{
|
||||
if (curMixer && !Core_IsStepping())
|
||||
@ -62,6 +71,8 @@ WindowsHost::WindowsHost(HWND mainWindow, HWND displayWindow)
|
||||
{
|
||||
mainWindow_ = mainWindow;
|
||||
displayWindow_ = displayWindow;
|
||||
mouseDeltaX = 0;
|
||||
mouseDeltaY = 0;
|
||||
|
||||
#define PUSH_BACK(Cls) do { list.push_back(std::shared_ptr<InputDevice>(new Cls())); } while (0)
|
||||
|
||||
@ -172,6 +183,24 @@ void WindowsHost::PollControllers(InputState &input_state)
|
||||
if (device->UpdateState(input_state) == InputDevice::UPDATESTATE_SKIP_PAD)
|
||||
doPad = false;
|
||||
}
|
||||
|
||||
mouseDeltaX *= 0.9f;
|
||||
mouseDeltaY *= 0.9f;
|
||||
|
||||
// TODO: Tweak!
|
||||
float mx = std::max(-1.0f, std::min(1.0f, mouseDeltaX * 0.01f));
|
||||
float my = std::max(-1.0f, std::min(1.0f, mouseDeltaY * 0.01f));
|
||||
AxisInput axisX, axisY;
|
||||
axisX.axisId = JOYSTICK_AXIS_MOUSE_REL_X;
|
||||
axisX.deviceId = DEVICE_ID_MOUSE;
|
||||
axisX.value = mx;
|
||||
axisY.axisId = JOYSTICK_AXIS_MOUSE_REL_Y;
|
||||
axisY.deviceId = DEVICE_ID_MOUSE;
|
||||
axisY.value = my;
|
||||
|
||||
// Disabled for now as it makes the mapping dialog unusable!
|
||||
//if (fabsf(mx) > 0.1f) NativeAxis(axisX);
|
||||
//if (fabsf(my) > 0.1f) NativeAxis(axisY);
|
||||
}
|
||||
|
||||
void WindowsHost::BootDone()
|
||||
|
@ -21,6 +21,9 @@
|
||||
#include <list>
|
||||
#include <memory>
|
||||
|
||||
extern float mouseDeltaX;
|
||||
extern float mouseDeltaY;
|
||||
|
||||
class WindowsHost : public Host
|
||||
{
|
||||
public:
|
||||
|
@ -80,6 +80,13 @@ extern InputState input_state;
|
||||
#define CURSORUPDATE_INTERVAL_MS 50
|
||||
#define CURSORUPDATE_MOVE_TIMESPAN_MS 500
|
||||
|
||||
#ifndef HID_USAGE_PAGE_GENERIC
|
||||
#define HID_USAGE_PAGE_GENERIC ((USHORT) 0x01)
|
||||
#endif
|
||||
#ifndef HID_USAGE_GENERIC_MOUSE
|
||||
#define HID_USAGE_GENERIC_MOUSE ((USHORT) 0x02)
|
||||
#endif
|
||||
|
||||
namespace MainWindow
|
||||
{
|
||||
HWND hwndMain;
|
||||
@ -349,12 +356,17 @@ namespace MainWindow
|
||||
RegisterTouchWindow(hwndDisplay, TWF_WANTPALM);
|
||||
#endif
|
||||
|
||||
RAWINPUTDEVICE keyboard;
|
||||
memset(&keyboard, 0, sizeof(keyboard));
|
||||
keyboard.usUsagePage = 1;
|
||||
keyboard.usUsage = 6;
|
||||
keyboard.dwFlags = 0;
|
||||
RegisterRawInputDevices(&keyboard, 1, sizeof(RAWINPUTDEVICE));
|
||||
RAWINPUTDEVICE dev[2];
|
||||
memset(dev, 0, sizeof(dev));
|
||||
|
||||
dev[0].usUsagePage = 1;
|
||||
dev[0].usUsage = 6;
|
||||
dev[0].dwFlags = 0;
|
||||
|
||||
dev[1].usUsagePage = HID_USAGE_PAGE_GENERIC;
|
||||
dev[1].usUsage = HID_USAGE_GENERIC_MOUSE;
|
||||
dev[1].dwFlags = 0;
|
||||
RegisterRawInputDevices(dev, 2, sizeof(RAWINPUTDEVICE));
|
||||
|
||||
SetFocus(hwndDisplay);
|
||||
|
||||
@ -1057,7 +1069,6 @@ namespace MainWindow
|
||||
}
|
||||
GetRawInputData((HRAWINPUT)lParam, RID_INPUT, rawInputBuffer, &dwSize, sizeof(RAWINPUTHEADER));
|
||||
RAWINPUT* raw = (RAWINPUT*)rawInputBuffer;
|
||||
|
||||
if (raw->header.dwType == RIM_TYPEKEYBOARD) {
|
||||
KeyInput key;
|
||||
key.deviceId = DEVICE_ID_KEYBOARD;
|
||||
@ -1074,6 +1085,12 @@ namespace MainWindow
|
||||
NativeKey(key);
|
||||
}
|
||||
}
|
||||
} else if (raw->header.dwType == RIM_TYPEMOUSE) {
|
||||
mouseDeltaX += raw->data.mouse.lLastX;
|
||||
mouseDeltaY += raw->data.mouse.lLastY;
|
||||
|
||||
// TODO : Smooth and translate to an axis every frame.
|
||||
// NativeAxis()
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
|
2
native
2
native
@ -1 +1 @@
|
||||
Subproject commit 46f7415bc99f89c508dd07aa02ac4452a7281465
|
||||
Subproject commit 76d0d5ceb38b6c50225a82501e88f96e503b2ee9
|
Loading…
x
Reference in New Issue
Block a user