Change NJInputAnalog so magnitudes of subactions are always positive (e.g. -1 magnitu...
authorJoe Wreschnig <joe.wreschnig@gmail.com>
Wed, 6 Mar 2013 10:44:33 +0000 (11:44 +0100)
committerJoe Wreschnig <joe.wreschnig@gmail.com>
Wed, 6 Mar 2013 10:44:33 +0000 (11:44 +0100)
English.lproj/MainMenu.xib
NJDeviceController.m
NJInput.h
NJInput.m
NJInputAnalog.m
NJInputButton.m
NJInputHat.m
NJOutputController.h
NJOutputController.m
NJOutputMouseMove.h
NJOutputMouseMove.m

index 402d345839306c869d64ca1516210c352d8c2d94..bd4f12a66c93ad6130e097565e6454add83fe691 100644 (file)
@@ -27,6 +27,8 @@
                        <string>NSScroller</string>
                        <string>NSSegmentedCell</string>
                        <string>NSSegmentedControl</string>
+                       <string>NSSlider</string>
+                       <string>NSSliderCell</string>
                        <string>NSSplitView</string>
                        <string>NSTableColumn</string>
                        <string>NSTableView</string>
                                                        <string key="NSToolbarItemPaletteLabel">Enabled</string>
                                                        <nil key="NSToolbarItemToolTip"/>
                                                        <object class="NSButton" key="NSToolbarItemView" id="385218002">
-                                                               <reference key="NSNextResponder"/>
+                                                               <nil key="NSNextResponder"/>
                                                                <int key="NSvFlags">268</int>
                                                                <string key="NSFrame">{{7, 14}, {36, 25}}</string>
-                                                               <reference key="NSSuperview"/>
-                                                               <reference key="NSWindow"/>
-                                                               <reference key="NSNextKeyView"/>
                                                                <string key="NSReuseIdentifierKey">_NS:9</string>
                                                                <bool key="NSEnabled">YES</bool>
                                                                <object class="NSButtonCell" key="NSCell" id="422366518">
                                                        <string key="NSToolbarItemPaletteLabel">Mapping Selector</string>
                                                        <nil key="NSToolbarItemToolTip"/>
                                                        <object class="NSButton" key="NSToolbarItemView" id="227597319">
-                                                               <reference key="NSNextResponder"/>
+                                                               <nil key="NSNextResponder"/>
                                                                <int key="NSvFlags">268</int>
                                                                <string key="NSFrame">{{0, 14}, {140, 25}}</string>
-                                                               <reference key="NSSuperview"/>
-                                                               <reference key="NSWindow"/>
-                                                               <reference key="NSNextKeyView"/>
                                                                <string key="NSReuseIdentifierKey">_NS:9</string>
                                                                <bool key="NSEnabled">YES</bool>
                                                                <object class="NSButtonCell" key="NSCell" id="850080795">
                                                                        <reference key="NSNextResponder" ref="206489479"/>
                                                                        <int key="NSvFlags">256</int>
                                                                        <array class="NSMutableArray" key="NSSubviews">
+                                                                               <object class="NSSlider" id="385416822">
+                                                                                       <reference key="NSNextResponder" ref="606740242"/>
+                                                                                       <int key="NSvFlags">268</int>
+                                                                                       <string key="NSFrame">{{228, 120}, {176, 12}}</string>
+                                                                                       <reference key="NSSuperview" ref="606740242"/>
+                                                                                       <reference key="NSWindow"/>
+                                                                                       <reference key="NSNextKeyView" ref="125828224"/>
+                                                                                       <string key="NSReuseIdentifierKey">_NS:9</string>
+                                                                                       <bool key="NSEnabled">YES</bool>
+                                                                                       <object class="NSSliderCell" key="NSCell" id="5417367">
+                                                                                               <int key="NSCellFlags">-2080374784</int>
+                                                                                               <int key="NSCellFlags2">262144</int>
+                                                                                               <string key="NSContents"/>
+                                                                                               <string key="NSCellIdentifier">_NS:9</string>
+                                                                                               <reference key="NSControlView" ref="385416822"/>
+                                                                                               <double key="NSMaxValue">20</double>
+                                                                                               <double key="NSMinValue">0.0</double>
+                                                                                               <double key="NSValue">4</double>
+                                                                                               <double key="NSAltIncValue">0.0</double>
+                                                                                               <int key="NSNumberOfTickMarks">0</int>
+                                                                                               <int key="NSTickMarkPosition">1</int>
+                                                                                               <bool key="NSAllowsTickMarkValuesOnly">NO</bool>
+                                                                                               <bool key="NSVertical">NO</bool>
+                                                                                       </object>
+                                                                                       <bool key="NSAllowsLogicalLayoutDirection">NO</bool>
+                                                                               </object>
                                                                                <object class="NSSegmentedControl" id="875916470">
                                                                                        <reference key="NSNextResponder" ref="606740242"/>
                                                                                        <int key="NSvFlags">265</int>
-                                                                                       <string key="NSFrame">{{227, 123}, {180, 24}}</string>
+                                                                                       <string key="NSFrame">{{226, 132}, {179, 15}}</string>
                                                                                        <reference key="NSSuperview" ref="606740242"/>
                                                                                        <reference key="NSWindow"/>
-                                                                                       <reference key="NSNextKeyView" ref="125828224"/>
+                                                                                       <reference key="NSNextKeyView" ref="385416822"/>
                                                                                        <string key="NSReuseIdentifierKey">_NS:9</string>
                                                                                        <bool key="NSEnabled">YES</bool>
                                                                                        <object class="NSSegmentedCell" key="NSCell" id="241270212">
                                                                                                <int key="NSCellFlags">67108864</int>
-                                                                                               <int key="NSCellFlags2">0</int>
-                                                                                               <object class="NSFont" key="NSSupport" id="515740949">
+                                                                                               <int key="NSCellFlags2">262144</int>
+                                                                                               <object class="NSFont" key="NSSupport" id="22">
                                                                                                        <string key="NSName">LucidaGrande</string>
-                                                                                                       <double key="NSSize">13</double>
-                                                                                                       <int key="NSfFlags">16</int>
+                                                                                                       <double key="NSSize">9</double>
+                                                                                                       <int key="NSfFlags">3614</int>
                                                                                                </object>
                                                                                                <string key="NSCellIdentifier">_NS:9</string>
                                                                                                <reference key="NSControlView" ref="875916470"/>
                                                                                                <array class="NSMutableArray" key="NSSegmentImages">
                                                                                                        <object class="NSSegmentItem">
-                                                                                                               <double key="NSSegmentItemWidth">87</double>
-                                                                                                               <string key="NSSegmentItemLabel">Horizontal</string>
+                                                                                                               <double key="NSSegmentItemWidth">43</double>
+                                                                                                               <string key="NSSegmentItemLabel"></string>
                                                                                                                <bool key="NSSegmentItemSelected">YES</bool>
                                                                                                                <int key="NSSegmentItemImageScaling">0</int>
                                                                                                        </object>
                                                                                                        <object class="NSSegmentItem">
-                                                                                                               <double key="NSSegmentItemWidth">86</double>
-                                                                                                               <string key="NSSegmentItemLabel">Vertical</string>
+                                                                                                               <double key="NSSegmentItemWidth">43</double>
+                                                                                                               <string key="NSSegmentItemLabel"></string>
                                                                                                                <int key="NSSegmentItemTag">1</int>
                                                                                                                <int key="NSSegmentItemImageScaling">0</int>
                                                                                                        </object>
+                                                                                                       <object class="NSSegmentItem">
+                                                                                                               <double key="NSSegmentItemWidth">42</double>
+                                                                                                               <string key="NSSegmentItemLabel">↑</string>
+                                                                                                               <int key="NSSegmentItemImageScaling">0</int>
+                                                                                                       </object>
+                                                                                                       <object class="NSSegmentItem">
+                                                                                                               <double key="NSSegmentItemWidth">42</double>
+                                                                                                               <string key="NSSegmentItemLabel">↓</string>
+                                                                                                               <int key="NSSegmentItemImageScaling">0</int>
+                                                                                                       </object>
                                                                                                </array>
                                                                                                <int key="NSSegmentStyle">1</int>
                                                                                        </object>
                                                                                <object class="NSSegmentedControl" id="921829691">
                                                                                        <reference key="NSNextResponder" ref="606740242"/>
                                                                                        <int key="NSvFlags">265</int>
-                                                                                       <string key="NSFrame">{{227, 55}, {180, 24}}</string>
+                                                                                       <string key="NSFrame">{{226, 55}, {180, 24}}</string>
                                                                                        <reference key="NSSuperview" ref="606740242"/>
                                                                                        <reference key="NSWindow"/>
                                                                                        <reference key="NSNextKeyView"/>
                                                                                        <object class="NSSegmentedCell" key="NSCell" id="301345285">
                                                                                                <int key="NSCellFlags">67108864</int>
                                                                                                <int key="NSCellFlags2">0</int>
-                                                                                               <reference key="NSSupport" ref="515740949"/>
+                                                                                               <object class="NSFont" key="NSSupport" id="515740949">
+                                                                                                       <string key="NSName">LucidaGrande</string>
+                                                                                                       <double key="NSSize">13</double>
+                                                                                                       <int key="NSfFlags">16</int>
+                                                                                               </object>
                                                                                                <string key="NSCellIdentifier">_NS:9</string>
                                                                                                <reference key="NSControlView" ref="921829691"/>
                                                                                                <array class="NSMutableArray" key="NSSegmentImages">
                                                                                <object class="NSSegmentedControl" id="125828224">
                                                                                        <reference key="NSNextResponder" ref="606740242"/>
                                                                                        <int key="NSvFlags">265</int>
-                                                                                       <string key="NSFrame">{{227, 89}, {180, 24}}</string>
+                                                                                       <string key="NSFrame">{{226, 89}, {180, 24}}</string>
                                                                                        <reference key="NSSuperview" ref="606740242"/>
                                                                                        <reference key="NSWindow"/>
                                                                                        <reference key="NSNextKeyView" ref="921829691"/>
                                                                                <object class="NSCustomView" id="57697638">
                                                                                        <reference key="NSNextResponder" ref="606740242"/>
                                                                                        <int key="NSvFlags">265</int>
-                                                                                       <string key="NSFrame">{{229, 190}, {176, 24}}</string>
+                                                                                       <string key="NSFrame">{{228, 190}, {176, 24}}</string>
                                                                                        <reference key="NSSuperview" ref="606740242"/>
                                                                                        <reference key="NSWindow"/>
                                                                                        <reference key="NSNextKeyView" ref="194275224"/>
                                                                                <object class="NSPopUpButton" id="194275224">
                                                                                        <reference key="NSNextResponder" ref="606740242"/>
                                                                                        <int key="NSvFlags">265</int>
-                                                                                       <string key="NSFrame">{{226, 156}, {182, 26}}</string>
+                                                                                       <string key="NSFrame">{{225, 156}, {182, 26}}</string>
                                                                                        <reference key="NSSuperview" ref="606740242"/>
                                                                                        <reference key="NSWindow"/>
                                                                                        <reference key="NSNextKeyView" ref="875916470"/>
                                                                                <object class="NSMatrix" id="120408205">
                                                                                        <reference key="NSNextResponder" ref="606740242"/>
                                                                                        <int key="NSvFlags">268</int>
-                                                                                       <string key="NSFrame">{{20, 16}, {201, 236}}</string>
+                                                                                       <string key="NSFrame">{{20, 16}, {200, 236}}</string>
                                                                                        <reference key="NSSuperview" ref="606740242"/>
                                                                                        <reference key="NSWindow"/>
                                                                                        <reference key="NSNextKeyView" ref="57697638"/>
                                                                                                        <int key="NSPeriodicInterval">75</int>
                                                                                                </object>
                                                                                        </array>
-                                                                                       <string key="NSCellSize">{201, 32}</string>
+                                                                                       <string key="NSCellSize">{200, 32}</string>
                                                                                        <string key="NSIntercellSpacing">{4, 2}</string>
                                                                                        <int key="NSMatrixFlags">1353195520</int>
                                                                                        <string key="NSCellClass">NSActionCell</string>
                                                        <int key="NSCellFlags">-2080374784</int>
                                                        <int key="NSCellFlags2">168034304</int>
                                                        <string key="NSContents"/>
-                                                       <object class="NSFont" key="NSSupport" id="22">
-                                                               <string key="NSName">LucidaGrande</string>
-                                                               <double key="NSSize">9</double>
-                                                               <int key="NSfFlags">3614</int>
-                                                       </object>
+                                                       <reference key="NSSupport" ref="22"/>
                                                        <string key="NSCellIdentifier">_NS:22</string>
                                                        <reference key="NSControlView" ref="149148392"/>
                                                        <int key="NSButtonFlags">1221349376</int>
                                        </object>
                                        <int key="connectionID">828</int>
                                </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBActionConnection" key="connection">
+                                               <string key="label">mouseSpeedChanged:</string>
+                                               <reference key="source" ref="801536542"/>
+                                               <reference key="destination" ref="385416822"/>
+                                       </object>
+                                       <int key="connectionID">885</int>
+                               </object>
+                               <object class="IBConnectionRecord">
+                                       <object class="IBOutletConnection" key="connection">
+                                               <string key="label">mouseSpeedSlider</string>
+                                               <reference key="source" ref="801536542"/>
+                                               <reference key="destination" ref="385416822"/>
+                                       </object>
+                                       <int key="connectionID">886</int>
+                               </object>
                                <object class="IBConnectionRecord">
                                        <object class="IBOutletConnection" key="connection">
                                                <string key="label">keyDelegate</string>
                                                        <reference ref="1016088174"/>
                                                        <reference ref="194275224"/>
                                                        <reference ref="57697638"/>
+                                                       <reference ref="385416822"/>
                                                </array>
                                                <reference key="parent" ref="206489479"/>
                                                <string key="objectName">Output Editor Pane</string>
                                                <reference key="object" ref="422366518"/>
                                                <reference key="parent" ref="385218002"/>
                                        </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">883</int>
+                                               <reference key="object" ref="385416822"/>
+                                               <array class="NSMutableArray" key="children">
+                                                       <reference ref="5417367"/>
+                                               </array>
+                                               <reference key="parent" ref="606740242"/>
+                                       </object>
+                                       <object class="IBObjectRecord">
+                                               <int key="objectID">884</int>
+                                               <reference key="object" ref="5417367"/>
+                                               <reference key="parent" ref="385416822"/>
+                                       </object>
                                </array>
                        </object>
                        <dictionary class="NSMutableDictionary" key="flattenedProperties">
                                <integer value="0" key="750.IBNSSegmentedControlInspectorSelectedSegmentMetadataKey"/>
                                <string key="750.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="754.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
-                               <integer value="1" key="755.IBNSSegmentedControlInspectorSelectedSegmentMetadataKey"/>
+                               <integer value="0" key="755.IBNSSegmentedControlInspectorSelectedSegmentMetadataKey"/>
                                <string key="755.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="778.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="81.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="872.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="873.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="874.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+                               <object class="NSMutableDictionary" key="883.IBAttributePlaceholdersKey">
+                                       <string key="NS.key.0">ToolTip</string>
+                                       <object class="IBToolTipAttribute" key="NS.object.0">
+                                               <string key="name">ToolTip</string>
+                                               <reference key="object" ref="385416822"/>
+                                               <string key="toolTip">Maximum mouse speed</string>
+                                       </object>
+                               </object>
+                               <string key="883.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
+                               <string key="884.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                                <string key="92.IBPluginDependency">com.apple.InterfaceBuilder.CocoaPlugin</string>
                        </dictionary>
                        <dictionary class="NSMutableDictionary" key="unlocalizedProperties"/>
                        <nil key="activeLocalization"/>
                        <dictionary class="NSMutableDictionary" key="localizations"/>
                        <nil key="sourceID"/>
-                       <int key="maxID">880</int>
+                       <int key="maxID">886</int>
                </object>
                <object class="IBClassDescriber" key="IBDocument.Classes">
                        <array class="NSMutableArray" key="referencedPartialClassDescriptions">
                                        <dictionary class="NSMutableDictionary" key="actions">
                                                <string key="mbtnChanged:">id</string>
                                                <string key="mdirChanged:">id</string>
+                                               <string key="mouseSpeedChanged:">id</string>
                                                <string key="radioChanged:">id</string>
                                                <string key="sdirChanged:">id</string>
                                        </dictionary>
                                                        <string key="name">mdirChanged:</string>
                                                        <string key="candidateClassName">id</string>
                                                </object>
+                                               <object class="IBActionInfo" key="mouseSpeedChanged:">
+                                                       <string key="name">mouseSpeedChanged:</string>
+                                                       <string key="candidateClassName">id</string>
+                                               </object>
                                                <object class="IBActionInfo" key="radioChanged:">
                                                        <string key="name">radioChanged:</string>
                                                        <string key="candidateClassName">id</string>
                                                <string key="mappingsController">NJMappingsController</string>
                                                <string key="mouseBtnSelect">NSSegmentedControl</string>
                                                <string key="mouseDirSelect">NSSegmentedControl</string>
+                                               <string key="mouseSpeedSlider">NSSlider</string>
                                                <string key="radioButtons">NSMatrix</string>
                                                <string key="scrollDirSelect">NSSegmentedControl</string>
                                                <string key="title">NSTextField</string>
                                                        <string key="name">mouseDirSelect</string>
                                                        <string key="candidateClassName">NSSegmentedControl</string>
                                                </object>
+                                               <object class="IBToOneOutletInfo" key="mouseSpeedSlider">
+                                                       <string key="name">mouseSpeedSlider</string>
+                                                       <string key="candidateClassName">NSSlider</string>
+                                               </object>
                                                <object class="IBToOneOutletInfo" key="radioButtons">
                                                        <string key="name">radioButtons</string>
                                                        <string key="candidateClassName">NSMatrix</string>
index 79938423c772fd72f1badea9dd64280f3d05664e..d553d7de3330c1eecfa503aa040a439e23ddf037 100644 (file)
@@ -64,9 +64,9 @@
     NSArray *children = mainInput.children ? mainInput.children : mainInput ? @[mainInput] : @[];
     for (NJInput *subInput in children) {
         NJOutput *output = mappingsController.currentMapping[subInput];
-        output.magnitude = mainInput.magnitude;
+        output.magnitude = subInput.magnitude;
         output.running = subInput.active;
-        if (output.running && output.isContinuous)
+        if ((output.running || output.magnitude) && output.isContinuous)
             [self addRunningOutput:output];
     }
 }
