Enigma2: add possibility to configure input device delay and repeat settings.
authoracid-burn <acid-burn@opendreambox.org>
Thu, 26 Aug 2010 06:34:43 +0000 (08:34 +0200)
committeracid-burn <acid-burn@opendreambox.org>
Thu, 26 Aug 2010 06:34:43 +0000 (08:34 +0200)
fixes #69

13 files changed:
data/menu.xml
data/skin_default/icons/Makefile.am
data/skin_default/icons/input_keyboard-configured.png [new file with mode: 0644]
data/skin_default/icons/input_keyboard.png [new file with mode: 0644]
data/skin_default/icons/input_mouse-configured.png [new file with mode: 0644]
data/skin_default/icons/input_mouse.png [new file with mode: 0644]
data/skin_default/icons/input_rcnew-configured.png [new file with mode: 0644]
data/skin_default/icons/input_rcnew.png [new file with mode: 0644]
data/skin_default/icons/input_rcold-configured.png [new file with mode: 0644]
data/skin_default/icons/input_rcold.png [new file with mode: 0644]
lib/python/Components/InputDevice.py [changed mode: 0644->0755]
lib/python/Screens/InputDeviceSetup.py [new file with mode: 0755]
lib/python/Screens/Makefile.am

index b437fbc..6507bfe 100755 (executable)
@@ -62,8 +62,9 @@
                                </menu>
                                <!--<item text="Remote Control"><setup id="rc" /></item>-->
                                <!--<item text="OSD"><setup id="osd" /></item>-->
-                               <item requires="Display"><setup level="1" id="lcd" /></item>
                                <item level="0" text="Network" entryID="network_setup"><screen module="NetworkSetup" screen="NetworkAdapterSelection" /></item>
+                               <item level="1" text="Input devices" entryID="input_device_setup"><screen module="InputDeviceSetup" screen="InputDeviceSelection" /></item>
+                               <item requires="Display"><setup level="1" id="lcd" /></item>
                                <item text="Keyboard"><setup id="keyboard" /></item>
                                <!--<menu level="1" text="Network..." entryID="network_setup">
                                        <id val="network" />
index 8e2052b..67fe52d 100644 (file)
@@ -27,7 +27,15 @@ dist_install_DATA = \
        icon_view.png \
        input_error.png \
        input_info.png \
+       input_keyboard-configured.png \
+       input_keyboard.png \
+       input_mouse-configured.png \
+       input_mouse.png \
        input_question.png \
+       input_rcnew-configured.png \
+       input_rcnew.png \
+       input_rcold-configured.png \
+       input_rcold.png \
        lock_error.png \
        lock_off.png \
        lock_on.png \
@@ -48,3 +56,4 @@ dist_install_DATA = \
        scan-s.png \
        scan-t.png \
        selectioncross.png
