Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2012-04-16 Thread Frederick Grose
On Mon, Apr 16, 2012 at 4:06 PM, Daniel Drake  wrote:

> On Mon, Apr 16, 2012 at 1:48 PM, Simon Schampijer 
> wrote:
> > This patch is needed now for latest kernel on the XO-1. Tested on the
> latest
> > 12.1.0 builds.
>
> OK, pushed with the changes noted earlier in the thread.
> Happy to act on the rest of Sascha's feeback if it solidifies.
>
> cheers
> Daniel


There is also a Sugar themed icon, which Benzea has approved, available for
this.
https://bugs.sugarlabs.org/ticket/2950

   --Fred
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2012-04-16 Thread Daniel Drake
On Mon, Apr 16, 2012 at 1:48 PM, Simon Schampijer  wrote:
> This patch is needed now for latest kernel on the XO-1. Tested on the latest
> 12.1.0 builds.

OK, pushed with the changes noted earlier in the thread.
Happy to act on the rest of Sascha's feeback if it solidifies.

cheers
Daniel
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2012-04-16 Thread Simon Schampijer

On 11/25/2011 09:10 PM, Daniel Drake wrote:

The HGPK pentablet selection code has gone upstream, but with a
different interface from the version included in previous OLPC kernels.
The interface is now:

echo -n pentablet>  hgpk_mode

Port the touchpad icon to this new API.
Compatibility with the old non-upstream API has been dropped; I don't
anticipate users running this new sugar with an old kernel.

This fixes touchpad mode selection on kernels newer than 2.6.35.
---
  extensions/deviceicon/touchpad.py |   49 ++---
  1 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/extensions/deviceicon/touchpad.py 
b/extensions/deviceicon/touchpad.py
index 6773afc..d6b4b37 100644
--- a/extensions/deviceicon/touchpad.py
+++ b/extensions/deviceicon/touchpad.py
@@ -31,19 +31,15 @@ from sugar.graphics import style

  from jarabe.frame.frameinvoker import FrameWidgetInvoker

-TOUCHPAD_MODE_CAPACITIVE = 'capacitive'
-TOUCHPAD_MODE_RESISTIVE = 'resistive'
-TOUCHPAD_MODES = [TOUCHPAD_MODE_CAPACITIVE, TOUCHPAD_MODE_RESISTIVE]
-STATUS_TEXT = {
-TOUCHPAD_MODE_CAPACITIVE: _('finger'),
-TOUCHPAD_MODE_RESISTIVE: _('stylus'),
-}
-STATUS_ICON = {
-TOUCHPAD_MODE_CAPACITIVE: 'touchpad-' + TOUCHPAD_MODE_CAPACITIVE,
-TOUCHPAD_MODE_RESISTIVE: 'touchpad-' + TOUCHPAD_MODE_RESISTIVE,
-}
+TOUCHPAD_MODE_MOUSE = 'mouse'
+TOUCHPAD_MODE_PENTABLET = 'pentablet'
+
+TOUCHPAD_MODES = (TOUCHPAD_MODE_MOUSE, TOUCHPAD_MODE_PENTABLET)
+STATUS_TEXT = (_('finger'), _('stylus'))
+STATUS_ICON = ('touchpad-capacitive', 'touchpad-resistive')
+
  # NODE_PATH is used to communicate with the touchpad device.
-NODE_PATH = '/sys/devices/platform/i8042/serio1/ptmode'
+NODE_PATH = '/sys/devices/platform/i8042/serio1/hgpk_mode'


  class DeviceView(TrayIcon):
@@ -105,7 +101,7 @@ class ResourcePalette(Palette):

  def toggle_mode(self):
  """ Toggle the touchpad mode. """
-self._mode = TOUCHPAD_MODES[1 - TOUCHPAD_MODES.index(self._mode)]
+self._mode = 1 - self._mode
  _write_touchpad_mode(self._mode)
  self._update()

