~ubuntu-branches/debian/wheezy/libwacom/wheezy

« back to all changes in this revision

Viewing changes to data/list.c

  • Committer: Package Import Robot
  • Author(s): Timo Aaltonen
  • Date: 2012-03-30 11:28:44 UTC
  • mfrom: (1.1.1)
  • Revision ID: package-import@ubuntu.com-20120330112844-fkwwo4yy947m6vaq
Tags: 0.4-1
* New upstream release. (Closes: #667064)
  - Add Intuos 5, Bamboo One definitions
* Drop git_touchpad_tablet.patch, included upstream.
* Add git-add-missing-buttons.patch, missing button sections for Intuos
  and Cintiq series.
* libwacom2.symbols: Add a new symbol.
* control: Add DM-Upload-Allowed field.
* copyright: Update the format url.

Show diffs side-by-side

added added

removed removed

Lines of Context:
 
1
/*
 
2
 * Copyright © 2012 Red Hat, Inc.
 
3
 *
 
4
 * Permission to use, copy, modify, distribute, and sell this software
 
5
 * and its documentation for any purpose is hereby granted without
 
6
 * fee, provided that the above copyright notice appear in all copies
 
7
 * and that both that copyright notice and this permission notice
 
8
 * appear in supporting documentation, and that the name of Red Hat
 
9
 * not be used in advertising or publicity pertaining to distribution
 
10
 * of the software without specific, written prior permission.  Red
 
11
 * Hat makes no representations about the suitability of this software
 
12
 * for any purpose.  It is provided "as is" without express or implied
 
13
 * warranty.
 
14
 *
 
15
 * THE AUTHORS DISCLAIM ALL WARRANTIES WITH REGARD TO THIS SOFTWARE,
 
16
 * INCLUDING ALL IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS, IN
 
17
 * NO EVENT SHALL THE AUTHORS BE LIABLE FOR ANY SPECIAL, INDIRECT OR
 
18
 * CONSEQUENTIAL DAMAGES OR ANY DAMAGES WHATSOEVER RESULTING FROM LOSS
 
19
 * OF USE, DATA OR PROFITS, WHETHER IN AN ACTION OF CONTRACT,
 
20
 * NEGLIGENCE OR OTHER TORTIOUS ACTION, ARISING OUT OF OR IN
 
21
 * CONNECTION WITH THE USE OR PERFORMANCE OF THIS SOFTWARE.
 
22
 *
 
23
 * Authors:
 
24
 *        Olivier Fourdan (ofourdan@redhat.com)
 
25
 */
 
26
 
 
27
#ifdef HAVE_CONFIG_H
 
28
#include "config.h"
 
29
#endif
 
30
 
 
31
#include <stdio.h>
 
32
#include <string.h>
 
33
#include "libwacom.h"
 
34
 
 
35
static void print_udev_header (void)
 
36
{
 
37
    printf ("# udev rules for libwacom supported devices\n");
 
38
    printf ("\n");
 
39
    printf ("ACTION!=\"add|change\", GOTO=\"libwacom_end\"\n");
 
40
    printf ("KERNEL!=\"event[0-9]*\", GOTO=\"libwacom_end\"\n");
 
41
    printf ("\n");
 
42
}
 
43
 
 
44
static void print_udev_entry (WacomDevice *device)
 
45
{
 
46
    WacomBusType type       = libwacom_get_bustype (device);
 
47
    int          vendor     = libwacom_get_vendor_id (device);
 
48
    int          product    = libwacom_get_product_id (device);
 
49
    int          has_touch  = libwacom_has_touch (device);
 
50
    static char *touchpad;
 
51
 
 
52
    if (has_touch)
 
53
        touchpad = ", ENV{ID_INPUT_TOUCHPAD}=\"1\"";
 
54
    else
 
55
        touchpad = "";
 
56
 
 
57
    switch (type) {
 
58
        case WBUSTYPE_USB:
 
59
            printf ("ENV{ID_BUS}==\"usb\", ENV{ID_VENDOR_ID}==\"%04x\", ENV{ID_MODEL_ID}==\"%04x\", ENV{ID_INPUT}=\"1\", ENV{ID_INPUT_TABLET}=\"1\"%s\n", vendor, product, touchpad);
 
60
            break;
 
61
        case WBUSTYPE_BLUETOOTH:
 
62
            printf ("ENV{ID_BUS}==\"bluetooth\", ENV{ID_VENDOR_ID}==\"%04x\", ENV{ID_MODEL_ID}==\"%04x\", ENV{ID_INPUT}=\"1\", ENV{ID_INPUT_TABLET}=\"1\"%s\n", vendor, product, touchpad);
 
63
            break;
 
64
        default:
 
65
            /* Not sure how to deal with serials  */
 
66
            break;
 
67
    }
 
68
}
 
69
 
 
70
static void print_udev_trailer (void)
 
71
{
 
72
    printf ("\n");
 
73
    printf ("# Match all serial wacom tablets with a serial ID starting with WACf\n");
 
74
    printf ("ENV{ID_BUS}==\"tty|pnp\", ATTRS{id}==\"WACf*\", ENV{ID_INPUT}=\"1\", ENV{ID_INPUT_TABLET}=\"1\"\n");
 
75
    printf ("ENV{ID_BUS}==\"tty|pnp\", ATTRS{id}==\"FUJ*\", ENV{ID_INPUT}=\"1\", ENV{ID_INPUT_TABLET}=\"1\"\n");
 
76
    printf ("\n");
 
77
    printf ("LABEL=\"libwacom_end\"\n");
 
78
}
 
79
 
 
80
 
 
81
int main(int argc, char **argv)
 
82
{
 
83
    WacomDeviceDatabase *db;
 
84
    WacomDevice **list, **p;
 
85
 
 
86
    db = libwacom_database_new_for_path(TOPSRCDIR"/data");
 
87
 
 
88
    list = libwacom_list_devices_from_database(db, NULL);
 
89
    if (!list) {
 
90
        fprintf(stderr, "Failed to load device database.\n");
 
91
        return 1;
 
92
    }
 
93
 
 
94
    print_udev_header ();
 
95
    for (p = list; *p; p++)
 
96
        print_udev_entry ((WacomDevice *) *p);
 
97
    print_udev_trailer ();
 
98
 
 
99
    libwacom_database_destroy (db);
 
100
 
 
101
    return 0;
 
102
}
 
103
 
 
104
/* vim: set noexpandtab tabstop=8 shiftwidth=8: */