mirror of
https://github.com/libretro/ppsspp.git
synced 2025-01-29 12:52:34 +00:00
Remove legacy input state usage on Windows.
This commit is contained in:
parent
255c726c1e
commit
14b1dac826
@ -96,7 +96,6 @@ struct VerySleepy_AddrInfo {
|
||||
|
||||
static RECT g_normalRC = {0};
|
||||
static std::wstring windowTitle;
|
||||
extern InputState input_state;
|
||||
extern ScreenManager *screenManager;
|
||||
|
||||
#define TIMER_CURSORUPDATE 1
|
||||
@ -538,27 +537,23 @@ namespace MainWindow
|
||||
// Then never erase, let the OpenGL drawing take care of everything.
|
||||
return 1;
|
||||
|
||||
// Poor man's touch - mouse input. We send the data both as an input_state pointer,
|
||||
// and as asynchronous touch events for minimal latency.
|
||||
// Poor man's touch - mouse input. We send the data asynchronous touch events for minimal latency.
|
||||
case WM_LBUTTONDOWN:
|
||||
if (!touchHandler.hasTouch() ||
|
||||
(GetMessageExtraInfo() & MOUSEEVENTF_MASK_PLUS_PENTOUCH) != MOUSEEVENTF_FROMTOUCH_NOPEN)
|
||||
{
|
||||
// Hack: Take the opportunity to show the cursor.
|
||||
mouseButtonDown = true;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(input_state.lock);
|
||||
input_state.pointer_down[0] = true;
|
||||
|
||||
input_state.pointer_x[0] = GET_X_LPARAM(lParam) * g_dpi_scale;
|
||||
input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * g_dpi_scale;
|
||||
}
|
||||
float x = GET_X_LPARAM(lParam) * g_dpi_scale;
|
||||
float y = GET_Y_LPARAM(lParam) * g_dpi_scale;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_DOWN;
|
||||
touch.x = input_state.pointer_x[0];
|
||||
touch.y = input_state.pointer_y[0];
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
SetCapture(hWnd);
|
||||
|
||||
@ -591,18 +586,16 @@ namespace MainWindow
|
||||
prevCursorX = cursorX;
|
||||
prevCursorY = cursorY;
|
||||
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(input_state.lock);
|
||||
input_state.pointer_x[0] = GET_X_LPARAM(lParam) * g_dpi_scale;
|
||||
input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * g_dpi_scale;
|
||||
}
|
||||
float x = GET_X_LPARAM(lParam) * g_dpi_scale;
|
||||
float y = GET_Y_LPARAM(lParam) * g_dpi_scale;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
if (wParam & MK_LBUTTON) {
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_MOVE;
|
||||
touch.x = input_state.pointer_x[0];
|
||||
touch.y = input_state.pointer_y[0];
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
}
|
||||
}
|
||||
@ -614,17 +607,16 @@ namespace MainWindow
|
||||
{
|
||||
// Hack: Take the opportunity to hide the cursor.
|
||||
mouseButtonDown = false;
|
||||
{
|
||||
std::lock_guard<std::mutex> guard(input_state.lock);
|
||||
input_state.pointer_down[0] = false;
|
||||
input_state.pointer_x[0] = GET_X_LPARAM(lParam) * g_dpi_scale;
|
||||
input_state.pointer_y[0] = GET_Y_LPARAM(lParam) * g_dpi_scale;
|
||||
}
|
||||
|
||||
float x = GET_X_LPARAM(lParam) * g_dpi_scale;
|
||||
float y = GET_Y_LPARAM(lParam) * g_dpi_scale;
|
||||
WindowsRawInput::SetMousePos(x, y);
|
||||
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_UP;
|
||||
touch.x = input_state.pointer_x[0];
|
||||
touch.y = input_state.pointer_y[0];
|
||||
touch.x = x;
|
||||
touch.y = y;
|
||||
NativeTouch(touch);
|
||||
ReleaseCapture();
|
||||
}
|
||||
|
@ -18,11 +18,11 @@
|
||||
#include <set>
|
||||
#include <algorithm>
|
||||
#include <vector>
|
||||
#include "base/NativeApp.h"
|
||||
|
||||
#include "base/NativeApp.h"
|
||||
#include "base/display.h"
|
||||
#include "Common/Log.h"
|
||||
#include "input/input_state.h"
|
||||
#include "Common/Log.h"
|
||||
#include "Windows/RawInput.h"
|
||||
#include "Windows/KeyboardDevice.h"
|
||||
#include "Windows/MainWindow.h"
|
||||
@ -55,8 +55,6 @@
|
||||
#define HID_USAGE_GENERIC_MULTIAXIS ((USHORT) 0x07)
|
||||
#endif
|
||||
|
||||
extern InputState input_state;
|
||||
|
||||
namespace WindowsRawInput {
|
||||
static std::set<int> keyboardKeysDown;
|
||||
static void *rawInputBuffer;
|
||||
@ -64,6 +62,8 @@ namespace WindowsRawInput {
|
||||
static bool menuActive;
|
||||
static bool focused = true;
|
||||
static bool mouseRightDown = false;
|
||||
static float mouseX = 0.0f;
|
||||
static float mouseY = 0.0f;
|
||||
|
||||
void Init() {
|
||||
RAWINPUTDEVICE dev[3];
|
||||
@ -197,8 +197,8 @@ namespace WindowsRawInput {
|
||||
TouchInput touch;
|
||||
touch.id = 0;
|
||||
touch.flags = TOUCH_MOVE;
|
||||
touch.x = input_state.pointer_x[0];
|
||||
touch.y = input_state.pointer_y[0];
|
||||
touch.x = mouseX;
|
||||
touch.y = mouseY;
|
||||
|
||||
KeyInput key;
|
||||
key.deviceId = DEVICE_ID_MOUSE;
|
||||
@ -273,6 +273,11 @@ namespace WindowsRawInput {
|
||||
return DefWindowProc(hWnd, WM_INPUT, wParam, lParam);
|
||||
}
|
||||
|
||||
void SetMousePos(float x, float y) {
|
||||
mouseX = x;
|
||||
mouseY = y;
|
||||
}
|
||||
|
||||
void GainFocus() {
|
||||
focused = true;
|
||||
}
|
||||
@ -299,4 +304,4 @@ namespace WindowsRawInput {
|
||||
}
|
||||
rawInputBuffer = 0;
|
||||
}
|
||||
};
|
||||
};
|
||||
|
@ -22,8 +22,9 @@ namespace WindowsRawInput {
|
||||
LRESULT Process(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
// Not actually RawInput but it kinda belongs here anyway.
|
||||
LRESULT ProcessChar(HWND hWnd, WPARAM wParam, LPARAM lParam);
|
||||
void SetMousePos(float x, float y);
|
||||
void GainFocus();
|
||||
void LoseFocus();
|
||||
void NotifyMenu();
|
||||
void Shutdown();
|
||||
};
|
||||
};
|
||||
|
@ -6,12 +6,9 @@
|
||||
|
||||
#include "base/display.h"
|
||||
#include "Common/CommonWindows.h"
|
||||
#include "input/input_state.h"
|
||||
#include "base/NativeApp.h"
|
||||
#include "Windows/MainWindow.h"
|
||||
|
||||
extern InputState input_state;
|
||||
|
||||
TouchInputHandler::TouchInputHandler() :
|
||||
touchInfo(nullptr),
|
||||
closeTouch(nullptr),
|
||||
@ -49,25 +46,12 @@ void TouchInputHandler::handleTouchEvent(HWND hWnd, UINT message, WPARAM wParam,
|
||||
for (UINT i = 0; i < inputCount; i++) {
|
||||
int id = 0;
|
||||
|
||||
//here we map the windows touch id to the ppsspp internal touch id
|
||||
//currently we ignore the fact that the mouse uses touch id 0, so that
|
||||
//the mouse could possibly interfere with the mapping so for safety
|
||||
//the maximum amount of touch points is MAX_POINTERS-1
|
||||
std::map<int, int>::const_iterator it = touchTranslate.find(inputs[i].dwID);
|
||||
if (it != touchTranslate.end()) //check if we already mapped this touch id
|
||||
{
|
||||
// Find or allocate an id for the touch.
|
||||
auto it = touchTranslate.find(inputs[i].dwID);
|
||||
if (it != touchTranslate.end()) {
|
||||
id = it->second;
|
||||
}
|
||||
else
|
||||
{
|
||||
if (touchTranslate.size() + 1 >= MAX_POINTERS) //check if we're tracking too many points
|
||||
{
|
||||
touchUp(touchTranslate.begin()->second, 0, 0);
|
||||
touchTranslate.erase(touchTranslate.begin());
|
||||
}
|
||||
//finding first free internal touch id and map this windows id to an internal id
|
||||
bool *first_free = std::find(input_state.pointer_down, input_state.pointer_down + MAX_POINTERS, false);
|
||||
id = (int)(first_free - input_state.pointer_down) / (int)sizeof(bool);
|
||||
} else {
|
||||
id = (int)touchTranslate.size();
|
||||
touchTranslate[inputs[i].dwID] = id;
|
||||
}
|
||||
|
||||
@ -129,11 +113,6 @@ void TouchInputHandler::touchUp(int id, float x, float y){
|
||||
touchevent.x = x;
|
||||
touchevent.y = y;
|
||||
touchevent.flags = TOUCH_UP;
|
||||
input_state.lock.lock();
|
||||
input_state.pointer_down[id] = false;
|
||||
input_state.pointer_x[id] = x;
|
||||
input_state.pointer_y[id] = y;
|
||||
input_state.lock.unlock();
|
||||
NativeTouch(touchevent);
|
||||
}
|
||||
|
||||
@ -143,11 +122,6 @@ void TouchInputHandler::touchDown(int id, float x, float y){
|
||||
touchevent.x = x;
|
||||
touchevent.y = y;
|
||||
touchevent.flags = TOUCH_DOWN;
|
||||
input_state.lock.lock();
|
||||
input_state.pointer_down[id] = true;
|
||||
input_state.pointer_x[id] = x;
|
||||
input_state.pointer_y[id] = y;
|
||||
input_state.lock.unlock();
|
||||
NativeTouch(touchevent);
|
||||
}
|
||||
|
||||
@ -157,10 +131,6 @@ void TouchInputHandler::touchMove(int id, float x, float y){
|
||||
touchevent.x = x;
|
||||
touchevent.y = y;
|
||||
touchevent.flags = TOUCH_MOVE;
|
||||
input_state.lock.lock();
|
||||
input_state.pointer_x[id] = x;
|
||||
input_state.pointer_y[id] = y;
|
||||
input_state.lock.unlock();
|
||||
NativeTouch(touchevent);
|
||||
}
|
||||
|
||||
@ -179,4 +149,4 @@ bool TouchInputHandler::hasTouch(){
|
||||
closeTouch != nullptr &&
|
||||
registerTouch != nullptr
|
||||
);
|
||||
}
|
||||
}
|
||||
|
Loading…
x
Reference in New Issue
Block a user