Update of /cvsroot/freevo/freevo/src/input/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv8632/src/input/plugins

Modified Files:
        event_device.py 
Log Message:
small cleanup and add logging


Index: event_device.py
===================================================================
RCS file: /cvsroot/freevo/freevo/src/input/plugins/event_device.py,v
retrieving revision 1.6
retrieving revision 1.7
diff -C2 -d -r1.6 -r1.7
*** event_device.py     4 Dec 2004 01:48:50 -0000       1.6
--- event_device.py     13 Dec 2004 01:45:17 -0000      1.7
***************
*** 9,12 ****
--- 9,15 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.7  2004/12/13 01:45:17  rshortt
+ # small cleanup and add logging
+ #
  # Revision 1.6  2004/12/04 01:48:50  rshortt
  # Comment some debug, too noisy.
***************
*** 76,79 ****
--- 79,83 ----
  import traceback
  import fcntl
+ import logging
  from time import sleep
  
***************
*** 81,85 ****
  import plugin
  
- #from input.linux_input import *
  import input.linux_input as li
  import input.evdev_keymaps as ek
--- 85,88 ----
***************
*** 87,90 ****
--- 90,94 ----
  from event import *
  
+ log = logging.getLogger('input')
  
  class PluginInterface(plugin.InputPlugin):
***************
*** 95,121 ****
          self.plugin_name = 'EVDEV'
          self.device_name = config.EVDEV_DEVICE
!         self.m_ignoreTill = 0
!         self.m_ignore = config.EVDEV_REPEAT_IGNORE
!         self.m_repeatRate = config.EVDEV_REPEAT_RATE
       
-         if not self.device_name:
-             print 'Input device plugin disabled, exiting.'
-             return
- 
          try:
              self.fd = os.open(self.device_name, 
                                os.O_RDONLY|os.O_NONBLOCK)
          except OSError:
!             print 'Unable to open %s, exiting.' % self.device_name
              return
  
          exclusive = li.exclusive_access(self.fd)
          if exclusive != -1:
!             print 'Freevo granted exclusive access to %s.' % self.device_name
! 
!         print 'Event device name: %s' % li.get_name(self.fd)
  
      
-         print 'Using input device %s.' % self.device_name
  
          self.keymap = {}
--- 99,121 ----
          self.plugin_name = 'EVDEV'
          self.device_name = config.EVDEV_DEVICE
!         self._ignore_until = 0
!         self.repeat_ignore = config.EVDEV_REPEAT_IGNORE
!         self.repeat_rate = config.EVDEV_REPEAT_RATE
       
          try:
              self.fd = os.open(self.device_name, 
                                os.O_RDONLY|os.O_NONBLOCK)
          except OSError:
!             log.error('Unable to open %s, exiting.' % self.device_name)
              return
  
+         log.info('Using input device %s.' % self.device_name)
+ 
          exclusive = li.exclusive_access(self.fd)
          if exclusive != -1:
!             log.info('Freevo granted exclusive access to %s.' % 
self.device_name)
  
+         log.info('Event device name: %s' % li.get_name(self.fd))
      
  
          self.keymap = {}
***************
*** 127,138 ****
          device_codes = ek.maps.get(config.EVDEV_NAME)
          for s, k in device_codes.items():
!             print 'Adding key: 0x%04x = %3d' % (s, k)
              if not li.set_keycode(self.fd, s, k):
!                 print 'Failed to set key: 0x%04x = %3d' % (s, k)
  
          keymap = li.get_keymap(self.fd)
!         print 'KEYCODES:'
          for s, k in keymap.items():
!             print '    0x%04x = %3d' % (s, k)
  
          notifier.addSocket( self.fd, self.handle )
--- 127,138 ----
          device_codes = ek.maps.get(config.EVDEV_NAME)
          for s, k in device_codes.items():
!             log.debug('Adding key: 0x%04x = %3d' % (s, k))
              if not li.set_keycode(self.fd, s, k):
!                 log.error('Failed to set key: 0x%04x = %3d' % (s, k))
  
          keymap = li.get_keymap(self.fd)
!         log.debug('KEYCODES:')
          for s, k in keymap.items():
!             log.debug('    0x%04x = %3d' % (s, k))
  
          notifier.addSocket( self.fd, self.handle )
