16
0
mirror of https://github.com/MaSzyna-EU07/maszyna.git synced 2026-07-17 23:39:18 +02:00

reformat: remove redundant parentheses

This commit is contained in:
jerrrrycho
2026-06-30 21:19:46 +02:00
parent 7c88907f6b
commit d85096f64d
108 changed files with 4098 additions and 4662 deletions

View File

@@ -145,7 +145,7 @@ bool TPoKeys55::Connect()
DeviceIDFromRegistry = ToLower( DeviceIDFromRegistry );
DeviceIDToFind = ToLower( DeviceIDToFind );
// Now check if the hardware ID we are looking at contains the correct VID/PID
MatchFound = ( contains( DeviceIDFromRegistry, DeviceIDToFind ) );
MatchFound = contains(DeviceIDFromRegistry, DeviceIDToFind);
if (MatchFound == true)
{
// Device must have been found. Open read and write handles. In order to do this,we
@@ -160,7 +160,7 @@ bool TPoKeys55::Connect()
SetupDiGetDeviceInterfaceDetail(DeviceInfoTable, InterfaceDataStructure, nullptr, 0,
&StructureSize, nullptr);
DetailedInterfaceDataStructure =
(PSP_DEVICE_INTERFACE_DETAIL_DATA)(malloc(StructureSize)); // Allocate enough memory
(PSP_DEVICE_INTERFACE_DETAIL_DATA)malloc(StructureSize); // Allocate enough memory
if (DetailedInterfaceDataStructure == nullptr) // if null,error,couldn't allocate enough memory
{ // Can't really recover from this situation,just exit instead.
SetupDiDestroyDeviceInfoList(
@@ -175,12 +175,12 @@ bool TPoKeys55::Connect()
// the device.
// We store the handles in the global variables "WriteHandle" and "ReadHandle",which we
// will use later to actually communicate.
WriteHandle = CreateFile((DetailedInterfaceDataStructure->DevicePath), GENERIC_WRITE,
WriteHandle = CreateFile(DetailedInterfaceDataStructure->DevicePath, GENERIC_WRITE,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, 0);
ErrorStatus = GetLastError();
// if (ErrorStatus==ERROR_SUCCESS)
// ToggleLedBtn->Enabled=true;//Make button no longer greyed out
ReadHandle = CreateFile((DetailedInterfaceDataStructure->DevicePath), GENERIC_READ,
ReadHandle = CreateFile(DetailedInterfaceDataStructure->DevicePath, GENERIC_READ,
FILE_SHARE_READ | FILE_SHARE_WRITE, nullptr, OPEN_EXISTING, 0, 0);
ErrorStatus = GetLastError();
if (ErrorStatus == ERROR_SUCCESS)
@@ -222,7 +222,7 @@ bool TPoKeys55::Write(unsigned char c, unsigned char b3, unsigned char b4, unsig
// The following call to WriteFile() sends 64 bytes of data to the USB device.
WriteFile(WriteHandle, &OutputBuffer, 65, &BytesWritten,
0); // Blocking function, unless an "overlapped" structure is used
return (BytesWritten == 65);
return BytesWritten == 65;
// Read(); //odczyt trzeba zrobić inaczej - w tym miejscu będzie za szybko i nic się nie odczyta
}
@@ -240,7 +240,7 @@ bool TPoKeys55::Read()
// InputPacketBuffer[0] is the report ID, which we don't care about.
// InputPacketBuffer[1] is an echo back of the command.
// InputPacketBuffer[2] contains the I/O port pin value for the pushbutton.
return (BytesRead == 65) ? InputBuffer[7] == cRequest : false;
return BytesRead == 65 ? InputBuffer[7] == cRequest : false;
}
//---------------------------------------------------------------------------
bool TPoKeys55::ReadLoop(int i)
@@ -305,13 +305,13 @@ bool TPoKeys55::Update(bool pause)
{
case 0: // uaktualnienie PWM raz na jakiś czas
OutputBuffer[9] = 0x3F; // maska użytych PWM
*((int *)(OutputBuffer + 10)) = iPWM[0]; // PWM1 (pin 22)
*((int *)(OutputBuffer + 14)) = iPWM[1]; // PWM2 (pin 21)
*((int *)(OutputBuffer + 18)) = iPWM[2]; // PWM3 (pin 20)
*((int *)(OutputBuffer + 22)) = iPWM[3]; // PWM4 (pin 19)
*((int *)(OutputBuffer + 26)) = iPWM[4]; // PWM5 (pin 18)
*((int *)(OutputBuffer + 30)) = iPWM[5]; // PWM6 (pin 17)
*((int *)(OutputBuffer + 34)) = iPWM[7]; // PWM period
*(int *)(OutputBuffer + 10) = iPWM[0]; // PWM1 (pin 22)
*(int *)(OutputBuffer + 14) = iPWM[1]; // PWM2 (pin 21)
*(int *)(OutputBuffer + 18) = iPWM[2]; // PWM3 (pin 20)
*(int *)(OutputBuffer + 22) = iPWM[3]; // PWM4 (pin 19)
*(int *)(OutputBuffer + 26) = iPWM[4]; // PWM5 (pin 18)
*(int *)(OutputBuffer + 30) = iPWM[5]; // PWM6 (pin 17)
*(int *)(OutputBuffer + 34) = iPWM[7]; // PWM period
if (Write(0xCB, 1)) // wysłanie ustawień (1-ustaw, 0-odczyt)
iRepeats = 0; // informacja, że poszło dobrze
++iFaza; // ta faza została zakończona
@@ -340,7 +340,7 @@ bool TPoKeys55::Update(bool pause)
Write(0x31, 0); // 0x31: blokowy odczyt wejść
else if (Read())
{ // jest odebrana ramka i zgodność numeru żądania
iInputs[0] = *((int *)(InputBuffer + 3)); // odczyt 32 bitów
iInputs[0] = *(int *)(InputBuffer + 3); // odczyt 32 bitów
iFaza = 3; // skoro odczytano, można kolejny cykl
iRepeats = 0; // zerowanie licznika prób
}
@@ -348,7 +348,7 @@ bool TPoKeys55::Update(bool pause)
++iRepeats; // licznik nieudanych prób
break;
case 3: // ustawienie wyjść analogowych, 0..4095 mapować na 0..65520 (<<4)
if (Write(0x41, 43 - 1, (iPWM[6] >> 4), (iPWM[6] << 4))) // wysłanie ustawień
if (Write(0x41, 43 - 1, iPWM[6] >> 4, iPWM[6] << 4)) // wysłanie ustawień
iRepeats = 0; // informacja, że poszło dobrze
iFaza = 0; //++iFaza; //ta faza została zakończona
// powinno jeszcze przyjść potwierdzenie o kodzie 0x41
@@ -366,7 +366,7 @@ bool TPoKeys55::Update(bool pause)
iRepeats = 1; // w nowej fazie nowe szanse, ale nie od 0!
bNoError = false; // zgłosić błąd
}
return (bNoError); // true oznacza prawidłowe działanie
return bNoError; // true oznacza prawidłowe działanie
// czy w przypadku błędu komunikacji z PoKeys włączać pauzę?
// dopiero poprawne podłączenie zeruje licznik prób
};