CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
CoCalc provides the best real-time collaborative environment for Jupyter Notebooks, LaTeX documents, and SageMath, scalable from individual users to large groups and classes!
Path: blob/master/Windows/WindowsHost.cpp
Views: 1401
// Copyright (c) 2012- PPSSPP Project.12// This program is free software: you can redistribute it and/or modify3// it under the terms of the GNU General Public License as published by4// the Free Software Foundation, version 2.0 or later versions.56// This program is distributed in the hope that it will be useful,7// but WITHOUT ANY WARRANTY; without even the implied warranty of8// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the9// GNU General Public License 2.0 for more details.1011// A copy of the GPL 2.0 should have been included with the program.12// If not, see http://www.gnu.org/licenses/1314// Official git repository and contact information can be found at15// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.1617#include "ppsspp_config.h"1819#include <algorithm>2021// native stuff22#include "Common/System/Display.h"23#include "Common/System/NativeApp.h"24#include "Common/Input/InputState.h"25#include "Common/Input/KeyCodes.h"26#include "Common/StringUtils.h"2728#include "Core/Core.h"29#include "Core/Config.h"30#include "Core/ConfigValues.h"31#include "Core/CoreParameter.h"32#include "Core/HLE/Plugins.h"33#include "Core/System.h"34#include "Core/Debugger/SymbolMap.h"35#include "Core/Instance.h"3637#include "UI/OnScreenDisplay.h"3839#include "Windows/EmuThread.h"40#include "Windows/WindowsHost.h"41#include "Windows/MainWindow.h"4243#ifndef _M_ARM44#include "Windows/DinputDevice.h"45#endif46#include "Windows/XinputDevice.h"4748#include "Windows/main.h"4950void SetConsolePosition() {51HWND console = GetConsoleWindow();52if (console != NULL && g_Config.iConsoleWindowX != -1 && g_Config.iConsoleWindowY != -1) {53SetWindowPos(console, NULL, g_Config.iConsoleWindowX, g_Config.iConsoleWindowY, 0, 0, SWP_NOSIZE | SWP_NOZORDER);54}55}5657void UpdateConsolePosition() {58RECT rc;59HWND console = GetConsoleWindow();60if (console != NULL && GetWindowRect(console, &rc) && !IsIconic(console)) {61g_Config.iConsoleWindowX = rc.left;62g_Config.iConsoleWindowY = rc.top;63}64}6566void WindowsInputManager::Init() {67//add first XInput device to respond68input.push_back(std::make_unique<XinputDevice>());69#ifndef _M_ARM70//find all connected DInput devices of class GamePad71numDinputDevices_ = DinputDevice::getNumPads();72for (size_t i = 0; i < numDinputDevices_; i++) {73input.push_back(std::make_unique<DinputDevice>(static_cast<int>(i)));74}75#endif76}7778void WindowsInputManager::PollControllers() {79static const int CHECK_FREQUENCY = 71; // Just an arbitrary prime to try to not collide with other periodic checks.80if (checkCounter_++ > CHECK_FREQUENCY) {81#ifndef _M_ARM82size_t newCount = DinputDevice::getNumPads();83if (newCount > numDinputDevices_) {84INFO_LOG(Log::System, "New controller device detected");85for (size_t i = numDinputDevices_; i < newCount; i++) {86input.push_back(std::make_unique<DinputDevice>(static_cast<int>(i)));87}88numDinputDevices_ = newCount;89}90#endif91checkCounter_ = 0;92}9394for (const auto &device : input) {95if (device->UpdateState() == InputDevice::UPDATESTATE_SKIP_PAD)96break;97}9899// Disabled by default, needs a workaround to map to psp keys.100if (g_Config.bMouseControl) {101NativeMouseDelta(mouseDeltaX_, mouseDeltaY_);102}103104mouseDeltaX_ *= g_Config.fMouseSmoothing;105mouseDeltaY_ *= g_Config.fMouseSmoothing;106107HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_X] = mouseDeltaX_;108HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = mouseDeltaY_;109}110111112