source: mainline/uspace/app/msim/arch_helenos/input.c@ b713ff80

lfn serial ticket/834-toolchain-update topic/msim-upgrade topic/simplify-dev-export
Last change on this file since b713ff80 was 6efb4d2, checked in by Vojtech Horky <vojtechhorky@…>, 13 years ago

Reorganize HelenOS specific files for MSIM

  • Property mode set to 100644
File size: 2.6 KB
Line 
1/*
2 * Copyright (c) 2012 Vojtech Horky
3 * All rights reserved.
4 *
5 * Redistribution and use in source and binary forms, with or without
6 * modification, are permitted provided that the following conditions
7 * are met:
8 *
9 * - Redistributions of source code must retain the above copyright
10 * notice, this list of conditions and the following disclaimer.
11 * - Redistributions in binary form must reproduce the above copyright
12 * notice, this list of conditions and the following disclaimer in the
13 * documentation and/or other materials provided with the distribution.
14 * - The name of the author may not be used to endorse or promote products
15 * derived from this software without specific prior written permission.
16 *
17 * THIS SOFTWARE IS PROVIDED BY THE AUTHOR ``AS IS'' AND ANY EXPRESS OR
18 * IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE IMPLIED WARRANTIES
19 * OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE ARE DISCLAIMED.
20 * IN NO EVENT SHALL THE AUTHOR BE LIABLE FOR ANY DIRECT, INDIRECT,
21 * INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT
22 * NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE,
23 * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY
24 * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT
25 * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE OF
26 * THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE.
27 */
28
29/** @addtogroup msim
30 * @{
31 */
32/** @file HelenOS specific functions for MSIM simulator.
33 */
34#include "../../io/input.h"
35#include "../../io/output.h"
36#include "../../fault.h"
37#include "helenos.h"
38#include <tinput.h>
39#include <errno.h>
40
41static tinput_t *input_prompt;
42
43/** Terminal and readline initialization
44 *
45 */
46void input_init(void)
47{
48 input_prompt = tinput_new();
49 if (input_prompt == NULL) {
50 die(1, "Failed to intialize input.");
51 }
52 helenos_dprinter_init();
53}
54
55void input_inter(void)
56{
57}
58
59void input_shadow( void)
60{
61}
62
63void input_back( void)
64{
65}
66
67char *helenos_input_get_next_command(void)
68{
69 tinput_set_prompt(input_prompt, "[msim] ");
70
71 char *commline = NULL;
72 int rc = tinput_read(input_prompt, &commline);
73
74 if (rc == ENOENT) {
75 rc = asprintf(&commline, "quit");
76 mprintf("Quit\n");
77 if (rc != EOK) {
78 exit(1);
79 }
80 }
81
82 /* On error, it remains NULL. */
83 return commline;
84}
85
86
87bool stdin_poll(char *key)
88{
89 kbd_event_t ev;
90 suseconds_t timeout = 0;
91 errno = EOK;
92 console_flush(input_prompt->console);
93 bool has_input = console_get_kbd_event_timeout(input_prompt->console, &ev, &timeout);
94 if (!has_input) {
95 return false;
96 }
97
98 if (ev.type != KEY_PRESS)
99 return false;
100
101 *key = ev.c;
102
103 return true;
104}
105
Note: See TracBrowser for help on using the repository browser.