Skip to content

Commit c8248bb

Browse files
authored
Merge branch 'PokemonAutomation:main' into main
2 parents 6bcc9fd + bd646c6 commit c8248bb

33 files changed

Lines changed: 131 additions & 82 deletions

.github/workflows/cpp-ci-serial-programs-base.yml

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -95,7 +95,7 @@ jobs:
9595
echo https://github.com/${{github.repository}}/commit/${{github.sha}} > ${{env.UPLOAD_FOLDER}}/version.txt
9696
9797
- name: Upload Build
98-
uses: actions/upload-artifact@v6
98+
uses: actions/upload-artifact@v7
9999
if: inputs.upload-build
100100
with:
101101
name: Serial Programs (os=${{inputs.os}} - compiler=${{inputs.compiler}})

.gitignore

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,7 @@
11
SerialPrograms/bin/
22

33
.vscode
4+
.qtcreator
45

56
discord_social_sdk_win/
67
discord_partner_sdk.dll
@@ -73,3 +74,4 @@ CLAUDE.md
7374
build_*/
7475
.cache/*
7576
Packages/*
77+

Common/Cpp/StreamConnections/MockDevice.cpp

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ using std::cout;
1515
using std::endl;
1616

1717
#if 1
18-
#define PABB2_DROP_HOST_TO_DEVICE 0.2
19-
#define PABB2_DROP_DEVICE_TO_HOST 0.2
18+
#define PABB2_DROP_HOST_TO_DEVICE 0.01
19+
#define PABB2_DROP_DEVICE_TO_HOST 0.01
2020
#else
2121
#define PABB2_DROP_HOST_TO_DEVICE 0
2222
#define PABB2_DROP_DEVICE_TO_HOST 0
@@ -98,6 +98,9 @@ size_t MockDevice::device_read_serial(void* data, size_t max_bytes){
9898
auto iter1 = iter0 + bytes;
9999
std::copy(iter0, iter1, (uint8_t*)data);
100100
m_host_to_device_line.erase(iter0, iter1);
101+
102+
// cout << "device_read_serial(): attempt = " << max_bytes << ", actual = " << bytes << endl;
103+
101104
return bytes;
102105
}
103106

Common/PABotBase2/PABotBase2_PacketParser.c

Lines changed: 7 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,8 @@
77
#include "Common/CRC32/pabb_CRC32.h"
88
#include "PABotBase2_PacketParser.h"
99

10+
//#include <stdio.h>
11+
1012

1113
const pabb2_PacketHeader* pabb2_PacketParser_pull_bytes(
1214
pabb2_PacketParser* self,
@@ -27,6 +29,7 @@ const pabb2_PacketHeader* pabb2_PacketParser_pull_bytes(
2729

2830
// Header is still incomplete.
2931
if (self->index < MIN_PACKET_SIZE){
32+
// printf("Incomplete Header: %d\n", self->index);
3033
return NULL;
3134
}
3235

@@ -43,20 +46,19 @@ const pabb2_PacketHeader* pabb2_PacketParser_pull_bytes(
4346

4447
// Magic byte never found.
4548
if (c == MIN_PACKET_SIZE){
46-
self->index = 0;
4749
break;
4850
}
4951

5052
// Magic byte found.
5153
if (buffer[c] == PABB2_CONNECTION_MAGIC_NUMBER){
5254
// Shift the buffer up so that the magic byte is at the start.
5355
memmove(self->buffer, self->buffer + c, MIN_PACKET_SIZE - c);
54-
goto EndLoop;
56+
break;
5557
}
5658
}
57-
}
5859

59-
EndLoop:;
60+
self->index -= c;
61+
}
6062

6163
// At this point, we have a complete and valid header.
6264

@@ -87,6 +89,7 @@ EndLoop:;
8789

8890
// Packet is incomplete.
8991
if (self->index < packet_bytes){
92+
// printf("Incomplete Packet: %d\n", packet_bytes);
9093
return NULL;
9194
}
9295

Common/PABotBase2/PABotBase2_PacketSender.c

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -299,7 +299,7 @@ bool pabb2_PacketSender_iterate_retransmits(pabb2_PacketSender* self){
299299
// Not old enough.
300300
if ((uint8_t)(seqnum - packet->magic_number) < PABB2_ConnectionSender_RETRANSMIT_COUNTER){
301301
#if 0
302-
printf("Not old enough.\n");
302+
printf("Not old enough: seqnum = %d, packet = %d\n", seqnum, packet->magic_number);
303303
fflush(stdout);
304304
#endif
305305
head++;

Common/PABotBase2/PABotBase2_StreamCoalescer.c

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -7,8 +7,8 @@
77
#include <string.h>
88
#include "PABotBase2_StreamCoalescer.h"
99

10-
//#include <stdio.h> // REMOVE
11-
//#include "PABotBase2_ConnectionDebug.h" // REMOVE
10+
//#include <stdio.h>
11+
//#include "PABotBase2_ConnectionDebug.h"
1212

1313
void pabb2_StreamCoalescer_init(pabb2_StreamCoalescer* self){
1414
// printf("pabb2_StreamCoalescer_init(%p)\n", self);

Common/PABotBase2/PABotbase2_ReliableStreamConnection.c

Lines changed: 8 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -4,7 +4,7 @@
44
*
55
*/
66

