diff --git a/Utilities/Timer.h b/Utilities/Timer.h index 8b0b3ad836..3a7d4e6f55 100644 --- a/Utilities/Timer.h +++ b/Utilities/Timer.h @@ -8,8 +8,8 @@ class Timer { private: bool m_stopped; - std::chrono::steady_clock::time_point m_start; - std::chrono::steady_clock::time_point m_end; + steady_clock::time_point m_start; + steady_clock::time_point m_end; public: Timer() : m_stopped(false) @@ -19,13 +19,13 @@ public: void Start() { m_stopped = false; - m_start = std::chrono::steady_clock::now(); + m_start = steady_clock::now(); } void Stop() { m_stopped = true; - m_end = std::chrono::steady_clock::now(); + m_end = steady_clock::now(); } double GetElapsedTimeInSec() const @@ -40,21 +40,21 @@ public: u64 GetElapsedTimeInMicroSec() const { - std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now(); + steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); return std::chrono::duration_cast(now - m_start).count(); } u64 GetElapsedTimeInNanoSec() const { - std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now(); + steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); return std::chrono::duration_cast(now - m_start).count(); } - u64 GetMsSince(std::chrono::steady_clock::time_point timestamp) + u64 GetMsSince(steady_clock::time_point timestamp) { - std::chrono::steady_clock::time_point now = m_stopped ? m_end : std::chrono::steady_clock::now(); + steady_clock::time_point now = m_stopped ? m_end : steady_clock::now(); return std::chrono::duration_cast(now - timestamp).count(); } diff --git a/Utilities/types.h b/Utilities/types.h index 76a1b975f8..83fe7a3141 100644 --- a/Utilities/types.h +++ b/Utilities/types.h @@ -17,6 +17,10 @@ #include #include +using std::chrono::steady_clock; + +using namespace std::literals; + #ifdef _MSC_VER #if !defined(__cpp_lib_bitops) && _MSC_VER < 1928 #define __cpp_lib_bitops @@ -43,9 +47,6 @@ #define CHECK_MAX_SIZE(type, size) static_assert(sizeof(type) <= size, #type " type size is too big") #define CHECK_SIZE_ALIGN(type, size, align) CHECK_SIZE(type, size); CHECK_ALIGN(type, align) -// Variant pattern matching helper -#define MATCH(arg, ...) constexpr(std::is_same_v, __VA_ARGS__>) - #define DECLARE(...) decltype(__VA_ARGS__) __VA_ARGS__ #define STR_CASE(...) case __VA_ARGS__: return #__VA_ARGS__ @@ -149,10 +150,6 @@ namespace std } #endif -using steady_clock = std::conditional< - std::chrono::high_resolution_clock::is_steady, - std::chrono::high_resolution_clock, std::chrono::steady_clock>::type; - // Get integral type from type size template struct get_int_impl diff --git a/rpcs3/Emu/Cell/Modules/cellPad.cpp b/rpcs3/Emu/Cell/Modules/cellPad.cpp index 79c49c491a..6b4b2b7d94 100644 --- a/rpcs3/Emu/Cell/Modules/cellPad.cpp +++ b/rpcs3/Emu/Cell/Modules/cellPad.cpp @@ -339,10 +339,10 @@ error_code cellPadGetData(u32 port_no, vm::ptr data) { // report back new data every ~10 ms even if the input doesn't change // this is observed behaviour when using a Dualshock 3 controller - static std::array, CELL_PAD_MAX_PORT_NUM> last_update = { }; - const std::chrono::time_point now = steady_clock::now(); + static std::array last_update = { }; + const auto now = steady_clock::now(); - if (btnChanged || pad->m_buffer_cleared || (std::chrono::duration_cast(now - last_update[port_no]).count() >= 10)) + if (btnChanged || pad->m_buffer_cleared || now - last_update[port_no] >= 10ms) { data->len = CELL_PAD_LEN_CHANGE_SENSOR_ON; last_update[port_no] = now; diff --git a/rpcs3/Emu/Cell/Modules/sceNp.cpp b/rpcs3/Emu/Cell/Modules/sceNp.cpp index f0817e050a..47778c9062 100644 --- a/rpcs3/Emu/Cell/Modules/sceNp.cpp +++ b/rpcs3/Emu/Cell/Modules/sceNp.cpp @@ -11,6 +11,7 @@ #include "sceNp.h" #include "cellSysutil.h" +#include "Emu/Cell/lv2/sys_time.h" #include "Emu/NP/np_handler.h" #include "Emu/NP/np_contexts.h" @@ -2519,9 +2520,18 @@ error_code sceNpManagerGetNetworkTime(vm::ptr pTick) return SCE_NP_ERROR_INVALID_STATE; } - auto now = std::chrono::system_clock::now(); - // That's assuming epoch is unix epoch which is not actually standardized, god I hate you C++ std - pTick->tick = std::chrono::duration_cast(now.time_since_epoch()).count() + (62135596800 * 1000 * 1000); + vm::var sec; + vm::var nsec; + + error_code ret = sys_time_get_current_time(sec, nsec); + + if (ret != CELL_OK) + { + return ret; + } + + // Taken from cellRtc + pTick->tick = *nsec / 1000 + *sec * cellRtcGetTickResolution() + 62135596800000000ULL; return CELL_OK; } diff --git a/rpcs3/Emu/Cell/lv2/sys_net.cpp b/rpcs3/Emu/Cell/lv2/sys_net.cpp index 56302295e6..9ecfb908a2 100644 --- a/rpcs3/Emu/Cell/lv2/sys_net.cpp +++ b/rpcs3/Emu/Cell/lv2/sys_net.cpp @@ -305,7 +305,7 @@ public: { std::lock_guard lock(data_mutex); - const auto now = std::chrono::system_clock::now(); + const auto now = steady_clock::now(); message msg; msg.dst_addr = *dst; @@ -328,7 +328,7 @@ public: std::lock_guard lock(data_mutex); rtts[sock_id].num_retries = 0; - const auto now = std::chrono::system_clock::now(); + const auto now = steady_clock::now(); for (auto it = msgs.begin(); it != msgs.end();) { @@ -366,7 +366,7 @@ public: if (thread_ctrl::state() == thread_state::aborting) return; - const auto now = std::chrono::system_clock::now(); + const auto now = steady_clock::now(); // Check for messages that haven't been acked std::set rtt_increased; for (auto it = msgs.begin(); it != msgs.end();) @@ -442,9 +442,9 @@ public: ::sockaddr_in dst_addr; std::vector data; u64 seq; - std::chrono::time_point initial_sendtime; + steady_clock::time_point initial_sendtime; }; - std::map, message> msgs; // (wakeup time, msg) + std::map msgs; // (wakeup time, msg) // List of rtts struct rtt_info { diff --git a/rpcs3/Emu/Io/MouseHandler.h b/rpcs3/Emu/Io/MouseHandler.h index e8204b4f83..f51a858c1f 100644 --- a/rpcs3/Emu/Io/MouseHandler.h +++ b/rpcs3/Emu/Io/MouseHandler.h @@ -135,12 +135,12 @@ class MouseHandlerBase protected: MouseInfo m_info; std::vector m_mice; - std::chrono::steady_clock::time_point last_update; + steady_clock::time_point last_update; bool is_time_for_update(double elapsed_time = 10.0) // 4-10 ms, let's use 10 for now { - std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); - double elapsed = std::chrono::duration_cast(now - last_update).count() / 1000.0; + steady_clock::time_point now = steady_clock::now(); + double elapsed = (now - last_update).count() / 1000'000.; if (elapsed > elapsed_time) { diff --git a/rpcs3/Emu/NP/rpcn_client.cpp b/rpcs3/Emu/NP/rpcn_client.cpp index 64f941a5c7..46e73fb6a6 100644 --- a/rpcs3/Emu/NP/rpcn_client.cpp +++ b/rpcs3/Emu/NP/rpcn_client.cpp @@ -305,7 +305,7 @@ bool rpcn_client::connect(const std::string& host) return false; } - last_ping_time = std::chrono::system_clock::now() - std::chrono::seconds(5); + last_ping_time = steady_clock::now() - 5s; last_pong_time = last_ping_time; return true; @@ -349,9 +349,9 @@ bool rpcn_client::login(const std::string& npid, const std::string& password, co // Make sure signaling works if (!in_config) { - auto start = std::chrono::system_clock::now(); + auto start = steady_clock::now(); - while (!get_addr_sig() && (std::chrono::system_clock::now() - start) < std::chrono::seconds(5)) + while (!get_addr_sig() && steady_clock::now() - start < 5s) { std::this_thread::sleep_for(5ms); } @@ -409,7 +409,7 @@ bool rpcn_client::manage_connection() if (authentified && !in_config) { // Ping the UDP Signaling Server - auto now = std::chrono::system_clock::now(); + auto now = steady_clock::now(); auto rpcn_msgs = get_rpcn_msgs(); @@ -432,7 +432,7 @@ bool rpcn_client::manage_connection() } // Send a packet every 5 seconds and then every 500 ms until reply is received - if ((now - last_pong_time) > std::chrono::seconds(5) && (now - last_ping_time) > std::chrono::milliseconds(500)) + if (now - last_pong_time > 5s && now - last_ping_time > 500ms) { std::vector ping(9); ping[0] = 1; diff --git a/rpcs3/Emu/NP/rpcn_client.h b/rpcs3/Emu/NP/rpcn_client.h index 14ee4d1455..1902cffcd5 100644 --- a/rpcs3/Emu/NP/rpcn_client.h +++ b/rpcs3/Emu/NP/rpcn_client.h @@ -236,7 +236,7 @@ protected: u32 received_version = 0; // UDP Signaling related - std::chrono::time_point last_ping_time{}, last_pong_time{}; + steady_clock::time_point last_ping_time{}, last_pong_time{}; sockaddr_in addr_rpcn{}; sockaddr_in addr_rpcn_udp{}; diff --git a/rpcs3/Emu/NP/signaling_handler.cpp b/rpcs3/Emu/NP/signaling_handler.cpp index 134f53f623..f4abd2c322 100644 --- a/rpcs3/Emu/NP/signaling_handler.cpp +++ b/rpcs3/Emu/NP/signaling_handler.cpp @@ -111,7 +111,7 @@ void signaling_handler::signal_sig2_callback(u64 room_id, u16 member_id, SceNpMa //// SIGNALING MSGS PROCESSING //// /////////////////////////////////// -void signaling_handler::reschedule_packet(std::shared_ptr& si, SignalingCommand cmd, std::chrono::time_point new_timepoint) +void signaling_handler::reschedule_packet(std::shared_ptr& si, SignalingCommand cmd, steady_clock::time_point new_timepoint) { for (auto it = qpackets.begin(); it != qpackets.end(); it++) { @@ -229,7 +229,7 @@ void signaling_handler::process_incoming_messages() continue; } - const auto now = std::chrono::system_clock::now(); + const auto now = steady_clock::now(); if (si) si->time_last_msg_recvd = now; @@ -257,7 +257,7 @@ void signaling_handler::process_incoming_messages() case signal_pong: reply = false; schedule_repeat = false; - reschedule_packet(si, signal_ping, now + std::chrono::seconds(15)); + reschedule_packet(si, signal_ping, now + 15s); break; case signal_connect: reply = true; @@ -324,14 +324,14 @@ void signaling_handler::operator()() process_incoming_messages(); - const auto now = std::chrono::system_clock::now(); + const auto now = steady_clock::now(); for (auto it = qpackets.begin(); it != qpackets.end();) { if (it->first > now) break; - if (it->second.sig_info->time_last_msg_recvd < now - std::chrono::seconds(60)) + if (it->second.sig_info->time_last_msg_recvd < now - 60s) { // We had no connection to opponent for 60 seconds, consider the connection dead sign_log.trace("Timeout disconnection"); @@ -461,7 +461,7 @@ void signaling_handler::send_signaling_packet(signaling_packet& sp, u32 addr, u1 } } -void signaling_handler::queue_signaling_packet(signaling_packet& sp, std::shared_ptr si, std::chrono::time_point wakeup_time) +void signaling_handler::queue_signaling_packet(signaling_packet& sp, std::shared_ptr si, steady_clock::time_point wakeup_time) { queued_packet qp; qp.sig_info = si; @@ -517,7 +517,7 @@ void signaling_handler::start_sig_nl(u32 conn_id, u32 addr, u16 port) si->port = port; send_signaling_packet(sent_packet, si->addr, si->port); - queue_signaling_packet(sent_packet, si, std::chrono::system_clock::now() + REPEAT_CONNECT_DELAY); + queue_signaling_packet(sent_packet, si, steady_clock::now() + REPEAT_CONNECT_DELAY); } void signaling_handler::start_sig2(u64 room_id, u16 member_id) @@ -530,7 +530,7 @@ void signaling_handler::start_sig2(u64 room_id, u16 member_id) auto si = sig2_peers.at(room_id).at(member_id); send_signaling_packet(sent_packet, si->addr, si->port); - queue_signaling_packet(sent_packet, si, std::chrono::system_clock::now() + REPEAT_CONNECT_DELAY); + queue_signaling_packet(sent_packet, si, steady_clock::now() + REPEAT_CONNECT_DELAY); } void signaling_handler::disconnect_sig2_users(u64 room_id) @@ -550,7 +550,7 @@ void signaling_handler::disconnect_sig2_users(u64 room_id) if (si->connStatus != SCE_NP_SIGNALING_CONN_STATUS_INACTIVE && !si->self) { send_signaling_packet(sent_packet, si->addr, si->port); - queue_signaling_packet(sent_packet, si, std::chrono::system_clock::now() + REPEAT_FINISHED_DELAY); + queue_signaling_packet(sent_packet, si, steady_clock::now() + REPEAT_FINISHED_DELAY); } } } diff --git a/rpcs3/Emu/NP/signaling_handler.h b/rpcs3/Emu/NP/signaling_handler.h index c6de6adebd..18a1f7e057 100644 --- a/rpcs3/Emu/NP/signaling_handler.h +++ b/rpcs3/Emu/NP/signaling_handler.h @@ -23,15 +23,16 @@ struct signaling_info u16 port = 0; // For handler - std::chrono::time_point time_last_msg_recvd = std::chrono::system_clock::now(); - bool self = false; - u32 version = 0; + steady_clock::time_point time_last_msg_recvd = steady_clock::now(); + + bool self = false; + u32 version = 0; // Signaling - u32 conn_id = 0; - ext_signaling_status ext_status = ext_sign_none; + u32 conn_id = 0; + ext_signaling_status ext_status = ext_sign_none; // Matching2 - u64 room_id = 0; - u16 member_id = 0; + u64 room_id = 0; + u16 member_id = 0; }; enum SignalingCommand : u32 @@ -128,7 +129,7 @@ private: private: bool validate_signaling_packet(const signaling_packet* sp); - void reschedule_packet(std::shared_ptr& si, SignalingCommand cmd, std::chrono::time_point new_timepoint); + void reschedule_packet(std::shared_ptr& si, SignalingCommand cmd, steady_clock::time_point new_timepoint); void retire_packet(std::shared_ptr& si, SignalingCommand cmd); void retire_all_packets(std::shared_ptr& si); @@ -139,7 +140,7 @@ private: signaling_packet sig1_packet{.version = 1u}; signaling_packet sig2_packet{.version = 2u}; - std::map, queued_packet> qpackets; // (wakeup time, packet) + std::map qpackets; // (wakeup time, packet) u32 cur_conn_id = 1; std::unordered_map npid_to_conn_id; // (npid, conn_id) @@ -150,5 +151,5 @@ private: void process_incoming_messages(); std::shared_ptr get_signaling_ptr(const signaling_packet* sp); void send_signaling_packet(signaling_packet& sp, u32 addr, u16 port); - void queue_signaling_packet(signaling_packet& sp, std::shared_ptr si, std::chrono::time_point wakeup_time); + void queue_signaling_packet(signaling_packet& sp, std::shared_ptr si, steady_clock::time_point wakeup_time); }; diff --git a/rpcs3/Emu/RSX/Overlays/overlays.cpp b/rpcs3/Emu/RSX/Overlays/overlays.cpp index 213035d485..98f1b72ded 100644 --- a/rpcs3/Emu/RSX/Overlays/overlays.cpp +++ b/rpcs3/Emu/RSX/Overlays/overlays.cpp @@ -44,12 +44,12 @@ namespace rsx s32 user_interface::run_input_loop() { const u64 ms_interval = 200; - std::array timestamp; - timestamp.fill(std::chrono::steady_clock::now()); + std::array timestamp; + timestamp.fill(steady_clock::now()); const u64 ms_threshold = 500; - std::array initial_timestamp; - initial_timestamp.fill(std::chrono::steady_clock::now()); + std::array initial_timestamp; + initial_timestamp.fill(steady_clock::now()); std::array, CELL_PAD_MAX_PORT_NUM> button_state; for (auto& state : button_state) @@ -155,14 +155,14 @@ namespace rsx if (!button_state[pad_index][button_id]) { // the d-pad button was not pressed before, so this is a new button press - timestamp[pad_index] = std::chrono::steady_clock::now(); + timestamp[pad_index] = steady_clock::now(); initial_timestamp[pad_index] = timestamp[pad_index]; on_button_pressed(static_cast(button_id)); } else if (input_timer.GetMsSince(initial_timestamp[pad_index]) > ms_threshold && input_timer.GetMsSince(timestamp[pad_index]) > ms_interval) { // the d-pad button was pressed for at least the given threshold in ms and will trigger at an interval - timestamp[pad_index] = std::chrono::steady_clock::now(); + timestamp[pad_index] = steady_clock::now(); on_button_pressed(static_cast(button_id)); } } diff --git a/rpcs3/Emu/RSX/rsx_cache.h b/rpcs3/Emu/RSX/rsx_cache.h index a03f2f68a5..9b80aa7c87 100644 --- a/rpcs3/Emu/RSX/rsx_cache.h +++ b/rpcs3/Emu/RSX/rsx_cache.h @@ -496,7 +496,7 @@ namespace rsx if (nb_workers == 1) { - std::chrono::time_point last_update; + steady_clock::time_point last_update; // Call the worker function directly, stoping it prematurely to be able update the screen u8 inc = 10; @@ -508,7 +508,7 @@ namespace rsx worker(stop_at); // Only update the screen at about 10fps since updating it everytime slows down the process - std::chrono::time_point now = std::chrono::steady_clock::now(); + steady_clock::time_point now = steady_clock::now(); processed_since_last_update += inc; if ((std::chrono::duration_cast(now - last_update) > 100ms) || (stop_at == entry_count)) { diff --git a/rpcs3/Emu/RSX/rsx_utils.h b/rpcs3/Emu/RSX/rsx_utils.h index 1c200168ba..4cb50209a9 100644 --- a/rpcs3/Emu/RSX/rsx_utils.h +++ b/rpcs3/Emu/RSX/rsx_utils.h @@ -1195,7 +1195,7 @@ namespace rsx struct profiling_timer { bool enabled = false; - std::chrono::time_point last; + steady_clock::time_point last; profiling_timer() = default; diff --git a/rpcs3/Input/keyboard_pad_handler.cpp b/rpcs3/Input/keyboard_pad_handler.cpp index 31bc889ef6..93dd6ec44a 100644 --- a/rpcs3/Input/keyboard_pad_handler.cpp +++ b/rpcs3/Input/keyboard_pad_handler.cpp @@ -13,7 +13,7 @@ constexpr auto qstr = QString::fromStdString; bool keyboard_pad_handler::Init() { - const std::chrono::steady_clock::time_point now = std::chrono::steady_clock::now(); + const steady_clock::time_point now = steady_clock::now(); m_last_mouse_move_left = now; m_last_mouse_move_right = now; m_last_mouse_move_up = now; @@ -372,13 +372,13 @@ void keyboard_pad_handler::mouseMoveEvent(QMouseEvent* event) { Key(mouse::move_right, false); Key(mouse::move_left, true, std::min(m_deadzone_x + std::abs(movement_x), 255)); - m_last_mouse_move_left = std::chrono::steady_clock::now(); + m_last_mouse_move_left = steady_clock::now(); } else if (movement_x > 0) { Key(mouse::move_left, false); Key(mouse::move_right, true, std::min(m_deadzone_x + movement_x, 255)); - m_last_mouse_move_right = std::chrono::steady_clock::now(); + m_last_mouse_move_right = steady_clock::now(); } // in Qt mouse up is equivalent to movement_y < 0 @@ -386,13 +386,13 @@ void keyboard_pad_handler::mouseMoveEvent(QMouseEvent* event) { Key(mouse::move_down, false); Key(mouse::move_up, true, std::min(m_deadzone_y + std::abs(movement_y), 255)); - m_last_mouse_move_up = std::chrono::steady_clock::now(); + m_last_mouse_move_up = steady_clock::now(); } else if (movement_y > 0) { Key(mouse::move_up, false); Key(mouse::move_down, true, std::min(m_deadzone_y + movement_y, 255)); - m_last_mouse_move_down = std::chrono::steady_clock::now(); + m_last_mouse_move_down = steady_clock::now(); } event->ignore(); @@ -415,12 +415,12 @@ void keyboard_pad_handler::mouseWheelEvent(QWheelEvent* event) if (to_left) { Key(mouse::wheel_left, true); - m_last_wheel_move_left = std::chrono::steady_clock::now(); + m_last_wheel_move_left = steady_clock::now(); } else { Key(mouse::wheel_right, true); - m_last_wheel_move_right = std::chrono::steady_clock::now(); + m_last_wheel_move_right = steady_clock::now(); } } if (const int y = direction.y()) @@ -430,12 +430,12 @@ void keyboard_pad_handler::mouseWheelEvent(QWheelEvent* event) if (to_up) { Key(mouse::wheel_up, true); - m_last_wheel_move_up = std::chrono::steady_clock::now(); + m_last_wheel_move_up = steady_clock::now(); } else { Key(mouse::wheel_down, true); - m_last_wheel_move_down = std::chrono::steady_clock::now(); + m_last_wheel_move_down = steady_clock::now(); } } } @@ -727,7 +727,7 @@ void keyboard_pad_handler::ThreadProc() static const double stick_interval = 10.0; static const double button_interval = 10.0; - const auto now = std::chrono::steady_clock::now(); + const auto now = steady_clock::now(); const double elapsed_left = std::chrono::duration_cast(now - m_last_mouse_move_left).count() / 1000.0; const double elapsed_right = std::chrono::duration_cast(now - m_last_mouse_move_right).count() / 1000.0; diff --git a/rpcs3/Input/keyboard_pad_handler.h b/rpcs3/Input/keyboard_pad_handler.h index 56ab2b737b..1b99e4ebad 100644 --- a/rpcs3/Input/keyboard_pad_handler.h +++ b/rpcs3/Input/keyboard_pad_handler.h @@ -107,12 +107,12 @@ private: std::vector> bindings; // Button Movements - std::chrono::steady_clock::time_point m_button_time; + steady_clock::time_point m_button_time; f32 m_analog_lerp_factor = 1.0f; f32 m_trigger_lerp_factor = 1.0f; // Stick Movements - std::chrono::steady_clock::time_point m_stick_time; + steady_clock::time_point m_stick_time; f32 m_l_stick_lerp_factor = 1.0f; f32 m_r_stick_lerp_factor = 1.0f; u8 m_stick_min[4] = { 0, 0, 0, 0 }; @@ -120,18 +120,18 @@ private: u8 m_stick_val[4] = { 128, 128, 128, 128 }; // Mouse Movements - std::chrono::steady_clock::time_point m_last_mouse_move_left; - std::chrono::steady_clock::time_point m_last_mouse_move_right; - std::chrono::steady_clock::time_point m_last_mouse_move_up; - std::chrono::steady_clock::time_point m_last_mouse_move_down; + steady_clock::time_point m_last_mouse_move_left; + steady_clock::time_point m_last_mouse_move_right; + steady_clock::time_point m_last_mouse_move_up; + steady_clock::time_point m_last_mouse_move_down; int m_deadzone_x = 60; int m_deadzone_y = 60; double m_multi_x = 2; double m_multi_y = 2.5; // Mousewheel - std::chrono::steady_clock::time_point m_last_wheel_move_up; - std::chrono::steady_clock::time_point m_last_wheel_move_down; - std::chrono::steady_clock::time_point m_last_wheel_move_left; - std::chrono::steady_clock::time_point m_last_wheel_move_right; + steady_clock::time_point m_last_wheel_move_up; + steady_clock::time_point m_last_wheel_move_down; + steady_clock::time_point m_last_wheel_move_left; + steady_clock::time_point m_last_wheel_move_right; }; diff --git a/rpcs3/Input/xinput_pad_handler.cpp b/rpcs3/Input/xinput_pad_handler.cpp index a00146c192..428598d6aa 100644 --- a/rpcs3/Input/xinput_pad_handler.cpp +++ b/rpcs3/Input/xinput_pad_handler.cpp @@ -492,7 +492,7 @@ void xinput_pad_handler::apply_pad_data(const std::shared_ptr& device dev->smallVibrate = speed_small; // XBox One Controller can't handle faster vibration updates than ~10ms. Elite is even worse. So I'll use 20ms to be on the safe side. No lag was noticable. - if (dev->newVibrateData && (std::chrono::duration_cast(std::chrono::high_resolution_clock::now() - dev->last_vibration) > 20ms)) + if (dev->newVibrateData && steady_clock::now() - dev->last_vibration > 20ms) { XINPUT_VIBRATION vibrate; vibrate.wLeftMotorSpeed = speed_large * 257; @@ -501,7 +501,7 @@ void xinput_pad_handler::apply_pad_data(const std::shared_ptr& device if ((*xinputSetState)(padnum, &vibrate) == ERROR_SUCCESS) { dev->newVibrateData = false; - dev->last_vibration = std::chrono::high_resolution_clock::now(); + dev->last_vibration = steady_clock::now(); } } } diff --git a/rpcs3/Input/xinput_pad_handler.h b/rpcs3/Input/xinput_pad_handler.h index 7d3680212e..5a1a14c03d 100644 --- a/rpcs3/Input/xinput_pad_handler.h +++ b/rpcs3/Input/xinput_pad_handler.h @@ -92,7 +92,7 @@ class xinput_pad_handler final : public PadHandlerBase bool newVibrateData{ true }; u16 largeVibrate{ 0 }; u16 smallVibrate{ 0 }; - std::chrono::high_resolution_clock::time_point last_vibration; + steady_clock::time_point last_vibration; bool is_scp_device{ false }; DWORD state{ ERROR_NOT_CONNECTED }; // holds internal controller state change SCP_EXTN state_scp{ 0 }; diff --git a/rpcs3/stdafx.h b/rpcs3/stdafx.h index 1340faee02..e7aec14ef3 100644 --- a/rpcs3/stdafx.h +++ b/rpcs3/stdafx.h @@ -13,13 +13,6 @@ #include "define_new_memleakdetect.h" #endif -#pragma warning( disable : 4351 ) - -// MSVC bug workaround -#ifdef _MSC_VER -namespace std { inline namespace literals { inline namespace chrono_literals {}}} -#endif - #include "Utilities/types.h" #include "Utilities/BEType.h" #include "util/atomic.hpp" @@ -39,5 +32,3 @@ namespace std { inline namespace literals { inline namespace chrono_literals {}} #include #include #include - -using namespace std::literals; diff --git a/rpcs3/util/logs.cpp b/rpcs3/util/logs.cpp index 2173776ead..ca42401aa3 100644 --- a/rpcs3/util/logs.cpp +++ b/rpcs3/util/logs.cpp @@ -137,7 +137,7 @@ namespace logs QueryPerformanceCounter(&start); } #else - std::chrono::steady_clock::time_point start = std::chrono::steady_clock::now(); + steady_clock::time_point start = steady_clock::now(); #endif u64 get() const @@ -148,7 +148,7 @@ namespace logs const LONGLONG diff = now.QuadPart - start.QuadPart; return diff / freq.QuadPart * 1'000'000 + diff % freq.QuadPart * 1'000'000 / freq.QuadPart; #else - return std::chrono::duration_cast(std::chrono::steady_clock::now() - start).count(); + return (steady_clock::now() - start).count() / 1000; #endif } } timebase{};