+
diff --git a/data/skin_default/icons/input_keyboard-configured.png b/data/skin_default/icons/input_keyboard-configured.png
new file mode 100644 (file)
index 0000000..c6623a5
Binary files /dev/null and b/data/skin_default/icons/input_keyboard-configured.png differ
diff --git a/data/skin_default/icons/input_keyboard.png b/data/skin_default/icons/input_keyboard.png
new file mode 100644 (file)
index 0000000..a922c89
Binary files /dev/null and b/data/skin_default/icons/input_keyboard.png differ
diff --git a/data/skin_default/icons/input_mouse-configured.png b/data/skin_default/icons/input_mouse-configured.png
new file mode 100644 (file)
index 0000000..3db9447
Binary files /dev/null and b/data/skin_default/icons/input_mouse-configured.png differ
diff --git a/data/skin_default/icons/input_mouse.png b/data/skin_default/icons/input_mouse.png
new file mode 100644 (file)
index 0000000..f70c84e
Binary files /dev/null and b/data/skin_default/icons/input_mouse.png differ
diff --git a/data/skin_default/icons/input_rcnew-configured.png b/data/skin_default/icons/input_rcnew-configured.png
new file mode 100644 (file)
index 0000000..6b16d39
Binary files /dev/null and b/data/skin_default/icons/input_rcnew-configured.png differ
diff --git a/data/skin_default/icons/input_rcnew.png b/data/skin_default/icons/input_rcnew.png
new file mode 100644 (file)
index 0000000..19cdeea
Binary files /dev/null and b/data/skin_default/icons/input_rcnew.png differ
diff --git a/data/skin_default/icons/input_rcold-configured.png b/data/skin_default/icons/input_rcold-configured.png
new file mode 100644 (file)
index 0000000..8d62685
Binary files /dev/null and b/data/skin_default/icons/input_rcold-configured.png differ
diff --git a/data/skin_default/icons/input_rcold.png b/data/skin_default/icons/input_rcold.png
new file mode 100644 (file)
index 0000000..ef8680b
Binary files /dev/null and b/data/skin_default/icons/input_rcold.png differ
old mode 100644 (file)
new mode 100755 (executable)
index 3c3bd7a..d675ca3
-from config import config, ConfigSlider, ConfigSubsection
+# coding: utf-8
+from config import config, configfile, ConfigSlider, ConfigSubsection, ConfigYesNo, ConfigText
+
+import struct, sys, time, errno
+from fcntl import ioctl
+from os import path as os_path, listdir, open as os_open, close as os_close, write as os_write, read as os_read, O_RDWR, O_NONBLOCK
+
+# asm-generic/ioctl.h
+IOC_NRBITS = 8L
+IOC_TYPEBITS = 8L
+IOC_SIZEBITS = 13L
+IOC_DIRBITS = 3L
+
+IOC_NRSHIFT = 0L
+IOC_TYPESHIFT = IOC_NRSHIFT+IOC_NRBITS
+IOC_SIZESHIFT = IOC_TYPESHIFT+IOC_TYPEBITS
+IOC_DIRSHIFT = IOC_SIZESHIFT+IOC_SIZEBITS
+
+IOC_READ = 2L
+
+def EVIOCGNAME(length):
+       return (IOC_READ<<IOC_DIRSHIFT)|(length<<IOC_SIZESHIFT)|(0x45<<IOC_TYPESHIFT)|(0x06<<IOC_NRSHIFT)
+
 
 class inputDevices:
