OpenCores
URL https://opencores.org/ocsvn/or1k/or1k/trunk

Subversion Repositories or1k

[/] [or1k/] [tags/] [MW_0_8_9PRE7/] [mw/] [src/] [demos/] [nxkbd/] [srvconn.c] - Blame information for rev 1765

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 673 markom
/*
2
 * Copyright (C) 2000 by Greg Haerr <greg@censoft.com>
3
 * Copyright (C) 2000 by VTech Informations LTD.
4
 * Vladimir Cotfas <vladimircotfas@vtech.ca> Aug 31, 2000
5
 */
6
#include <unistd.h>
7
#include <fcntl.h>
8
#include "nano-X.h"
9
 
10
#define KBDPIPE         0        /* =1 to use named pipe for soft kbd*/
11
 
12
#if KBDPIPE
13
static char KBD_NAMED_PIPE[] = "/tmp/.nano-X-softkbd";
14
static int kbd_fd = -1;
15
 
16
int
17
KbdOpen(void)
18
{
19
        if (kbd_fd != -1)
20
                close(kbd_fd);
21
 
22
        if ((kbd_fd = open(KBD_NAMED_PIPE, O_WRONLY)) < 0)
23
                return -1;
24
 
25
        return kbd_fd;
26
}
27
 
28
void
29
KbdClose(void)
30
{
31
        if(kbd_fd >= 0) {
32
                close(kbd_fd);
33
                kbd_fd = -1;
34
        }
35
}
36
 
37
int
38
KbdWrite(int c)
39
{
40
        char cc = c & 0xff;
41
 
42
        return write(kbd_fd, &cc, 1);
43
}
44
 
45
#else /* !KBDPIPE*/
46
 
47
int
48
KbdOpen(void)
49
{
50
        return 0;
51
}
52
 
53
void
54
KbdClose(void)
55
{
56
}
57
 
58
int
59
KbdWrite(int c)
60
{
61
        GR_WINDOW_ID    win = GrGetFocus();
62
 
63
        /* FIXME: modifiers are incorrect*/
64
        GrInjectKeyboardEvent(win, c, 0, 0, 1);
65
        GrInjectKeyboardEvent(win, c, 0, 0, 0);
66
        return 1;
67
}
68
#endif /* KBDPIPE*/

powered by: WebSVN 2.1.0

© copyright 1999-2024 OpenCores.org, equivalent to Oliscience, all rights reserved. OpenCores®, registered trademark.