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

Subversion Repositories openrisc

[/] [openrisc/] [trunk/] [rtos/] [ecos-3.0/] [packages/] [services/] [gfx/] [mw/] [current/] [src/] [drivers/] [mou_vnc_ecos.c] - Blame information for rev 786

Details | Compare with Previous | View Log

Line No. Rev Author Line
1 786 skrzyp
//==========================================================================
2
//
3
//      mou_vnc_ecos.c
4
//
5
//
6
//
7
//==========================================================================
8
// ####ECOSGPLCOPYRIGHTBEGIN####                                            
9
// -------------------------------------------                              
10
// This file is part of eCos, the Embedded Configurable Operating System.   
11
// Copyright (C) 1998, 1999, 2000, 2001, 2002, 2003 Free Software Foundation, Inc.
12
//
13
// eCos is free software; you can redistribute it and/or modify it under    
14
// the terms of the GNU General Public License as published by the Free     
15
// Software Foundation; either version 2 or (at your option) any later      
16
// version.                                                                 
17
//
18
// eCos is distributed in the hope that it will be useful, but WITHOUT      
19
// ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or    
20
// FITNESS FOR A PARTICULAR PURPOSE.  See the GNU General Public License    
21
// for more details.                                                        
22
//
23
// You should have received a copy of the GNU General Public License        
24
// along with eCos; if not, write to the Free Software Foundation, Inc.,    
25
// 51 Franklin Street, Fifth Floor, Boston, MA  02110-1301, USA.            
26
//
27
// As a special exception, if other files instantiate templates or use      
28
// macros or inline functions from this file, or you compile this file      
29
// and link it with other works to produce a work based on this file,       
30
// this file does not by itself cause the resulting work to be covered by   
31
// the GNU General Public License. However the source code for this file    
32
// must still be made available in accordance with section (3) of the GNU   
33
// General Public License v2.                                               
34
//
35
// This exception does not invalidate any other reasons why a work based    
36
// on this file might be covered by the GNU General Public License.         
37
// -------------------------------------------                              
38
// ####ECOSGPLCOPYRIGHTEND####                                              
39
//==========================================================================
40
//#####DESCRIPTIONBEGIN####
41
//
42
// Author(s):    Chris Garry <cgarry@sweeneydesign.co.uk>
43
// Contributors:
44
// Date:         2003-08-22
45
// Purpose:
46
// Description:  Microwindows mouse driver for VNC server on eCos
47
//
48
//####DESCRIPTIONEND####
49
//
50
//========================================================================*/
51
 
52
 
53
#include <stdio.h>
54
#include <stdlib.h>
55
#include <unistd.h>
56
#include <errno.h>
57
#include <fcntl.h>
58
#include <math.h>
59
#include <sys/ioctl.h>
60
#include <pkgconf/vnc_server.h>  /* CYGDAT_VNC_SERVER_MOUSE_NAME */
61
#include "device.h"
62
 
63
static int vnc_Open(MOUSEDEVICE *pmd);
64
static void vnc_Close(void);
65
static int vnc_GetButtonInfo(void);
66
static void vnc_GetDefaultAccel(int *pscale,int *pthresh);
67
static int vnc_Read(MWCOORD *px, MWCOORD *py, MWCOORD *pz, int *pb);
68
 
69
static int mouse_fd = -1;
70
 
71
/* Hack extern to used when hiding the mouse cursor
72
 * There needs to be a better way to do this
73
*/
74
extern SCREENDEVICE scrdev;
75
 
76
MOUSEDEVICE mousedev = {
77
    vnc_Open,
78
    vnc_Close,
79
    vnc_GetButtonInfo,
80
    vnc_GetDefaultAccel,
81
    vnc_Read,
82
    NULL
83
};
84
 
85
 
86
static int vnc_Open(MOUSEDEVICE *pmd)
87
{
88
    mouse_fd = open(CYGDAT_VNC_SERVER_MOUSE_NAME, O_RDONLY | O_NONBLOCK);
89
    if (mouse_fd < 0)
90
    {
91
        EPRINTF("Error %d opening VNC mouse\n", errno);
92
        return -1;
93
    }
94
 
95
//    GdHideCursor(&scrdev);
96
    return mouse_fd;
97
}
98
 
99
static void vnc_Close(void)
100
{
101
    /* Close the mouse device. */
102
    if (mouse_fd >= 0)
103
    {
104
        close(mouse_fd);
105
    }
106
 
107
    mouse_fd = -1;
108
}
109
 
110
static int vnc_GetButtonInfo(void)
111
{
112
        /* Get mouse buttons supported */
113
    return (MWBUTTON_L + MWBUTTON_R);
114
}
115
 
116
static void vnc_GetDefaultAccel(int *pscale,int *pthresh)
117
{
118
        /*
119
         * Get default mouse acceleration settings
120
         * Just return something inconspicuous for now.
121
         */
122
//     diag_printf("Mouse: vnc_GetDefaultAccel()\n");
123
        *pscale = 3;
124
        *pthresh = 5;
125
}
126
 
127
static int vnc_Read(MWCOORD *px, MWCOORD *py, MWCOORD *pz, int *pb)
128
{
129
        /* Read a mouse event */
130
    cyg_uint8 data[8];
131
    int bytes_read;
132
 
133
    bytes_read = read(mouse_fd, data, 8);
134
 
135
    if (bytes_read != sizeof(data))
136
    {
137
        if (errno == EINTR || errno == EAGAIN)
138
        {
139
            return 0;
140
        }
141
        /*
142
         * kernel driver bug: select returns read available,
143
         * but read returns -1
144
         * we return 0 here to avoid GsError above
145
         */
146
        /*return -1;*/
147
 
148
        return 0;
149
    }
150
 
151
    *px = data[2]*256 + data[3];
152
    *py = data[4]*256 + data[5];
153
    *pb = 0;
154
    if (data[1] & 0x01)
155
    {
156
        *pb += MWBUTTON_L;
157
    }
158
    if (data[1] & 0x04)
159
    {
160
        *pb += MWBUTTON_R;
161
    }
162
 
163
    *pz = 0;
164
 
165
    return 2;
166
 
167
#if 0
168
    if(! *pb )
169
    {
170
        return 1;         /* Don't have button data */
171
    }
172
    else
173
    {
174
        return 2;         /* Have full set of data */
175
    }
176
#endif
177
 
178
}

powered by: WebSVN 2.1.0

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