mirror of
https://github.com/afska/gba-link-connection.git
synced 2026-03-21 17:44:21 -05:00
Adding clear parameter and missing bindings
This commit is contained in:
parent
468e6e61c5
commit
f6b3204f32
|
|
@ -126,7 +126,7 @@ You can also change these compile-time constants:
|
|||
| `read(playerId)` | **u16** | Dequeues and returns the next message from player #`playerId`. If there's no data from that player, a `0` will be returned. |
|
||||
| `peek(playerId)` | **u16** | Returns the next message from player #`playerId` without dequeuing it. If there's no data from that player, a `0` will be returned. |
|
||||
| `send(data)` | - | Sends `data` to all connected players. If `data` is invalid or the send queue is full, a `false` will be returned. |
|
||||
| `didQueueOverflow()` | **bool** | Returns whether the internal receive queue lost messages at some point due to being full. This can happen if your queue size is too low, if you receive too much data without calling `sync(...)` enough times, or if you don't `read(...)` enough messages before the next `sync()` call. The flag is cleared on each call. |
|
||||
| `didQueueOverflow()` | **bool** | Returns whether the internal receive queue lost messages at some point due to being full. This can happen if your queue size is too low, if you receive too much data without calling `sync(...)` enough times, or if you don't `read(...)` enough messages before the next `sync()` call. After this call, the overflow flag is cleared if `clear` is `true` (default behavior). |
|
||||
| `resetTimer()` | - | Restarts the send timer without disconnecting. Call this if you changed `config.interval` |
|
||||
|
||||
⚠️ `0xFFFF` and `0x0` are reserved values, so don't send them!
|
||||
|
|
@ -262,7 +262,7 @@ You can also change these compile-time constants:
|
|||
| `isServerClosed()` | **bool** | Returns `true` if the server was closed with `closeServer()`. |
|
||||
| `playerCount()` | **u8** _(1~5)_ | Returns the number of connected players. |
|
||||
| `currentPlayerId()` | **u8** _(0~4)_ | Returns the current player ID. |
|
||||
| `didQueueOverflow()` | **bool** | Returns whether the internal receive queue lost messages at some point due to being full. This can happen if your queue size is too low, if you receive too much data without calling `receive(...)` enough times, or if excessive `receive(...)` calls prevent the ISR from copying data. The flag is cleared on each call. |
|
||||
| `didQueueOverflow()` | **bool** | Returns whether the internal receive queue lost messages at some point due to being full. This can happen if your queue size is too low, if you receive too much data without calling `receive(...)` enough times, or if excessive `receive(...)` calls prevent the ISR from copying data. After this call, the overflow flag is cleared if `clear` is `true` (default behavior). |
|
||||
| `getLastError([clear])` | **LinkWireless::Error** | If one of the other methods returns `false`, you can inspect this to know the cause. After this call, the last error is cleared if `clear` is `true` (default behavior). |
|
||||
| `resetTimer()` | - | Restarts the send timer without disconnecting. Call this if you changed `config.interval`. |
|
||||
|
||||
|
|
@ -530,7 +530,7 @@ You can change these compile-time constants:
|
|||
| `peek()` | **u32** | Returns the next received value without dequeuing it. If there's no received data, a `0` will be returned. |
|
||||
| `send(data)` | - | Sends 32-bit `data`. If the other end asks for data at the same time you call this method, a `0x00000000` will be sent. |
|
||||
| `pendingCount()` | **u32** | Returns the number of pending outgoing transfers. |
|
||||
| `didQueueOverflow()` | **bool** | Returns whether the internal receive queue lost messages at some point due to being full. This can happen if your queue size is too low, if you receive too much data without calling `read(...)` enough times, or if excessive `read(...)` calls prevent the ISR from copying data. The flag is cleared on each call. |
|
||||
| `didQueueOverflow([clear])` | **bool** | Returns whether the internal receive queue lost messages at some point due to being full. This can happen if your queue size is too low, if you receive too much data without calling `read(...)` enough times, or if excessive `read(...)` calls prevent the ISR from copying data. After this call, the overflow flag is cleared if `clear` is `true` (default behavior). |
|
||||
| `didReset([clear])` | **bool** | Returns whether a JOYBUS reset was requested or not. After this call, the reset flag is cleared if `clear` is `true` (default behavior). |
|
||||
|
||||
# 📱 LinkMobile
|
||||
|
|
|
|||
|
|
@ -263,20 +263,23 @@ class LinkCable {
|
|||
* @brief Returns whether the internal receive queue lost messages at some
|
||||
* point due to being full. This can happen if your queue size is too low, if
|
||||
* you receive too much data without calling `sync(...)` enough times, or if
|
||||
* you don't `read(...)` enough messages before the next `sync()` call.
|
||||
* \warning The flag is cleared on each call.
|
||||
* you don't `read(...)` enough messages before the next `sync()` call. After
|
||||
* this call, the overflow flag is cleared if `clear` is `true` (default
|
||||
* behavior).
|
||||
*/
|
||||
[[nodiscard]] bool didQueueOverflow() {
|
||||
bool flag = false;
|
||||
[[nodiscard]] bool didQueueOverflow(bool clear = true) {
|
||||
bool overflow = false;
|
||||
|
||||
for (u32 i = 0; i < LINK_CABLE_MAX_PLAYERS; i++) {
|
||||
flag = flag || _state.newMessages[i].overflow ||
|
||||
_state.readyToSyncMessages[i].overflow;
|
||||
_state.newMessages[i].overflow = false;
|
||||
state.syncedIncomingMessages[i].overflow = false;
|
||||
overflow = overflow || _state.newMessages[i].overflow ||
|
||||
_state.readyToSyncMessages[i].overflow;
|
||||
if (clear) {
|
||||
_state.newMessages[i].overflow = false;
|
||||
state.syncedIncomingMessages[i].overflow = false;
|
||||
}
|
||||
}
|
||||
|
||||
return flag;
|
||||
return overflow;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -156,13 +156,15 @@ class LinkCube {
|
|||
* @brief Returns whether the internal receive queue lost messages at some
|
||||
* point due to being full. This can happen if your queue size is too low, if
|
||||
* you receive too much data without calling `read(...)` enough times, or
|
||||
* if excessive `read(...)` calls prevent the ISR from copying data.
|
||||
* \warning The flag is cleared on each call.
|
||||
* if excessive `read(...)` calls prevent the ISR from copying data. After
|
||||
* this call, the overflow flag is cleared if `clear` is `true` (default
|
||||
* behavior).
|
||||
*/
|
||||
[[nodiscard]] bool didQueueOverflow() {
|
||||
bool flag = newIncomingQueue.overflow;
|
||||
newIncomingQueue.overflow = false;
|
||||
return flag;
|
||||
[[nodiscard]] bool didQueueOverflow(bool clear = true) {
|
||||
bool overflow = newIncomingQueue.overflow;
|
||||
if (clear)
|
||||
newIncomingQueue.overflow = false;
|
||||
return overflow;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -364,19 +364,21 @@ class LinkUniversal {
|
|||
* @brief Returns whether the internal receive queue lost messages at some
|
||||
* point due to being full. This can happen if your queue size is too low, if
|
||||
* you receive too much data without calling `sync(...)` enough times, or if
|
||||
* you don't `read(...)` enough messages before the next `sync()` call.
|
||||
* \warning The flag is cleared on each call.
|
||||
* you don't `read(...)` enough messages before the next `sync()` call. After
|
||||
* this call, the overflow flag is cleared if `clear` is `true` (default
|
||||
* behavior).
|
||||
*/
|
||||
[[nodiscard]] bool didQueueOverflow() {
|
||||
bool flag = mode == LINK_CABLE ? linkCable.didQueueOverflow()
|
||||
: linkWireless.didQueueOverflow();
|
||||
[[nodiscard]] bool didQueueOverflow(bool clear = true) {
|
||||
bool overflow = mode == LINK_CABLE ? linkCable.didQueueOverflow()
|
||||
: linkWireless.didQueueOverflow();
|
||||
|
||||
for (u32 i = 0; i < LINK_UNIVERSAL_MAX_PLAYERS; i++) {
|
||||
flag = flag || incomingMessages[i].overflow;
|
||||
incomingMessages[i].overflow = false;
|
||||
overflow = overflow || incomingMessages[i].overflow;
|
||||
if (clear)
|
||||
incomingMessages[i].overflow = false;
|
||||
}
|
||||
|
||||
return flag;
|
||||
return overflow;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -686,13 +686,15 @@ class LinkWireless {
|
|||
* @brief Returns whether the internal receive queue lost messages at some
|
||||
* point due to being full. This can happen if your queue size is too low, if
|
||||
* you receive too much data without calling `receive(...)` enough times, or
|
||||
* if excessive `receive(...)` calls prevent the ISR from copying data.
|
||||
* \warning The flag is cleared on each call.
|
||||
* if excessive `receive(...)` calls prevent the ISR from copying data. After
|
||||
* this call, the overflow flag is cleared if `clear` is `true` (default
|
||||
* behavior).
|
||||
*/
|
||||
[[nodiscard]] bool didQueueOverflow() {
|
||||
bool flag = sessionState.newIncomingMessages.overflow;
|
||||
sessionState.newIncomingMessages.overflow = false;
|
||||
return flag;
|
||||
[[nodiscard]] bool didQueueOverflow(bool clear = true) {
|
||||
bool overflow = sessionState.newIncomingMessages.overflow;
|
||||
if (clear)
|
||||
sessionState.newIncomingMessages.overflow = false;
|
||||
return overflow;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
|
|||
|
|
@ -73,8 +73,8 @@ bool C_LinkCable_send(C_LinkCableHandle handle, u16 data) {
|
|||
return static_cast<LinkCable*>(handle)->send(data);
|
||||
}
|
||||
|
||||
bool C_LinkCable_didQueueOverflow(C_LinkCableHandle handle) {
|
||||
static_cast<LinkCable*>(handle)->didQueueOverflow();
|
||||
bool C_LinkCable_didQueueOverflow(C_LinkCableHandle handle, bool clear) {
|
||||
static_cast<LinkCable*>(handle)->didQueueOverflow(clear);
|
||||
}
|
||||
|
||||
void C_LinkCable_resetTimer(C_LinkCableHandle handle) {
|
||||
|
|
|
|||
|
|
@ -57,7 +57,7 @@ u16 C_LinkCable_peek(C_LinkCableHandle handle, u8 playerId);
|
|||
|
||||
bool C_LinkCable_send(C_LinkCableHandle handle, u16 data);
|
||||
|
||||
bool C_LinkCable_didQueueOverflow(C_LinkCableHandle handle);
|
||||
bool C_LinkCable_didQueueOverflow(C_LinkCableHandle handle, bool clear);
|
||||
void C_LinkCable_resetTimer(C_LinkCableHandle handle);
|
||||
|
||||
C_LinkCable_Config C_LinkCable_getConfig(C_LinkCableHandle handle);
|
||||
|
|
|
|||
|
|
@ -51,8 +51,8 @@ u32 C_LinkCube_pendingCount(C_LinkCubeHandle handle) {
|
|||
return static_cast<LinkCube*>(handle)->pendingCount();
|
||||
}
|
||||
|
||||
bool C_LinkCube_didQueueOverflow(C_LinkCubeHandle handle) {
|
||||
return static_cast<LinkCube*>(handle)->didQueueOverflow();
|
||||
bool C_LinkCube_didQueueOverflow(C_LinkCubeHandle handle, bool clear) {
|
||||
return static_cast<LinkCube*>(handle)->didQueueOverflow(clear);
|
||||
}
|
||||
|
||||
bool C_LinkCube_didReset(C_LinkCubeHandle handle, bool clear) {
|
||||
|
|
|
|||
|
|
@ -25,8 +25,8 @@ u32 C_LinkCube_peek(C_LinkCubeHandle handle);
|
|||
|
||||
void C_LinkCube_send(C_LinkCubeHandle handle, u32 data);
|
||||
u32 C_LinkCube_pendingCount(C_LinkCubeHandle handle);
|
||||
bool C_LinkCube_didQueueOverflow(C_LinkCubeHandle handle);
|
||||
|
||||
bool C_LinkCube_didQueueOverflow(C_LinkCubeHandle handle, bool clear);
|
||||
bool C_LinkCube_didReset(C_LinkCubeHandle handle, bool clear);
|
||||
|
||||
void C_LinkCube_onSerial(C_LinkCubeHandle handle);
|
||||
|
|
|
|||
|
|
@ -88,6 +88,11 @@ bool C_LinkUniversal_send(C_LinkUniversalHandle handle, u16 data) {
|
|||
return static_cast<LinkUniversal*>(handle)->send(data);
|
||||
}
|
||||
|
||||
bool C_LinkUniversal_didQueueOverflow(C_LinkUniversalHandle handle,
|
||||
bool clear) {
|
||||
return static_cast<LinkUniversal*>(handle)->didQueueOverflow(clear);
|
||||
}
|
||||
|
||||
void C_LinkUniversal_resetTimer(C_LinkUniversalHandle handle) {
|
||||
return static_cast<LinkUniversal*>(handle)->resetTimer();
|
||||
}
|
||||
|
|
|
|||
|
|
@ -79,6 +79,7 @@ u16 C_LinkUniversal_peek(C_LinkUniversalHandle handle, u8 playerId);
|
|||
|
||||
bool C_LinkUniversal_send(C_LinkUniversalHandle handle, u16 data);
|
||||
|
||||
bool C_LinkUniversal_didQueueOverflow(C_LinkUniversalHandle handle, bool clear);
|
||||
void C_LinkUniversal_resetTimer(C_LinkUniversalHandle handle);
|
||||
|
||||
C_LinkUniversal_State C_LinkUniversal_getState(C_LinkUniversalHandle handle);
|
||||
|
|
|
|||
|
|
@ -151,8 +151,8 @@ u8 C_LinkWireless_currentPlayerId(C_LinkWirelessHandle handle) {
|
|||
return static_cast<LinkWireless*>(handle)->currentPlayerId();
|
||||
}
|
||||
|
||||
bool C_LinkWireless_didQueueOverflow(C_LinkWirelessHandle handle) {
|
||||
return static_cast<LinkWireless*>(handle)->didQueueOverflow();
|
||||
bool C_LinkWireless_didQueueOverflow(C_LinkWirelessHandle handle, bool clear) {
|
||||
return static_cast<LinkWireless*>(handle)->didQueueOverflow(clear);
|
||||
}
|
||||
|
||||
C_LinkWireless_Error C_LinkWireless_getLastError(C_LinkWirelessHandle handle,
|
||||
|
|
|
|||
|
|
@ -123,7 +123,7 @@ bool C_LinkWireless_isSessionActive(C_LinkWirelessHandle handle);
|
|||
bool C_LinkWireless_isServerClosed(C_LinkWirelessHandle handle);
|
||||
u8 C_LinkWireless_playerCount(C_LinkWirelessHandle handle);
|
||||
u8 C_LinkWireless_currentPlayerId(C_LinkWirelessHandle handle);
|
||||
bool C_LinkWireless_didQueueOverflow(C_LinkWirelessHandle handle);
|
||||
bool C_LinkWireless_didQueueOverflow(C_LinkWirelessHandle handle, bool clear);
|
||||
|
||||
C_LinkWireless_Error C_LinkWireless_getLastError(C_LinkWirelessHandle handle,
|
||||
bool clear);
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user