***************
*** 148,175 ****
                  ( 'EVDEV_NAME', 'Hauppauge PVR-250/350 IR remote', 'Long name 
of device.' ),
                  ( 'EVDEV_DEVICE', '/dev/input/event0', 'Input device to use.' 
),
!                 ( 'EVDEV_REPEAT_IGNORE', 500, 
                    'Time before first repeat (miliseconds).' ),
!                 ( 'EVDEV_REPEAT_RATE',   100, 
                    'Time between consecutive repeats (miliseconds).' ), ]
  
  
      def handle( self, socket ):
-         command = ''    
-         c = os.read(self.fd, 16)
- 
- #struct input_event {
- #        struct timeval time;
- #        __u16 type;
- #        __u16 code;
- #        __s32 value;
- #};
- #struct timeval {
- #        time_t          tv_sec;         /* seconds */ long
- #        suseconds_t     tv_usec;        /* microseconds */ long
- #};
- 
- #        S_EVDATA = '2l2Hi'
          S_EVDATA = '@llHHi'
! 
          data = struct.unpack(S_EVDATA, c)
  
--- 148,160 ----
                  ( 'EVDEV_NAME', 'Hauppauge PVR-250/350 IR remote', 'Long name 
of device.' ),
                  ( 'EVDEV_DEVICE', '/dev/input/event0', 'Input device to use.' 
),
!                 ( 'EVDEV_REPEAT_IGNORE', 400, 
                    'Time before first repeat (miliseconds).' ),
!                 ( 'EVDEV_REPEAT_RATE',  100, 
                    'Time between consecutive repeats (miliseconds).' ), ]
  
  
      def handle( self, socket ):
          S_EVDATA = '@llHHi'
!         c = os.read(self.fd, 16)
          data = struct.unpack(S_EVDATA, c)
  
***************
*** 180,220 ****
          value = data[4]
  
!         #print '  time: %d type=%04x code=%04x value=%08x' % (now, type, 
code, value)
  
          # was it a reset?  if so, ignore
          if type == 0 :
!             # print '  ignoring reset from input'
              return True
-         else :
-             pass
          
          # I also want to ignore the "up"
          if value == 0 :
!             # print '  ignoring up'
              return True
          elif value == 1 :
              # set when we want to start paying attention to repeats
!             self.m_ignoreTill = now + self.m_ignore
          elif value == 2 :
!             if now < self.m_ignoreTill :
!                 #print '  ignoring repeat until %d' % self.m_ignoreTill
                  return True
              else:
                  # we let this one through, but set when we want to start
                  # paying attention to the next repeat 
!                 self.m_ignoreTill = now + self.m_repeatRate
!                 pass
!             pass
!         else:
!             pass
                  
          key = self.keymap.get(code)
          if not key :
!             print ' UNMAPPED KEY'
              return True
-         else:
-             pass
  
!         #print '  sending off event %s' % key
          self.post_key(key)
  
--- 165,197 ----
          value = data[4]
  
!         # log.debug('time: %d type=%04x code=%04x value=%08x' % (now, type, 
code, value))
  
          # was it a reset?  if so, ignore
          if type == 0 :
!             # log.debug('ignoring reset from input')
              return True
          
          # I also want to ignore the "up"
          if value == 0 :
!             # log.debug('ignoring up')
              return True
          elif value == 1 :
              # set when we want to start paying attention to repeats
!             self._ignore_until = now + self.repeat_ignore
          elif value == 2 :
!             if now < self._ignore_until :
!                 # log.debug('ignoring repeat until %d' % self._ignore_until)
                  return True
              else:
                  # we let this one through, but set when we want to start
                  # paying attention to the next repeat 
!                 self._ignore_until = now + self.repeat_rate
                  
          key = self.keymap.get(code)
          if not key :
!             log.warning('unmapped key: code=%s' % code)
              return True
  
!         log.debug('posting key: %s' % key)
          self.post_key(key)
  



-------------------------------------------------------
SF email is sponsored by - The IT Product Guide
Read honest & candid reviews on hundreds of IT Products from real users.
Discover which products truly live up to the hype. Start reading now. 
http://productguide.itmanagersjournal.com/
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to