index e2c8404248fbb04383fc4194333872a29350ddab..380e85858ad4a67cb182d75afecb119c9e2e4a25 100644 (file)
--- a/NJInput.h
+++ b/NJInput.h
@@ -15,7 +15,7 @@
 @property (nonatomic, weak) id base;
 @property (nonatomic, copy) NSString *name;
 @property (nonatomic, assign) BOOL active;
-@property (nonatomic, readonly) float magnitude;
+@property (nonatomic, assign) float magnitude;
 @property (readonly) NSString *uid;
 
 - (id)initWithName:(NSString *)newName base:(id <NJInputPathElement>)newBase;
index cccda295603b3c6d8f1ef843bfc5cf2af8e593aa..077dac86158748c377fa8181e8b0886661ebc301 100644 (file)
--- a/NJInput.m
+++ b/NJInput.m
@@ -29,8 +29,4 @@
     [self doesNotRecognizeSelector:_cmd];
 }
 
-- (float)magnitude {
-    return 0.f;
-}
-
 @end
index 98ed0187c68d55eb4ac344c8f1a0fefe3cc142ca..7b4b15a831c4d0fcfde586972e79560ceb5e93c7 100644 (file)
@@ -42,6 +42,8 @@ static float normalize(long p, long min, long max) {
 
 - (void)notifyEvent:(IOHIDValueRef)value {
     magnitude = normalize(IOHIDValueGetIntegerValue(value), rawMin, rawMax);
+    [self.children[0] setMagnitude:fabsf(MIN(magnitude, 0))];
+    [self.children[1] setMagnitude:fabsf(MAX(magnitude, 0))];
     [self.children[0] setActive:magnitude < -DEAD_ZONE];
     [self.children[1] setActive:magnitude > DEAD_ZONE];
 }
index c5002768a34c4da81f1d02073d7328a72745d23b..0c3b0ce32de0105413d0d1c4e68c86be853e62b7 100644 (file)
@@ -28,6 +28,7 @@
 
 - (void)notifyEvent:(IOHIDValueRef)value {
     self.active = IOHIDValueGetIntegerValue(value) == _max;
+    self.magnitude = IOHIDValueGetIntegerValue(value) / (float)_max;
 }
 
 @end
index b7d01610a4606c80de663c70f51ff77dbd992838..409ae0778832d4d12c4d3931f5fad7614aacf3ff 100644 (file)
@@ -89,8 +89,11 @@ static BOOL active_fourway[20] = {
         size++;
     }
     BOOL *activechildren = (size == 8) ? active_eightway : active_fourway;
-    for (int i = 0; i < 4; i++)
-        [self.children[i] setActive:activechildren[parsed * 4 + i]];
+    for (int i = 0; i < 4; i++) {
+        BOOL active = activechildren[parsed * 4 + i];
+        [self.children[i] setActive:active];
+        [self.children[i] setMagnitude:active];
+    }
 }
 
 @end
