mirror of
https://github.com/WerWolv/ImHex.git
synced 2026-04-02 05:27:41 -05:00
sys: Reformat all
This commit is contained in:
@@ -33,10 +33,10 @@ namespace hex::plugin::windows {
|
||||
HANDLE m_portHandle = INVALID_HANDLE_VALUE;
|
||||
std::jthread m_receiveThread;
|
||||
|
||||
int m_selectedPort = 0;
|
||||
int m_selectedBaudRate = 11; // 115200
|
||||
int m_selectedNumBits = 3; // 8
|
||||
int m_selectedStopBits = 0; // 1
|
||||
int m_selectedPort = 0;
|
||||
int m_selectedBaudRate = 11; // 115200
|
||||
int m_selectedNumBits = 3; // 8
|
||||
int m_selectedStopBits = 0; // 1
|
||||
int m_selectedParityBits = 0; // None
|
||||
bool m_hasCTSFlowControl = false; // No
|
||||
|
||||
|
||||
@@ -15,10 +15,10 @@ namespace hex::plugin::windows {
|
||||
static ULONGLONG subtractTimes(const FILETIME &left, const FILETIME &right) {
|
||||
LARGE_INTEGER a, b;
|
||||
|
||||
a.LowPart = left.dwLowDateTime;
|
||||
a.LowPart = left.dwLowDateTime;
|
||||
a.HighPart = left.dwHighDateTime;
|
||||
|
||||
b.LowPart = right.dwLowDateTime;
|
||||
b.LowPart = right.dwLowDateTime;
|
||||
b.HighPart = right.dwHighDateTime;
|
||||
|
||||
return a.QuadPart - b.QuadPart;
|
||||
@@ -63,9 +63,9 @@ namespace hex::plugin::windows {
|
||||
(user.QuadPart - lastUserCPU.QuadPart);
|
||||
cpuUsage /= (now.QuadPart - lastCPU.QuadPart);
|
||||
cpuUsage /= numProcessors;
|
||||
lastCPU = now;
|
||||
lastCPU = now;
|
||||
lastUserCPU = user;
|
||||
lastSysCPU = sys;
|
||||
lastSysCPU = sys;
|
||||
}
|
||||
|
||||
cpuUsage *= 100;
|
||||
@@ -85,7 +85,7 @@ namespace hex::plugin::windows {
|
||||
}
|
||||
|
||||
auto totalMem = memInfo.ullTotalPhys;
|
||||
auto usedMem = pmc.PrivateUsage;
|
||||
auto usedMem = pmc.PrivateUsage;
|
||||
|
||||
ImGui::TextFormatted(ICON_FA_MICROCHIP " {0} / {1}", hex::toByteString(usedMem), hex::toByteString(totalMem));
|
||||
});
|
||||
|
||||
@@ -190,12 +190,12 @@ namespace hex::plugin::windows {
|
||||
return true; // If false, connect_error error popup will override this error popup
|
||||
}
|
||||
this->m_portHandle = ::CreateFile(("\\\\.\\" + this->m_comPorts[this->m_selectedPort].first).c_str(),
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
nullptr);
|
||||
GENERIC_READ | GENERIC_WRITE,
|
||||
0,
|
||||
nullptr,
|
||||
OPEN_EXISTING,
|
||||
FILE_FLAG_OVERLAPPED,
|
||||
nullptr);
|
||||
|
||||
if (this->m_portHandle == INVALID_HANDLE_VALUE)
|
||||
return false;
|
||||
@@ -211,20 +211,20 @@ namespace hex::plugin::windows {
|
||||
if (!::GetCommState(this->m_portHandle, &serialParams))
|
||||
return false;
|
||||
|
||||
serialParams.BaudRate = std::stoi(ViewTTYConsole::BaudRates[this->m_selectedBaudRate]);
|
||||
serialParams.ByteSize = std::stoi(ViewTTYConsole::NumBits[this->m_selectedNumBits]);
|
||||
serialParams.StopBits = this->m_selectedStopBits;
|
||||
serialParams.Parity = this->m_selectedParityBits;
|
||||
serialParams.BaudRate = std::stoi(ViewTTYConsole::BaudRates[this->m_selectedBaudRate]);
|
||||
serialParams.ByteSize = std::stoi(ViewTTYConsole::NumBits[this->m_selectedNumBits]);
|
||||
serialParams.StopBits = this->m_selectedStopBits;
|
||||
serialParams.Parity = this->m_selectedParityBits;
|
||||
serialParams.fOutxCtsFlow = this->m_hasCTSFlowControl;
|
||||
|
||||
if (!::SetCommState(this->m_portHandle, &serialParams))
|
||||
return false;
|
||||
|
||||
COMMTIMEOUTS timeouts;
|
||||
timeouts.ReadIntervalTimeout = 500;
|
||||
timeouts.ReadTotalTimeoutConstant = 500;
|
||||
timeouts.ReadTotalTimeoutMultiplier = 100;
|
||||
timeouts.WriteTotalTimeoutConstant = 500;
|
||||
timeouts.ReadIntervalTimeout = 500;
|
||||
timeouts.ReadTotalTimeoutConstant = 500;
|
||||
timeouts.ReadTotalTimeoutMultiplier = 100;
|
||||
timeouts.WriteTotalTimeoutConstant = 500;
|
||||
timeouts.WriteTotalTimeoutMultiplier = 100;
|
||||
|
||||
if (!::SetCommTimeouts(this->m_portHandle, &timeouts))
|
||||
@@ -233,7 +233,7 @@ namespace hex::plugin::windows {
|
||||
closeHandle.release();
|
||||
|
||||
this->m_receiveThread = std::jthread([this](const std::stop_token &token) {
|
||||
bool waitingOnRead = false;
|
||||
bool waitingOnRead = false;
|
||||
OVERLAPPED overlapped = { 0 };
|
||||
|
||||
overlapped.hEvent = ::CreateEvent(nullptr, true, false, nullptr);
|
||||
@@ -267,16 +267,16 @@ namespace hex::plugin::windows {
|
||||
waitingOnRead = true;
|
||||
}
|
||||
} else {
|
||||
byte = 0;
|
||||
byte = 0;
|
||||
auto res = ::WaitForSingleObject(overlapped.hEvent, 500);
|
||||
switch (res) {
|
||||
case WAIT_OBJECT_0:
|
||||
if (::GetOverlappedResult(this->m_portHandle, &overlapped, &bytesRead, false)) {
|
||||
addByte(byte);
|
||||
waitingOnRead = false;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
case WAIT_OBJECT_0:
|
||||
if (::GetOverlappedResult(this->m_portHandle, &overlapped, &bytesRead, false)) {
|
||||
addByte(byte);
|
||||
waitingOnRead = false;
|
||||
}
|
||||
default:
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Reference in New Issue
Block a user