Subversion Repositories HelenOS

Rev

Rev 4327 | Show entire file | Ignore whitespace | Details | Blame | Last modification | View Log | RSS feed

Rev 4327 Rev 4581
Line 42... Line 42...
42
#include <arch/asm.h>
42
#include <arch/asm.h>
43
#include <arch/drivers/kbd.h>
43
#include <arch/drivers/kbd.h>
44
#include <string.h>
44
#include <string.h>
45
#include <arch.h>
45
#include <arch.h>
46
 
46
 
-
 
47
enum {
-
 
48
    /** Interval between polling in microseconds */
47
#define POLL_INTERVAL  10000  /* 10 ms */
49
    POLL_INTERVAL =  10000,  /* 0.01 s */
-
 
50
 
-
 
51
    /** Max. number of characters to pull out at a time */
-
 
52
    POLL_LIMIT    =     30,
48
 
53
 
49
#define SKI_INIT_CONSOLE  20
54
    SKI_INIT_CONSOLE  = 20,
50
#define SKI_GETCHAR       21
55
    SKI_GETCHAR       = 21,
51
#define SKI_PUTCHAR       31
56
    SKI_PUTCHAR       = 31
-
 
57
};
52
 
58
 
53
static void ski_putchar(outdev_t *, const wchar_t, bool);
59
static void ski_putchar(outdev_t *, const wchar_t, bool);
54
 
60
 
55
static outdev_operations_t skiout_ops = {
61
static outdev_operations_t skiout_ops = {
56
    .write = ski_putchar
62
    .write = ski_putchar
Line 152... Line 158...
152
    );
158
    );
153
   
159
   
154
    return (wchar_t) ch;
160
    return (wchar_t) ch;
155
}
161
}
156
 
162
 
157
/** Ask keyboard if a key was pressed. */
163
/** Ask keyboard if a key was pressed.
-
 
164
 *
-
 
165
 * If so, it will repeat and pull up to POLL_LIMIT characters.
-
 
166
 */
158
static void poll_keyboard(ski_instance_t *instance)
167
static void poll_keyboard(ski_instance_t *instance)
159
{
168
{
-
 
169
    wchar_t ch;
-
 
170
    int count;
-
 
171
 
160
    if (kbd_disabled)
172
    if (kbd_disabled)
161
        return;
173
        return;
-
 
174
 
-
 
175
    count = POLL_LIMIT;
162
   
176
 
-
 
177
    while (count > 0) {
163
    wchar_t ch = ski_getchar();
178
        ch = ski_getchar();
164
   
179
 
165
    if (ch != 0)
180
        if (ch == '\0')
-
 
181
            break;
-
 
182
 
166
        indev_push_character(instance->srlnin, ch);
183
        indev_push_character(instance->srlnin, ch);
-
 
184
        --count;
-
 
185
    }
167
}
186
}
168
 
187
 
169
/** Kernel thread for polling keyboard. */
188
/** Kernel thread for polling keyboard. */
170
static void kskipoll(void *arg)
189
static void kskipoll(void *arg)
171
{
190
{
Line 213... Line 232...
213
    sysinfo_set_item_val("kbd.type", NULL, KBD_SKI);
232
    sysinfo_set_item_val("kbd.type", NULL, KBD_SKI);
214
}
233
}
215
 
234
 
216
void ski_kbd_grab(void)
235
void ski_kbd_grab(void)
217
{
236
{
218
    kbd_disabled = true;
237
    kbd_disabled = false;
219
}
238
}
220
 
239
 
221
void ski_kbd_release(void)
240
void ski_kbd_release(void)
222
{
241
{
223
    kbd_disabled = false;
242
    kbd_disabled = true;
224
}
243
}
225
 
244
 
226
/** @}
245
/** @}
227
 */
246
 */