Make Windows sleep for less

This commit is contained in:
Lorenzooone 2025-02-10 21:47:50 +01:00
parent 50ba513adc
commit 5c3b79b85e
4 changed files with 20 additions and 1 deletions

View File

@ -60,6 +60,7 @@ uint32_t ms_since_start();
std::string to_hex(uint16_t value);
std::string get_float_str_decimals(float value, int decimals);
void init_threads(void);
void complete_threads(void);
class ConsumerMutex {
public:

View File

@ -851,6 +851,7 @@ int main(int argc, char **argv) {
delete capture_data;
end_extra_buttons_poll();
capture_close();
complete_threads();
return ret_val;
}

View File

@ -1,6 +1,7 @@
#include "frontend.hpp"
#include <iostream>
#include <thread>
#include <SFML/System.hpp>
const CropData default_3ds_crop = {
.top_width = TOP_WIDTH_3DS, .top_height = HEIGHT_3DS,
@ -875,7 +876,7 @@ void update_connected_specific_settings(FrontendData* frontend_data, const Captu
void default_sleep(float wanted_ms) {
if(wanted_ms < 0)
wanted_ms = 1000.0/USB_CHECKS_PER_SECOND;
std::this_thread::sleep_for(std::chrono::microseconds((int)(wanted_ms * 1000)));
sf::sleep(sf::microseconds((int)(wanted_ms * 1000)));
}
void screen_display_thread(WindowScreen *screen) {

View File

@ -3,6 +3,9 @@
#if defined (__linux__) && defined(XLIB_BASED)
#include <X11/Xlib.h>
#endif
#ifdef _WIN32
#include <windows.h>
#endif
#include <iostream>
#include <fstream>
#include <sstream>
@ -195,6 +198,19 @@ void init_threads(void) {
#if defined(__linux__) && defined(XLIB_BASED)
XInitThreads();
#endif
/*
#ifdef _WIN32
timeBeginPeriod(4);
#endif
*/
}
void complete_threads(void) {
/*
#ifdef _WIN32
timeEndPeriod(4);
#endif
*/
}
std::string get_version_string(bool get_letter) {