2013-03-10 23:08:57 +01:00
|
|
|
// Copyright (c) 2012- PPSSPP Project.
|
|
|
|
|
|
|
|
// This program is free software: you can redistribute it and/or modify
|
|
|
|
// it under the terms of the GNU General Public License as published by
|
|
|
|
// the Free Software Foundation, version 2.0 or later versions.
|
|
|
|
|
|
|
|
// This program is distributed in the hope that it will be useful,
|
|
|
|
// but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
// GNU General Public License 2.0 for more details.
|
|
|
|
|
|
|
|
// A copy of the GPL 2.0 should have been included with the program.
|
|
|
|
// If not, see http://www.gnu.org/licenses/
|
|
|
|
|
|
|
|
// Official git repository and contact information can be found at
|
|
|
|
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
|
|
|
|
|
2017-02-24 18:59:41 +01:00
|
|
|
#include "ppsspp_config.h"
|
|
|
|
|
2013-08-12 23:26:01 +02:00
|
|
|
#include <algorithm>
|
|
|
|
|
2013-08-26 19:00:16 +02:00
|
|
|
// native stuff
|
2020-10-04 10:10:55 +02:00
|
|
|
#include "Common/System/Display.h"
|
2020-10-04 10:30:18 +02:00
|
|
|
#include "Common/System/NativeApp.h"
|
2020-10-01 09:36:43 +02:00
|
|
|
#include "Common/Input/InputState.h"
|
|
|
|
#include "Common/Input/KeyCodes.h"
|
2016-05-27 22:00:14 -07:00
|
|
|
#include "Common/StringUtils.h"
|
2020-10-04 20:48:47 +02:00
|
|
|
|
2013-01-29 21:38:05 +01:00
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/Config.h"
|
2018-06-16 18:42:31 -07:00
|
|
|
#include "Core/ConfigValues.h"
|
2013-03-29 22:56:57 +01:00
|
|
|
#include "Core/CoreParameter.h"
|
2023-03-24 17:52:17 +01:00
|
|
|
#include "Core/HLE/Plugins.h"
|
2013-05-04 23:21:06 +02:00
|
|
|
#include "Core/System.h"
|
2016-05-27 22:00:14 -07:00
|
|
|
#include "Core/Debugger/SymbolMap.h"
|
2020-07-20 11:38:39 +02:00
|
|
|
#include "Core/Instance.h"
|
|
|
|
|
2023-03-24 17:52:17 +01:00
|
|
|
#include "UI/OnScreenDisplay.h"
|
|
|
|
|
2015-09-19 13:14:05 +02:00
|
|
|
#include "Windows/EmuThread.h"
|
|
|
|
#include "Windows/WindowsHost.h"
|
|
|
|
#include "Windows/MainWindow.h"
|
2017-02-24 18:59:41 +01:00
|
|
|
|
2019-05-04 06:06:50 +08:00
|
|
|
#ifndef _M_ARM
|
2013-07-06 19:08:59 +02:00
|
|
|
#include "Windows/DinputDevice.h"
|
2019-05-04 06:06:50 +08:00
|
|
|
#endif
|
2013-07-06 19:08:59 +02:00
|
|
|
#include "Windows/XinputDevice.h"
|
|
|
|
|
2015-09-19 13:14:05 +02:00
|
|
|
#include "Windows/main.h"
|
2012-11-01 16:19:01 +01:00
|
|
|
|
2023-03-25 10:43:00 +01:00
|
|
|
void SetConsolePosition() {
|
2015-09-19 14:28:43 +02:00
|
|
|
HWND console = GetConsoleWindow();
|
2020-07-20 11:38:39 +02:00
|
|
|
if (console != NULL && g_Config.iConsoleWindowX != -1 && g_Config.iConsoleWindowY != -1) {
|
2015-09-19 14:28:43 +02:00
|
|
|
SetWindowPos(console, NULL, g_Config.iConsoleWindowX, g_Config.iConsoleWindowY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
2020-07-20 11:38:39 +02:00
|
|
|
}
|
2015-09-19 14:28:43 +02:00
|
|
|
}
|
|
|
|
|
2023-03-25 10:43:00 +01:00
|
|
|
void UpdateConsolePosition() {
|
2015-09-19 14:28:43 +02:00
|
|
|
RECT rc;
|
|
|
|
HWND console = GetConsoleWindow();
|
2015-12-31 16:59:40 +01:00
|
|
|
if (console != NULL && GetWindowRect(console, &rc) && !IsIconic(console)) {
|
2015-09-19 14:28:43 +02:00
|
|
|
g_Config.iConsoleWindowX = rc.left;
|
|
|
|
g_Config.iConsoleWindowY = rc.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-24 19:57:24 +01:00
|
|
|
void WindowsInputManager::Init() {
|
|
|
|
//add first XInput device to respond
|
|
|
|
input.push_back(std::make_unique<XinputDevice>());
|
|
|
|
#ifndef _M_ARM
|
|
|
|
//find all connected DInput devices of class GamePad
|
|
|
|
numDinputDevices_ = DinputDevice::getNumPads();
|
|
|
|
for (size_t i = 0; i < numDinputDevices_; i++) {
|
|
|
|
input.push_back(std::make_unique<DinputDevice>(static_cast<int>(i)));
|
|
|
|
}
|
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
|
|
|
void WindowsInputManager::PollControllers() {
|
2023-12-14 19:24:39 +01:00
|
|
|
static const int CHECK_FREQUENCY = 71; // Just an arbitrary prime to try to not collide with other periodic checks.
|
2023-03-24 19:57:24 +01:00
|
|
|
if (checkCounter_++ > CHECK_FREQUENCY) {
|
2019-05-04 06:06:50 +08:00
|
|
|
#ifndef _M_ARM
|
2018-10-08 21:21:37 -07:00
|
|
|
size_t newCount = DinputDevice::getNumPads();
|
|
|
|
if (newCount > numDinputDevices_) {
|
|
|
|
INFO_LOG(SYSTEM, "New controller device detected");
|
|
|
|
for (size_t i = numDinputDevices_; i < newCount; i++) {
|
2019-06-29 00:55:45 +02:00
|
|
|
input.push_back(std::make_unique<DinputDevice>(static_cast<int>(i)));
|
2018-10-08 21:21:37 -07:00
|
|
|
}
|
|
|
|
numDinputDevices_ = newCount;
|
|
|
|
}
|
2019-05-04 06:06:50 +08:00
|
|
|
#endif
|
2023-03-24 19:57:24 +01:00
|
|
|
checkCounter_ = 0;
|
2018-10-08 21:21:37 -07:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto &device : input) {
|
2017-03-14 22:01:18 -07:00
|
|
|
if (device->UpdateState() == InputDevice::UPDATESTATE_SKIP_PAD)
|
2019-06-29 00:55:45 +02:00
|
|
|
break;
|
2013-04-07 18:41:26 -07:00
|
|
|
}
|
2013-08-12 23:26:01 +02:00
|
|
|
|
2017-04-26 16:48:55 +02:00
|
|
|
// Disabled by default, needs a workaround to map to psp keys.
|
2018-10-08 21:21:37 -07:00
|
|
|
if (g_Config.bMouseControl) {
|
2023-12-09 21:40:09 +01:00
|
|
|
NativeMouseDelta(mouseDeltaX_, mouseDeltaY_);
|
2017-04-26 16:48:55 +02:00
|
|
|
}
|
|
|
|
|
2023-03-24 19:57:24 +01:00
|
|
|
mouseDeltaX_ *= g_Config.fMouseSmoothing;
|
|
|
|
mouseDeltaY_ *= g_Config.fMouseSmoothing;
|
2022-12-05 15:14:14 +03:00
|
|
|
|
2023-03-24 19:57:24 +01:00
|
|
|
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_X] = mouseDeltaX_;
|
|
|
|
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = mouseDeltaY_;
|
2012-11-01 16:19:01 +01:00
|
|
|
}
|