[mousetrap/gnome3-wip: 131/240] Extract nose_joystick configuration.



commit 88c2951a77c602c4531eee92dbe56000063d8515
Author: Stoney Jackson <dr stoney gmail com>
Date:   Mon Jun 23 15:37:52 2014 -0400

    Extract nose_joystick configuration.

 src/mousetrap/config.py                |    3 +++
 src/mousetrap/plugins/nose_joystick.py |    6 +++---
 2 files changed, 6 insertions(+), 3 deletions(-)
---
diff --git a/src/mousetrap/config.py b/src/mousetrap/config.py
index 25e0fcf..261da4a 100644
--- a/src/mousetrap/config.py
+++ b/src/mousetrap/config.py
@@ -76,6 +76,9 @@ class Config(dict):
                     'min_neighbors': 10,
                     },
                 },
+            'mousetrap.plugins.nose_joystick.NoseJoystickPlugin': {
+                'threshold': 5,
+                },
             }
 
 
diff --git a/src/mousetrap/plugins/nose_joystick.py b/src/mousetrap/plugins/nose_joystick.py
index 5f3cc20..f2eec7c 100644
--- a/src/mousetrap/plugins/nose_joystick.py
+++ b/src/mousetrap/plugins/nose_joystick.py
@@ -4,10 +4,10 @@ from mousetrap.plugins.nose import NoseLocator
 
 
 class NoseJoystickPlugin(interface.Plugin):
-    THRESHOLD = 5
 
     def __init__(self, config):
         self._config = config
+        self._threshold = config[self]['threshold']
         self._nose_locator = NoseLocator(config)
         self._initial_image_location = (0, 0)
         self._last_delta = (0, 0)
@@ -47,10 +47,10 @@ class NoseJoystickPlugin(interface.Plugin):
         delta_x = initial_x - image_x
         delta_y = image_y - initial_y
 
-        if abs(delta_x) < self.THRESHOLD:
+        if abs(delta_x) < self._threshold:
             delta_x = 0
 
-        if abs(delta_y) < self.THRESHOLD:
+        if abs(delta_y) < self._threshold:
             delta_y = 0
 
         delta = (delta_x, delta_y)


[Date Prev][Date Next]   [Thread Prev][Thread Next]   [Thread Index] [Date Index] [Author Index]