2013-03-10 22:08:57 +00: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 17:59:41 +00:00
|
|
|
#include "ppsspp_config.h"
|
|
|
|
|
2013-08-12 21:26:01 +00:00
|
|
|
#include <algorithm>
|
|
|
|
|
2013-08-26 17:00:16 +00:00
|
|
|
// native stuff
|
2020-10-04 08:10:55 +00:00
|
|
|
#include "Common/System/Display.h"
|
2020-10-04 08:30:18 +00:00
|
|
|
#include "Common/System/NativeApp.h"
|
2020-10-01 07:36:43 +00:00
|
|
|
#include "Common/Input/InputState.h"
|
|
|
|
#include "Common/Input/KeyCodes.h"
|
2016-05-28 05:00:14 +00:00
|
|
|
#include "Common/StringUtils.h"
|
2020-10-04 18:48:47 +00:00
|
|
|
|
2013-01-29 20:38:05 +00:00
|
|
|
#include "Core/Core.h"
|
|
|
|
#include "Core/Config.h"
|
2018-06-17 01:42:31 +00:00
|
|
|
#include "Core/ConfigValues.h"
|
2013-03-29 21:56:57 +00:00
|
|
|
#include "Core/CoreParameter.h"
|
2023-03-24 16:52:17 +00:00
|
|
|
#include "Core/HLE/Plugins.h"
|
2013-05-04 21:21:06 +00:00
|
|
|
#include "Core/System.h"
|
2016-05-28 05:00:14 +00:00
|
|
|
#include "Core/Debugger/SymbolMap.h"
|
2020-07-20 09:38:39 +00:00
|
|
|
#include "Core/Instance.h"
|
|
|
|
|
2023-03-24 16:52:17 +00:00
|
|
|
#include "UI/OnScreenDisplay.h"
|
|
|
|
|
2015-09-19 11:14:05 +00:00
|
|
|
#include "Windows/EmuThread.h"
|
|
|
|
#include "Windows/WindowsHost.h"
|
|
|
|
#include "Windows/MainWindow.h"
|
2017-02-24 17:59:41 +00:00
|
|
|
|
2019-05-03 22:06:50 +00:00
|
|
|
#ifndef _M_ARM
|
2013-07-06 17:08:59 +00:00
|
|
|
#include "Windows/DinputDevice.h"
|
2019-05-03 22:06:50 +00:00
|
|
|
#endif
|
2013-07-06 17:08:59 +00:00
|
|
|
#include "Windows/XinputDevice.h"
|
|
|
|
|
2015-09-19 11:14:05 +00:00
|
|
|
#include "Windows/main.h"
|
2012-11-01 15:19:01 +00:00
|
|
|
|
2023-03-25 09:43:00 +00:00
|
|
|
void SetConsolePosition() {
|
2015-09-19 12:28:43 +00:00
|
|
|
HWND console = GetConsoleWindow();
|
2020-07-20 09:38:39 +00:00
|
|
|
if (console != NULL && g_Config.iConsoleWindowX != -1 && g_Config.iConsoleWindowY != -1) {
|
2015-09-19 12:28:43 +00:00
|
|
|
SetWindowPos(console, NULL, g_Config.iConsoleWindowX, g_Config.iConsoleWindowY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);
|
2020-07-20 09:38:39 +00:00
|
|
|
}
|
2015-09-19 12:28:43 +00:00
|
|
|
}
|
|
|
|
|
2023-03-25 09:43:00 +00:00
|
|
|
void UpdateConsolePosition() {
|
2015-09-19 12:28:43 +00:00
|
|
|
RECT rc;
|
|
|
|
HWND console = GetConsoleWindow();
|
2015-12-31 15:59:40 +00:00
|
|
|
if (console != NULL && GetWindowRect(console, &rc) && !IsIconic(console)) {
|
2015-09-19 12:28:43 +00:00
|
|
|
g_Config.iConsoleWindowX = rc.left;
|
|
|
|
g_Config.iConsoleWindowY = rc.top;
|
|
|
|
}
|
|
|
|
}
|
|
|
|
|
2023-03-24 18:57:24 +00: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 18:24:39 +00:00
|
|
|
static const int CHECK_FREQUENCY = 71; // Just an arbitrary prime to try to not collide with other periodic checks.
|
2023-03-24 18:57:24 +00:00
|
|
|
if (checkCounter_++ > CHECK_FREQUENCY) {
|
2019-05-03 22:06:50 +00:00
|
|
|
#ifndef _M_ARM
|
2018-10-09 04:21:37 +00: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-28 22:55:45 +00:00
|
|
|
input.push_back(std::make_unique<DinputDevice>(static_cast<int>(i)));
|
2018-10-09 04:21:37 +00:00
|
|
|
}
|
|
|
|
numDinputDevices_ = newCount;
|
|
|
|
}
|
2019-05-03 22:06:50 +00:00
|
|
|
#endif
|
2023-03-24 18:57:24 +00:00
|
|
|
checkCounter_ = 0;
|
2018-10-09 04:21:37 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
for (const auto &device : input) {
|
2017-03-15 05:01:18 +00:00
|
|
|
if (device->UpdateState() == InputDevice::UPDATESTATE_SKIP_PAD)
|
2019-06-28 22:55:45 +00:00
|
|
|
break;
|
2013-04-08 01:41:26 +00:00
|
|
|
}
|
2013-08-12 21:26:01 +00:00
|
|
|
|
2017-04-26 14:48:55 +00:00
|
|
|
// Disabled by default, needs a workaround to map to psp keys.
|
2018-10-09 04:21:37 +00:00
|
|
|
if (g_Config.bMouseControl) {
|
2023-12-09 20:40:09 +00:00
|
|
|
NativeMouseDelta(mouseDeltaX_, mouseDeltaY_);
|
2017-04-26 14:48:55 +00:00
|
|
|
}
|
|
|
|
|
2023-03-24 18:57:24 +00:00
|
|
|
mouseDeltaX_ *= g_Config.fMouseSmoothing;
|
|
|
|
mouseDeltaY_ *= g_Config.fMouseSmoothing;
|
2022-12-05 12:14:14 +00:00
|
|
|
|
2023-03-24 18:57:24 +00:00
|
|
|
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_X] = mouseDeltaX_;
|
|
|
|
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = mouseDeltaY_;
|
2012-11-01 15:19:01 +00:00
|
|
|
}
|