7-
#include <stdio.h> // REMOVE
7+
//#include <stdio.h>
88
#include "PABotBase2_ConnectionDebug.h"
99
#include "PABotbase2_ReliableStreamConnection.h"
1010

@@ -44,26 +44,28 @@ void pabb2_ReliableStreamConnection_run_events(pabb2_ReliableStreamConnection* s
4444
case PABB2_PacketParser_RESULT_VALID:
4545
break;
4646
case PABB2_PacketParser_RESULT_INVALID:
47-
printf("PABB2_PacketParser_RESULT_INVALID\n");
47+
// printf("PABB2_PacketParser_RESULT_INVALID\n");
4848
pabb2_PacketSender_send_info(
4949
&self->reliable_sender,
5050
packet->seqnum,
5151
PABB2_CONNECTION_OPCODE_INVALID_LENGTH
5252
);
5353
return;
5454
case PABB2_PacketParser_RESULT_CHECKSUM_FAIL:
55-
printf("PABB2_PacketParser_RESULT_CHECKSUM_FAIL\n");
55+
// printf("PABB2_PacketParser_RESULT_CHECKSUM_FAIL\n");
5656
pabb2_PacketSender_send_info(
5757
&self->reliable_sender,
5858
packet->seqnum,
5959
PABB2_CONNECTION_OPCODE_INVALID_CHECKSUM_FAIL
6060
);
6161
return;
6262
default:
63-
printf("Internal Error: Unrecognized packet state.\n");
63+
// printf("Internal Error: Unrecognized packet state.\n");
6464
return;
6565
}
6666

67+
// printf("Device Received: %d\n", packet->opcode);
68+
6769
// Now handle the different opcodes.
6870
switch (packet->opcode){
6971
case PABB2_CONNECTION_OPCODE_ASK_RESET:
@@ -124,10 +126,10 @@ void pabb2_ReliableStreamConnection_run_events(pabb2_ReliableStreamConnection* s
124126
pabb2_StreamCoalescer_bytes_available(&self->stream_coalescer)
125127
);
126128
}else{
127-
printf("Device: Failed to push.\n");
129+
// printf("Device: Failed to push.\n");
128130
pabb2_StreamCoalescer_print(&self->stream_coalescer, true);
129131
}
130-
fflush(stdout);
132+
// fflush(stdout);
131133
return;
132134
default:
133135
pabb2_PacketSender_send_info(

Common/Qt/NoWheelComboBox.h

Lines changed: 27 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
/* ComboBox without mouse wheel scrolling.
1+
/* ComboBox without mouse wheel scrolling. Also, the height has been set to be more compact.
22
*
33
* From: https://github.com/PokemonAutomation/
44
*
@@ -8,15 +8,39 @@
88
#define PokemonAutomation_NoWheelComboBox_H
99

1010
#include <QComboBox>
11+
#include <QAbstractItemView>
12+
#include <QStyledItemDelegate>
1113

1214
//#define PA_ENABLE_SIZE_CACHING
1315

1416
namespace PokemonAutomation{
1517

1618

17-
class NoWheelComboBox : public QComboBox{
19+
class HeightDelegate : public QStyledItemDelegate {
1820
public:
19-
using QComboBox::QComboBox;
21+
using QStyledItemDelegate::QStyledItemDelegate;
22+
QSize sizeHint(const QStyleOptionViewItem &option, const QModelIndex &index) const override {
23+
QSize s = QStyledItemDelegate::sizeHint(option, index);
24+
int vertical_padding = 2;
25+
s.setHeight(option.fontMetrics.height() + vertical_padding);
26+
return s;
27+
}
28+
};
29+
30+
31+
class NoWheelCompactComboBox : public QComboBox{
32+
public:
33+
explicit NoWheelCompactComboBox(QWidget* parent = nullptr) : QComboBox(parent) {
34+
// Set the height for every line in the dropdown
35+
this->view()->setItemDelegate(new HeightDelegate(this));
36+
37+
// this->setStyleSheet("QAbstractItemView::item { height: 100px; }");
38+
39+
// Optional: Force a standard list view to ensure the stylesheet
40+
// is respected on all platforms (like Windows/macOS)
41+
// #include <QListView>
42+
// this->setView(new QListView());
43+
}
2044

2145
void update_size_cache(){
2246
#ifdef PA_ENABLE_SIZE_CACHING

Common/Qt/Options/EnumDropdownWidget.cpp

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -22,7 +22,7 @@ EnumDropdownCellWidget::~EnumDropdownCellWidget(){
2222
m_value.remove_listener(*this);
2323
}
2424
EnumDropdownCellWidget::EnumDropdownCellWidget(QWidget& parent, IntegerEnumDropdownCell& value)
25-
: NoWheelComboBox(&parent)
25+
: NoWheelCompactComboBox(&parent)
2626
, ConfigWidget(value, *this)
2727
, m_value(value)
2828
{

Common/Qt/Options/EnumDropdownWidget.h

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -15,7 +15,7 @@
1515
namespace PokemonAutomation{
1616

1717

18-
class EnumDropdownCellWidget : public NoWheelComboBox, public ConfigWidget{
18+
class EnumDropdownCellWidget : public NoWheelCompactComboBox, public ConfigWidget{
1919
public:
2020
using ParentOption = IntegerEnumDropdownCell;
2121

0 commit comments

Comments
 (0)