Main Page | Modules | Data Structures | File List | Data Fields | Related Pages

input_class_device.c

00001 /***************************************************************************
00002  * CVSID: $Id: input_class_device.c,v 1.6 2004/04/12 20:11:51 joe Exp $
00003  *
00004  * Input device class
00005  *
00006  * Copyright (C) 2003 David Zeuthen, <david@fubar.dk>
00007  *
00008  * Licensed under the Academic Free License version 2.0
00009  *
00010  * This program is free software; you can redistribute it and/or modify
00011  * it under the terms of the GNU General Public License as published by
00012  * the Free Software Foundation; either version 2 of the License, or
00013  * (at your option) any later version.
00014  *
00015  * This program is distributed in the hope that it will be useful,
00016  * but WITHOUT ANY WARRANTY; without even the implied warranty of
00017  * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
00018  * GNU General Public License for more details.
00019  *
00020  * You should have received a copy of the GNU General Public License
00021  * along with this program; if not, write to the Free Software
00022  * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
00023  *
00024  **************************************************************************/
00025 
00026 #ifdef HAVE_CONFIG_H
00027 #  include <config.h>
00028 #endif
00029 
00030 #include <ctype.h>
00031 #include <stdio.h>
00032 #include <stdlib.h>
00033 #include <string.h>
00034 #include <getopt.h>
00035 #include <assert.h>
00036 #include <unistd.h>
00037 #include <stdarg.h>
00038 #include <limits.h>
00039 
00040 #include "../logger.h"
00041 #include "../device_store.h"
00042 #include "../hald.h"
00043 
00044 #include "class_device.h"
00045 #include "common.h"
00046 
00069 static void 
00070 input_class_pre_process (ClassDeviceHandler *self,
00071              HalDevice *d,
00072              const char *sysfs_path,
00073              struct sysfs_class_device *class_device)
00074 {
00075     /* add capabilities for device */
00076     hal_device_property_set_string (d, "info.category", "input");
00077     hal_device_add_capability (d, "input");
00078 
00083 }
00084 
00100 static void
00101 input_class_get_device_file_target (ClassDeviceHandler *self,
00102                     HalDevice *d,
00103                     const char *sysfs_path,
00104                     struct sysfs_class_device *class_device,
00105                     char* dev_file_prop,
00106                     int dev_file_prop_len)
00107 {
00108     const char *sysfs_name;
00109 
00110     /* since we have multiple device files for class mouse we need 
00111      * to merge them into different, welldefined, properties */
00112     sysfs_name = get_last_element (sysfs_path);
00113     if (strlen (sysfs_name) > sizeof("event")-1 && 
00114         strncmp (sysfs_name, "event", sizeof("event")-1) == 0) {
00115         strncpy(dev_file_prop, "input.device", dev_file_prop_len);
00116     } else {
00117         /* according to kernel sources if the sysfs name doesn't
00118          * conform to /sys/class/input/event%d it is a device file
00119          * for accessing the input device through an architecture
00120          * dependent inferface (e.g. PS/2 on x86). */
00121         strncpy(dev_file_prop, "input.device.arch", dev_file_prop_len);
00122     }
00123 }
00124 
00126 ClassDeviceHandler input_class_handler = {
00127     class_device_init,                  
00128     class_device_detection_done,        
00129     class_device_shutdown,              
00130     class_device_tick,                  
00131     class_device_accept,                
00132     class_device_visit,                 
00133     class_device_removed,               
00134     class_device_udev_event,            
00135     input_class_get_device_file_target, 
00136     input_class_pre_process,            
00137     class_device_post_merge,            
00138     class_device_got_udi,               
00139     NULL,                               
00140     "input",                            
00141     "input",                            
00142     TRUE,                               
00143     TRUE                                
00144 };
00145 

Generated on Sat Apr 24 19:57:45 2004 for HAL by doxygen 1.3.6-20040222