Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
hrydgard
GitHub Repository: hrydgard/ppsspp
Path: blob/master/Windows/WindowsHost.cpp
3185 views
1
// Copyright (c) 2012- PPSSPP Project.
2
3
// This program is free software: you can redistribute it and/or modify
4
// it under the terms of the GNU General Public License as published by
5
// the Free Software Foundation, version 2.0 or later versions.
6
7
// This program is distributed in the hope that it will be useful,
8
// but WITHOUT ANY WARRANTY; without even the implied warranty of
9
// MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
10
// GNU General Public License 2.0 for more details.
11
12
// A copy of the GPL 2.0 should have been included with the program.
13
// If not, see http://www.gnu.org/licenses/
14
15
// Official git repository and contact information can be found at
16
// https://github.com/hrydgard/ppsspp and http://www.ppsspp.org/.
17
18
#include "ppsspp_config.h"
19
20
#include <algorithm>
21
22
// native stuff
23
#include "Common/System/Display.h"
24
#include "Common/System/NativeApp.h"
25
#include "Common/Input/InputState.h"
26
#include "Common/Input/KeyCodes.h"
27
#include "Common/StringUtils.h"
28
29
#include "Core/Core.h"
30
#include "Core/Config.h"
31
#include "Core/ConfigValues.h"
32
#include "Core/CoreParameter.h"
33
#include "Core/HLE/Plugins.h"
34
#include "Core/System.h"
35
#include "Core/Debugger/SymbolMap.h"
36
#include "Core/Instance.h"
37
38
#include "UI/OnScreenDisplay.h"
39
40
#include "Windows/EmuThread.h"
41
#include "Windows/WindowsHost.h"
42
#include "Windows/MainWindow.h"
43
44
#ifndef _M_ARM
45
#include "Windows/DinputDevice.h"
46
#endif
47
#include "Windows/XinputDevice.h"
48
49
#include "Windows/main.h"
50
51
void WindowsInputManager::PollControllers() {
52
static const int CHECK_FREQUENCY = 71; // Just an arbitrary prime to try to not collide with other periodic checks.
53
if (checkCounter_++ > CHECK_FREQUENCY) {
54
#ifndef _M_ARM
55
size_t newCount = DinputDevice::getNumPads();
56
if (newCount > numDinputDevices_) {
57
INFO_LOG(Log::System, "New controller device detected");
58
for (size_t i = numDinputDevices_; i < newCount; i++) {
59
input.push_back(std::make_unique<DinputDevice>(static_cast<int>(i)));
60
}
61
numDinputDevices_ = newCount;
62
}
63
#endif
64
checkCounter_ = 0;
65
}
66
67
for (const auto &device : input) {
68
if (device->UpdateState() == InputDevice::UPDATESTATE_SKIP_PAD)
69
break;
70
}
71
72
// Disabled by default, needs a workaround to map to psp keys.
73
if (g_Config.bMouseControl) {
74
NativeMouseDelta(mouseDeltaX_, mouseDeltaY_);
75
}
76
77
mouseDeltaX_ *= g_Config.fMouseSmoothing;
78
mouseDeltaY_ *= g_Config.fMouseSmoothing;
79
80
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_X] = mouseDeltaX_;
81
HLEPlugins::PluginDataAxis[JOYSTICK_AXIS_MOUSE_REL_Y] = mouseDeltaY_;
82
}
83
84