Update of /cvsroot/freevo/freevo/WIP/RobShortt/plugins
In directory sc8-pr-cvs1.sourceforge.net:/tmp/cvs-serv28425

Modified Files:
        evdev.py 
Log Message:
Some improvements David Benoit and I worked on.


Index: evdev.py
===================================================================
RCS file: /cvsroot/freevo/freevo/WIP/RobShortt/plugins/evdev.py,v
retrieving revision 1.1
retrieving revision 1.2
diff -C2 -d -r1.1 -r1.2
*** evdev.py    1 Sep 2004 17:36:43 -0000       1.1
--- evdev.py    20 Sep 2004 01:36:15 -0000      1.2
***************
*** 9,12 ****
--- 9,15 ----
  # -----------------------------------------------------------------------
  # $Log$
+ # Revision 1.2  2004/09/20 01:36:15  rshortt
+ # Some improvements David Benoit and I worked on.
+ #
  # Revision 1.1  2004/09/01 17:36:43  rshortt
  # Event input device support.  A work in progress / proof of concept.  With this
***************
*** 47,53 ****
  import config
  import plugin
! import rc
  
! rc = rc.get_singleton()
  
  class PluginInterface(plugin.DaemonPlugin):
--- 50,133 ----
  import config
  import plugin
! import eventhandler
  
! from event import *
! 
! ev = eventhandler.get_singleton()
! 
! keymap = {
! #     0x001c : 'SELECT', # OK
! #     0x0193 : 'CH-',    # CH-
! #     0x0192 : 'CH+',    # CH+
! #     0x0072 : 'DOWN',   # VOL-
! #     0x0073 : 'UP',     # VOL+
! #     0x0074 : 'POWER',  # POWER
! #     0x0084 : 'GO',     # GO
! #     0x0047 : '7',      # 7
! #     0x0048 : '8',      # 8
! #     0x0049 : '9',      # 9
! #     0x004b : '4',      # 4
! #     0x004c : '5',      # 5
! #     0x004d : '6',      # 6
! #     0x004f : '1',      # 1
! #     0x0050 : '2',      # 2
! #     0x0051 : '3',      # 3
! #     0x0052 : '0',      # 0
! #     0x0001 : 'EXIT',   # BACK/EXIT
! #     0x008b : 'MENU',   # MENU
! #     0x0078 : None,     # RED
! #     0x0079 : None,     # GREEN
! #     0x007a : None,     # YELLOW
! #     0x007b : None,     # BLUE
! #     0x0071 : 'MUTE',   # MUTE
! #     0x00f0 : None,     # BLANK
! #     0x0021 : None,     # FULL
! #     0x00a8 : 'REW',    # REWIND
! #     0x00cf : 'PLAY',   # PLAY
! #     0x00d0 : 'FFWD',   # FFWD
! #     0x00a7 : 'RECORD', # RECORD
! #     0x0080 : 'STOP',   # STOP
! #     0x00a4 : 'PAUSE',  # PAUSE
! #     0x00a5 : 'PREV',   # REPLAY
! #     0x00a3 : 'NEXT'    # SKIP
! 
!     # Brad's old lirc converted
!     0x001c : 'SELECT', # OK
!     0x0193 : 'DOWN',    # CH-
!     0x0192 : 'UP',    # CH+
!     0x0072 : 'LEFT',   # VOL-
!     0x0073 : 'RIGHT',     # VOL+
!     0x0074 : 'POWER',  # POWER
!     0x0084 : 'ENTER',     # GO
!     0x0047 : '7',      # 7
!     0x0048 : '8',      # 8
!     0x0049 : '9',      # 9
!     0x004b : '4',      # 4
!     0x004c : '5',      # 5
!     0x004d : '6',      # 6
!     0x004f : '1',      # 1
!     0x0050 : '2',      # 2
!     0x0051 : '3',      # 3
!     0x0052 : '0',      # 0
!     0x0001 : 'EXIT',   # BACK/EXIT
!     0x008b : 'MENU',   # MENU
!     0x0078 : 'CH-',    # RED
!     0x0079 : 'CH+',  # GREEN
!     0x007a : None, # YELLOW
!     0x007b : 'ENTER',   # BLUE
!     0x0071 : 'MUTE',   # MUTE
!     0x00f0 : 'EJECT',     # BLANK
!     0x0021 : 'DISPLAY',    # FULL
!     0x00a8 : 'REW',    # REWIND
!     0x00cf : 'PLAY',   # PLAY
!     0x00d0 : 'FFWD',   # FFWD
!     0x00a7 : 'REC', # RECORD
!     0x0080 : 'STOP',   # STOP
!     0x00a4 : 'PAUSE',  # PAUSE
!     0x00a5 : 'VOL-',  # REPLAY
!     0x00a3 : 'VOL+'    # SKIP
! }
! 
!     
  
  class PluginInterface(plugin.DaemonPlugin):
***************
*** 59,62 ****
--- 139,145 ----
          self.device_name = device_name
          self.poll_interval = 0
+         self.m_ignoreTill = 0
+         self.m_ignore = config.EVDEV_REPEAT_IGNORE
+         self.m_repeatRate = config.EVDEV_REPEAT_RATE
       
          if not self.device_name:
***************
*** 71,75 ****
              return
      
!         print 'Using input device %s.', self.device_name
      
          self.poll_interval = 1
--- 154,158 ----
              return
      
!         print 'Using input device %s.' % self.device_name
      
          self.poll_interval = 1
***************
*** 84,89 ****
          
          if r:
!             c = os.read(self.fd, 1024)
!             print 'RLS: got stuff from event device'
          else: 
              return
--- 167,173 ----
          
          if r:
! #            c = os.read(self.fd, 1024)
!             c = os.read(self.fd, 16)
! #            print 'RLS: got stuff from event device'
          else: 
              return
***************
*** 100,110 ****
  #};
  
!         S_EVDATA = '2l2Hi'
  
          data = struct.unpack(S_EVDATA, c)
  
!         print '  time: %s' % data[0]
!         print '  type: %s' % data[2]
!         print '  code: %s' % data[3]
!         print '  value: %s' % data[4]
  
--- 184,235 ----
  #};
  
! #        S_EVDATA = '2l2Hi'
!         S_EVDATA = '@llHHi'
  
          data = struct.unpack(S_EVDATA, c)
  
!         # make that in milliseconds
!         now = (data[0] * 1000) + (data[1] / 1000)
!         type = data[2]
!         code = data[3]
!         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
!         else :
!             pass
!         
!         # I also want to ignore the "up"
!         if value == 0 :
!             # print '  ignoring up'
!             return
!         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
!             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 = keymap.get(code)
!         if not key :
!             print ' UNMAPPED KEY'
!             return
!         else:
!             pass
! 
!         print '  sending off event %s' % key
!         ev.post_key(key)
  



-------------------------------------------------------
This SF.Net email is sponsored by: YOU BE THE JUDGE. Be one of 170
Project Admins to receive an Apple iPod Mini FREE for your judgement on
who ports your project to Linux PPC the best. Sponsored by IBM.
Deadline: Sept. 24. Go here: http://sf.net/ppc_contest.php
_______________________________________________
Freevo-cvslog mailing list
[EMAIL PROTECTED]
https://lists.sourceforge.net/lists/listinfo/freevo-cvslog

Reply via email to