[b27a97bb] | 1 | /*
|
---|
[df4ed85] | 2 | * Copyright (c) 2006 Josef Cejka
|
---|
| 3 | * Copyright (c) 2006 Jakub Vana
|
---|
[2595dab] | 4 | * Copyright (c) 2008 Jiri Svoboda
|
---|
[b27a97bb] | 5 | * All rights reserved.
|
---|
| 6 | *
|
---|
| 7 | * Redistribution and use in source and binary forms, with or without
|
---|
| 8 | * modification, are permitted provided that the following conditions
|
---|
| 9 | * are met:
|
---|
| 10 | *
|
---|
| 11 | * - Redistributions of source code must retain the above copyright
|
---|
| 12 | * notice, this list of conditions and the following disclaimer.
|
---|
| 13 | * - Redistributions in binary form must reproduce the above copyright
|
---|
| 14 | * notice, this list of conditions and the following disclaimer in the
|
---|
| 15 | * documentation and/or other materials provided with the distribution.
|
---|
| 16 | * - The name of the author may not be used to endorse or promote products
|
---|
| 17 | * derived from this software without specific prior written permission.
|
---|
| 18 | *
|
---|
| 19 | * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
|
---|
| 20 | * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
|
---|
| 21 | * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
|
---|
| 22 | * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
|
---|
| 23 | * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
|
---|
| 24 | * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
|
---|
| 25 | * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
|
---|
| 26 | * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
|
---|
| 27 | * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
|
---|
| 28 | * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
|
---|
| 29 | */
|
---|
| 30 |
|
---|
[a46da63] | 31 | /** @addtogroup libc
|
---|
[b2951e2] | 32 | * @{
|
---|
| 33 | */
|
---|
| 34 | /** @file
|
---|
| 35 | */
|
---|
| 36 |
|
---|
[afa6e74] | 37 | #include <libc.h>
|
---|
[b917098] | 38 | #include <async.h>
|
---|
[2595dab] | 39 | #include <io/console.h>
|
---|
| 40 | #include <ipc/console.h>
|
---|
[afa6e74] | 41 |
|
---|
[2595dab] | 42 | void console_clear(int phone)
|
---|
[afa6e74] | 43 | {
|
---|
[2595dab] | 44 | async_msg_0(phone, CONSOLE_CLEAR);
|
---|
| 45 | }
|
---|
| 46 |
|
---|
[96b02eb9] | 47 | int console_get_size(int phone, sysarg_t *cols, sysarg_t *rows)
|
---|
[2595dab] | 48 | {
|
---|
[9f1362d4] | 49 | return async_req_0_2(phone, CONSOLE_GET_SIZE, cols, rows);
|
---|
[2595dab] | 50 | }
|
---|
| 51 |
|
---|
[9f1362d4] | 52 | void console_set_style(int phone, uint8_t style)
|
---|
[2595dab] | 53 | {
|
---|
| 54 | async_msg_1(phone, CONSOLE_SET_STYLE, style);
|
---|
| 55 | }
|
---|
| 56 |
|
---|
[9f1362d4] | 57 | void console_set_color(int phone, uint8_t fg_color, uint8_t bg_color,
|
---|
| 58 | uint8_t flags)
|
---|
[2595dab] | 59 | {
|
---|
| 60 | async_msg_3(phone, CONSOLE_SET_COLOR, fg_color, bg_color, flags);
|
---|
[d2cc7e1] | 61 | }
|
---|
| 62 |
|
---|
[9f1362d4] | 63 | void console_set_rgb_color(int phone, uint32_t fg_color, uint32_t bg_color)
|
---|
[0b6d70d] | 64 | {
|
---|
[2595dab] | 65 | async_msg_2(phone, CONSOLE_SET_RGB_COLOR, fg_color, bg_color);
|
---|
[0b6d70d] | 66 | }
|
---|
| 67 |
|
---|
[2595dab] | 68 | void console_cursor_visibility(int phone, bool show)
|
---|
[1c03c17] | 69 | {
|
---|
[9f1362d4] | 70 | async_msg_1(phone, CONSOLE_CURSOR_VISIBILITY, (show != false));
|
---|
[2595dab] | 71 | }
|
---|
| 72 |
|
---|
[96b02eb9] | 73 | int console_get_color_cap(int phone, sysarg_t *ccap)
|
---|
[50cfa6c] | 74 | {
|
---|
[9f1362d4] | 75 | return async_req_0_1(phone, CONSOLE_GET_COLOR_CAP, ccap);
|
---|
[50cfa6c] | 76 | }
|
---|
| 77 |
|
---|
[2595dab] | 78 | void console_kcon_enable(int phone)
|
---|
| 79 | {
|
---|
| 80 | async_msg_0(phone, CONSOLE_KCON_ENABLE);
|
---|
| 81 | }
|
---|
| 82 |
|
---|
[96b02eb9] | 83 | int console_get_pos(int phone, sysarg_t *col, sysarg_t *row)
|
---|
[19528516] | 84 | {
|
---|
[9f1362d4] | 85 | return async_req_0_2(phone, CONSOLE_GET_POS, col, row);
|
---|
[19528516] | 86 | }
|
---|
| 87 |
|
---|
[96b02eb9] | 88 | void console_set_pos(int phone, sysarg_t col, sysarg_t row)
|
---|
[2595dab] | 89 | {
|
---|
[9b11daef] | 90 | async_msg_2(phone, CONSOLE_GOTO, col, row);
|
---|
[2595dab] | 91 | }
|
---|
| 92 |
|
---|
| 93 | bool console_get_event(int phone, console_event_t *event)
|
---|
| 94 | {
|
---|
[96b02eb9] | 95 | sysarg_t type;
|
---|
| 96 | sysarg_t key;
|
---|
| 97 | sysarg_t mods;
|
---|
| 98 | sysarg_t c;
|
---|
[2595dab] | 99 |
|
---|
| 100 | int rc = async_req_0_4(phone, CONSOLE_GET_EVENT, &type, &key, &mods, &c);
|
---|
| 101 | if (rc < 0)
|
---|
| 102 | return false;
|
---|
| 103 |
|
---|
| 104 | event->type = type;
|
---|
| 105 | event->key = key;
|
---|
| 106 | event->mods = mods;
|
---|
| 107 | event->c = c;
|
---|
| 108 |
|
---|
| 109 | return true;
|
---|
[1c03c17] | 110 | }
|
---|
| 111 |
|
---|
[a46da63] | 112 | /** @}
|
---|
[b2951e2] | 113 | */
|
---|