Skip to content

Commit

Permalink
feat: added internal serial options
Browse files Browse the repository at this point in the history
  • Loading branch information
midwan committed Oct 29, 2024
1 parent 021290e commit 469fa32
Show file tree
Hide file tree
Showing 2 changed files with 42 additions and 6 deletions.
37 changes: 31 additions & 6 deletions src/osdep/gui/PanelIOPorts.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -64,7 +64,18 @@ class IOActionListener : public gcn::ActionListener
else
{
const auto port_name = serial_ports_list.getElementAt(selected);
_sntprintf(changed_prefs.sername, 256, "%s", port_name.c_str());
if (port_name == "Amiberry inter-process serial port")
{
_sntprintf(changed_prefs.sername, 256, "%s", SERIAL_INTERNAL);
}
else if (port_name == "Amiberry loopback serial port")
{
_sntprintf(changed_prefs.sername, 256, "%s", SERIAL_LOOPBACK);
}
else
{
_sntprintf(changed_prefs.sername, 256, "%s", port_name.c_str());
}
changed_prefs.use_serial = true;
}
}
Expand Down Expand Up @@ -154,16 +165,30 @@ void InitPanelIO(const config_category& category)
serial_ports_list.clear();
serial_ports_list.add("none");
for(const auto& i : serial_ports) {
serial_ports_list.add(i);
if (i != "Amiberry inter-process serial port")
{
std::string tmp = i;
if (!shmem_serial_state())
shmem_serial_create();
switch (shmem_serial_state())
{
case 1:
tmp += " [Master]";
break;
case 2:
tmp += " [Slave]";
break;
}
serial_ports_list.add(tmp);
}
else
serial_ports_list.add(i);
}
// Add TCP ports also
serial_ports_list.add("TCP://0.0.0.0:1234");
serial_ports_list.add("TCP://0.0.0.0:1234/wait");

midi_in_ports_list.clear();
midi_in_ports_list.add("none");
for(const auto& i : midi_in_ports) {
midi_in_ports_list.add(i.c_str());
midi_in_ports_list.add(i);
}

midi_out_ports_list.clear();
Expand Down
11 changes: 11 additions & 0 deletions src/parser.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -519,6 +519,7 @@ int enumserialports (void)
}
else
{
serial_ports.clear();
for (int i = 0; port_list[i] != nullptr; i++)
{
cnt++;
Expand All @@ -530,6 +531,16 @@ int enumserialports (void)
/* Free the array created by sp_list_ports(). */
sp_free_port_list(port_list);
}

serial_ports.emplace_back("Amiberry inter-process serial port");
cnt++;
serial_ports.emplace_back("Amiberry loopback serial port");
cnt++;
serial_ports.emplace_back("TCP://0.0.0.0:1234");
cnt++;
serial_ports.emplace_back("TCP://0.0.0.0:1234/wait");
cnt++;
write_log(_T("Port enumeration end\n"));
return cnt;
}

Expand Down

0 comments on commit 469fa32

Please sign in to comment.