@@ -115,24 +111,37 @@ def setup(tray):
  Frame. """
  if os.path.exists(NODE_PATH):
  tray.add_device(DeviceView())
-_write_touchpad_mode(TOUCHPAD_MODE_CAPACITIVE)
+_write_touchpad_mode_str(TOUCHPAD_MODE_MOUSE)


-def _read_touchpad_mode():
-""" Read the touchpad mode from the node path. """
+def _read_touchpad_mode_str():
+""" Read the touchpad mode string from the node path. """
  node_file_handle = open(NODE_PATH, 'r')
-text = node_file_handle.read()
+text = node_file_handle.read().strip().lower()
  node_file_handle.close()
+return text
+

-return TOUCHPAD_MODES[int(text[0])]
+def _read_touchpad_mode():
+""" Read the touchpad mode and return the mode indice. """
+mode_str = _read_touchpad_mode_str()
+if not mode_str in TOUCHPAD_MODES:
+return None
+return TOUCHPAD_MODES.index(mode_str)


-def _write_touchpad_mode(touchpad):
+def _write_touchpad_mode_str(mode_str):
  """ Write the touchpad mode to the node path. """
  try:
  node_file_handle = open(NODE_PATH, 'w')
  except IOError, e:
  logging.error('Error opening %s for writing: %s', NODE_PATH, e)
  return
-node_file_handle.write(str(TOUCHPAD_MODES.index(touchpad)))
+node_file_handle.write(mode_str)
  node_file_handle.close()
+
+
+def _write_touchpad_mode(mode_num):
+""" Look up the mode (by indice) and write to node path. """
+return _write_touchpad_mode_str(TOUCHPAD_MODES[mode_num])
+


This patch is needed now for latest kernel on the XO-1. Tested on the 
latest 12.1.0 builds.


Please push,
   Simon
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2011-12-09 Thread Frederick Grose
On Fri, Dec 9, 2011 at 6:23 PM, Daniel Drake  wrote:

> On Mon, Nov 28, 2011 at 7:51 AM, Sascha Silbe 
> wrote:
> >> Port the touchpad icon to this new API.
> >
> > You're doing more than this. The additional changes are fine, but should
> > be mentioned.
>
> I've checked again and I don't see any changes in the patch other than
> porting the touchpad icon to the new kernel interface.
>
> >> Compatibility with the old non-upstream API has been dropped; I don't
> >> anticipate users running this new sugar with an old kernel.
> >
> > FWIW, I'm still running a 2.6.35 kernel on my XO-1 (but Sugar from
> > sugar-jhbuild, i.e. mainline/master). Not sure if anyone who cares about
> > this Frame device icon does, though.
>
> For simplicity I think we should go ahead and merge this despite
> breaking uncommon use cases.
>
> > [extensions/deviceicon/touchpad.py]
> >> @@ -31,19 +31,15 @@ from sugar.graphics import style
> >>
> >>  from jarabe.frame.frameinvoker import FrameWidgetInvoker
> >>
> >> -TOUCHPAD_MODE_CAPACITIVE = 'capacitive'
> >> -TOUCHPAD_MODE_RESISTIVE = 'resistive'
> >> -TOUCHPAD_MODES = [TOUCHPAD_MODE_CAPACITIVE, TOUCHPAD_MODE_RESISTIVE]
> >> -STATUS_TEXT = {
> >> -TOUCHPAD_MODE_CAPACITIVE: _('finger'),
> >> -TOUCHPAD_MODE_RESISTIVE: _('stylus'),
> >> -}
> >> -STATUS_ICON = {
> >> -TOUCHPAD_MODE_CAPACITIVE: 'touchpad-' + TOUCHPAD_MODE_CAPACITIVE,
> >> -TOUCHPAD_MODE_RESISTIVE: 'touchpad-' + TOUCHPAD_MODE_RESISTIVE,
> >> -}
> >
> >> +TOUCHPAD_MODE_MOUSE = 'mouse'
> >> +TOUCHPAD_MODE_PENTABLET = 'pentablet'
> >
> > Do we need these as individual constants? I don't see them used anywhere
> > except when defining TOUCHPAD_MODES and since we seem to change the name
> > of the constants any time the content changes, I see no reason to use
> > them at all. Especially since we don't do the same for STATUS_TEXT and
> > STATUS_ICON:
>
> The constants are used elsewhere - take another look. It also follows
> the earlier design which had e.g. TOUCHPAD_MODE_CAPACITIVE. Does that
> change your opinion?
>
> > Typo: s/indice/index/
> > I find "if a not in b" easier to read than "if not a in b"; YMMV.
>
> If  these are the only real issues that you have identified then I
> would be happy to fix them up at commit time.
>
> Daniel
>

There is also a Sugar themed icon available for this.
https://bugs.sugarlabs.org/ticket/2950

 --Fred
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2011-12-09 Thread Daniel Drake
On Mon, Nov 28, 2011 at 7:51 AM, Sascha Silbe  wrote:
>> Port the touchpad icon to this new API.
>
> You're doing more than this. The additional changes are fine, but should
> be mentioned.

I've checked again and I don't see any changes in the patch other than
porting the touchpad icon to the new kernel interface.

>> Compatibility with the old non-upstream API has been dropped; I don't
>> anticipate users running this new sugar with an old kernel.
>
> FWIW, I'm still running a 2.6.35 kernel on my XO-1 (but Sugar from
> sugar-jhbuild, i.e. mainline/master). Not sure if anyone who cares about
> this Frame device icon does, though.

For simplicity I think we should go ahead and merge this despite
breaking uncommon use cases.

> [extensions/deviceicon/touchpad.py]
>> @@ -31,19 +31,15 @@ from sugar.graphics import style
>>
>>  from jarabe.frame.frameinvoker import FrameWidgetInvoker
>>
>> -TOUCHPAD_MODE_CAPACITIVE = 'capacitive'
>> -TOUCHPAD_MODE_RESISTIVE = 'resistive'
>> -TOUCHPAD_MODES = [TOUCHPAD_MODE_CAPACITIVE, TOUCHPAD_MODE_RESISTIVE]
>> -STATUS_TEXT = {
>> -    TOUCHPAD_MODE_CAPACITIVE: _('finger'),
>> -    TOUCHPAD_MODE_RESISTIVE: _('stylus'),
>> -}
>> -STATUS_ICON = {
>> -    TOUCHPAD_MODE_CAPACITIVE: 'touchpad-' + TOUCHPAD_MODE_CAPACITIVE,
>> -    TOUCHPAD_MODE_RESISTIVE: 'touchpad-' + TOUCHPAD_MODE_RESISTIVE,
>> -}
>
>> +TOUCHPAD_MODE_MOUSE = 'mouse'
>> +TOUCHPAD_MODE_PENTABLET = 'pentablet'
>
> Do we need these as individual constants? I don't see them used anywhere
> except when defining TOUCHPAD_MODES and since we seem to change the name
> of the constants any time the content changes, I see no reason to use
> them at all. Especially since we don't do the same for STATUS_TEXT and
> STATUS_ICON:

The constants are used elsewhere - take another look. It also follows
the earlier design which had e.g. TOUCHPAD_MODE_CAPACITIVE. Does that
change your opinion?

> Typo: s/indice/index/
> I find "if a not in b" easier to read than "if not a in b"; YMMV.

If  these are the only real issues that you have identified then I
would be happy to fix them up at commit time.

Daniel
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


Re: [Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2011-11-28 Thread Sascha Silbe
Excerpts from Daniel Drake's message of 2011-11-25 21:10:04 +0100:

> The HGPK pentablet selection code has gone upstream, but with a
> different interface from the version included in previous OLPC kernels.
> The interface is now:
> 
> echo -n pentablet > hgpk_mode
> 
> Port the touchpad icon to this new API.

You're doing more than this. The additional changes are fine, but should
be mentioned.

> Compatibility with the old non-upstream API has been dropped; I don't
> anticipate users running this new sugar with an old kernel.

FWIW, I'm still running a 2.6.35 kernel on my XO-1 (but Sugar from
sugar-jhbuild, i.e. mainline/master). Not sure if anyone who cares about
this Frame device icon does, though.


[extensions/deviceicon/touchpad.py]
> @@ -31,19 +31,15 @@ from sugar.graphics import style
>  
>  from jarabe.frame.frameinvoker import FrameWidgetInvoker
>  
> -TOUCHPAD_MODE_CAPACITIVE = 'capacitive'
> -TOUCHPAD_MODE_RESISTIVE = 'resistive'
> -TOUCHPAD_MODES = [TOUCHPAD_MODE_CAPACITIVE, TOUCHPAD_MODE_RESISTIVE]
> -STATUS_TEXT = {
> -TOUCHPAD_MODE_CAPACITIVE: _('finger'),
> -TOUCHPAD_MODE_RESISTIVE: _('stylus'),
> -}
> -STATUS_ICON = {
> -TOUCHPAD_MODE_CAPACITIVE: 'touchpad-' + TOUCHPAD_MODE_CAPACITIVE,
> -TOUCHPAD_MODE_RESISTIVE: 'touchpad-' + TOUCHPAD_MODE_RESISTIVE,
> -}

> +TOUCHPAD_MODE_MOUSE = 'mouse'
> +TOUCHPAD_MODE_PENTABLET = 'pentablet'

Do we need these as individual constants? I don't see them used anywhere
except when defining TOUCHPAD_MODES and since we seem to change the name
of the constants any time the content changes, I see no reason to use
them at all. Especially since we don't do the same for STATUS_TEXT and
STATUS_ICON:


> +TOUCHPAD_MODES = (TOUCHPAD_MODE_MOUSE, TOUCHPAD_MODE_PENTABLET)
> +STATUS_TEXT = (_('finger'), _('stylus'))
> +STATUS_ICON = ('touchpad-capacitive', 'touchpad-resistive')


[...]
> +def _read_touchpad_mode():
> +""" Read the touchpad mode and return the mode indice. """

Typo: s/indice/index/


> +mode_str = _read_touchpad_mode_str()
> +if not mode_str in TOUCHPAD_MODES:
> +return None
> +return TOUCHPAD_MODES.index(mode_str)

I find "if a not in b" easier to read than "if not a in b"; YMMV.


[...]
> +def _write_touchpad_mode(mode_num):
> +""" Look up the mode (by indice) and write to node path. """

See above (indice).

Sascha

-- 
http://sascha.silbe.org/
http://www.infra-silbe.de/


signature.asc
Description: PGP signature
___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel


[Sugar-devel] [PATCH] Touchpad icon: update for upstream kernel API

2011-11-25 Thread Daniel Drake
The HGPK pentablet selection code has gone upstream, but with a
different interface from the version included in previous OLPC kernels.
The interface is now:

echo -n pentablet > hgpk_mode

Port the touchpad icon to this new API.
Compatibility with the old non-upstream API has been dropped; I don't
anticipate users running this new sugar with an old kernel.

This fixes touchpad mode selection on kernels newer than 2.6.35.
---
 extensions/deviceicon/touchpad.py |   49 ++---
 1 files changed, 29 insertions(+), 20 deletions(-)

diff --git a/extensions/deviceicon/touchpad.py 
b/extensions/deviceicon/touchpad.py
index 6773afc..d6b4b37 100644
--- a/extensions/deviceicon/touchpad.py
+++ b/extensions/deviceicon/touchpad.py
@@ -31,19 +31,15 @@ from sugar.graphics import style
 
 from jarabe.frame.frameinvoker import FrameWidgetInvoker
 
-TOUCHPAD_MODE_CAPACITIVE = 'capacitive'
-TOUCHPAD_MODE_RESISTIVE = 'resistive'
-TOUCHPAD_MODES = [TOUCHPAD_MODE_CAPACITIVE, TOUCHPAD_MODE_RESISTIVE]
-STATUS_TEXT = {
-TOUCHPAD_MODE_CAPACITIVE: _('finger'),
-TOUCHPAD_MODE_RESISTIVE: _('stylus'),
-}
-STATUS_ICON = {
-TOUCHPAD_MODE_CAPACITIVE: 'touchpad-' + TOUCHPAD_MODE_CAPACITIVE,
-TOUCHPAD_MODE_RESISTIVE: 'touchpad-' + TOUCHPAD_MODE_RESISTIVE,
-}
+TOUCHPAD_MODE_MOUSE = 'mouse'
+TOUCHPAD_MODE_PENTABLET = 'pentablet'
+
+TOUCHPAD_MODES = (TOUCHPAD_MODE_MOUSE, TOUCHPAD_MODE_PENTABLET)
+STATUS_TEXT = (_('finger'), _('stylus'))
+STATUS_ICON = ('touchpad-capacitive', 'touchpad-resistive')
+
 # NODE_PATH is used to communicate with the touchpad device.
-NODE_PATH = '/sys/devices/platform/i8042/serio1/ptmode'
+NODE_PATH = '/sys/devices/platform/i8042/serio1/hgpk_mode'
 
 
 class DeviceView(TrayIcon):
@@ -105,7 +101,7 @@ class ResourcePalette(Palette):
 
 def toggle_mode(self):
 """ Toggle the touchpad mode. """
-self._mode = TOUCHPAD_MODES[1 - TOUCHPAD_MODES.index(self._mode)]
+self._mode = 1 - self._mode
 _write_touchpad_mode(self._mode)
 self._update()
 
@@ -115,24 +111,37 @@ def setup(tray):
 Frame. """
 if os.path.exists(NODE_PATH):
 tray.add_device(DeviceView())
