1 /*
2    (c) Copyright 2001-2010  The world wide DirectFB Open Source Community (directfb.org)
3    (c) Copyright 2000-2004  Convergence (integrated media) GmbH
4 
5    All rights reserved.
6 
7    Written by Denis Oliver Kropp <dok@directfb.org>,
8               Andreas Hundt <andi@fischlustig.de>,
9               Sven Neumann <neo@directfb.org>,
10               Ville Syrjälä <syrjala@sci.fi> and
11               Claudio Ciccani <klan@users.sf.net>.
12 
13    This library is free software; you can redistribute it and/or
14    modify it under the terms of the GNU Lesser General Public
15    License as published by the Free Software Foundation; either
16    version 2 of the License, or (at your option) any later version.
17 
18    This library is distributed in the hope that it will be useful,
19    but WITHOUT ANY WARRANTY; without even the implied warranty of
20    MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the GNU
21    Lesser General Public License for more details.
22 
23    You should have received a copy of the GNU Lesser General Public
24    License along with this library; if not, write to the
25    Free Software Foundation, Inc., 59 Temple Place - Suite 330,
26    Boston, MA 02111-1307, USA.
27 */
28 
29 #ifndef __INPUT_DRIVER_H__
30 #define __INPUT_DRIVER_H__
31 
32 #include <core/input.h>
33 
34 
35 static int
36 driver_get_available( void );
37 
38 static void
39 driver_get_info( InputDriverInfo *info );
40 
41 static DFBResult
42 driver_open_device( CoreInputDevice  *device,
43                     unsigned int      number,
44                     InputDeviceInfo  *info,
45                     void            **driver_data );
46 
47 static DFBResult
48 driver_get_keymap_entry( CoreInputDevice           *device,
49                          void                      *driver_data,
50                          DFBInputDeviceKeymapEntry *entry );
51 
52 #ifdef DFB_INPUTDRIVER_HAS_AXIS_INFO
53 static DFBResult
54 driver_get_axis_info( CoreInputDevice              *device,
55                       void                         *driver_data,
56                       DFBInputDeviceAxisIdentifier  axis,
57                       DFBInputDeviceAxisInfo       *ret_info );
58 #endif
59 
60 static void
61 driver_close_device( void *driver_data );
62 
63 static DFBResult
64 driver_suspend( void );
65 
66 static DFBResult
67 driver_resume( void );
68 
69 static DFBResult
70 is_created( int event_num, void *data);
71 
72 static InputDriverCapability
73 get_capability( void );
74 
75 static DFBResult
76 launch_hotplug(CoreDFB         *core,
77                void            *input_driver);
78 
79 static DFBResult
80 stop_hotplug( void );
81 
82 #if !defined(DISABLE_INPUT_HOTPLUG_FUNCTION_STUB)
83 /* Add hot-plug stub function implementations for all input providers by
84  * default when DISABLE_INPUT_HOTPLUG_FUNCTION_STUB is not defined.
85  */
86 
87 static DFBResult
driver_suspend(void)88 driver_suspend( void )
89 {
90      return DFB_UNSUPPORTED;
91 }
92 
93 static DFBResult
driver_resume(void)94 driver_resume( void )
95 {
96      return DFB_UNSUPPORTED;
97 }
98 
99 static DFBResult
is_created(int event_num,void * data)100 is_created( int event_num, void *data)
101 {
102      D_UNUSED_P( event_num );
103      D_UNUSED_P( data );
104 
105      return DFB_UNSUPPORTED;
106 }
107 
108 static InputDriverCapability
get_capability(void)109 get_capability( void )
110 {
111      return IDC_NONE;
112 }
113 
114 static DFBResult
launch_hotplug(CoreDFB * core,void * input_driver)115 launch_hotplug(CoreDFB         *core,
116                void            *input_driver)
117 {
118      D_UNUSED_P( core );
119      D_UNUSED_P( input_driver );
120 
121      return DFB_UNSUPPORTED;
122 }
123 
124 static DFBResult
stop_hotplug(void)125 stop_hotplug( void )
126 {
127      return DFB_UNSUPPORTED;
128 }
129 #endif
130 
131 static const InputDriverFuncs driver_funcs = {
132      .GetAvailable       = driver_get_available,
133      .GetDriverInfo      = driver_get_info,
134      .OpenDevice         = driver_open_device,
135      .GetKeymapEntry     = driver_get_keymap_entry,
136      .CloseDevice        = driver_close_device,
137      .Suspend            = driver_suspend,
138      .Resume             = driver_resume,
139      .IsCreated          = is_created,
140      .GetCapability      = get_capability,
141      .LaunchHotplug      = launch_hotplug,
142      .StopHotplug        = stop_hotplug,
143 
144 #ifdef DFB_INPUTDRIVER_HAS_AXIS_INFO
145      .GetAxisInfo        = driver_get_axis_info
146 #endif
147 };
148 
149 #define DFB_INPUT_DRIVER(shortname)                                             \
150 __attribute__((constructor)) void directfb_##shortname##_ctor( void );          \
151 __attribute__((destructor))  void directfb_##shortname##_dtor( void );          \
152                                                                                 \
153 void                                                                            \
154 directfb_##shortname##_ctor( void )                                             \
155 {                                                                               \
156      direct_modules_register( &dfb_input_modules, DFB_INPUT_DRIVER_ABI_VERSION, \
157                               #shortname, &driver_funcs );                      \
158 }                                                                               \
159                                                                                 \
160 void                                                                            \
161 directfb_##shortname##_dtor( void )                                             \
162 {                                                                               \
163      direct_modules_unregister( &dfb_input_modules, #shortname );               \
164 }
165 
166 #endif
167