diff --git a/Machines/Apple/ADB/Mouse.cpp b/Machines/Apple/ADB/Mouse.cpp index 2bd2e7ae6..ba0a5310f 100644 --- a/Machines/Apple/ADB/Mouse.cpp +++ b/Machines/Apple/ADB/Mouse.cpp @@ -8,6 +8,8 @@ #include "Mouse.hpp" +#include + using namespace Apple::ADB; Mouse::Mouse(Bus &bus) : ReactiveDevice(bus, 3) {} @@ -20,8 +22,8 @@ void Mouse::perform_command(const Command &command) { const int buttons = button_flags_; // Clamp deltas. - delta_x = std::max(std::min(delta_x, int16_t(127)), int16_t(-128)); - delta_y = std::max(std::min(delta_y, int16_t(127)), int16_t(-128)); + delta_x = std::clamp(delta_x, int16_t(-128), int16_t(127)); + delta_y = std::clamp(delta_y, int16_t(-128), int16_t(127)); // Figure out what that would look like, and don't respond if there's // no change to report. diff --git a/Machines/Atari/ST/IntelligentKeyboard.cpp b/Machines/Atari/ST/IntelligentKeyboard.cpp index 4fab68478..fdec08d7f 100644 --- a/Machines/Atari/ST/IntelligentKeyboard.cpp +++ b/Machines/Atari/ST/IntelligentKeyboard.cpp @@ -68,8 +68,8 @@ void IntelligentKeyboard::run_for(HalfCycles duration) { mouse_position_[1] += mouse_y_multiplier_ * scaled_movement[1]; // Clamp to range. - mouse_position_[0] = std::min(std::max(mouse_position_[0], 0), mouse_range_[0]); - mouse_position_[1] = std::min(std::max(mouse_position_[1], 0), mouse_range_[1]); + mouse_position_[0] = std::clamp(mouse_position_[0], 0, mouse_range_[0]); + mouse_position_[1] = std::clamp(mouse_position_[1], 0, mouse_range_[1]); mouse_movement_[0] -= scaled_movement[0] * mouse_scale_[0]; mouse_movement_[1] -= scaled_movement[1] * mouse_scale_[1];