index 0c6a8594fde054b1e5e70de35608a47b3685577b..de8b4171fe687338a4ecc04e992d217e1f242643 100644 (file)
@@ -17,6 +17,7 @@
     IBOutlet NJKeyInputField *keyInput;
     IBOutlet NSMatrix *radioButtons;
     IBOutlet NSSegmentedControl *mouseDirSelect;
+    IBOutlet NSSlider *mouseSpeedSlider;
     IBOutlet NSSegmentedControl *mouseBtnSelect;
     IBOutlet NSSegmentedControl *scrollDirSelect;
     IBOutlet NSTextField *title;
@@ -32,6 +33,8 @@
 - (IBAction)mdirChanged:(id)sender;
 - (IBAction)mbtnChanged:(id)sender;
 - (IBAction)sdirChanged:(id)sender;
+- (IBAction)mouseSpeedChanged:(id)sender;
+
 - (void)focusKey;
 
 @end
index 0c301ff6811f9e407101ef89a2296ed6b6973d1a..e60a83e742fda18539db22973520302cff303aae 100644 (file)
     
     if (row != 3) {
         mouseDirSelect.selectedSegment = -1;
+        mouseSpeedSlider.floatValue = mouseSpeedSlider.minValue;
         [mouseDirSelect resignIfFirstResponder];
-    } else if (mouseDirSelect.selectedSegment == -1)
-        mouseDirSelect.selectedSegment = 0;
+    } else {
+        if (mouseDirSelect.selectedSegment == -1)
+            mouseDirSelect.selectedSegment = 0;
+        if (!mouseSpeedSlider.floatValue)
+            mouseSpeedSlider.floatValue = 4;
+    }
     
     if (row != 4) {
         mouseBtnSelect.selectedSegment = -1;
     [self commit];
 }
 
