Browse Source

Only use one button in GUI

Thomas Buck 9 years ago
parent
commit
138a52c015

+ 0
- 4
README.md View File

16
 
16
 
17
 ![Screenshot](https://i.imgur.com/x0hnWq5.png)
17
 ![Screenshot](https://i.imgur.com/x0hnWq5.png)
18
 
18
 
19
-First, press `Connect` to establish a connection to your Transmitter. As soon as it is working the current stick positions will be visualized. Then, press `Create` to create a virtual HID Gamepad.
20
-
21
-As long as both have been initialized, you can use your Transmitter in your Simulator. The connection will be closed and the virtual device destroyed automatically when you close the App window.
22
-
23
 ## foohid command-line app
19
 ## foohid command-line app
24
 
20
 
25
 This small utility does the same thing as the SerialGamepad.app without a graphical user interface.
21
 This small utility does the same thing as the SerialGamepad.app without a graphical user interface.

BIN
SerialGamepad.xcodeproj/project.xcworkspace/xcuserdata/thomas.xcuserdatad/UserInterfaceState.xcuserstate View File


+ 2
- 13
SerialGamepad/Base.lproj/MainMenu.xib View File

1
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
1
 <?xml version="1.0" encoding="UTF-8" standalone="no"?>
2
-<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="14F1505" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
2
+<document type="com.apple.InterfaceBuilder3.Cocoa.XIB" version="3.0" toolsVersion="9531" systemVersion="14F1509" targetRuntime="MacOSX.Cocoa" propertyAccessControl="none" useAutolayout="YES" customObjectInstantitationMethod="direct">
3
     <dependencies>
3
     <dependencies>
4
         <deployment identifier="macosx"/>
4
         <deployment identifier="macosx"/>
5
         <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
5
         <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
677
                 <autoresizingMask key="autoresizingMask"/>
677
                 <autoresizingMask key="autoresizingMask"/>
678
                 <subviews>
678
                 <subviews>
679
                     <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fCd-m1-NwV">
679
                     <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="fCd-m1-NwV">
680
-                        <rect key="frame" x="14" y="169" width="152" height="32"/>
680
+                        <rect key="frame" x="14" y="169" width="302" height="32"/>
681
                         <buttonCell key="cell" type="push" title="Connect" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="adp-gD-EEf">
681
                         <buttonCell key="cell" type="push" title="Connect" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="adp-gD-EEf">
682
                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
682
                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
683
                             <font key="font" metaFont="system"/>
683
                             <font key="font" metaFont="system"/>
686
                             <action selector="connectButtonPressed:" target="QvC-M9-y7g" id="3UW-Gk-OUp"/>
686
                             <action selector="connectButtonPressed:" target="QvC-M9-y7g" id="3UW-Gk-OUp"/>
687
                         </connections>
687
                         </connections>
688
                     </button>
688
                     </button>
689
-                    <button verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="v8W-R7-l4G">
690
-                        <rect key="frame" x="164" y="169" width="152" height="32"/>
691
-                        <buttonCell key="cell" type="push" title="Create" bezelStyle="rounded" alignment="center" enabled="NO" borderStyle="border" imageScaling="proportionallyDown" inset="2" id="EEe-0L-Dx7">
692
-                            <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
693
-                            <font key="font" metaFont="system"/>
694
-                        </buttonCell>
695
-                        <connections>
696
-                            <action selector="createButtonPressed:" target="QvC-M9-y7g" id="Iff-L2-DFe"/>
697
-                        </connections>
698
-                    </button>
699
                     <levelIndicator verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Bo5-fb-a0u">
689
                     <levelIndicator verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Bo5-fb-a0u">
700
                         <rect key="frame" x="20" y="140" width="290" height="16"/>
690
                         <rect key="frame" x="20" y="140" width="290" height="16"/>
701
                         <levelIndicatorCell key="cell" alignment="left" maxValue="1023" warningValue="2000" criticalValue="2000" levelIndicatorStyle="continuousCapacity" id="xcx-tB-hUl"/>
691
                         <levelIndicatorCell key="cell" alignment="left" maxValue="1023" warningValue="2000" criticalValue="2000" levelIndicatorStyle="continuousCapacity" id="xcx-tB-hUl"/>
736
             </view>
726
             </view>
737
             <connections>
727
             <connections>
738
                 <outlet property="connectButton" destination="fCd-m1-NwV" id="3l3-JM-thL"/>
728
                 <outlet property="connectButton" destination="fCd-m1-NwV" id="3l3-JM-thL"/>
739
-                <outlet property="createButton" destination="v8W-R7-l4G" id="dGA-CN-AUM"/>
740
                 <outlet property="level1" destination="Bo5-fb-a0u" id="EHR-Gm-wah"/>
729
                 <outlet property="level1" destination="Bo5-fb-a0u" id="EHR-Gm-wah"/>
741
                 <outlet property="level2" destination="LlC-lV-IAQ" id="iMK-OU-OLi"/>
730
                 <outlet property="level2" destination="LlC-lV-IAQ" id="iMK-OU-OLi"/>
742
                 <outlet property="level3" destination="URz-Id-X9n" id="dgR-4v-LBR"/>
731
                 <outlet property="level3" destination="URz-Id-X9n" id="dgR-4v-LBR"/>

+ 1
- 1
SerialGamepad/Info.plist View File

21
 	<key>CFBundleSignature</key>
21
 	<key>CFBundleSignature</key>
22
 	<string>????</string>
22
 	<string>????</string>
23
 	<key>CFBundleVersion</key>
23
 	<key>CFBundleVersion</key>
24
-	<string>93</string>
24
+	<string>94</string>
25
 	<key>LSApplicationCategoryType</key>
25
 	<key>LSApplicationCategoryType</key>
26
 	<string>public.app-category.utilities</string>
26
 	<string>public.app-category.utilities</string>
27
 	<key>LSMinimumSystemVersion</key>
27
 	<key>LSMinimumSystemVersion</key>

+ 0
- 2
SerialGamepad/MainWindow.h View File

24
 
24
 
25
 @property (strong) Thread *serialThread;
25
 @property (strong) Thread *serialThread;
26
 
26
 
27
-@property (assign) BOOL gamepadCreated;
28
-
29
 - (void)populatePortList;
27
 - (void)populatePortList;
30
 - (void)setChannels:(id)data;
28
 - (void)setChannels:(id)data;
31
 
29
 

+ 11
- 23
SerialGamepad/MainWindow.m View File

16
 
16
 
17
 @synthesize portList, connectButton, createButton;
17
 @synthesize portList, connectButton, createButton;
18
 @synthesize level1, level2, level3, level4, level5, level6;
18
 @synthesize level1, level2, level3, level4, level5, level6;
19
-@synthesize serialThread, gamepadCreated;
19
+@synthesize serialThread;
20
 
20
 
21
 - (id)init {
21
 - (id)init {
22
     self = [super init];
22
     self = [super init];
23
     if (self != nil) {
23
     if (self != nil) {
24
         serialThread = nil;
24
         serialThread = nil;
25
-        gamepadCreated = NO;
26
         [self setDelegate:self];
25
         [self setDelegate:self];
27
     }
26
     }
28
     return self;
27
     return self;
29
 }
28
 }
30
 
29
 
31
 - (BOOL)windowShouldClose:(id)sender {
30
 - (BOOL)windowShouldClose:(id)sender {
32
-    if (gamepadCreated) {
33
-        [fooHID close];
34
-        gamepadCreated = NO;
35
-    }
36
-    
37
     if (serialThread != nil) {
31
     if (serialThread != nil) {
32
+        [fooHID close];
33
+        
38
         // Stop thread and wait for it to finish
34
         // Stop thread and wait for it to finish
39
         [serialThread setRunning:NO];
35
         [serialThread setRunning:NO];
40
         while ([serialThread isFinished] == NO) {
36
         while ([serialThread isFinished] == NO) {
54
         if ([serialThread openPort] != 0) {
50
         if ([serialThread openPort] != 0) {
55
             serialThread = nil;
51
             serialThread = nil;
56
         } else {
52
         } else {
57
-            [serialThread start];
58
-            [connectButton setTitle:@"Disconnect"];
53
+            if ([fooHID init] == 0) {
54
+                [serialThread start];
55
+                [connectButton setTitle:@"Disconnect"];
56
+            } else {
57
+                serialThread = nil;
58
+            }
59
         }
59
         }
60
     } else {
60
     } else {
61
         [serialThread setRunning:NO];
61
         [serialThread setRunning:NO];
62
         serialThread = nil;
62
         serialThread = nil;
63
-        [connectButton setTitle:@"Connect"];
64
-    }
65
-}
66
-
67
-- (IBAction)createButtonPressed:(id)sender {
68
-    if (gamepadCreated) {
69
         [fooHID close];
63
         [fooHID close];
70
-        gamepadCreated = NO;
71
-        [createButton setTitle:@"Create"];
72
-    } else {
73
-        if ([fooHID init] == 0) {
74
-            gamepadCreated = YES;
75
-            [createButton setTitle:@"Destroy"];
76
-        }
64
+        [connectButton setTitle:@"Connect"];
77
     }
65
     }
78
 }
66
 }
79
 
67
 
108
         [level5 setDoubleValue:[[data objectAtIndex:4] doubleValue]];
96
         [level5 setDoubleValue:[[data objectAtIndex:4] doubleValue]];
109
         [level6 setDoubleValue:[[data objectAtIndex:5] doubleValue]];
97
         [level6 setDoubleValue:[[data objectAtIndex:5] doubleValue]];
110
         
98
         
111
-        if (gamepadCreated) {
99
+        if (serialThread != nil) {
112
             [fooHID send:data];
100
             [fooHID send:data];
113
         }
101
         }
114
     }
102
     }

Loading…
Cancel
Save