Browse Source

Only use one button in GUI

Thomas Buck 9 years ago
parent
commit
138a52c015

+ 0
- 4
README.md View File

@@ -16,10 +16,6 @@ This app can connect to a compatible transmitter over a serial port and then pro
16 16
 
17 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 19
 ## foohid command-line app
24 20
 
25 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,5 +1,5 @@
1 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 3
     <dependencies>
4 4
         <deployment identifier="macosx"/>
5 5
         <plugIn identifier="com.apple.InterfaceBuilder.CocoaPlugin" version="9531"/>
@@ -677,7 +677,7 @@
677 677
                 <autoresizingMask key="autoresizingMask"/>
678 678
                 <subviews>
679 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 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 682
                             <behavior key="behavior" pushIn="YES" lightByBackground="YES" lightByGray="YES"/>
683 683
                             <font key="font" metaFont="system"/>
@@ -686,16 +686,6 @@
686 686
                             <action selector="connectButtonPressed:" target="QvC-M9-y7g" id="3UW-Gk-OUp"/>
687 687
                         </connections>
688 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 689
                     <levelIndicator verticalHuggingPriority="750" fixedFrame="YES" translatesAutoresizingMaskIntoConstraints="NO" id="Bo5-fb-a0u">
700 690
                         <rect key="frame" x="20" y="140" width="290" height="16"/>
701 691
                         <levelIndicatorCell key="cell" alignment="left" maxValue="1023" warningValue="2000" criticalValue="2000" levelIndicatorStyle="continuousCapacity" id="xcx-tB-hUl"/>
@@ -736,7 +726,6 @@
736 726
             </view>
737 727
             <connections>
738 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 729
                 <outlet property="level1" destination="Bo5-fb-a0u" id="EHR-Gm-wah"/>
741 730
                 <outlet property="level2" destination="LlC-lV-IAQ" id="iMK-OU-OLi"/>
742 731
                 <outlet property="level3" destination="URz-Id-X9n" id="dgR-4v-LBR"/>

+ 1
- 1
SerialGamepad/Info.plist View File

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

+ 0
- 2
SerialGamepad/MainWindow.h View File

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

+ 11
- 23
SerialGamepad/MainWindow.m View File

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

Loading…
Cancel
Save