mirror of
https://github.com/CalcProgrammer1/OpenRGB.git
synced 2025-12-23 23:37:48 -05:00
Replace Sleep() by std::thread::sleep_for()
This commit is contained in:
committed by
Adam Honse
parent
60baf6d05f
commit
b79ff124e6
@@ -14,16 +14,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| This list contains the available I2C addresses for Aura GPUs |
|
||||
@@ -88,7 +79,7 @@ void DetectAuraGPUControllers(std::vector<i2c_smbus_interface*> &busses, std::ve
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
}
|
||||
} /* DetectAuraGPUControllers() */
|
||||
@@ -6,16 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/*----------------------------------------------------------------------*\
|
||||
| This list contains the available SMBus addresses for mapping Aura RAM |
|
||||
@@ -178,7 +169,7 @@ void DetectAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
// Add Aura-enabled motherboard controllers
|
||||
@@ -191,7 +182,7 @@ void DetectAuraSMBusControllers(std::vector<i2c_smbus_interface*> &busses, std::
|
||||
rgb_controllers.push_back(new_controller);
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,16 +28,7 @@
|
||||
#define THREADRETURN return(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
@@ -75,7 +66,7 @@ void CorsairLightingNodeController::KeepaliveThread()
|
||||
while(1)
|
||||
{
|
||||
SendCommit();
|
||||
Sleep(5000);
|
||||
std::this_thread::sleep_for(5s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -11,16 +11,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x00, 0x01, 0x02, 0x03, 0x04, 0x05, 0x06, 0x07, 0x08, 0x09, 0x0C, 0x0D, 0x0E, 0x0F, 0x11, 0x12,
|
||||
0x14, 0x15, 0x18, 0x19, 0x1A, 0x1B, 0x1C, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x24, 0x25, 0x26,
|
||||
@@ -44,7 +35,7 @@ static void send_usb_msg(hid_device* dev, char * data_pkt)
|
||||
int bytes = hid_send_feature_report(dev, (unsigned char *)usb_pkt, 65);
|
||||
bytes++;
|
||||
|
||||
Sleep(2);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
CorsairPeripheralController::CorsairPeripheralController(hid_device* dev_handle)
|
||||
|
||||
@@ -10,16 +10,7 @@
|
||||
#include "CorsairVengeanceProController.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
CorsairVengeanceProController::CorsairVengeanceProController(i2c_smbus_interface* bus, corsair_dev_id dev)
|
||||
{
|
||||
@@ -89,9 +80,9 @@ void CorsairVengeanceProController::SetLEDColor(unsigned int led, unsigned char
|
||||
void CorsairVengeanceProController::ApplyColors()
|
||||
{
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x02);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
for (int i = 0; i < 10; i++)
|
||||
{
|
||||
@@ -119,9 +110,9 @@ void CorsairVengeanceProController::SetEffect(unsigned char mode,
|
||||
effect_mode = mode;
|
||||
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x26, 0x01);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
bus->i2c_smbus_write_byte_data(dev, 0x21, 0x00);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
unsigned char random_byte;
|
||||
|
||||
@@ -165,7 +156,7 @@ bool CorsairVengeanceProController::WaitReady()
|
||||
while (bus->i2c_smbus_read_byte_data(dev, 0x41) != 0x00)
|
||||
{
|
||||
i++;
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
return false;
|
||||
|
||||
@@ -6,16 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -50,7 +41,7 @@ bool TestForCorsairVengeanceProController(i2c_smbus_interface* bus, unsigned cha
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
return(pass);
|
||||
|
||||
|
||||
@@ -10,16 +10,7 @@
|
||||
#include "GloriousModelOController.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
GloriousModelOController::GloriousModelOController(hid_device* dev_handle)
|
||||
{
|
||||
@@ -139,7 +130,7 @@ void GloriousModelOController::SetLEDColor(RGBColor* color_buf)
|
||||
*/
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
void GloriousModelOController::SetMode(unsigned char mode,
|
||||
@@ -283,5 +274,5 @@ void GloriousModelOController::SetMode(unsigned char mode,
|
||||
}
|
||||
|
||||
hid_send_feature_report(dev, usb_buf, sizeof(usb_buf));
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
@@ -11,16 +11,7 @@
|
||||
#include <string>
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
HuePlusController::HuePlusController()
|
||||
{
|
||||
@@ -64,7 +55,7 @@ unsigned int HuePlusController::GetLEDsOnChannel(unsigned int channel)
|
||||
serialport->serial_write((char *)serial_buf, 2);
|
||||
serialport->serial_flush_tx();
|
||||
|
||||
Sleep(50);
|
||||
std::this_thread::sleep_for(50ms);
|
||||
|
||||
int bytes_read = serialport->serial_read((char *)serial_buf, 5);
|
||||
|
||||
@@ -244,5 +235,5 @@ void HuePlusController::SendPacket
|
||||
/*-----------------------------------------------------*\
|
||||
| Delay to allow Hue+ device to ready for next packet |
|
||||
\*-----------------------------------------------------*/
|
||||
Sleep(20);
|
||||
std::this_thread::sleep_for(20ms);
|
||||
}
|
||||
|
||||
@@ -6,16 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -76,7 +67,7 @@ void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std:
|
||||
{
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
for(int slot_addr = 0x50; slot_addr <= 0x57; slot_addr++)
|
||||
{
|
||||
@@ -89,7 +80,7 @@ void DetectHyperXDRAMControllers(std::vector<i2c_smbus_interface*> &busses, std:
|
||||
slots_valid |= (1 << (slot_addr - 0x50));
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
if(slots_valid != 0)
|
||||
|
||||
@@ -11,17 +11,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x14,
|
||||
0x15, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x20, 0x21, 0x22, 0x23, 0x24,
|
||||
@@ -107,7 +97,7 @@ void HyperXKeyboardController::SetMode
|
||||
mode_colors[8]
|
||||
);
|
||||
|
||||
Sleep(100);
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
@@ -137,7 +127,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
red_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirect
|
||||
(
|
||||
@@ -145,7 +135,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirect
|
||||
(
|
||||
@@ -153,7 +143,7 @@ void HyperXKeyboardController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendDirectExtended
|
||||
(
|
||||
@@ -189,7 +179,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
red_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
@@ -198,7 +188,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
@@ -207,7 +197,7 @@ void HyperXKeyboardController::SetLEDs(std::vector<RGBColor> colors)
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
SendExtendedColor
|
||||
(
|
||||
|
||||
@@ -6,16 +6,7 @@
|
||||
#include <stdio.h>
|
||||
#include <stdlib.h>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/******************************************************************************************\
|
||||
* *
|
||||
@@ -44,13 +35,13 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, st
|
||||
// Tests SPD addresses in order: 0x00, 0x40, 0x41, 0x61, 0x62, 0x63, 0x64, 0x65, 0x66, 0x67, 0x68
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x36, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
if(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x00) == 0x23)
|
||||
{
|
||||
busses[bus]->i2c_smbus_write_byte_data(0x37, 0x00, 0xFF);
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
|
||||
if((busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x40) == 0x85)
|
||||
&&(busses[bus]->i2c_smbus_read_byte_data(slot_addr, 0x41) == 0x02)
|
||||
@@ -67,7 +58,7 @@ void DetectPatriotViperControllers(std::vector<i2c_smbus_interface*> &busses, st
|
||||
}
|
||||
}
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
if(slots_valid != 0)
|
||||
|
||||
@@ -11,16 +11,7 @@
|
||||
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static unsigned int keys[] = {0x08, 0x09, 0x0A, 0x0B, 0x0C, 0x0D, 0x0E, 0x0F, 0x10, 0x11, 0x12, 0x13, 0x15,
|
||||
0x16, 0x17, 0x18, 0x19, 0x1A, 0x1B, 0x1D, 0x1E, 0x1F, 0x20, 0x21, 0x22, 0x23,
|
||||
@@ -57,7 +48,7 @@ void PoseidonZRGBController::SetMode(unsigned char mode, unsigned char direction
|
||||
active_speed
|
||||
);
|
||||
|
||||
Sleep(200);
|
||||
std::this_thread::sleep_for(200ms);
|
||||
}
|
||||
|
||||
void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
@@ -107,7 +98,7 @@ void PoseidonZRGBController::SetLEDsDirect(std::vector<RGBColor> colors)
|
||||
\*-----------------------------------------------------*/
|
||||
hid_send_feature_report(dev, red_grn_buf, 264);
|
||||
|
||||
Sleep(5);
|
||||
std::this_thread::sleep_for(5ms);
|
||||
|
||||
hid_send_feature_report(dev, blu_buf, 264);
|
||||
}
|
||||
@@ -132,7 +123,7 @@ void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
|
||||
red_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
@@ -141,7 +132,7 @@ void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
|
||||
grn_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendColor
|
||||
(
|
||||
@@ -150,7 +141,7 @@ void PoseidonZRGBController::SetLEDs(std::vector<RGBColor> colors)
|
||||
blu_color_data
|
||||
);
|
||||
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);
|
||||
|
||||
SendControl
|
||||
(
|
||||
|
||||
@@ -18,22 +18,14 @@
|
||||
#ifdef __APPLE__
|
||||
#include <unistd.h>
|
||||
#define MSG_NOSIGNAL 0
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
NetworkClient::NetworkClient(std::vector<RGBController *>& control) : controllers(control)
|
||||
{
|
||||
strcpy(port_ip, "127.0.0.1");
|
||||
@@ -183,7 +175,7 @@ void NetworkClient::ConnectionThreadFunction()
|
||||
server_controller_count = 0;
|
||||
|
||||
//Wait for server to connect
|
||||
Sleep(100);
|
||||
std::this_thread::sleep_for(100ms);
|
||||
|
||||
//Once server is connected, send client string
|
||||
SendData_ClientString();
|
||||
@@ -194,7 +186,7 @@ void NetworkClient::ConnectionThreadFunction()
|
||||
//Wait for server controller count
|
||||
while(server_controller_count == 0)
|
||||
{
|
||||
Sleep(100);
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
printf("Client: Received controller count from server: %d\r\n", server_controller_count);
|
||||
@@ -209,7 +201,7 @@ void NetworkClient::ConnectionThreadFunction()
|
||||
//Wait until controller is received
|
||||
while(server_controllers.size() == requested_controllers)
|
||||
{
|
||||
Sleep(100);
|
||||
std::this_thread::sleep_for(100ms);
|
||||
}
|
||||
|
||||
requested_controllers++;
|
||||
@@ -230,7 +222,7 @@ void NetworkClient::ConnectionThreadFunction()
|
||||
ClientInfoChanged();
|
||||
}
|
||||
|
||||
Sleep(1000);
|
||||
std::this_thread::sleep_for(1s);
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
@@ -28,11 +28,6 @@ const char yes = 1;
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
NetworkServer::NetworkServer(std::vector<RGBController *>& control) : controllers(control)
|
||||
|
||||
@@ -12,6 +12,7 @@
|
||||
|
||||
#include <mutex>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
#pragma once
|
||||
|
||||
|
||||
@@ -1,16 +1,7 @@
|
||||
#include "RGBController.h"
|
||||
#include <cstring>
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
RGBController::RGBController()
|
||||
{
|
||||
@@ -1335,7 +1326,7 @@ void RGBController::DeviceCallThreadFunction()
|
||||
}
|
||||
else
|
||||
{
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
@@ -13,6 +13,7 @@
|
||||
#include <vector>
|
||||
#include <string>
|
||||
#include <thread>
|
||||
#include <chrono>
|
||||
|
||||
typedef unsigned int RGBColor;
|
||||
|
||||
|
||||
@@ -26,16 +26,7 @@
|
||||
#define THREADRETURN return(NULL);
|
||||
#endif
|
||||
|
||||
#ifdef WIN32
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
THREAD keepalive_thread(void *param)
|
||||
{
|
||||
@@ -375,6 +366,6 @@ void RGBController_HyperXKeyboard::KeepaliveThread()
|
||||
UpdateLEDs();
|
||||
}
|
||||
}
|
||||
Sleep(10);
|
||||
std::this_thread::sleep_for(10ms);;
|
||||
}
|
||||
}
|
||||
|
||||
@@ -12,13 +12,11 @@
|
||||
#include <fstream>
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
void RGBController_OpenRazer::DeviceUpdateLEDs()
|
||||
{
|
||||
|
||||
switch(matrix_type)
|
||||
{
|
||||
case RAZER_TYPE_MATRIX_FRAME:
|
||||
@@ -79,7 +77,7 @@ void RGBController_OpenRazer::DeviceUpdateLEDs()
|
||||
|
||||
delete[] output_array;
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
@@ -550,7 +548,7 @@ void RGBController_OpenRazer::UpdateMode()
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(20);
|
||||
std::this_thread::sleep_for(20ms);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
@@ -16,6 +16,8 @@
|
||||
#include <linux/module.h>
|
||||
#include <linux/hid.h>
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
void RGBController_OpenRazer::DeviceUpdateLEDs()
|
||||
{
|
||||
switch(matrix_type)
|
||||
@@ -75,7 +77,7 @@ void RGBController_OpenRazer::DeviceUpdateLEDs()
|
||||
|
||||
delete[] output_array;
|
||||
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
}
|
||||
|
||||
if(matrix_type == RAZER_TYPE_MATRIX_FRAME)
|
||||
@@ -485,7 +487,7 @@ void RGBController_OpenRazer::UpdateMode()
|
||||
break;
|
||||
}
|
||||
|
||||
Sleep(20);
|
||||
std::this_thread::sleep_for(20ms);
|
||||
}
|
||||
break;
|
||||
|
||||
|
||||
28
cli.cpp
28
cli.cpp
@@ -9,29 +9,15 @@
|
||||
#include "i2c_smbus.h"
|
||||
#include "NetworkServer.h"
|
||||
|
||||
/*-------------------------------------------------------------*\
|
||||
| Quirk for MSVC; which doesn't support this case-insensitive |
|
||||
| function |
|
||||
\*-------------------------------------------------------------*/
|
||||
#ifdef _WIN32
|
||||
#include <Windows.h>
|
||||
/* swy: quirk for MSVC; which doesn't support this case-insensitive function */
|
||||
#define strcasecmp strcmpi
|
||||
#define strcasecmp strcmpi
|
||||
#endif
|
||||
|
||||
#ifdef __APPLE__
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
#ifdef __linux__
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
static std::vector<RGBController*> rgb_controllers;
|
||||
static ProfileManager* profile_manager;
|
||||
@@ -943,7 +929,7 @@ void WaitWhileServerOnline(NetworkServer* srv)
|
||||
{
|
||||
while (network_server->GetOnline())
|
||||
{
|
||||
Sleep(1000);
|
||||
std::this_thread::sleep_for(1s);
|
||||
};
|
||||
}
|
||||
|
||||
|
||||
@@ -13,11 +13,6 @@
|
||||
#include <Windows.h>
|
||||
#else
|
||||
#include <unistd.h>
|
||||
|
||||
static void Sleep(unsigned int milliseconds)
|
||||
{
|
||||
usleep(1000 * milliseconds);
|
||||
}
|
||||
#endif
|
||||
|
||||
i2c_smbus_interface::i2c_smbus_interface()
|
||||
|
||||
@@ -12,6 +12,8 @@
|
||||
#include <Windows.h>
|
||||
#include "inpout32.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
/* Return negative errno on error. */
|
||||
s32 i2c_smbus_i801::i801_access(u16 addr, char read_write, u8 command, int size, i2c_smbus_data *data)
|
||||
{
|
||||
@@ -299,7 +301,7 @@ int i2c_smbus_i801::i801_check_post(int status)
|
||||
/* try to stop the current command */
|
||||
Out32(SMBHSTCNT, Inp32(SMBHSTCNT) | SMBHSTCNT_KILL);
|
||||
//usleep_range(1000, 2000);
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
Out32(SMBHSTCNT, Inp32(SMBHSTCNT) & (~SMBHSTCNT_KILL));
|
||||
|
||||
Out32(SMBHSTSTS, STATUS_FLAGS);
|
||||
@@ -437,13 +439,14 @@ int i2c_smbus_i801::i801_transaction(int xact)
|
||||
/* Wait for either BYTE_DONE or an error flag being set */
|
||||
int i2c_smbus_i801::i801_wait_byte_done()
|
||||
{
|
||||
|
||||
int timeout = 0;
|
||||
int status;
|
||||
|
||||
/* We will always wait for a fraction of a second! */
|
||||
do
|
||||
{
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);
|
||||
//usleep_range(250, 500);
|
||||
status = Inp32(SMBHSTSTS);
|
||||
} while (!(status & (STATUS_ERROR_FLAGS | SMBHSTSTS_BYTE_DONE)) && (timeout++ < MAX_RETRIES));
|
||||
|
||||
@@ -10,6 +10,8 @@
|
||||
#include <Windows.h>
|
||||
#include "inpout32.h"
|
||||
|
||||
using namespace std::chrono_literals;
|
||||
|
||||
s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int size, i2c_smbus_data *data)
|
||||
{
|
||||
int i, len, status, cnt;
|
||||
@@ -115,7 +117,7 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
||||
{
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);;
|
||||
timeout++;
|
||||
}
|
||||
|
||||
@@ -154,7 +156,7 @@ s32 i2c_smbus_nct6775::nct6775_access(u16 addr, char read_write, u8 command, int
|
||||
{
|
||||
return -ETIMEDOUT;
|
||||
}
|
||||
Sleep(1);
|
||||
std::this_thread::sleep_for(1ms);;
|
||||
timeout++;
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user