From: Michael Mrozek Date: Fri, 10 Jun 2011 19:37:44 +0000 (+0200) Subject: pandora-scripts: Added new Nubselector by Caine, removed Arora and Midori-PND files... X-Git-Tag: sz_beta3~150 X-Git-Url: http://git.openpandora.org/cgi-bin/gitweb.cgi?a=commitdiff_plain;h=1c52352f3d0dc2be4ffad216f2d7b95d09aea5f0;p=openpandora.oe.git pandora-scripts: Added new Nubselector by Caine, removed Arora and Midori-PND files, bumped recipe --- diff --git a/recipes/pandora-system/pandora-scripts.bb b/recipes/pandora-system/pandora-scripts.bb index 3bc1d11..b16b4b1 100644 --- a/recipes/pandora-system/pandora-scripts.bb +++ b/recipes/pandora-system/pandora-scripts.bb @@ -6,7 +6,7 @@ COMPATIBLE_MACHINE = "omap3-pandora" DEPENDS = "zenity dbus" RDEPENDS = "zenity dbus" -PR = "r61" +PR = "r62" SRC_URI = " \ file://op_bright.sh \ @@ -39,7 +39,7 @@ SRC_URI = " \ file://op_videofir.sh \ file://op_storage.sh \ file://op_storage.pnd \ - file://op_nubmode.sh \ + file://op_nubmode.py \ file://op_nubmode.pnd \ file://op_tvout.sh \ file://op_tvout.pnd \ @@ -48,13 +48,14 @@ SRC_URI = " \ file://cpu.conf \ file://gamma.conf \ file://service.conf \ + file://nub_profiles.conf \ + file://nubmode.glade \ + file://pndlogo.png \ file://default_up \ file://none_up \ file://op_env.sh \ - file://arora.pnd \ file://evince.pnd \ file://gigolo.pnd \ - file://midori.pnd \ file://mousepad.pnd \ file://ristretto.pnd \ file://squeeze.pnd \ @@ -84,7 +85,7 @@ do_install() { install -m 0755 ${WORKDIR}/op_lcdsettings.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_lcdrate.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_videofir.sh ${D}${prefix}/pandora/scripts/ - install -m 0755 ${WORKDIR}/op_nubmode.sh ${D}${prefix}/pandora/scripts/ + install -m 0755 ${WORKDIR}/op_nubmode.py ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_storage.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_tvout.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_bright_down.sh ${D}${prefix}/pandora/scripts/ @@ -93,6 +94,7 @@ do_install() { install -m 0755 ${WORKDIR}/op_battlow.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_bright_up.sh ${D}${prefix}/pandora/scripts/ install -m 0755 ${WORKDIR}/op_menu.sh ${D}${prefix}/pandora/scripts/ + install -m 0644 ${WORKDIR}/pndlogo.png ${D}${prefix}/pandora/scripts/ @@ -112,10 +114,8 @@ do_install() { install -m 0755 ${WORKDIR}/op_inputtest.pnd ${D}${prefix}/pandora/apps/ install -d ${D}${prefix}/pandora/mmenu/ - install -m 0755 ${WORKDIR}/arora.pnd ${D}${prefix}/pandora/mmenu/ install -m 0755 ${WORKDIR}/evince.pnd ${D}${prefix}/pandora/mmenu/ install -m 0755 ${WORKDIR}/gigolo.pnd ${D}${prefix}/pandora/mmenu/ - install -m 0755 ${WORKDIR}/midori.pnd ${D}${prefix}/pandora/mmenu/ install -m 0755 ${WORKDIR}/mousepad.pnd ${D}${prefix}/pandora/mmenu/ install -m 0755 ${WORKDIR}/ristretto.pnd ${D}${prefix}/pandora/mmenu/ install -m 0755 ${WORKDIR}/squeeze.pnd ${D}${prefix}/pandora/mmenu/ @@ -134,6 +134,7 @@ do_install() { install -m 0644 ${WORKDIR}/cpu.conf ${D}${sysconfdir}/pandora/conf/cpu.conf install -m 0644 ${WORKDIR}/gamma.conf ${D}${sysconfdir}/pandora/conf/gamma.conf install -m 0644 ${WORKDIR}/service.conf ${D}${sysconfdir}/pandora/conf/service.conf + install -m 0644 ${WORKDIR}/nub_profiles.conf ${D}${sysconfdir}/pandora/conf/nub_profiles.conf install -d ${D}${sysconfdir}/pandora/conf/dss_fir/ install -m 0644 ${WORKDIR}/default_up ${D}${sysconfdir}/pandora/conf/dss_fir/ diff --git a/recipes/pandora-system/pandora-scripts/nub_profiles.conf b/recipes/pandora-system/pandora-scripts/nub_profiles.conf new file mode 100755 index 0000000..e69de29 diff --git a/recipes/pandora-system/pandora-scripts/nubmode.glade b/recipes/pandora-system/pandora-scripts/nubmode.glade new file mode 100755 index 0000000..a77be2b --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/nubmode.glade @@ -0,0 +1,595 @@ + + + + + + Nub configuration + center + + + True + 11 + 3 + 4 + + + True + 0 + none + + + True + 12 + + + True + + + mouse movement + True + True + False + True + True + + + 0 + + + + + mouse buttons + True + True + False + True + True + LeftRadio_mouse + + + 1 + + + + + scrolling + True + True + False + True + True + LeftRadio_mouse + + + 2 + + + + + joystick + True + True + False + True + True + LeftRadio_mouse + + + 3 + + + + + + + + + True + <b>Left nub mode</b> + True + + + + + + + True + 0 + none + + + True + 12 + + + True + + + mouse movement + True + True + False + True + True + + + 0 + + + + + mouse buttons + True + True + False + True + True + RightRadio_mouse + + + 1 + + + + + scrolling + True + True + False + True + True + RightRadio_mouse + + + 2 + + + + + joystick + True + True + False + True + True + RightRadio_mouse + + + 3 + + + + + + + + + True + <b>Right nub mode</b> + True + + + + + 2 + 3 + + + + + True + True + lbutton + 0 + + + 3 + 4 + + + + + True + True + lmouse + 0 + + + 2 + 3 + + + + + 8 + True + + + 3 + 1 + 2 + + + + + True + Scroll sensitivity (y-axis) + + + 1 + 2 + 6 + 7 + + + + + True + Scroll sensitivity (x-axis) + + + 1 + 2 + 5 + 6 + + + + + True + Scroll speed + + + 1 + 2 + 4 + 5 + + + + + True + Mouse button sensitivity + + + 1 + 2 + 3 + 4 + + + + + True + Mouse speed + + + 1 + 2 + 2 + 3 + + + + + True + True + lscroll + 0 + + + 4 + 5 + + + + + True + True + lscrollx + 0 + + + 5 + 6 + + + + + True + True + lscrolly + 0 + + + 6 + 7 + + + + + True + True + rmouse + 0 + + + 2 + 3 + 2 + 3 + + + + + True + True + rbutton + 0 + + + 2 + 3 + 3 + 4 + + + + + True + True + rscroll + 0 + + + 2 + 3 + 4 + 5 + + + + + True + True + rscrollx + 0 + + + 2 + 3 + 5 + 6 + + + + + True + True + delayed + rscrolly + 0 + + + 2 + 3 + 6 + 7 + + + + + 6 + True + + + 3 + 7 + 8 + + + + + Reset left nub + True + True + True + + + + 8 + 9 + 2 + + + + + Reset right nub + True + True + True + + + + 2 + 3 + 8 + 9 + 2 + + + + + Scan nub state + True + True + True + top + + + + 1 + 2 + 8 + 9 + 2 + + + + + True + + + 84 + True + pndlogo.png + + + 0 + + + + + Apply configuration + True + True + True + + + + 1 + + + + + 1 + 2 + + + + + Save profile + True + True + True + + + + 9 + 10 + 2 + + + + + True + + + 1 + 2 + 9 + 10 + 2 + + + + + Load profile + True + True + True + + + + 2 + 3 + 9 + 10 + 2 + + + + + True + 2 + + + 3 + 10 + 11 + + + + + + + 150 + 50 + 300 + 1 + 10 + + + 150 + 50 + 300 + 1 + 10 + + + 20 + 1 + 40 + 1 + 10 + + + 20 + 1 + 40 + 1 + 10 + + + 20 + 1 + 40 + 1 + 10 + + + 20 + 1 + 40 + 1 + 10 + + + 7 + -32 + 32 + 1 + 10 + + + 7 + -32 + 32 + 1 + 10 + + + 7 + -32 + 32 + 1 + 10 + + + 7 + -32 + 32 + 1 + 10 + + diff --git a/recipes/pandora-system/pandora-scripts/op_nubmode.pnd b/recipes/pandora-system/pandora-scripts/op_nubmode.pnd index 9f5d7e6..ac19600 100644 Binary files a/recipes/pandora-system/pandora-scripts/op_nubmode.pnd and b/recipes/pandora-system/pandora-scripts/op_nubmode.pnd differ diff --git a/recipes/pandora-system/pandora-scripts/op_nubmode.py b/recipes/pandora-system/pandora-scripts/op_nubmode.py new file mode 100755 index 0000000..f20dfda --- /dev/null +++ b/recipes/pandora-system/pandora-scripts/op_nubmode.py @@ -0,0 +1,255 @@ +#!/usr/bin/python + +# TODO: +# - fix nub reset (permission issue) and add test +# - wrap into PND +# - upload into beta software, gather & process feedback +# - upload into repo + +import os +import re +import sys +import gtk +import time +import optparse + +# EDs reset in op_nubmode.sh +# +# @left-nub: 3-0066/reset + +# echo 1 > /sys/bus/i2c/drivers/vsense/3-0067/reset +# sleep 1 +# echo 0 > /sys/bus/i2c/drivers/vsense/3-0067/reset +# curmode=$(cat /proc/pandora/nub1/mode) +# echo mouse > /proc/pandora/nub1/mode +# while ! zenity --question --title="Resetted right nub" --text="The right nub has been resetted.\nPlease try to move the mouse cursor\nto test if it is working properly." --ok-label="Working properly" --cancel-label="Reset again"; do +# echo 1 > /sys/bus/i2c/drivers/vsense/3-0067/reset +# sleep 1 +# echo 0 > /sys/bus/i2c/drivers/vsense/3-0067/reset +# done +# echo $curmode > /proc/pandora/nub1/mode + +# ================================================================ + +GUI_DESCRIPTION = 'nubmode.glade' +PROFILES = '/etc/pandora/conf/nub_profiles.conf' + +MODES = ("mouse", "mbuttons", "scroll", "absolute") +SLIDERS = ("mouse", "button", "scroll", "scrollx", "scrolly") + +DEFAULT_PROFILENAME = "Default" +DEFAULT_PROFILE = [DEFAULT_PROFILENAME, + "mouse 150 20 20 7 7", "mbuttons 150 20 20 7 7"] + +RESET_CMD_LEFT = 'echo %i > /sys/bus/i2c/drivers/vsense/3-0066/reset' +RESET_CMD_RIGHT = 'echo %i > /sys/bus/i2c/drivers/vsense/3-0067/reset' + +# Settings read/written to /proc/pandora/nub (: 0 or 1) +FILES = "mode mouse_sensitivity mbutton_threshold scroll_rate scrollx_sensitivity scrolly_sensitivity".split(' ') +LEFT_NUB_CONFIG = [os.path.join('/proc/pandora/nub0', x) for x in FILES] +RIGHT_NUB_CONFIG = [os.path.join('/proc/pandora/nub1', x) for x in FILES] + +RE_FORMAT = "(%s),(\d+),(\d+),(\d+),(\d+),(\d+)" % '|'.join(MODES) +BOUNDS = ((50, 300), (1, 40), (1, 40), (-32, 32), (-32, 32)) + +# ================================================================ + +def Validate(value): + mo = re.match(RE_FORMAT, value) + if mo and all(lower <= int(value) <= upper for (value, (lower, upper)) in + zip(mo.groups()[1:], BOUNDS)): + return True, list(mo.groups()) + else: + return False, None + +def ReadConfigFromProc(paths): + config = [] + for filepath in paths: + with open(filepath) as f: + config.append(f.readline().strip()) + return config + +def StoreConfigToProc(paths, values): + # fix for scrollx, scrolly being stored one closer to zero than specified + values[-2:] = [int(v) + (-1 if v < 0 else 1) for v in values[-2:]] + + for filepath, value in zip(paths, values): + with open(filepath, 'w') as f: + f.write('%s\n' % value) + + +class Nub(object): + def __init__(self, builder, modeprefix, sliderprefix): + self.radios = [builder.get_object(modeprefix % m) for m in MODES] + self.sliders = [builder.get_object(sliderprefix % s) for s in SLIDERS] + + def SetConfig(self, config): + i = MODES.index(config[0]) + self.radios[i].set_active(True) + for s, v in zip(self.sliders, config[1:]): + s.value = int(v) + + def GetConfig(self): + i = (j for j, r in enumerate(self.radios) if r.get_active()).next() + config = [MODES[i]] + for s in self.sliders: + config.append(str(int(s.value))) + return config + + +class NubConfig(object): + """GUI application for modifying the pandora nub configuration""" + def __init__(self): + builder = gtk.Builder() + builder.add_from_file( + os.path.join(os.path.dirname(__file__), GUI_DESCRIPTION)) + builder.connect_signals(self) + + self.leftnub = Nub(builder, "LeftRadio_%s", "l%s") + self.rightnub = Nub(builder, "RightRadio_%s", "r%s") + + self.profiles = gtk.ListStore(str, str, str) + self.profiles.append(DEFAULT_PROFILE) + with open(PROFILES) as f: + c = map(str.rstrip, f.readlines()) + for p in zip(*(c[i::3] for i in range(3))): + self.profiles.append(p) + + self.statusbar = builder.get_object("statusbar") + self.contextid = self.statusbar.get_context_id('') + + self.comboentry = builder.get_object("ProfileComboEntry") + self.comboentry.set_model(self.profiles) + self.comboentry.set_text_column(0) + + self.entry = self.comboentry.get_child() + self.entry.connect('changed', self.on_combo_changed) + + self.load = builder.get_object('LoadProfile') + self.save = builder.get_object('SaveProfile') + + self.comboentry.set_active(0) + + # read current config: + self.on_UndoChanges_clicked(None) + + self.window = builder.get_object("window") + self.window.connect("destroy", self.on_window_destroy) + self.window.show_all() + + accelgrp = gtk.AccelGroup() + key, mod = gtk.accelerator_parse('Q') + accelgrp.connect_group(key, mod, 0, self.on_window_destroy) + self.window.add_accel_group(accelgrp) + + def write_profiles_to_file(self): + with open(PROFILES, 'w') as f: + for name,left,right in self.profiles: + if name != DEFAULT_PROFILENAME: + f.write("%s\n%s\n%s\n" % (name, left, right)) + + def Notify(self, message): + self.statusbar.pop(self.contextid) + self.statusbar.push(self.contextid, message) + + def on_combo_changed(self, widget, *data): + profileid = self.comboentry.get_active() + self.load.set_sensitive(profileid != -1) + self.save.set_sensitive(profileid != 0 and self.entry.get_text() != '') + + def on_ResetLeft_clicked(self, widget, *data): + self.Notify("Resetting left nub...") + os.system(RESET_CMD_LEFT % 1) + time.sleep(1) + os.system(RESET_CMD_LEFT % 0) + self.Notify("Left nub reset") + + def on_ResetRight_clicked(self, widget, *data): + self.Notify("Resetting right nub...") + os.system(RESET_CMD_RIGHT % 1) + time.sleep(1) + os.system(RESET_CMD_RIGHT % 0) + self.Notify("Right nub reset") + + def on_UndoChanges_clicked(self, widget, *data): + self.leftnub.SetConfig(ReadConfigFromProc(LEFT_NUB_CONFIG)) + self.rightnub.SetConfig(ReadConfigFromProc(RIGHT_NUB_CONFIG)) + self.Notify("Active nub configuration loaded.") + + def on_ApplyChanges_clicked(self, widget, *data): + StoreConfigToProc(LEFT_NUB_CONFIG, self.leftnub.GetConfig()) + StoreConfigToProc(RIGHT_NUB_CONFIG, self.rightnub.GetConfig()) + self.Notify("Nub configuration updated.") + + def on_SaveProfile_clicked(self, widget, *data): + name = self.entry.get_text().replace(' ', '_') + if name == '' or name == DEFAULT_PROFILENAME: + self.Notify("Invalid profile name") + else: + left = ' '.join(self.leftnub.GetConfig()) + right = ' '.join(self.rightnub.GetConfig()) + for profileid, row in enumerate(self.profiles): + if row[0] == name: + row[1] = left + row[2] = right + self.comboentry.set_active(profileid) + break + else: + self.profiles.append([name, left, right]) + self.entry.set_text(name) + self.Notify("Profile saved as: %s" % name) + + def on_LoadProfile_clicked(self, widget, *data): + profileid = self.comboentry.get_active() + if profileid == -1: + self.Notify("Cannot load profile, please select an existing profile.") + else: + name, left, right = self.profiles[profileid] + self.leftnub.SetConfig(left.split(' ')) + self.rightnub.SetConfig(right.split(' ')) + self.Notify("Profile loaded, hit 'Apply configuration' to make it active") + + def on_window_destroy(self, widget, *data): + self.Notify("Storing profiles...") + self.write_profiles_to_file() + gtk.main_quit() + +if __name__ == '__main__': + parser = optparse.OptionParser() + parser.add_option('--reset', default='', + help="Reset specified nub(s). Format: left,right") + parser.add_option('-l', '--left_nub', default='', + help="Configure left nub. Format: %s. E.g. mouse,150,20,20,7,7" % ' '.join(FILES).replace(' ', ',')) + parser.add_option('-r', '--right_nub', default='', + help="Configure right nub. Format: %s. E.g. mbuttons,150,20,20,7,7" % ' '.join(FILES).replace(' ', ',')) + parser.add_option('-s', '--save_profile', default='', + help="Store current configuration as specified profile (no spaces allowed)") + parser.add_option('-p', '--load_profile', default='', + help="Load specified nub configuration profile") + options, args = parser.parse_args() + + app = NubConfig() + if len(sys.argv) == 1: # run gui app + gtk.main() + else: # run command line app + if 'left' in options.reset: + app.on_ResetLeft_clicked(None) + if 'right' in options.reset: + app.on_ResetRight_clicked(None) + ok, values = Validate(options.left_nub) + if ok: + StoreConfigToProc(LEFT_NUB_CONFIG, values) + ok, values = Validate(options.right_nub) + if ok: + StoreConfigToProc(RIGHT_NUB_CONFIG, values) + if options.save_profile: + app.on_UndoChanges_clicked(None) + app.entry.set_text(options.save_profile) + app.on_SaveProfile_clicked(None) + app.write_profiles_to_file() + if options.load_profile: + for profileid, row in enumerate(app.profiles): + if row[0] == options.load_profile: + app.comboentry.set_active(profileid) + app.on_LoadProfile_clicked(None) + app.on_ApplyChanges_clicked(None) diff --git a/recipes/pandora-system/pandora-scripts/pndlogo.png b/recipes/pandora-system/pandora-scripts/pndlogo.png new file mode 100755 index 0000000..4fb50c1 Binary files /dev/null and b/recipes/pandora-system/pandora-scripts/pndlogo.png differ