+
+       def __init__(self):
+               self.Devices = {}
+               self.currentDevice = ""
+               self.getInputDevices()
+       
+       def getInputDevices(self):
+               devices = listdir("/dev/input/")
+
+               for evdev in devices:
+                       try:
+                               buffer = "\0"*512
+                               self.fd = os_open("/dev/input/" + evdev, O_RDWR | O_NONBLOCK)
+                               self.name = ioctl(self.fd, EVIOCGNAME(256), buffer)
+                               self.name = self.name[:self.name.find("\0")]
+                               os_close(self.fd)
+                       except (IOError,OSError), err:
+                               print '[iInputDevices] getInputDevices  <ERROR: ioctl(EVIOCGNAME): ' + str(err) + ' >'
+                               self.name = None
+                       
+                       if self.name:
+                               if self.name == 'dreambox front panel':
+                                       continue
+                               if self.name == "dreambox advanced remote control (native)" and config.misc.rcused.value != 0:
+                                       continue
+                               if self.name == "dreambox remote control (native)" and config.misc.rcused.value == 0:
+                                       continue
+                               self.Devices[evdev] = {'name': self.name, 'type': self.getInputDeviceType(self.name),'enabled': False, 'configuredName': None }
+       
+
+       def getInputDeviceType(self,name):
+               if name.find("remote control") != -1:
+                       return "remote"
+               elif name.find("keyboard") != -1:
+                       return "keyboard"
+               elif name.find("mouse") != -1:
+                       return "mouse"
+               else:
+                       print "Unknown device type:",name
+                       return None
+                       
+       def getDeviceName(self, x):
+               if x in self.Devices.keys():
+                       return self.Devices[x].get("name", x)
+               else:
+                       return "Unknown device name"
+
+       def getDeviceList(self):
+               return sorted(self.Devices.iterkeys())
+
+       def getDefaultRCdeviceName(self):
+               if config.misc.rcused.value == 0:
+                       for device in self.Devices.iterkeys():
+                               if self.Devices[device]["name"] == "dreambox advanced remote control (native)":
+                                       return device
+               else:
+                       for device in self.Devices.iterkeys():
+                               if self.Devices[device]["name"] == "dreambox remote control (native)":
+                                       return device
+
+       def setDeviceAttribute(self, device, attribute, value):
+               #print "[iInputDevices] setting for device", device, "attribute", attribute, " to value", value
+               if self.Devices.has_key(device):
+                       self.Devices[device][attribute] = value
+                       
+       def getDeviceAttribute(self, device, attribute):
+               if self.Devices.has_key(device):
+                       if self.Devices[device].has_key(attribute):
+                               return self.Devices[device][attribute]
+               return None
+                       
+       def setEnabled(self, device, value):
+               oldval = self.getDeviceAttribute(device, 'enabled')
+               #print "[iInputDevices] setEnabled for device %s to %s from %s" % (device,value,oldval)
+               self.setDeviceAttribute(device, 'enabled', value)
+               if oldval is True and value is False:
+                       self.setDefaults(device)
+
+       def setName(self, device, value):
+               #print "[iInputDevices] setName for device %s to %s" % (device,value)
+               self.setDeviceAttribute(device, 'configuredName', value)
+               
+       #struct input_event {
+       #       struct timeval time;    -> ignored
+       #       __u16 type;             -> EV_REP (0x14)
+       #       __u16 code;             -> REP_DELAY (0x00) or REP_PERIOD (0x01)
+       #       __s32 value;            -> DEFAULTS: 700(REP_DELAY) or 100(REP_PERIOD)
+       #}; -> size = 16
+
+       def setDefaults(self, device):
+               print "[iInputDevices] setDefaults for device %s" % (device)
+               self.setDeviceAttribute(device, 'configuredName', None)
+               event_repeat = struct.pack('iihhi', 0, 0, 0x14, 0x01, 100)
+               event_delay = struct.pack('iihhi', 0, 0, 0x14, 0x00, 700)
+               fd = os_open("/dev/input/" + device, O_RDWR)
+               os_write(fd, event_repeat)
+               os_write(fd, event_delay)
+               os_close(fd)
+
+       def setRepeat(self, device, value): #REP_PERIOD
+               if self.getDeviceAttribute(device, 'enabled') == True:
+                       print "[iInputDevices] setRepeat for device %s to %d ms" % (device,value)
+                       event = struct.pack('iihhi', 0, 0, 0x14, 0x01, int(value))
+                       fd = os_open("/dev/input/" + device, O_RDWR)
+                       os_write(fd, event)
+                       os_close(fd)
+
+       def setDelay(self, device, value): #REP_DELAY
+               if self.getDeviceAttribute(device, 'enabled') == True:
+                       print "[iInputDevices] setDelay for device %s to %d ms" % (device,value)
+                       event = struct.pack('iihhi', 0, 0, 0x14, 0x00, int(value))
+                       fd = os_open("/dev/input/" + device, O_RDWR)
+                       os_write(fd, event)
+                       os_close(fd)
+
+
+class InitInputDevices:
+       
        def __init__(self):
-               pass
-       def setRepeat(self, value):
-               #print "setup rc repeat"
-               pass
-       def setDelay(self, value):
-               #print "setup rc delay"
-               pass
-
-def InitInputDevices():
-       config.inputDevices = ConfigSubsection();
-       config.inputDevices.repeat = ConfigSlider(default=5, limits=(1, 10))
-       config.inputDevices.delay = ConfigSlider(default=4, limits=(1, 10))
-
-       #this instance anywhere else needed?    
-       iDevices = inputDevices();      
+               self.currentDevice = ""
+               self.createConfig()
        
