mirror of
https://github.com/afska/gba-link-connection.git
synced 2026-10-01 13:27:18 -05:00
Improving wireless adapter deactivation in LinkUniversal and LinkWirelessMultiboot
This commit is contained in:
@@ -238,7 +238,7 @@ You can also change these compile-time constants:
|
||||
| `isActive()` | **bool** | Returns whether the library is active or not. |
|
||||
| `activate()` | **bool** | Activates the library. When an adapter is connected, it changes the state to `AUTHENTICATED`. It can also be used to disconnect or reset the adapter. |
|
||||
| `restoreExistingConnection()` | **bool** | Restores the state from an existing connection on the Wireless Adapter hardware. This is useful, for example, after a fresh launch of a Multiboot game, to synchronize the library with the current state and avoid a reconnection. Returns whether the restoration was successful. On success, the state should be either `SERVING` or `CONNECTED`. This should be used as a replacement for `activate()`. |
|
||||
| `deactivate()` | **bool** | Puts the adapter into a low consumption mode and then deactivates the library. It returns a boolean indicating whether the transition to low consumption mode was successful. You can disable the transition and deactivate directly by setting `turnOff` to `true`. |
|
||||
| `deactivate([turnOff])` | **bool** | Puts the adapter into a low consumption mode and then deactivates the library. It returns a boolean indicating whether the transition to low consumption mode was successful. You can disable the transition and deactivate directly by setting `turnOff` to `true`. |
|
||||
| `serve([gameName], [userName], [gameId])` | **bool** | Starts broadcasting a server and changes the state to `SERVING`. You can, optionally, provide a `gameName` (max `14` characters), a `userName` (max `8` characters), and a `gameId` _(0 ~ 0x7FFF)_ that games will be able to read. The strings must be null-terminated character arrays. If the adapter is already serving, this method only updates the broadcast data. Updating broadcast data while serving can fail if the adapter is busy. In that case, this will return `false` and `getLastError()` will be `BUSY_TRY_AGAIN`. |
|
||||
| `closeServer()` | **bool** | Closes the server while keeping the session active, to prevent new users from joining the room. Closing the server can fail if the adapter is busy. In that case, this will return `false` and `getLastError()` will be `BUSY_TRY_AGAIN`. |
|
||||
| `getServers(servers, [onWait])` | **bool** | Fills the `servers` array with all the currently broadcasting servers. This action takes 1 second to complete, but you can optionally provide an `onWait()` function which will be invoked each time VBlank starts. |
|
||||
|
||||
@@ -175,13 +175,15 @@ class LinkUniversal {
|
||||
}
|
||||
|
||||
/**
|
||||
* @brief Deactivates the library.
|
||||
* @brief Deactivates the library, disabling both cable and wireless modes.
|
||||
* Returns whether the deactivation of the Wireless Adapter was successful.
|
||||
*/
|
||||
void deactivate() {
|
||||
bool deactivate(bool turnOffWireless = true) {
|
||||
isEnabled = false;
|
||||
linkCable->deactivate();
|
||||
linkWireless->deactivate();
|
||||
bool success = linkWireless->deactivate(turnOffWireless);
|
||||
resetState();
|
||||
return success;
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -581,10 +581,9 @@ class LinkWirelessMultiboot {
|
||||
}
|
||||
|
||||
Result finish(Result result, bool keepConnectionAlive = false) {
|
||||
if (result != SUCCESS || !keepConnectionAlive) {
|
||||
if (result != SUCCESS || !keepConnectionAlive)
|
||||
linkRawWireless->bye();
|
||||
linkRawWireless->deactivate();
|
||||
}
|
||||
linkRawWireless->deactivate();
|
||||
resetState();
|
||||
return result;
|
||||
}
|
||||
|
||||
@@ -38,8 +38,12 @@ void C_LinkUniversal_activate(C_LinkUniversalHandle handle) {
|
||||
static_cast<LinkUniversal*>(handle)->activate();
|
||||
}
|
||||
|
||||
void C_LinkUniversal_deactivate(C_LinkUniversalHandle handle) {
|
||||
static_cast<LinkUniversal*>(handle)->deactivate();
|
||||
bool C_LinkUniversal_deactivate(C_LinkUniversalHandle handle) {
|
||||
return static_cast<LinkUniversal*>(handle)->deactivate();
|
||||
}
|
||||
|
||||
bool C_LinkUniversal_deactivateButKeepWirelessOn(C_LinkUniversalHandle handle) {
|
||||
return static_cast<LinkUniversal*>(handle)->deactivate(false);
|
||||
}
|
||||
|
||||
bool C_LinkUniversal_isConnected(C_LinkUniversalHandle handle) {
|
||||
|
||||
@@ -60,7 +60,8 @@ void C_LinkUniversal_destroy(C_LinkUniversalHandle handle);
|
||||
|
||||
bool C_LinkUniversal_isActive(C_LinkUniversalHandle handle);
|
||||
void C_LinkUniversal_activate(C_LinkUniversalHandle handle);
|
||||
void C_LinkUniversal_deactivate(C_LinkUniversalHandle handle);
|
||||
bool C_LinkUniversal_deactivate(C_LinkUniversalHandle handle);
|
||||
bool C_LinkUniversal_deactivateButKeepWirelessOn(C_LinkUniversalHandle handle);
|
||||
|
||||
bool C_LinkUniversal_isConnected(C_LinkUniversalHandle handle);
|
||||
u8 C_LinkUniversal_playerCount(C_LinkUniversalHandle handle);
|
||||
|
||||
Reference in New Issue
Block a user