-_write_touchpad_mode(TOUCHPAD_MODE_CAPACITIVE)
+_write_touchpad_mode_str(TOUCHPAD_MODE_MOUSE)
 
 
-def _read_touchpad_mode():
-""" Read the touchpad mode from the node path. """
+def _read_touchpad_mode_str():
+""" Read the touchpad mode string from the node path. """
 node_file_handle = open(NODE_PATH, 'r')
-text = node_file_handle.read()
+text = node_file_handle.read().strip().lower()
 node_file_handle.close()
+return text
+
 
-return TOUCHPAD_MODES[int(text[0])]
+def _read_touchpad_mode():
+""" Read the touchpad mode and return the mode indice. """
+mode_str = _read_touchpad_mode_str()
+if not mode_str in TOUCHPAD_MODES:
+return None
+return TOUCHPAD_MODES.index(mode_str)
 
 
-def _write_touchpad_mode(touchpad):
+def _write_touchpad_mode_str(mode_str):
 """ Write the touchpad mode to the node path. """
 try:
 node_file_handle = open(NODE_PATH, 'w')
 except IOError, e:
 logging.error('Error opening %s for writing: %s', NODE_PATH, e)
 return
-node_file_handle.write(str(TOUCHPAD_MODES.index(touchpad)))
+node_file_handle.write(mode_str)
 node_file_handle.close()
+
+
+def _write_touchpad_mode(mode_num):
+""" Look up the mode (by indice) and write to node path. """
+return _write_touchpad_mode_str(TOUCHPAD_MODES[mode_num])
+
-- 
1.7.7.3

___
Sugar-devel mailing list
Sugar-devel@lists.sugarlabs.org
http://lists.sugarlabs.org/listinfo/sugar-devel