-       def inputDevicesRepeatChanged(configElement):
-               iDevices.setRepeat(configElement.value);
+       def createConfig(self, *args):
+               config.inputDevices = ConfigSubsection()
+               for device in sorted(iInputDevices.Devices.iterkeys()):
+                       self.currentDevice = device
+                       #print "[InitInputDevices] -> creating config entry for device: %s -> %s  " % (self.currentDevice, iInputDevices.Devices[device]["name"])
+                       self.setupConfigEntries(self.currentDevice)
+                       self.currentDevice = ""
+
+       def inputDevicesEnabledChanged(self,configElement):
+               if self.currentDevice != "" and iInputDevices.currentDevice == "":
+                       iInputDevices.setEnabled(self.currentDevice, configElement.value)
+               elif iInputDevices.currentDevice != "":
+                       iInputDevices.setEnabled(iInputDevices.currentDevice, configElement.value)
+
+       def inputDevicesNameChanged(self,configElement):
+               if self.currentDevice != "" and iInputDevices.currentDevice == "":
+                       iInputDevices.setName(self.currentDevice, configElement.value)
+                       if configElement.value != "":
+                               devname = iInputDevices.getDeviceAttribute(self.currentDevice, 'name')
+                               if devname != configElement.value:
+                                       cmd = "config.inputDevices." + self.currentDevice + ".enabled.value = False"
+                                       exec (cmd)
+                                       cmd = "config.inputDevices." + self.currentDevice + ".enabled.save()"
+                                       exec (cmd)
+               elif iInputDevices.currentDevice != "":
+                       iInputDevices.setName(iInputDevices.currentDevice, configElement.value)
+
+       def inputDevicesRepeatChanged(self,configElement):
+               if self.currentDevice != "" and iInputDevices.currentDevice == "":
+                       iInputDevices.setRepeat(self.currentDevice, configElement.value)
+               elif iInputDevices.currentDevice != "":
+                       iInputDevices.setRepeat(iInputDevices.currentDevice, configElement.value)
+               
+       def inputDevicesDelayChanged(self,configElement):
+               if self.currentDevice != "" and iInputDevices.currentDevice == "":
+                       iInputDevices.setDelay(self.currentDevice, configElement.value)
+               elif iInputDevices.currentDevice != "":
+                       iInputDevices.setDelay(iInputDevices.currentDevice, configElement.value)
+
+       def setupConfigEntries(self,device):
+               cmd = "config.inputDevices." + device + " = ConfigSubsection()"
+               exec (cmd)
+               cmd = "config.inputDevices." + device + ".enabled = ConfigYesNo(default = False)"
+               exec (cmd)
+               cmd = "config.inputDevices." + device + ".enabled.addNotifier(self.inputDevicesEnabledChanged,config.inputDevices." + device + ".enabled)"
+               exec (cmd)
+               cmd = "config.inputDevices." + device + '.name = ConfigText(default="")'
+               exec (cmd)
+               cmd = "config.inputDevices." + device + ".name.addNotifier(self.inputDevicesNameChanged,config.inputDevices." + device + ".name)"
+               exec (cmd)
+               cmd = "config.inputDevices." + device + ".repeat = ConfigSlider(default=100, increment = 10, limits=(0, 500))"
+               exec (cmd)
+               cmd = "config.inputDevices." + device + ".repeat.addNotifier(self.inputDevicesRepeatChanged,config.inputDevices." + device + ".repeat)"
+               exec (cmd)
+               cmd = "config.inputDevices." + device + ".delay = ConfigSlider(default=700, increment = 100, limits=(0, 5000))"
+               exec (cmd)
+               cmd = "config.inputDevices." + device + ".delay.addNotifier(self.inputDevicesDelayChanged,config.inputDevices." + device + ".delay)"
+               exec (cmd)
 
-       def inputDevicesDelayChanged(configElement):
-               iDevices.setDelay(configElement.value);
 
