Compare commits

..

1 Commits

Author SHA1 Message Date
german77
e4c63d432d wall_clock: use standard wall clock if rtsc frequency is too low 2022-01-27 17:07:52 -06:00
6 changed files with 16 additions and 19 deletions

View File

@@ -72,7 +72,9 @@ std::unique_ptr<WallClock> CreateBestMatchingClock(u32 emulated_cpu_frequency,
if (caps.invariant_tsc) {
rtsc_frequency = EstimateRDTSCFrequency();
}
if (rtsc_frequency == 0) {
// Fallback to StandardWallClock if rtsc period is higher than a nano second
if (rtsc_frequency <= 1000000000) {
return std::make_unique<StandardWallClock>(emulated_cpu_frequency,
emulated_clock_frequency);
} else {

View File

@@ -16,7 +16,7 @@
// Pad Identifier of data source
struct PadIdentifier {
Common::UUID guid{Common::INVALID_UUID};
Common::UUID guid{};
std::size_t port{};
std::size_t pad{};
@@ -89,7 +89,7 @@ struct UpdateCallback {
// Triggered if data changed on the controller and the engine is on configuring mode
struct MappingCallback {
std::function<void(const MappingData&)> on_data;
std::function<void(MappingData)> on_data;
};
// Input Identifier of data source

View File

@@ -2,13 +2,14 @@
// Licensed under GPLv2 or any later version
// Refer to the license.txt file included
#include "common/common_types.h"
#include "common/settings.h"
#include "input_common/input_engine.h"
#include "input_common/input_mapping.h"
namespace InputCommon {
MappingFactory::MappingFactory() = default;
MappingFactory::MappingFactory() {}
void MappingFactory::BeginMapping(Polling::InputType type) {
is_enabled = true;
@@ -18,7 +19,7 @@ void MappingFactory::BeginMapping(Polling::InputType type) {
second_axis = -1;
}
Common::ParamPackage MappingFactory::GetNextInput() {
[[nodiscard]] const Common::ParamPackage MappingFactory::GetNextInput() {
Common::ParamPackage input;
input_queue.Pop(input);
return input;
@@ -56,7 +57,7 @@ void MappingFactory::StopMapping() {
void MappingFactory::RegisterButton(const MappingData& data) {
Common::ParamPackage new_input;
new_input.Set("engine", data.engine);
if (data.pad.guid.IsValid()) {
if (data.pad.guid != Common::UUID{}) {
new_input.Set("guid", data.pad.guid.Format());
}
new_input.Set("port", static_cast<int>(data.pad.port));
@@ -92,7 +93,7 @@ void MappingFactory::RegisterButton(const MappingData& data) {
void MappingFactory::RegisterStick(const MappingData& data) {
Common::ParamPackage new_input;
new_input.Set("engine", data.engine);
if (data.pad.guid.IsValid()) {
if (data.pad.guid != Common::UUID{}) {
new_input.Set("guid", data.pad.guid.Format());
}
new_input.Set("port", static_cast<int>(data.pad.port));
@@ -137,7 +138,7 @@ void MappingFactory::RegisterStick(const MappingData& data) {
void MappingFactory::RegisterMotion(const MappingData& data) {
Common::ParamPackage new_input;
new_input.Set("engine", data.engine);
if (data.pad.guid.IsValid()) {
if (data.pad.guid != Common::UUID{}) {
new_input.Set("guid", data.pad.guid.Format());
}
new_input.Set("port", static_cast<int>(data.pad.port));

View File

@@ -3,14 +3,8 @@
// Refer to the license.txt file included
#pragma once
#include "common/param_package.h"
#include "common/threadsafe_queue.h"
namespace InputCommon::Polling {
enum class InputType;
}
namespace InputCommon {
class InputEngine;
struct MappingData;
@@ -26,7 +20,7 @@ public:
void BeginMapping(Polling::InputType type);
/// Returns an input event with mapping information from the input_queue
[[nodiscard]] Common::ParamPackage GetNextInput();
[[nodiscard]] const Common::ParamPackage GetNextInput();
/**
* Registers mapping input data from the driver

View File

@@ -27,7 +27,7 @@ namespace InputCommon {
struct InputSubsystem::Impl {
void Initialize() {
mapping_factory = std::make_shared<MappingFactory>();
MappingCallback mapping_callback{[this](const MappingData& data) { RegisterInput(data); }};
MappingCallback mapping_callback{[this](MappingData data) { RegisterInput(data); }};
keyboard = std::make_shared<Keyboard>("keyboard");
keyboard->SetMappingCallback(mapping_callback);
@@ -284,7 +284,7 @@ struct InputSubsystem::Impl {
#endif
}
void RegisterInput(const MappingData& data) {
void RegisterInput(MappingData data) {
mapping_factory->RegisterInput(data);
}
@@ -394,7 +394,7 @@ void InputSubsystem::BeginMapping(Polling::InputType type) {
impl->mapping_factory->BeginMapping(type);
}
Common::ParamPackage InputSubsystem::GetNextInput() const {
const Common::ParamPackage InputSubsystem::GetNextInput() const {
return impl->mapping_factory->GetNextInput();
}

View File

@@ -126,7 +126,7 @@ public:
void BeginMapping(Polling::InputType type);
/// Returns an input event with mapping information.
[[nodiscard]] Common::ParamPackage GetNextInput() const;
[[nodiscard]] const Common::ParamPackage GetNextInput() const;
/// Stop polling from all backends.
void StopMapping() const;