Skip to content

Commit 02b9faf

Browse files
committed
fix setCustomConsole and event callback functions
1 parent e99889b commit 02b9faf

File tree

2 files changed

+9
-9
lines changed

2 files changed

+9
-9
lines changed

sites/cheerpx/src/content/docs/12-reference/CheerpX.Linux/04-setCustomConsole.md

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -7,23 +7,23 @@ description: Configure custom console behavior for handling keyboard input and o
77
namespace CheerpX {
88
class Linux {
99
setCustomConsole(
10-
writeFunc: (buf: Buffer) => void,
10+
writeFunc: (buf: Uint8Array, vt: number) => void,
1111
cols: number,
1212
rows: number
13-
): (keyCode: number) => void;
13+
): client.EventListener;
1414
}
1515
}
1616
```
1717

1818
## Parameters
1919

20-
- **writeFunc (`(buf: Buffer) => void`)** - Function to handle the output sent to the console.
20+
- **writeFunc (`(buf: Uint8Array, vt: number) => void`)** - Function to handle the output sent to the console.
2121
- **cols (`number`)** - Number of columns for the console.
2222
- **rows (`number`)** - Number of rows for the console.
2323

2424
## Returns
2525

26-
`setCustomConsole` returns a function of type `(keyCode: number) => void`. This function should be called to simulate user input by sending key codes to the console.
26+
`setCustomConsole` returns an event listener function of type `client.EventListener`. This function simulates user input by sending key codes to the console when triggered.
2727

2828
## Examples
2929

sites/cheerpx/src/content/docs/12-reference/CheerpX.Linux/06-event callbacks.md

Lines changed: 5 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -8,30 +8,30 @@ The `CheerpX.Linux` instance returned by `create` provides methods to register a
88
### `registerCallback`
99

1010
```ts
11-
registerCallback(eventName: string, callback: (state: string | number) => void): void
11+
registerCallback(eventName: string, callback: EventListener): void
1212
```
1313

1414
Registers a callback function for a specific event type.
1515

1616
**Parameters**
1717

1818
- **eventName (`string`)** - A string specifying the event type. Can be `"cpuActivity"`, `"diskActivity"`, or `"diskLatency"`.
19-
- **callback (`(state: string | number) => void`)** - A function that will be called when the event occurs. It receives a parameter which varies based on the event type:
20-
- For `"cpuActivity"` and `"diskActivity"`: `state` can be either "ready" (idle, no activity at this time) or "wait" (active, currently in use).
19+
- **callback (`EventListener`)** - A function that will be called when the event occurs. It receives a parameter, `state`, which varies based on the event type:
20+
- For `"cpuActivity"` and `"diskActivity"`: `state` can be either `"ready"` (idle, no activity at this time) or `"wait"` (active, currently in use).
2121
- For `"diskLatency"`: `state` is a number representing the time in milliseconds between requesting and receiving the last disk block from the backend.
2222

2323
### `unregisterCallback`
2424

2525
```ts
26-
unregisterCallback(eventName: string, callback: (state: string | number) => void): void
26+
unregisterCallback(eventName: string, callback: EventListener): void
2727
```
2828

2929
Unregisters a previously registered callback function for a specific event type.
3030

3131
**Parameters**
3232

3333
- **eventName (`string`)** - A string specifying the event type. See the `registerCallback` reference above for the supported event types.
34-
- **callback (`(state: string | number) => void`)** - The function to be unregistered.
34+
- **callback (`EventListener`)** - The callback function to unregister, which must be the same function that was previously registered with `registerCallback`.
3535

3636
Example usage:
3737

0 commit comments

Comments
 (0)