-       # this will call the "setup-val" initial
-       config.inputDevices.repeat.addNotifier(inputDevicesRepeatChanged);
-       config.inputDevices.delay.addNotifier(inputDevicesDelayChanged);
+iInputDevices = inputDevices()
diff --git a/lib/python/Screens/InputDeviceSetup.py b/lib/python/Screens/InputDeviceSetup.py
new file mode 100755 (executable)
index 0000000..bd8550b
--- /dev/null
@@ -0,0 +1,280 @@
+from Screen import Screen
+from Screens.HelpMenu import HelpableScreen
+from Screens.MessageBox import MessageBox
+from Components.InputDevice import iInputDevices
+from Components.Sources.StaticText import StaticText
+from Components.Sources.Boolean import Boolean
+from Components.Sources.List import List
+from Components.config import config, ConfigSlider, ConfigSubsection, ConfigYesNo, ConfigText, getConfigListEntry, ConfigNothing
+from Components.ConfigList import ConfigListScreen
+from Components.ActionMap import ActionMap, NumberActionMap, HelpableActionMap
+from Tools.Directories import resolveFilename, SCOPE_CURRENT_SKIN
+from Tools.LoadPixmap import LoadPixmap
+
+class InputDeviceSelection(Screen,HelpableScreen):
+       skin = """
+       <screen name="InputDeviceSelection" position="center,center" size="560,400" title="Select input device">
+               <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on"/>
+               <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on"/>
+               <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on"/>
+               <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on"/>
+               <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1"/>
+               <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1"/>
+               <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1"/>
+               <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1"/>
+               <widget source="list" render="Listbox" position="5,50" size="550,280" zPosition="10" scrollbarMode="showOnDemand">
+                       <convert type="TemplatedMultiContent">
+                       <!--  device, description, devicepng, divpng  -->
+                                                       {"template": [
+                                                                       MultiContentEntryPixmapAlphaTest(pos = (2, 8), size = (54, 54), png = 2), # index 3 is the interface pixmap
+                                                                       MultiContentEntryText(pos = (65, 6), size = (450, 54), font=0, flags = RT_HALIGN_LEFT|RT_VALIGN_CENTER|RT_WRAP, text = 1), # index 1 is the interfacename
+                                                               ],
+                                                       "fonts": [gFont("Regular", 28),gFont("Regular", 20)],
+                                                       "itemHeight": 70
+                                                       }
+                                               
+                       </convert>
+               </widget>
+               <ePixmap pixmap="skin_default/div-h.png" position="0,340" zPosition="1" size="560,2"/>
+               <widget source="introduction" render="Label" position="0,350" size="560,50" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1"/>
+       </screen>"""
+
+
+       def __init__(self, session):
+               Screen.__init__(self, session)
+               HelpableScreen.__init__(self)
+               
+               self.edittext = _("Press OK to edit the settings.")
+               
+               self["key_red"] = StaticText(_("Close"))
+               self["key_green"] = StaticText(_("Select"))
+               self["key_yellow"] = StaticText("")
+               self["key_blue"] = StaticText("")
+               self["introduction"] = StaticText(self.edittext)
+               
+               self.devices = [(iInputDevices.getDeviceName(x),x) for x in iInputDevices.getDeviceList()]
+               print "[InputDeviceSelection] found devices :->", len(self.devices),self.devices
+                       
+               self["OkCancelActions"] = HelpableActionMap(self, "OkCancelActions",
+                       {
+                       "cancel": (self.close, _("Exit input device selection.")),
+                       "ok": (self.okbuttonClick, _("Select input device.")),
+                       }, -2)
+
+               self["ColorActions"] = HelpableActionMap(self, "ColorActions",
+                       {
+                       "red": (self.close, _("Exit input device selection.")),
+                       "green": (self.okbuttonClick, _("Select input device.")),
+                       }, -2)
+               
+               self.currentIndex = 0
+               self.list = []
+               self["list"] = List(self.list)
+               self.updateList()
+               self.onLayoutFinish.append(self.layoutFinished)
+               self.onClose.append(self.cleanup)
+
+       def layoutFinished(self):
+               self.setTitle(_("Select input device"))
+
+       def cleanup(self):
+               self.currentIndex = 0
+
+       def buildInterfaceList(self,device,description,type ):
+               divpng = LoadPixmap(cached=True, path=resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/div-h.png"))
+               activepng = None
+               devicepng = None
+               enabled = iInputDevices.getDeviceAttribute(device, 'enabled')
+
+               if type == 'remote':
+                       if config.misc.rcused.value == 0:
+                               if enabled:
+                                       devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_rcnew-configured.png"))
+                               else:
+                                       devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_rcnew.png"))
+                       else:
+                               if enabled:
+                                       devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_rcold-configured.png"))
+                               else:
+                                       devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_rcold.png"))
+               elif type == 'keyboard':
+                       if enabled:
+                               devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_keyboard-configured.png"))
+                       else:
+                               devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_keyboard.png"))
+               elif type == 'mouse':
+                       if enabled:
+                               devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_mouse-configured.png"))
+                       else:
+                               devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_mouse.png"))
+               else:
+                       devicepng = LoadPixmap(resolveFilename(SCOPE_CURRENT_SKIN, "skin_default/icons/input_rcnew.png"))
+               return((device, description, devicepng, divpng))        
+
+       def updateList(self):
+               self.list = []
+               for x in self.devices:
+                       dev_type = iInputDevices.getDeviceAttribute(x[1], 'type')
+                       self.list.append(self.buildInterfaceList(x[1],_(x[0]), dev_type ))
+               self["list"].setList(self.list)
+               self["list"].setIndex(self.currentIndex)
+
+       def okbuttonClick(self):
+               selection = self["list"].getCurrent()
+               self.currentIndex = self["list"].getIndex()
+               if selection is not None:
+                       self.session.openWithCallback(self.DeviceSetupClosed, InputDeviceSetup, selection[0])
+
+       def DeviceSetupClosed(self, *ret):
+               self.updateList()
+
+
+class InputDeviceSetup(Screen, ConfigListScreen):
+
+       skin = """
+               <screen name="InputDeviceSetup" position="center,center" size="560,440" title="Input device setup">
+                       <ePixmap pixmap="skin_default/buttons/red.png" position="0,0" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/green.png" position="140,0" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/yellow.png" position="280,0" size="140,40" alphatest="on" />
+                       <ePixmap pixmap="skin_default/buttons/blue.png" position="420,0" size="140,40" alphatest="on" />
+                       <widget source="key_red" render="Label" position="0,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#9f1313" transparent="1" />
+                       <widget source="key_green" render="Label" position="140,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#1f771f" transparent="1" />
+                       <widget source="key_yellow" render="Label" position="280,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#a08500" transparent="1" />
+                       <widget source="key_blue" render="Label" position="420,0" zPosition="1" size="140,40" font="Regular;20" halign="center" valign="center" backgroundColor="#18188b" transparent="1" />
+                       <widget name="config" position="5,50" size="550,350" scrollbarMode="showOnDemand" />
+                       <ePixmap pixmap="skin_default/div-h.png" position="0,400" zPosition="1" size="560,2" />
+                       <widget source="introduction" render="Label" position="5,410" size="550,30" zPosition="10" font="Regular;21" halign="center" valign="center" backgroundColor="#25062748" transparent="1" />
+               </screen>"""
+
+       def __init__(self, session, device):
+               Screen.__init__(self, session)
+               self.inputDevice = device
+               iInputDevices.currentDevice = self.inputDevice
+               self.onChangedEntry = [ ]
+               self.setup_title = _("Input device setup")
+               self.isStepSlider = None
+               self.enableEntry = None
+               self.repeatEntry = None
+               self.delayEntry = None
+               self.nameEntry = None
+               self.enableConfigEntry = None
+
+               self.list = [ ]
+               ConfigListScreen.__init__(self, self.list, session = session, on_change = self.changedEntry)
+
+               self["actions"] = ActionMap(["SetupActions"],
+                       {
+                               "cancel": self.keyCancel,
+                               "save": self.apply,
+                       }, -2)
+
+               self["key_red"] = StaticText(_("Cancel"))
+               self["key_green"] = StaticText(_("OK"))
+               self["key_yellow"] = StaticText()
+               self["key_blue"] = StaticText()
+               self["introduction"] = StaticText()
+
+               self.createSetup()
+               self.onLayoutFinish.append(self.layoutFinished)
+               self.onClose.append(self.cleanup)
+
+       def layoutFinished(self):
+               self.setTitle(self.setup_title)
+
+       def cleanup(self):
+               iInputDevices.currentDevice = ""
+
+       def createSetup(self):
+               self.list = [ ]
+               cmd = "self.enableEntry = getConfigListEntry(_('"'Change repeat and delay settings?'"'), config.inputDevices." + self.inputDevice + ".enabled)"
+               exec (cmd)
+               cmd = "self.repeatEntry = getConfigListEntry(_('"'Interval between keys when repeating:'"'), config.inputDevices." + self.inputDevice + ".repeat)"
+               exec (cmd)
+               cmd = "self.delayEntry = getConfigListEntry(_('"'Delay before key repeat starts:'"'), config.inputDevices." + self.inputDevice + ".delay)"
+               exec (cmd)
+               cmd = "self.nameEntry = getConfigListEntry(_('"'Devicename:'"'), config.inputDevices." + self.inputDevice + ".name)"
+               exec (cmd)
+               if self.enableEntry:
+                       if isinstance(self.enableEntry[1], ConfigYesNo):
+                               self.enableConfigEntry = self.enableEntry[1]
+
+               self.list.append(self.enableEntry)
+               if self.enableConfigEntry:
+                       if self.enableConfigEntry.value is True:
+                               self.list.append(self.repeatEntry)
+                               self.list.append(self.delayEntry)
+                       else:
+                               self.repeatEntry[1].setValue(self.repeatEntry[1].default)
+                               self["config"].invalidate(self.repeatEntry)
+                               self.delayEntry[1].setValue(self.delayEntry[1].default)
+                               self["config"].invalidate(self.delayEntry)
+                               self.nameEntry[1].setValue(self.nameEntry[1].default)
+                               self["config"].invalidate(self.nameEntry)
+                               
+               self["config"].list = self.list
+               self["config"].l.setSeperation(400)
+               self["config"].l.setList(self.list)
+               if not self.selectionChanged in self["config"].onSelectionChanged:
+                       self["config"].onSelectionChanged.append(self.selectionChanged)
+               self.selectionChanged()
+
+       def selectionChanged(self):
+               if self["config"].getCurrent() == self.enableEntry:
+                       self["introduction"].setText(_("Current device: ") + str(iInputDevices.getDeviceAttribute(self.inputDevice, 'name')) )
+               else:
+                       self["introduction"].setText(_("Current value: ") + self.getCurrentValue() + _(" ms"))
+
+       def newConfig(self):
+               current = self["config"].getCurrent()
+               if current:
+                       if current == self.enableEntry:
+                               self.createSetup()
+
+       def keyLeft(self):
+               ConfigListScreen.keyLeft(self)
+               self.newConfig()
+
+       def keyRight(self):
+               ConfigListScreen.keyRight(self)
+               self.newConfig()
+
+       def confirm(self, confirmed):
+               if not confirmed:
+                       print "not confirmed"
+                       return
+               else:
+                       self.nameEntry[1].setValue(iInputDevices.getDeviceAttribute(self.inputDevice, 'name'))
+                       cmd = "config.inputDevices." + self.inputDevice + ".name.save()"
+                       exec (cmd)
+                       self.keySave()
+
+       def apply(self):
+               self.session.openWithCallback(self.confirm, MessageBox, _("Use this input device settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = True)
+
+       def cancelConfirm(self, result):
+               if not result:
+                       return
+               for x in self["config"].list:
+                       x[1].cancel()
+               self.close()
+
+       def keyCancel(self):
+               if self["config"].isChanged():
+                       self.session.openWithCallback(self.cancelConfirm, MessageBox, _("Really close without saving settings?"), MessageBox.TYPE_YESNO, timeout = 20, default = True)
+               else:
+                       self.close()
+       # for summary:
+       def changedEntry(self):
+               for x in self.onChangedEntry:
+                       x()
+               self.selectionChanged()
+
+       def getCurrentEntry(self):
+               return self["config"].getCurrent()[0]
+
+       def getCurrentValue(self):
+               return str(self["config"].getCurrent()[1].value)
+
+       def createSummary(self):
+               from Screens.Setup import SetupSummary
+               return SetupSummary
index d96b491..a4b158d 100755 (executable)
@@ -14,5 +14,6 @@ install_PYTHON = \
        SubtitleDisplay.py SubservicesQuickzap.py ParentalControlSetup.py NumericalTextInputHelpDialog.py \
        SleepTimerEdit.py Ipkg.py RdsDisplay.py Globals.py DefaultWizard.py \
        SessionGlobals.py LocationBox.py WizardLanguage.py TaskView.py Rc.py VirtualKeyBoard.py \
-       TextBox.py FactoryReset.py RecordPaths.py UnhandledKey.py ServiceStopScreen.py
+       TextBox.py FactoryReset.py RecordPaths.py UnhandledKey.py ServiceStopScreen.py \
+       InputDeviceSetup.py