Changes in uspace/srv/hid/output/ctl/serial.c [28a5ebd:d31c3ea] in mainline
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/srv/hid/output/ctl/serial.c
r28a5ebd rd31c3ea 1 1 /* 2 * Copyright (c) 2024 Jiri Svoboda 2 3 * Copyright (c) 2006 Ondrej Palkovsky 3 4 * Copyright (c) 2008 Martin Decky … … 37 38 #include <errno.h> 38 39 #include <io/chargrid.h> 40 #include <vt/vt100.h> 39 41 #include "../output.h" 40 #include "../proto/vt100.h"41 42 #include "serial.h" 42 43 43 44 #define SERIAL_COLS 80 44 45 #define SERIAL_ROWS 24 46 47 static serial_putuchar_t serial_putuchar_fn; 48 static serial_control_puts_t serial_control_puts_fn; 49 static serial_flush_t serial_flush_fn; 50 51 static void serial_vt_putuchar(void *, char32_t); 52 static void serial_vt_control_puts(void *, const char *); 53 static void serial_vt_flush(void *); 54 55 static vt100_cb_t serial_vt_cb = { 56 .putuchar = serial_vt_putuchar, 57 .control_puts = serial_vt_control_puts, 58 .flush = serial_vt_flush 59 }; 45 60 46 61 /** Draw the character at the specified position. … … 52 67 * 53 68 */ 54 static void draw_char(vt100_ state_t *state, charfield_t *field,69 static void draw_char(vt100_t *state, charfield_t *field, 55 70 sysarg_t col, sysarg_t row) 56 71 { … … 62 77 static errno_t serial_yield(outdev_t *dev) 63 78 { 64 vt100_ state_t *state = (vt100_state_t *) dev->data;79 vt100_t *state = (vt100_t *) dev->data; 65 80 66 81 return vt100_yield(state); … … 69 84 static errno_t serial_claim(outdev_t *dev) 70 85 { 71 vt100_ state_t *state = (vt100_state_t *) dev->data;86 vt100_t *state = (vt100_t *) dev->data; 72 87 73 88 return vt100_claim(state); … … 77 92 sysarg_t *rows) 78 93 { 79 vt100_ state_t *state = (vt100_state_t *) dev->data;94 vt100_t *state = (vt100_t *) dev->data; 80 95 81 96 vt100_get_dimensions(state, cols, rows); … … 84 99 static console_caps_t serial_get_caps(outdev_t *dev) 85 100 { 86 return (CONSOLE_CAP_STYLE | CONSOLE_CAP_INDEXED); 101 return (CONSOLE_CAP_CURSORCTL | CONSOLE_CAP_STYLE | 102 CONSOLE_CAP_INDEXED | CONSOLE_CAP_RGB); 87 103 } 88 104 … … 90 106 sysarg_t prev_row, sysarg_t col, sysarg_t row, bool visible) 91 107 { 92 vt100_ state_t *state = (vt100_state_t *) dev->data;108 vt100_t *state = (vt100_t *) dev->data; 93 109 94 110 vt100_goto(state, col, row); … … 98 114 static void serial_char_update(outdev_t *dev, sysarg_t col, sysarg_t row) 99 115 { 100 vt100_ state_t *state = (vt100_state_t *) dev->data;116 vt100_t *state = (vt100_t *) dev->data; 101 117 charfield_t *field = 102 118 chargrid_charfield_at(dev->backbuf, col, row); … … 107 123 static void serial_flush(outdev_t *dev) 108 124 { 109 vt100_ state_t *state = (vt100_state_t *) dev->data;125 vt100_t *state = (vt100_t *) dev->data; 110 126 111 127 vt100_flush(state); … … 122 138 }; 123 139 124 errno_t serial_init( vt100_putuchar_t putuchar_fn,125 vt100_control_puts_t control_puts_fn, vt100_flush_t flush_fn)140 errno_t serial_init(serial_putuchar_t putuchar_fn, 141 serial_control_puts_t control_puts_fn, serial_flush_t flush_fn) 126 142 { 127 vt100_state_t *state = 128 vt100_state_create(SERIAL_COLS, SERIAL_ROWS, putuchar_fn, 129 control_puts_fn, flush_fn); 130 if (state == NULL) 143 char_attrs_t attrs; 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); 151 if (vt100 == NULL) 131 152 return ENOMEM; 153 vt100->enable_rgb = true; 132 154 133 outdev_t *dev = outdev_register(&serial_ops, state); 155 vt100_cursor_visibility(vt100, false); 156 attrs.type = CHAR_ATTR_STYLE; 157 attrs.val.style = STYLE_NORMAL; 158 vt100_set_attr(vt100, attrs); 159 vt100_cls(vt100); 160 161 outdev_t *dev = outdev_register(&serial_ops, vt100); 134 162 if (dev == NULL) { 135 vt100_ state_destroy(state);163 vt100_destroy(vt100); 136 164 return ENOMEM; 137 165 } … … 140 168 } 141 169 170 static void serial_vt_putuchar(void *arg, char32_t c) 171 { 172 (void)arg; 173 serial_putuchar_fn(c); 174 } 175 176 static void serial_vt_control_puts(void *arg, const char *str) 177 { 178 (void)arg; 179 serial_control_puts_fn(str); 180 } 181 182 static void serial_vt_flush(void *arg) 183 { 184 (void)arg; 185 serial_flush_fn(); 186 } 187 142 188 /** @} 143 189 */
Note:
See TracChangeset
for help on using the changeset viewer.