You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Copy file name to clipboardExpand all lines: README.md
+79-1Lines changed: 79 additions & 1 deletion
Display the source diff
Display the rich diff
Original file line number
Diff line number
Diff line change
@@ -12,6 +12,9 @@ A set of Game Boy Advance (GBA) C++ libraries to interact with the Serial Port.
12
12
-[🌎](#-LinkUniversal)[LinkUniversal.hpp](lib/LinkUniversal.hpp): Add multiplayer support to your game, both with 👾 *Link Cables* and 📻 *Wireless Adapters*, using the **same API**!
13
13
-[🔌](#-LinkGPIO)[LinkGPIO.hpp](lib/LinkGPIO.hpp): Use the Link Port however you want to control **any device** (like LEDs, rumble motors, and that kind of stuff)!
14
14
-[🔗](#-LinkSPI)[LinkSPI.hpp](lib/LinkSPI.hpp): Connect with a PC (like a **Raspberry Pi**) or another GBA (with a GBC Link Cable) using this mode. Transfer up to 2Mbit/s!
15
+
-[⏱️](#%EF%B8%8F-LinkUART)[LinkUART.hpp](lib/LinkUART.hpp): Easily connect to **any PC** using a USB to UART cable!
16
+
-[🖱️](#%EF%B8%8F-LinkPS2Mouse)[LinkPS2Mouse.hpp](lib/LinkPS2Mouse.hpp): Connect a **PS/2 mouse** to the GBA for extended controls!
17
+
-[⌨️](#%EF%B8%8F-LinkPS2Keyboard)[LinkPS2Keyboard.hpp](lib/LinkPS2Keyboard.hpp): Connect a **PS/2 keyboard** to the GBA for extended controls!
15
18
16
19
*(click on the emojis for documentation)*
17
20
@@ -87,7 +90,7 @@ Name | Return type | Description
87
90
88
91
# 💻 LinkCableMultiboot
89
92
90
-
*(aka Multiboot through Multi-Play mode)*
93
+
*(aka Multiboot through Multi-Play Mode)*
91
94
92
95
This tool allows sending Multiboot ROMs (small 256KiB programs that fit in EWRAM) from one GBA to up to 3 slaves, using a single cartridge.
93
96
@@ -343,3 +346,78 @@ The GBA operates using **SPI mode 3** (`CPOL=1, CPHA=1`). Here's a connection di
343
346
</td>
344
347
</tr>
345
348
</table>
349
+
350
+
# ⏱️ LinkUART
351
+
352
+
*(aka UART Mode)*
353
+
354
+
This is the GBA's implementation of UART. You can use this to interact with a PC using a _USB to UART cable_. You can change the buffer size by changing the compile-time constant `LINK_UART_QUEUE_SIZE`.
`isActive()` | **bool** | Returns whether the library is active or not.
363
+
`activate(baudRate, dataSize, parity, useCTS)` | - | Activates the library using a specific UART mode. _Defaults: 9600bps, 8-bit data, no parity bit, no CTS_.
364
+
`deactivate()` | - | Deactivates the library.
365
+
`sendLine(string)` | - | Takes a null-terminated `string`, and sends it followed by a `'\n'` character. The null character is not sent.
366
+
`sendLine(data, cancel)` | - | Like `sendLine(string)` but accepts a `cancel()` function. The library will continuously invoke it, and abort the transfer if it returns `true`.
367
+
`readLine(string, [limit])` | **bool** | Reads characters into `string` until finding a `'\n'` character or a character `limit` is reached. A null terminator is added at the end. Returns `false` if the limit has been reached without finding a newline character.
368
+
`readLine(string, cancel, [limit])` | - | Like `readLine(string, [limit])` but accepts a `cancel()` function. The library will continuously invoke it, and abort the transfer if it returns `true`.
369
+
`send(buffer, size, offset)` | - | Sends `size` bytes from `buffer`, starting at byte `offset`.
370
+
`read(buffer, size, offset)` | **u32** | Tries to read `size` bytes into `(u8*)(buffer + offset)`. Returns the number of read bytes.
371
+
`canRead()` | **bool** | Returns whether there are bytes to read or not.
372
+
`canSend()` | **bool** | Returns whether there is room to send new messages or not.
373
+
`availableForRead()` | **u32** | Returns the number of bytes available for read.
374
+
`availableForSend()` | **u32** | Returns the number of bytes available for send (buffer size - queued bytes).
375
+
`read()` | **u8** | Reads a byte. Returns 0 if nothing is found.
376
+
`send(data)` | - | Sends a `data` byte.
377
+
378
+
## UART Configuration
379
+
380
+
The GBA operates using 1 stop bit, but everything else can be configured. By default, the library uses `8N1`, which means 8-bit data and no parity bit. RTS/CTS is disabled by default.
`new LinkPS2Mouse(timerId)`, where `timerId` is the GBA Timer used for delays.
397
+
398
+
## Methods
399
+
400
+
Name | Return type | Description
401
+
--- | --- | ---
402
+
`isActive()` | **bool** | Returns whether the library is active or not.
403
+
`activate()` | - | Activates the library.
404
+
`deactivate()` | - | Deactivates the library.
405
+
`report(data[3])` | - | Fills the `data` int array with a report. The first int contains _clicks_ that you can check against the bitmasks `LINK_PS2_MOUSE_LEFT_CLICK`, `LINK_PS2_MOUSE_MIDDLE_CLICK`, and `LINK_PS2_MOUSE_RIGHT_CLICK`. The second int is the _X movement_, and the third int is the _Y movement_.
406
+
407
+
# ⌨️ LinkPS2Keyboard
408
+
409
+
A PS/2 keyboard driver for the GBA. Use it to add keyboard support to your homebrew games.
`new LinkPS2Keyboard(onEvent)`, where `onEvent` is a function pointer that will receive the scan codes (`u8`). You should check a PS/2 scan code list online, but there are some examples included like `LINK_PS2_KEYBOARD_KEY_ENTER` and `LINK_PS2_KEYBOARD_KEY_RELEASE`.
416
+
417
+
## Methods
418
+
419
+
Name | Return type | Description
420
+
--- | --- | ---
421
+
`isActive()` | **bool** | Returns whether the library is active or not.
0 commit comments