Package elisa :: Package base_components :: Module input_provider
[hide private]
[frames] | no frames]

Source Code for Module elisa.base_components.input_provider

  1  # -*- coding: utf-8 -*- 
  2  # Elisa - Home multimedia server 
  3  # Copyright (C) 2006-2008 Fluendo Embedded S.L. (www.fluendo.com). 
  4  # All rights reserved. 
  5  # 
  6  # This file is available under one of two license agreements. 
  7  # 
  8  # This file is licensed under the GPL version 3. 
  9  # See "LICENSE.GPL" in the root of this distribution including a special 
 10  # exception to use Elisa with Fluendo's plugins. 
 11  # 
 12  # The GPL part of Elisa is also available under a commercial licensing 
 13  # agreement from Fluendo. 
 14  # See "LICENSE.Elisa" in the root directory of this distribution package 
 15  # for details on that license. 
 16   
 17  """ 
 18  Input events providers Component base classes 
 19  """ 
 20   
 21   
 22  __maintainer__ = 'Philippe Normand <philippe@fluendo.com>' 
 23  __maintainer2__ = 'Florian Boucault <florian@fluendo.com>' 
 24   
 25   
 26  from elisa.core.component import Component 
 27  from elisa.core.frontend import Frontend 
 28  from elisa.core.backend import Backend 
 29   
 30   
31 -class InputProvider(Component):
32 """ Input events provider class. Plugins can't subclass it 33 directly, they have to use either L{PollInputProvider} or 34 L{PushInputProvider} classes. 35 36 @ivar viewport: DOCME 37 @type viewport: 38 @ivar origin: source of the events; can be a frontend, a backend or None 39 @type origin: L{Backend} or L{Frontend} or None 40 """ 41
42 - def create_input_event(self, data):
43 """ Translate external input data to an InputEvent object, 44 understandable by the InputManager. This method has to be 45 overriden by InputProvider implementations. This method is 46 called by InputProvider implementations. 47 48 @param data: the data to translate, can be of any type 49 @returns: L{elisa.core.input_event.InputEvent} 50 """
51
52 -class PollInputProvider(InputProvider):
53 """ Non-blocking way to retrieve user input events. Plugins can 54 provide InputProviders to support new input devices (remote 55 controls, wiimote, gyro mouse, joystick, ...) 56 """ 57
58 - def get_input_events(self):
59 """ Retrieve events from an input device and translate them in 60 L{elisa.core.input_event.InputEvent} objects understandable by 61 the InputManager. 62 The returned list can be built with the create_input_event() method, 63 for each data retrieved from the input device. 64 65 @returns: Input events from a user-input device 66 @rtype: L{elisa.core.input_event.InputEvent} list 67 """ 68 return []
69
70 -class PushInputProvider(InputProvider):
71 """ InputProvider that will be able to push InputEvents directly 72 to the InputManager by method calls 73 (input_manager.process_event). This class should be used to 74 support input devices that can't be polled for events. 75 76 @ivar input_manager: the InputManager the Provider is registered with 77 @type input_manager: L{elisa.core.input_manager.InputManager} 78 """ 79
80 - def clean(self):
81 """ Additional cleanups to default Component's cleanup: 82 disconnect our handlers from external component signals. 83 """ 84 self.unbind() 85 InputProvider.clean(self)
86
87 - def bind(self):
88 """ Subscribe to the input device 89 90 This can be done by connecting external component signals to 91 our handlers or register a local callback that will be called 92 by the external component when it receives an input event. 93 94 This method must be overriden by implementation because it's 95 totally dependent on the infrastructure used by the input 96 device the component supports. 97 """
98
99 - def unbind(self):
100 """ Unsubscribe from the input device 101 102 This can be done by disconnecting our handlers from the 103 external component signals or unregistering the local callback 104 previously registered by the register() method. 105 106 This method must be overriden by implementation because it's 107 totally dependent on the infrastructure used by the input 108 device the component supports. 109 """
110