diff options
author | FeralChild64 <unknown> | 2022-10-12 13:45:03 +0300 |
---|---|---|
committer | kcgen <1557255+kcgen@users.noreply.github.com> | 2022-10-22 21:15:34 +0300 |
commit | 8dbfbf9e7a6c9ef4ad476967a2d705731457ecc6 (patch) | |
tree | b8bb323abf850cc11fa591a0514946b52497fd1f /include | |
parent | ec9df4708b60715772d1322d7de42eb8e4c67459 (diff) |
Handle code review remarks
Diffstat (limited to 'include')
-rw-r--r-- | include/math_utils.h | 27 | ||||
-rw-r--r-- | include/mouse.h | 24 |
2 files changed, 38 insertions, 13 deletions
diff --git a/include/math_utils.h b/include/math_utils.h index 34d4f37f3..81fce34a6 100644 --- a/include/math_utils.h +++ b/include/math_utils.h @@ -127,6 +127,33 @@ constexpr T1 left_shift_signed(T1 value, T2 amount) return static_cast<T1>(shifted); } +template <typename T> +int8_t clamp_to_int8(const T val) +{ + const auto tmp = std::clamp(val, + static_cast<T>(INT8_MIN), + static_cast<T>(INT8_MAX)); + return static_cast<int8_t>(tmp); +} + +template <typename T> +int16_t clamp_to_int16(const T val) +{ + const auto tmp = std::clamp(val, + static_cast<T>(INT16_MIN), + static_cast<T>(INT16_MAX)); + return static_cast<int16_t>(tmp); +} + +template <typename T> +int32_t clamp_to_int32(const T val) +{ + const auto tmp = std::clamp(val, + static_cast<T>(INT32_MIN), + static_cast<T>(INT32_MAX)); + return static_cast<int32_t>(tmp); +} + inline float decibel_to_gain(const float decibel) { return powf(10.0f, decibel / 20.0f); diff --git a/include/mouse.h b/include/mouse.h index 7f0bb4260..ad93aa28c 100644 --- a/include/mouse.h +++ b/include/mouse.h @@ -1,5 +1,5 @@ /* - * Copyright (C) 2022 The DOSBox Staging Team + * Copyright (C) 2022-2022 The DOSBox Staging Team * Copyright (C) 2002-2021 The DOSBox Team * * This program is free software; you can redistribute it and/or modify @@ -88,13 +88,11 @@ void MOUSE_NewScreenParams(const uint16_t clip_x, const uint16_t clip_y, const uint16_t y_abs); // *************************************************************************** -// Variables shared with external modules +// Information for the GFX subsystem // *************************************************************************** -// If driver with seamless pointer support is running -extern bool mouse_seamless_driver; -// If user selected seamless mode is in effect -extern bool mouse_seamless_user; +bool MOUSE_IsUsingSeamlessDriver(); // if driver with seamless pointer support is running +bool MOUSE_IsUsingSeamlessSetting(); // if user selected seamless mode is in effect // *************************************************************************** // BIOS mouse interface for PS/2 mouse @@ -168,15 +166,15 @@ private: const MousePhysical &Physical() const; }; -class MouseConfigAPI final { +class MouseControlAPI final { public: // Always destroy the object once it is not needed anymore // (configuration tool finishes it's job) and we are returning // to normal code execution! - MouseConfigAPI(); - ~MouseConfigAPI(); + MouseControlAPI(); + ~MouseControlAPI(); // Empty list = performs operation on all emulated interfaces typedef std::vector<MouseInterfaceId> ListIDs; @@ -213,13 +211,13 @@ public: static const std::vector<uint16_t> &GetValidMinRateList(); static const std::string &GetValidMinRateStr(); - bool SetMinRate(const MouseConfigAPI::ListIDs &list_ids, + bool SetMinRate(const MouseControlAPI::ListIDs &list_ids, const uint16_t value_hz); - bool ResetMinRate(const MouseConfigAPI::ListIDs &list_ids); + bool ResetMinRate(const MouseControlAPI::ListIDs &list_ids); private: - MouseConfigAPI(const MouseConfigAPI &) = delete; - MouseConfigAPI &operator=(const MouseConfigAPI &) = delete; + MouseControlAPI(const MouseControlAPI &) = delete; + MouseControlAPI &operator=(const MouseControlAPI &) = delete; }; #endif // DOSBOX_MOUSE_H |