+- (void)mouseSpeedChanged:(NSSlider *)sender {
+    [radioButtons selectCellAtRow:3 column:0];
+    [sender.window makeFirstResponder:sender];
+    [self commit];
+}
+
 - (void)mbtnChanged:(NSView *)sender {
     [radioButtons selectCellAtRow:4 column:0];
     [sender.window makeFirstResponder:sender];
         case 3: {
             NJOutputMouseMove *mm = [[NJOutputMouseMove alloc] init];
             mm.axis = mouseDirSelect.selectedSegment;
+            mm.speed = mouseSpeedSlider.floatValue;
             return mm;
         }
         case 4: {
     [keyInput setEnabled:enabled];
     [mappingPopup setEnabled:enabled];
     [mouseDirSelect setEnabled:enabled];
+    [mouseSpeedSlider setEnabled:enabled];
     [mouseBtnSelect setEnabled:enabled];
     [scrollDirSelect setEnabled:enabled];
 }
     }
     else if ([output isKindOfClass:NJOutputMouseMove.class]) {
         [radioButtons selectCellAtRow:3 column:0];
-        [mouseDirSelect setSelectedSegment:[(NJOutputMouseMove *)output axis]];
+        mouseDirSelect.selectedSegment = [(NJOutputMouseMove *)output axis];
+        mouseSpeedSlider.floatValue = [(NJOutputMouseMove *)output speed];
     }
     else if ([output isKindOfClass:NJOutputMouseButton.class]) {
         [radioButtons selectCellAtRow:4 column:0];
index 21db41620f7b7054b310e4e88e06cd544cefc00a..428416fa541f5b617b87414eabfaa969d3ee3e6d 100644 (file)
@@ -10,5 +10,6 @@
 @interface NJOutputMouseMove : NJOutput
 
 @property (nonatomic, assign) int axis;
+@property (nonatomic, assign) float speed;
 
 @end
index 8efb8cb29c174c1708b5b55762e81c0bd9dd3f87..bca5d2d042221ece61ede692a11250403fbe295b 100644 (file)
@@ -9,9 +9,7 @@
 
 #import "NJDeviceController.h"
 
-@implementation NJOutputMouseMove {
-    int sign;
-}
+@implementation NJOutputMouseMove
 
 -(BOOL) isContinuous {
     return YES;
 }
 
 - (NSDictionary *)serialize {
-    return @{ @"type": self.class.serializationCode, @"axis": @(_axis) };
+    return @{ @"type": self.class.serializationCode,
+              @"axis": @(_axis),
+              @"speed": @(_speed),
+              };
 }
 
 + (NJOutput *)outputDeserialize:(NSDictionary *)serialization
                   withMappings:(NSArray *)mappings {
        NJOutputMouseMove *output = [[NJOutputMouseMove alloc] init];
     output.axis = [serialization[@"axis"] intValue];
+    output.speed = [serialization[@"speed"] floatValue];
+    if (!output.speed)
+        output.speed = 4;
        return output;
 }
 
 - (BOOL)update:(NJDeviceController *)jc {
-    if (fabsf(self.magnitude) < 0.01) {
-        sign = 0;
+    if (self.magnitude < 0.05)
         return NO; // dead zone
-    }
-
-    // If the input crossed over High/Low, this output is done.
-    if (!sign)
-        sign = self.magnitude < 0 ? -1 : 1;
-    else if (sign / self.magnitude < 0) {
-        sign = 0;
-        return NO;
-    }
     
     CGFloat height = NSScreen.mainScreen.frame.size.height;
     
-    // TODO
-    float speed = 4.f;
-    if (jc.frontWindowOnly)
-        speed = 12.f;
     float dx = 0.f, dy = 0.f;
-    if (_axis == 0)
-        dx = self.magnitude * speed;
-    else
-        dy = self.magnitude * speed;
+    switch (_axis) {
+        case 0:
+            dx = -self.magnitude * _speed;
+            break;
+        case 1:
+            dx = self.magnitude * _speed;
+            break;
+        case 2:
+            dy = -self.magnitude * _speed;
+            break;
+        case 3:
+            dy = self.magnitude * _speed;
+            break;
+    }
     NSPoint mouseLoc = jc.mouseLoc;
     mouseLoc.x += dx;
     mouseLoc.y -= dy;