Changeset bb4ba92 in mainline
- Timestamp:
- 2022-06-27T10:46:59Z (3 years ago)
- Branches:
- master, ticket/834-toolchain-update, topic/msim-upgrade, topic/simplify-dev-export
- Children:
- 9e9d9bc6
- Parents:
- b7155d7
- git-author:
- Jiri Svoboda <jiri@…> (2022-06-26 17:46:37)
- git-committer:
- Jiri Svoboda <jiri@…> (2022-06-27 10:46:59)
- File:
-
- 1 edited
Legend:
- Unmodified
- Added
- Removed
-
uspace/drv/hid/xtkbd/xtkbd.c
rb7155d7 rbb4ba92 1 1 /* 2 * Copyright (c) 2022 Jiri Svoboda 2 3 * Copyright (c) 2011 Jan Vesely 3 * Copyright (c) 2017 Jiri Svoboda4 4 * All rights reserved. 5 5 * … … 198 198 } 199 199 200 /** Get one scancode byte from the keyboard. 201 * 202 * @param kbd Keyboard 203 * @param code Place to store scancode byte 204 * @return EOK on success or an error code 205 */ 206 static errno_t xtkbd_get_code(xt_kbd_t *kbd, uint8_t *code) 207 { 208 errno_t rc; 209 size_t nread; 210 211 *code = 0; 212 rc = chardev_read(kbd->chardev, code, 1, &nread, chardev_f_none); 213 if (rc != EOK) { 214 ddf_msg(LVL_WARN, "Error reading from keyboard device."); 215 return EIO; 216 } 217 218 ddf_msg(LVL_DEBUG, "Read scancode: 0x%02hhx", *code); 219 220 return EOK; 221 } 222 200 223 /** Get data and parse scancodes. 201 224 * … … 208 231 { 209 232 xt_kbd_t *kbd = arg; 210 size_t nread;211 233 errno_t rc; 212 234 … … 216 238 217 239 uint8_t code = 0; 218 rc = chardev_read(kbd->chardev, &code, 1, &nread, chardev_f_none);240 rc = xtkbd_get_code(kbd, &code); 219 241 if (rc != EOK) 220 242 return EIO; … … 229 251 map_size = sizeof(scanmap_e0) / sizeof(unsigned int); 230 252 231 rc = chardev_read(kbd->chardev, &code, 1, &nread, 232 chardev_f_none); 253 rc = xtkbd_get_code(kbd, &code); 233 254 if (rc != EOK) 234 255 return EIO; … … 237 258 238 259 if (code == 0x2a) { /* Print Screen */ 239 rc = chardev_read(kbd->chardev, &code, 1, &nread, 240 chardev_f_none); 260 rc = xtkbd_get_code(kbd, &code); 241 261 if (rc != EOK) 242 262 return EIO; … … 245 265 continue; 246 266 247 rc = chardev_read(kbd->chardev, &code, 1, &nread, 248 chardev_f_none); 267 rc = xtkbd_get_code(kbd, &code); 249 268 if (rc != EOK) 250 269 return EIO; … … 257 276 258 277 if (code == 0x46) { /* Break */ 259 rc = chardev_read(kbd->chardev, &code, 1, &nread, 260 chardev_f_none); 278 rc = xtkbd_get_code(kbd, &code); 261 279 if (rc != EOK) 262 280 return EIO; … … 265 283 continue; 266 284 267 rc = chardev_read(kbd->chardev, &code, 1, &nread, 268 chardev_f_none); 285 rc = xtkbd_get_code(kbd, &code); 269 286 if (rc != EOK) 270 287 return EIO; … … 279 296 /* Extended special set */ 280 297 if (code == KBD_SCANCODE_SET_EXTENDED_SPECIAL) { 281 rc = chardev_read(kbd->chardev, &code, 1, &nread, 282 chardev_f_none); 298 rc = xtkbd_get_code(kbd, &code); 283 299 if (rc != EOK) 284 300 return EIO; … … 287 303 continue; 288 304 289 rc = chardev_read(kbd->chardev, &code, 1, &nread, 290 chardev_f_none); 305 rc = xtkbd_get_code(kbd, &code); 291 306 if (rc != EOK) 292 307 return EIO; … … 295 310 continue; 296 311 297 rc = chardev_read(kbd->chardev, &code, 1, &nread, 298 chardev_f_none); 312 rc = xtkbd_get_code(kbd, &code); 299 313 if (rc != EOK) 300 314 return EIO; … … 303 317 continue; 304 318 305 rc = chardev_read(kbd->chardev, &code, 1, &nread, 306 chardev_f_none); 319 rc = xtkbd_get_code(kbd, &code); 307 320 if (rc != EOK) 308 321 return EIO; … … 311 324 continue; 312 325 313 rc = chardev_read(kbd->chardev, &code, 1, &nread, 314 chardev_f_none); 326 rc = xtkbd_get_code(kbd, &code); 315 327 if (rc != EOK) 316 328 return EIO;
Note:
See TracChangeset
for help on using the changeset viewer.