~ubuntu-branches/ubuntu/edgy/xorg-server/edgy-updates

« back to all changes in this revision

Viewing changes to hw/kdrive/linux/bus.c

  • Committer: Bazaar Package Importer
  • Author(s): Rodrigo Parra Novo
  • Date: 2006-07-25 20:06:28 UTC
  • mfrom: (1.1.4 upstream)
  • Revision ID: james.westby@ubuntu.com-20060725200628-gjmmd9gxfxdc4ejs
Tags: 1:1.1.1-0ubuntu1
* New Upstream version
* Changed Build-Depends from mesa-swrast-source to mesa-swx11-source,
  following Debian package nomenclature
* Re-did 12_security_policy_in_etc.diff for 1.1.1
* Dropped 15_security_allocate_local.diff (applied upstream)
* Dropped 16_SECURITY_setuid.diff (applied upstream)
* Dropped 000_ubuntu_fix_read_kernel_mapping.patch (applied upstream)
* Dropped 002_ubuntu_fix_for_certain_intel_chipsets.patch (applied upstream)
* Updated versioned Build-Depends on mesa-swx11-source to version
  6.5.0.cvs.20060725-0ubuntu1
* Added arrayobj.c, arrayobj.h, bitset.h & rbadaptors.h to
  GL/symlink-mesa.sh (linked from mesa-swx11-source)
* Added arrayobj.c to default build target on GL/mesa/main

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * $RCSId: xc/programs/Xserver/hw/kdrive/linux/bus.c,v 1.2 2001/06/29 14:00:41 keithp Exp $
 
3
 *
 
4
 * Copyright � 2000 Keith Packard
 
5
 *
 
6
 * Permission to use, copy, modify, distribute, and sell this software and its
 
7
 * documentation for any purpose is hereby granted without fee, provided that
 
8
 * the above copyright notice appear in all copies and that both that
 
9
 * copyright notice and this permission notice appear in supporting
 
10
 * documentation, and that the name of Keith Packard not be used in
 
11
 * advertising or publicity pertaining to distribution of the software without
 
12
 * specific, written prior permission.  Keith Packard makes no
 
13
 * representations about the suitability of this software for any purpose.  It
 
14
 * is provided "as is" without express or implied warranty.
 
15
 *
 
16
 * KEITH PACKARD DISCLAIMS ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
17
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN NO
 
18
 * EVENT SHALL KEITH PACKARD BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
19
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS OF USE,
 
20
 * DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT, NEGLIGENCE OR OTHER
 
21
 * TORTIOUS ACTION, ARISING OUT OF OR IN CONNECTION WITH THE USE OR
 
22
 * PERFORMANCE OF THIS SOFTWARE.
 
23
 */
 
24
 
 
25
#ifdef HAVE_CONFIG_H
 
26
#include <kdrive-config.h>
 
27
#endif
 
28
#define NEED_EVENTS
 
29
#include <X11/X.h>
 
30
#include <X11/Xproto.h>
 
31
#include <X11/Xpoll.h>
 
32
#include "inputstr.h"
 
33
#include "scrnintstr.h"
 
34
#include "kdrive.h"
 
35
 
 
36
/* /dev/adbmouse is a busmouse */
 
37
 
 
38
static void
 
39
BusRead (int adbPort, void *closure)
 
40
{
 
41
    unsigned char   buf[3];
 
42
    int             n;
 
43
    int             dx, dy;
 
44
    unsigned long   flags;
 
45
 
 
46
    n = read (adbPort, buf, 3);
 
47
    if (n == 3)
 
48
    {
 
49
        flags = KD_MOUSE_DELTA;
 
50
        dx = (char) buf[1];
 
51
        dy = -(char) buf[2];
 
52
        if ((buf[0] & 4) == 0)
 
53
            flags |= KD_BUTTON_1;
 
54
        if ((buf[0] & 2) == 0)
 
55
            flags |= KD_BUTTON_2;
 
56
        if ((buf[0] & 1) == 0)
 
57
            flags |= KD_BUTTON_3;
 
58
        KdEnqueueMouseEvent (kdMouseInfo, flags, dx, dy);
 
59
    }
 
60
}
 
61
 
 
62
char    *BusNames[] = {
 
63
    "/dev/adbmouse",
 
64
    "/dev/mouse",
 
65
};
 
66
 
 
67
#define NUM_BUS_NAMES   (sizeof (BusNames) / sizeof (BusNames[0]))
 
68
 
 
69
int     BusInputType;
 
70
 
 
71
static int
 
72
BusInit (void)
 
73
{
 
74
    int     i;
 
75
    int     busPort;
 
76
    int     n = 0;
 
77
 
 
78
    if (!BusInputType)
 
79
        BusInputType = KdAllocInputType ();
 
80
    
 
81
    for (i = 0; i < NUM_BUS_NAMES; i++)
 
82
    {
 
83
        busPort = open (BusNames[i], 0);
 
84
        {
 
85
            KdRegisterFd (BusInputType, busPort, BusRead, 0);
 
86
            n++;
 
87
        }
 
88
    }
 
89
    return n;
 
90
}
 
91
 
 
92
static void
 
93
BusFini (void)
 
94
{
 
95
    KdUnregisterFds (BusInputType, TRUE);
 
96
}
 
97
 
 
98
KdMouseFuncs BusMouseFuncs = {
 
99
    BusInit,
 
100
    BusFini
 
101
};