Adding WIRELESS_CLIENT option

This commit is contained in:
Rodrigo Alfonso
2023-02-12 21:35:48 -03:00
parent 43775f946e
commit e6dcfe7a7e
3 changed files with 13 additions and 8 deletions

View File

@@ -202,7 +202,7 @@ https://user-images.githubusercontent.com/1631752/218244610-99618911-0be9-4861-a
Name | Type | Default | Description
--- | --- | --- | ---
`protocol` | **LinkUniversal::Protocol** | `AUTODETECT` | Specifies what protocol should be used (one of `LinkUniversal::Protocol::AUTODETECT`, `LinkUniversal::Protocol::CABLE`, or `LinkUniversal::Protocol::WIRELESS`).
`protocol` | **LinkUniversal::Protocol** | `AUTODETECT` | Specifies what protocol should be used (one of `LinkUniversal::Protocol::AUTODETECT`, `LinkUniversal::Protocol::CABLE`, `LinkUniversal::Protocol::WIRELESS_AUTO`, or `LinkUniversal::Protocol::WIRELESS_CLIENT`).
`gameName` | **std::string** | `""` | The game name that will be broadcasted in wireless sessions. The library uses this to only connect to servers from the same game.
`cableOptions` | **LinkUniversal::CableOptions** | *same as LinkCable* | All the [👾 LinkCable](#constructor) constructor parameters in one *struct*.
`wirelessOptions` | **LinkUniversal::WirelessOptions** | *same as LinkWireless* | All the [📻 LinkWireless](#constructor-2) constructor parameters in one *struct*.

View File

@@ -27,10 +27,10 @@ int main() {
u16 initialKeys = ~REG_KEYS & KEY_ANY;
bool forceCable = initialKeys & KEY_LEFT;
bool forceWireless = initialKeys & KEY_RIGHT;
LinkUniversal::Protocol protocol = forceCable ? LinkUniversal::Protocol::CABLE
: forceWireless
? LinkUniversal::Protocol::WIRELESS
: LinkUniversal::Protocol::AUTODETECT;
LinkUniversal::Protocol protocol =
forceCable ? LinkUniversal::Protocol::CABLE
: forceWireless ? LinkUniversal::Protocol::WIRELESS_AUTO
: LinkUniversal::Protocol::AUTODETECT;
// (1) Create a LinkUniversal instance
linkUniversal = new LinkUniversal(protocol);

View File

@@ -64,7 +64,7 @@ class LinkUniversal {
public:
enum State { INITIALIZING, WAITING, CONNECTED };
enum Mode { LINK_CABLE, LINK_WIRELESS };
enum Protocol { AUTODETECT, CABLE, WIRELESS };
enum Protocol { AUTODETECT, CABLE, WIRELESS_AUTO, WIRELESS_CLIENT };
struct CableOptions {
LinkCable::BaudRate baudRate;
@@ -350,6 +350,9 @@ class LinkUniversal {
if (!linkWireless->connect(servers[serverIndex].id))
return false;
} else {
if (config.protocol == WIRELESS_CLIENT)
return false;
subWaitCount = 0;
serveWait = LINK_UNIVERSAL_SERVE_WAIT_FRAMES +
qran_range(1, LINK_UNIVERSAL_SERVE_WAIT_FRAMES_RANDOM);
@@ -371,7 +374,8 @@ class LinkUniversal {
setMode(LINK_CABLE);
break;
}
case WIRELESS: {
case WIRELESS_AUTO:
case WIRELESS_CLIENT: {
setMode(LINK_WIRELESS);
break;
}
@@ -395,7 +399,8 @@ class LinkUniversal {
setMode(LINK_CABLE);
break;
}
case WIRELESS: {
case WIRELESS_AUTO:
case WIRELESS_CLIENT: {
setMode(LINK_WIRELESS);
break;
}