Hi, I finally had a chance to look at these.
Dirk Meyer wrote:
** freevo-irremote.diff - breaks out irremote support out of rc.py and puts it into a plugin of its own. Has nice side effect of allowing repeated commands to be received by freevo consistently. Previously repeated commands sent via LIRC would be processed very sporadically. Currently breaks network remote control - If time permits I plan to put this into a similar plugin in the future.
I like the looks of this and it makes a lot of sense to have the different remote controls as plugins. I will look at this closer and perhaps make a network remote plugin so that we don't break it.
** freevo-ivtv_mencoder_record.diff - I was having trouble with the default recording plugin dying for the IVTV cards. I modified the existing plugin to use mencoder instead of simply reading directly from the video device for a set time. Allows you to save to raw mpeg file dumps generated via the TV card or re-encode real-time to avi if your pc if fast enough. Could be modified in the future to allow selection of record quality.
I don't want to apply this one because this can be done just as easily using tv.generic_record and VCR_CMD. If there are problems with how this plugin does the recording I would like to hear about it.
** freevo-joystick.diff - modified to allow binding of commands to multiple axis and to allow simultaneous use of joystick in freevo and the games freevo supports.
I am not setup at the moment to test the joystick plugin but this looks good. Can someone else who uses the joystick plugin try it? I have reattached the file.
-Rob
diff -ur --new-file freevo-1.4.1-new/src/games/game.py freevo-1.4.1/src/games/game.py --- freevo-1.4.1-new/src/games/game.py 2003-12-14 18:22:30.000000000 -0500 +++ freevo-1.4.1/src/games/game.py 2003-10-22 20:30:42.000000000 -0400 @@ -171,16 +175,24 @@ if DEBUG: print 'Game_Thread.run(): Started, cmd=%s' % self.command - osd.stopdisplay() + osd.stopdisplay() + + if plugin.is_active('joy'): + plugin.getbyname('JOY').enable(False) + self.app = GameApp(self.command) while self.mode == 'play' and self.app.isAlive(): time.sleep(0.5) - print('Game_Thread::run: GAME OVER') + if DEBUG: + print('Game_Thread::run: GAME OVER') self.app.kill() + if plugin.is_active('joy'): + plugin.getbyname('JOY').enable(True) + if config.OSD_SDL_EXEC_AFTER_STARTUP: os.system(config.OSD_SDL_EXEC_AFTER_STARTUP) diff -ur --new-file freevo-1.4.1-new/src/plugins/joy.py freevo-1.4.1/src/plugins/joy.py --- freevo-1.4.1-new/src/plugins/joy.py 2003-12-19 04:24:32.000000000 -0500 +++ freevo-1.4.1/src/plugins/joy.py 2003-10-04 14:37:29.000000000 -0400 @@ -2,15 +2,44 @@ # ----------------------------------------------------------------------- # joy.py - A joystick control plugin for Freevo. # ----------------------------------------------------------------------- -# $Id: joy.py,v 1.10 2003/10/04 18:37:29 dischi Exp $ +# $Id: joy.py,v 1.11 2003/12/06 23:20:29 kareejb Exp $ # # Notes: -# To use this plugin make sure that your joystick is already working +# To use this plugin make sure that your joystick is already working # properly and then configure JOY_DEV and JOY_CMDS in your local_conf.py. # You will also need to have plugin.activate('joy') in your config as well. # # ----------------------------------------------------------------------- # $Log: joy.py,v $ +# +# Revision 1.11 2003/12/06 23:20:29 kareejb +# Modified to allow binding of different axis to freevo events and +# to allow plugin to coexist with freevo games that also use the joystick. +# ie: +# +# <!-snip local_conf.py-!> +# JOY_CMDS = { +# 'axis 1 neg' : 'UP', +# 'axis 1 pos' : 'DOWN', +# 'axis 0 neg' : 'LEFT', +# 'axis 0 pos' : 'RIGHT', +# 'axis 6 neg' : 'UP', +# 'axis 6 pos' : 'DOWN', +# 'axis 5 neg' : 'LEFT', +# 'axis 5 pos' : 'RIGHT', +# 'button 1' : 'SELECT', +# 'button 4' : 'EXIT', +# 'button 7' : 'SELECT', +# 'button 10' : 'EXIT', +# 'button 2' : 'PAUSE', +# 'button 6' : 'DISPLAY', +# 'button 3' : 'ENTER', +# 'button 8' : 'DISPLAY', +# 'button 11' : 'ENTER', +# 'button 6' : 'MENU' +# } +# </!-snip local_conf.py-!> +# # Revision 1.10 2003/10/04 18:37:29 dischi # i18n changes and True/False usage # @@ -49,6 +78,7 @@ import struct import traceback from time import sleep +from time import time import config import plugin @@ -66,7 +96,8 @@ # If we make it to the end of __init__ successfully then # poll_interval is set to run ok. self.poll_interval = 0 - + self.enabled = False + if config.JOY_DEV == 0: print 'Joystick input module disabled, exiting' return @@ -82,53 +113,64 @@ self.device_name = '/dev/js'+str((config.JOY_DEV - 1)) try: - self.joyfd = os.open(self.device_name, + self.joyfd = os.open(self.device_name, os.O_RDONLY|os.O_NONBLOCK) except OSError: print 'Unable to open %s, check modules and/or permissions' % \ self.device_name print 'exiting...' return - - print 'using joystick', config.JOY_DEV - + + _debug_('using joystick %s' % config.JOY_DEV) + self.poll_interval = 1 + self.enabled = True self.poll_menu_only = False + self.last_command_time = time() + self.last_command = None def poll(self): - command = '' + command = '' _debug_('self.joyfd = %s' % self.joyfd, level=3) (r, w, e) = select.select([self.joyfd], [], [], 0) _debug_('r,w,e = %s,%s,%s' % (r,w,e), level=3) - + if r: c = os.read(self.joyfd, 8) - else: + else: return data = struct.unpack('IhBB', c) if data[2] == 1 & data[1] == 1: button = 'button '+str((data[3] + 1)) command = config.JOY_CMDS.get(button, '') - sleep(0.3) # the direction pad can use lower debounce time + if command != '': + if self.enabled: + command = rc.key_event_mapper(command) + if command: + _debug_('Translation: "%s" -> "%s"' % (button, command)) + rc.post_event(command) if data[2] == 2: - if ((data[3] == 1) & (data[1] < -16384)): - button = 'up' - command = config.JOY_CMDS['up'] - if ((data[3] == 1) & (data[1] > 16384)): - button = 'down' - command = config.JOY_CMDS['down'] - if ((data[3] == 0) & (data[1] < -16384)): - button = 'left' - command = config.JOY_CMDS['left'] - if ((data[3] == 0) & (data[1] > 16384)): - button = 'right' - command = config.JOY_CMDS['right'] - if command != '': - _debug_('Translation: "%s" -> "%s"' % (button, command)) - command = rc.key_event_mapper(command) - if command: - rc.post_event(command) - + if data[1] < -16384: + button = 'axis '+str((data[3]))+' neg' + command = config.JOY_CMDS.get(button, '') + if data[1] > 16384: + button = 'axis '+str((data[3]))+' pos' + command = config.JOY_CMDS.get(button, '') + if command != '': + if self.enabled: + command = rc.key_event_mapper(command) + if command: + # set debounce time on repeated commands - 4cps + if not (command == self.last_command and time() - self.last_command_time < .25): + _debug_('Translation: "%s" -> "%s"' % (button, command)) + rc.post_event(command) + self.last_command_time = time() + self.last_command = command + + + def enable(self, enable_joy=True): + self.enabled = enable_joy + return + mpl = str(' ').join(args) else: print 'Mode "%s" is not implemented' % mode # XXX ui.message()