Changeset d31c3ea in mainline for uspace/srv/hid/output/ctl/serial.c


Ignore:
Timestamp:
2024-10-01T11:13:28Z (3 months ago)
Author:
Jiri Svoboda <jiri@…>
Branches:
master
Children:
6907f26
Parents:
357d9dd
git-author:
Jiri Svoboda <jiri@…> (2024-09-30 19:13:18)
git-committer:
Jiri Svoboda <jiri@…> (2024-10-01 11:13:28)
Message:

Group vt callbacks into a callback structure

File:
1 edited

Legend:

Unmodified
Added
Removed
  • uspace/srv/hid/output/ctl/serial.c

    r357d9dd rd31c3ea  
    4444#define SERIAL_COLS  80
    4545#define SERIAL_ROWS  24
     46
     47static serial_putuchar_t serial_putuchar_fn;
     48static serial_control_puts_t serial_control_puts_fn;
     49static serial_flush_t serial_flush_fn;
     50
     51static void serial_vt_putuchar(void *, char32_t);
     52static void serial_vt_control_puts(void *, const char *);
     53static void serial_vt_flush(void *);
     54
     55static vt100_cb_t serial_vt_cb = {
     56        .putuchar = serial_vt_putuchar,
     57        .control_puts = serial_vt_control_puts,
     58        .flush = serial_vt_flush
     59};
    4660
    4761/** Draw the character at the specified position.
     
    124138};
    125139
    126 errno_t serial_init(vt100_putuchar_t putuchar_fn,
    127     vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn)
     140errno_t serial_init(serial_putuchar_t putuchar_fn,
     141    serial_control_puts_t control_puts_fn, serial_flush_t flush_fn)
    128142{
    129143        char_attrs_t attrs;
    130         vt100_t *vt100 =
    131             vt100_create(NULL, SERIAL_COLS, SERIAL_ROWS, putuchar_fn,
    132             control_puts_fn, flush_fn);
     144        vt100_t *vt100;
     145
     146        serial_putuchar_fn = putuchar_fn;
     147        serial_control_puts_fn = control_puts_fn;
     148        serial_flush_fn = flush_fn;
     149
     150        vt100 = vt100_create(NULL, SERIAL_COLS, SERIAL_ROWS, &serial_vt_cb);
    133151        if (vt100 == NULL)
    134152                return ENOMEM;
     
    150168}
    151169
     170static void serial_vt_putuchar(void *arg, char32_t c)
     171{
     172        (void)arg;
     173        serial_putuchar_fn(c);
     174}
     175
     176static void serial_vt_control_puts(void *arg, const char *str)
     177{
     178        (void)arg;
     179        serial_control_puts_fn(str);
     180}
     181
     182static void serial_vt_flush(void *arg)
     183{
     184        (void)arg;
     185        serial_flush_fn();
     186}
     187
    152188/** @}
    153189 */
Note: See TracChangeset for help on using the changeset viewer.