├── .gitignore
├── .gitmodules
├── .travis.yml
├── LICENSE
├── LiveFlight.xcodeproj
├── project.pbxproj
└── project.xcworkspace
│ ├── contents.xcworkspacedata
│ └── xcshareddata
│ └── LiveFlight.xcscmblueprint
├── LiveFlight
├── AppDelegate.swift
├── Controllers
│ ├── ControlPadViewController.h
│ ├── ControlPadViewController.m
│ ├── FlightControls.swift
│ ├── JoystickViewController.swift
│ ├── KeyboardCommandsView.swift
│ ├── OptionsViewController.swift
│ └── ViewController.swift
├── Infinite Flight Connect
│ ├── InfiniteFlightAPIConnector.h
│ ├── InfiniteFlightAPIConnector.m
│ ├── UDPReceiver.h
│ └── UDPReceiver.m
├── Joystick
│ ├── Joystick.h
│ ├── Joystick.m
│ ├── JoystickHatswitch.h
│ ├── JoystickHatswitch.m
│ ├── JoystickHelper.swift
│ ├── JoystickManager.h
│ ├── JoystickManager.m
│ └── JoystickNotificationDelegate.h
├── Keyboard
│ └── KeyboardListenerWindow.swift
├── LiveFlight Connect.entitlements
├── LiveFlight-Bridging-Header.h
├── Resources
│ ├── Credits.rtf
│ ├── Images.xcassets
│ │ ├── AppIcon.appiconset
│ │ │ ├── AppIcon_mac_128x128.png
│ │ │ ├── AppIcon_mac_128x128@2x.png
│ │ │ ├── AppIcon_mac_16x16.png
│ │ │ ├── AppIcon_mac_16x16@2x.png
│ │ │ ├── AppIcon_mac_256x256.png
│ │ │ ├── AppIcon_mac_256x256@2x.png
│ │ │ ├── AppIcon_mac_32x32.png
│ │ │ ├── AppIcon_mac_32x32@2x.png
│ │ │ ├── AppIcon_mac_512x512.png
│ │ │ ├── AppIcon_mac_512x512@2x.png
│ │ │ └── Contents.json
│ │ └── Contents.json
│ ├── Info.plist
│ ├── Main.storyboard
│ ├── Reachability.swift
│ └── RoundedIcon.icns
└── ViewSubclasses
│ ├── ControlPad
│ ├── ControlPad.h
│ └── ControlPad.m
│ └── StatusMessages
│ └── Status.swift
└── README.md
/.gitignore:
--------------------------------------------------------------------------------
1 | # Xcode
2 | #
3 | build/
4 | *.pbxuser
5 | !default.pbxuser
6 | *.mode1v3
7 | !default.mode1v3
8 | *.mode2v3
9 | !default.mode2v3
10 | *.perspectivev3
11 | !default.perspectivev3
12 | xcuserdata
13 | *.xccheckout
14 | *.moved-aside
15 | DerivedData
16 | *.hmap
17 | *.ipa
18 | *.xcuserstate
19 |
20 | # CocoaPods
21 | #
22 | # We recommend against adding the Pods directory to your .gitignore. However
23 | # you should judge for yourself, the pros and cons are mentioned at:
24 | # http://guides.cocoapods.org/using/using-cocoapods.html#should-i-ignore-the-pods-directory-in-source-control
25 | #
26 | # Pods/
27 |
28 | # Carthage
29 | #
30 | # Add this line if you want to avoid checking in source code from Carthage dependencies.
31 | # Carthage/Checkouts
32 |
33 | Carthage/Build
34 |
35 | ##
36 | ## these are local versions of things used for App Store releases
37 | ##
38 |
39 | Release.xcodeproj
40 | Release/
41 | Crashlytics.framework/
42 | Fabric.framework/
43 |
--------------------------------------------------------------------------------
/.gitmodules:
--------------------------------------------------------------------------------
1 | [submodule "LiveFlight/libs/JoystickMapping"]
2 | path = LiveFlight/libs/JoystickMapping
3 | url = https://github.com/LiveFlightApp/JoystickMapping
4 | [submodule "LiveFlight/libs/CocoaAsyncSocket"]
5 | path = LiveFlight/libs/CocoaAsyncSocket
6 | url = https://github.com/robbiehanson/CocoaAsyncSocket
7 | [submodule "LiveFlight/libs/SwiftHTTP"]
8 | path = LiveFlight/libs/SwiftHTTP
9 | url = https://github.com/daltoniam/SwiftHTTP
10 | [submodule "LiveFlight/libs/Reachability.swift"]
11 | path = LiveFlight/libs/Reachability.swift
12 | url = https://github.com/ashleymills/Reachability.swift
13 |
--------------------------------------------------------------------------------
/.travis.yml:
--------------------------------------------------------------------------------
1 | language: objective-c
2 | osx_image: xcode7.2
3 | xcode_project: LiveFlight.xcodeproj
4 | before_install:
5 | - git submodule init
6 | - git submodule update
7 |
--------------------------------------------------------------------------------
/LICENSE:
--------------------------------------------------------------------------------
1 | GNU GENERAL PUBLIC LICENSE
2 | Version 3, 29 June 2007
3 |
4 | Copyright (C) 2007 Free Software Foundation, Inc.
5 | Everyone is permitted to copy and distribute verbatim copies
6 | of this license document, but changing it is not allowed.
7 |
8 | Preamble
9 |
10 | The GNU General Public License is a free, copyleft license for
11 | software and other kinds of works.
12 |
13 | The licenses for most software and other practical works are designed
14 | to take away your freedom to share and change the works. By contrast,
15 | the GNU General Public License is intended to guarantee your freedom to
16 | share and change all versions of a program--to make sure it remains free
17 | software for all its users. We, the Free Software Foundation, use the
18 | GNU General Public License for most of our software; it applies also to
19 | any other work released this way by its authors. You can apply it to
20 | your programs, too.
21 |
22 | When we speak of free software, we are referring to freedom, not
23 | price. Our General Public Licenses are designed to make sure that you
24 | have the freedom to distribute copies of free software (and charge for
25 | them if you wish), that you receive source code or can get it if you
26 | want it, that you can change the software or use pieces of it in new
27 | free programs, and that you know you can do these things.
28 |
29 | To protect your rights, we need to prevent others from denying you
30 | these rights or asking you to surrender the rights. Therefore, you have
31 | certain responsibilities if you distribute copies of the software, or if
32 | you modify it: responsibilities to respect the freedom of others.
33 |
34 | For example, if you distribute copies of such a program, whether
35 | gratis or for a fee, you must pass on to the recipients the same
36 | freedoms that you received. You must make sure that they, too, receive
37 | or can get the source code. And you must show them these terms so they
38 | know their rights.
39 |
40 | Developers that use the GNU GPL protect your rights with two steps:
41 | (1) assert copyright on the software, and (2) offer you this License
42 | giving you legal permission to copy, distribute and/or modify it.
43 |
44 | For the developers' and authors' protection, the GPL clearly explains
45 | that there is no warranty for this free software. For both users' and
46 | authors' sake, the GPL requires that modified versions be marked as
47 | changed, so that their problems will not be attributed erroneously to
48 | authors of previous versions.
49 |
50 | Some devices are designed to deny users access to install or run
51 | modified versions of the software inside them, although the manufacturer
52 | can do so. This is fundamentally incompatible with the aim of
53 | protecting users' freedom to change the software. The systematic
54 | pattern of such abuse occurs in the area of products for individuals to
55 | use, which is precisely where it is most unacceptable. Therefore, we
56 | have designed this version of the GPL to prohibit the practice for those
57 | products. If such problems arise substantially in other domains, we
58 | stand ready to extend this provision to those domains in future versions
59 | of the GPL, as needed to protect the freedom of users.
60 |
61 | Finally, every program is threatened constantly by software patents.
62 | States should not allow patents to restrict development and use of
63 | software on general-purpose computers, but in those that do, we wish to
64 | avoid the special danger that patents applied to a free program could
65 | make it effectively proprietary. To prevent this, the GPL assures that
66 | patents cannot be used to render the program non-free.
67 |
68 | The precise terms and conditions for copying, distribution and
69 | modification follow.
70 |
71 | TERMS AND CONDITIONS
72 |
73 | 0. Definitions.
74 |
75 | "This License" refers to version 3 of the GNU General Public License.
76 |
77 | "Copyright" also means copyright-like laws that apply to other kinds of
78 | works, such as semiconductor masks.
79 |
80 | "The Program" refers to any copyrightable work licensed under this
81 | License. Each licensee is addressed as "you". "Licensees" and
82 | "recipients" may be individuals or organizations.
83 |
84 | To "modify" a work means to copy from or adapt all or part of the work
85 | in a fashion requiring copyright permission, other than the making of an
86 | exact copy. The resulting work is called a "modified version" of the
87 | earlier work or a work "based on" the earlier work.
88 |
89 | A "covered work" means either the unmodified Program or a work based
90 | on the Program.
91 |
92 | To "propagate" a work means to do anything with it that, without
93 | permission, would make you directly or secondarily liable for
94 | infringement under applicable copyright law, except executing it on a
95 | computer or modifying a private copy. Propagation includes copying,
96 | distribution (with or without modification), making available to the
97 | public, and in some countries other activities as well.
98 |
99 | To "convey" a work means any kind of propagation that enables other
100 | parties to make or receive copies. Mere interaction with a user through
101 | a computer network, with no transfer of a copy, is not conveying.
102 |
103 | An interactive user interface displays "Appropriate Legal Notices"
104 | to the extent that it includes a convenient and prominently visible
105 | feature that (1) displays an appropriate copyright notice, and (2)
106 | tells the user that there is no warranty for the work (except to the
107 | extent that warranties are provided), that licensees may convey the
108 | work under this License, and how to view a copy of this License. If
109 | the interface presents a list of user commands or options, such as a
110 | menu, a prominent item in the list meets this criterion.
111 |
112 | 1. Source Code.
113 |
114 | The "source code" for a work means the preferred form of the work
115 | for making modifications to it. "Object code" means any non-source
116 | form of a work.
117 |
118 | A "Standard Interface" means an interface that either is an official
119 | standard defined by a recognized standards body, or, in the case of
120 | interfaces specified for a particular programming language, one that
121 | is widely used among developers working in that language.
122 |
123 | The "System Libraries" of an executable work include anything, other
124 | than the work as a whole, that (a) is included in the normal form of
125 | packaging a Major Component, but which is not part of that Major
126 | Component, and (b) serves only to enable use of the work with that
127 | Major Component, or to implement a Standard Interface for which an
128 | implementation is available to the public in source code form. A
129 | "Major Component", in this context, means a major essential component
130 | (kernel, window system, and so on) of the specific operating system
131 | (if any) on which the executable work runs, or a compiler used to
132 | produce the work, or an object code interpreter used to run it.
133 |
134 | The "Corresponding Source" for a work in object code form means all
135 | the source code needed to generate, install, and (for an executable
136 | work) run the object code and to modify the work, including scripts to
137 | control those activities. However, it does not include the work's
138 | System Libraries, or general-purpose tools or generally available free
139 | programs which are used unmodified in performing those activities but
140 | which are not part of the work. For example, Corresponding Source
141 | includes interface definition files associated with source files for
142 | the work, and the source code for shared libraries and dynamically
143 | linked subprograms that the work is specifically designed to require,
144 | such as by intimate data communication or control flow between those
145 | subprograms and other parts of the work.
146 |
147 | The Corresponding Source need not include anything that users
148 | can regenerate automatically from other parts of the Corresponding
149 | Source.
150 |
151 | The Corresponding Source for a work in source code form is that
152 | same work.
153 |
154 | 2. Basic Permissions.
155 |
156 | All rights granted under this License are granted for the term of
157 | copyright on the Program, and are irrevocable provided the stated
158 | conditions are met. This License explicitly affirms your unlimited
159 | permission to run the unmodified Program. The output from running a
160 | covered work is covered by this License only if the output, given its
161 | content, constitutes a covered work. This License acknowledges your
162 | rights of fair use or other equivalent, as provided by copyright law.
163 |
164 | You may make, run and propagate covered works that you do not
165 | convey, without conditions so long as your license otherwise remains
166 | in force. You may convey covered works to others for the sole purpose
167 | of having them make modifications exclusively for you, or provide you
168 | with facilities for running those works, provided that you comply with
169 | the terms of this License in conveying all material for which you do
170 | not control copyright. Those thus making or running the covered works
171 | for you must do so exclusively on your behalf, under your direction
172 | and control, on terms that prohibit them from making any copies of
173 | your copyrighted material outside their relationship with you.
174 |
175 | Conveying under any other circumstances is permitted solely under
176 | the conditions stated below. Sublicensing is not allowed; section 10
177 | makes it unnecessary.
178 |
179 | 3. Protecting Users' Legal Rights From Anti-Circumvention Law.
180 |
181 | No covered work shall be deemed part of an effective technological
182 | measure under any applicable law fulfilling obligations under article
183 | 11 of the WIPO copyright treaty adopted on 20 December 1996, or
184 | similar laws prohibiting or restricting circumvention of such
185 | measures.
186 |
187 | When you convey a covered work, you waive any legal power to forbid
188 | circumvention of technological measures to the extent such circumvention
189 | is effected by exercising rights under this License with respect to
190 | the covered work, and you disclaim any intention to limit operation or
191 | modification of the work as a means of enforcing, against the work's
192 | users, your or third parties' legal rights to forbid circumvention of
193 | technological measures.
194 |
195 | 4. Conveying Verbatim Copies.
196 |
197 | You may convey verbatim copies of the Program's source code as you
198 | receive it, in any medium, provided that you conspicuously and
199 | appropriately publish on each copy an appropriate copyright notice;
200 | keep intact all notices stating that this License and any
201 | non-permissive terms added in accord with section 7 apply to the code;
202 | keep intact all notices of the absence of any warranty; and give all
203 | recipients a copy of this License along with the Program.
204 |
205 | You may charge any price or no price for each copy that you convey,
206 | and you may offer support or warranty protection for a fee.
207 |
208 | 5. Conveying Modified Source Versions.
209 |
210 | You may convey a work based on the Program, or the modifications to
211 | produce it from the Program, in the form of source code under the
212 | terms of section 4, provided that you also meet all of these conditions:
213 |
214 | a) The work must carry prominent notices stating that you modified
215 | it, and giving a relevant date.
216 |
217 | b) The work must carry prominent notices stating that it is
218 | released under this License and any conditions added under section
219 | 7. This requirement modifies the requirement in section 4 to
220 | "keep intact all notices".
221 |
222 | c) You must license the entire work, as a whole, under this
223 | License to anyone who comes into possession of a copy. This
224 | License will therefore apply, along with any applicable section 7
225 | additional terms, to the whole of the work, and all its parts,
226 | regardless of how they are packaged. This License gives no
227 | permission to license the work in any other way, but it does not
228 | invalidate such permission if you have separately received it.
229 |
230 | d) If the work has interactive user interfaces, each must display
231 | Appropriate Legal Notices; however, if the Program has interactive
232 | interfaces that do not display Appropriate Legal Notices, your
233 | work need not make them do so.
234 |
235 | A compilation of a covered work with other separate and independent
236 | works, which are not by their nature extensions of the covered work,
237 | and which are not combined with it such as to form a larger program,
238 | in or on a volume of a storage or distribution medium, is called an
239 | "aggregate" if the compilation and its resulting copyright are not
240 | used to limit the access or legal rights of the compilation's users
241 | beyond what the individual works permit. Inclusion of a covered work
242 | in an aggregate does not cause this License to apply to the other
243 | parts of the aggregate.
244 |
245 | 6. Conveying Non-Source Forms.
246 |
247 | You may convey a covered work in object code form under the terms
248 | of sections 4 and 5, provided that you also convey the
249 | machine-readable Corresponding Source under the terms of this License,
250 | in one of these ways:
251 |
252 | a) Convey the object code in, or embodied in, a physical product
253 | (including a physical distribution medium), accompanied by the
254 | Corresponding Source fixed on a durable physical medium
255 | customarily used for software interchange.
256 |
257 | b) Convey the object code in, or embodied in, a physical product
258 | (including a physical distribution medium), accompanied by a
259 | written offer, valid for at least three years and valid for as
260 | long as you offer spare parts or customer support for that product
261 | model, to give anyone who possesses the object code either (1) a
262 | copy of the Corresponding Source for all the software in the
263 | product that is covered by this License, on a durable physical
264 | medium customarily used for software interchange, for a price no
265 | more than your reasonable cost of physically performing this
266 | conveying of source, or (2) access to copy the
267 | Corresponding Source from a network server at no charge.
268 |
269 | c) Convey individual copies of the object code with a copy of the
270 | written offer to provide the Corresponding Source. This
271 | alternative is allowed only occasionally and noncommercially, and
272 | only if you received the object code with such an offer, in accord
273 | with subsection 6b.
274 |
275 | d) Convey the object code by offering access from a designated
276 | place (gratis or for a charge), and offer equivalent access to the
277 | Corresponding Source in the same way through the same place at no
278 | further charge. You need not require recipients to copy the
279 | Corresponding Source along with the object code. If the place to
280 | copy the object code is a network server, the Corresponding Source
281 | may be on a different server (operated by you or a third party)
282 | that supports equivalent copying facilities, provided you maintain
283 | clear directions next to the object code saying where to find the
284 | Corresponding Source. Regardless of what server hosts the
285 | Corresponding Source, you remain obligated to ensure that it is
286 | available for as long as needed to satisfy these requirements.
287 |
288 | e) Convey the object code using peer-to-peer transmission, provided
289 | you inform other peers where the object code and Corresponding
290 | Source of the work are being offered to the general public at no
291 | charge under subsection 6d.
292 |
293 | A separable portion of the object code, whose source code is excluded
294 | from the Corresponding Source as a System Library, need not be
295 | included in conveying the object code work.
296 |
297 | A "User Product" is either (1) a "consumer product", which means any
298 | tangible personal property which is normally used for personal, family,
299 | or household purposes, or (2) anything designed or sold for incorporation
300 | into a dwelling. In determining whether a product is a consumer product,
301 | doubtful cases shall be resolved in favor of coverage. For a particular
302 | product received by a particular user, "normally used" refers to a
303 | typical or common use of that class of product, regardless of the status
304 | of the particular user or of the way in which the particular user
305 | actually uses, or expects or is expected to use, the product. A product
306 | is a consumer product regardless of whether the product has substantial
307 | commercial, industrial or non-consumer uses, unless such uses represent
308 | the only significant mode of use of the product.
309 |
310 | "Installation Information" for a User Product means any methods,
311 | procedures, authorization keys, or other information required to install
312 | and execute modified versions of a covered work in that User Product from
313 | a modified version of its Corresponding Source. The information must
314 | suffice to ensure that the continued functioning of the modified object
315 | code is in no case prevented or interfered with solely because
316 | modification has been made.
317 |
318 | If you convey an object code work under this section in, or with, or
319 | specifically for use in, a User Product, and the conveying occurs as
320 | part of a transaction in which the right of possession and use of the
321 | User Product is transferred to the recipient in perpetuity or for a
322 | fixed term (regardless of how the transaction is characterized), the
323 | Corresponding Source conveyed under this section must be accompanied
324 | by the Installation Information. But this requirement does not apply
325 | if neither you nor any third party retains the ability to install
326 | modified object code on the User Product (for example, the work has
327 | been installed in ROM).
328 |
329 | The requirement to provide Installation Information does not include a
330 | requirement to continue to provide support service, warranty, or updates
331 | for a work that has been modified or installed by the recipient, or for
332 | the User Product in which it has been modified or installed. Access to a
333 | network may be denied when the modification itself materially and
334 | adversely affects the operation of the network or violates the rules and
335 | protocols for communication across the network.
336 |
337 | Corresponding Source conveyed, and Installation Information provided,
338 | in accord with this section must be in a format that is publicly
339 | documented (and with an implementation available to the public in
340 | source code form), and must require no special password or key for
341 | unpacking, reading or copying.
342 |
343 | 7. Additional Terms.
344 |
345 | "Additional permissions" are terms that supplement the terms of this
346 | License by making exceptions from one or more of its conditions.
347 | Additional permissions that are applicable to the entire Program shall
348 | be treated as though they were included in this License, to the extent
349 | that they are valid under applicable law. If additional permissions
350 | apply only to part of the Program, that part may be used separately
351 | under those permissions, but the entire Program remains governed by
352 | this License without regard to the additional permissions.
353 |
354 | When you convey a copy of a covered work, you may at your option
355 | remove any additional permissions from that copy, or from any part of
356 | it. (Additional permissions may be written to require their own
357 | removal in certain cases when you modify the work.) You may place
358 | additional permissions on material, added by you to a covered work,
359 | for which you have or can give appropriate copyright permission.
360 |
361 | Notwithstanding any other provision of this License, for material you
362 | add to a covered work, you may (if authorized by the copyright holders of
363 | that material) supplement the terms of this License with terms:
364 |
365 | a) Disclaiming warranty or limiting liability differently from the
366 | terms of sections 15 and 16 of this License; or
367 |
368 | b) Requiring preservation of specified reasonable legal notices or
369 | author attributions in that material or in the Appropriate Legal
370 | Notices displayed by works containing it; or
371 |
372 | c) Prohibiting misrepresentation of the origin of that material, or
373 | requiring that modified versions of such material be marked in
374 | reasonable ways as different from the original version; or
375 |
376 | d) Limiting the use for publicity purposes of names of licensors or
377 | authors of the material; or
378 |
379 | e) Declining to grant rights under trademark law for use of some
380 | trade names, trademarks, or service marks; or
381 |
382 | f) Requiring indemnification of licensors and authors of that
383 | material by anyone who conveys the material (or modified versions of
384 | it) with contractual assumptions of liability to the recipient, for
385 | any liability that these contractual assumptions directly impose on
386 | those licensors and authors.
387 |
388 | All other non-permissive additional terms are considered "further
389 | restrictions" within the meaning of section 10. If the Program as you
390 | received it, or any part of it, contains a notice stating that it is
391 | governed by this License along with a term that is a further
392 | restriction, you may remove that term. If a license document contains
393 | a further restriction but permits relicensing or conveying under this
394 | License, you may add to a covered work material governed by the terms
395 | of that license document, provided that the further restriction does
396 | not survive such relicensing or conveying.
397 |
398 | If you add terms to a covered work in accord with this section, you
399 | must place, in the relevant source files, a statement of the
400 | additional terms that apply to those files, or a notice indicating
401 | where to find the applicable terms.
402 |
403 | Additional terms, permissive or non-permissive, may be stated in the
404 | form of a separately written license, or stated as exceptions;
405 | the above requirements apply either way.
406 |
407 | 8. Termination.
408 |
409 | You may not propagate or modify a covered work except as expressly
410 | provided under this License. Any attempt otherwise to propagate or
411 | modify it is void, and will automatically terminate your rights under
412 | this License (including any patent licenses granted under the third
413 | paragraph of section 11).
414 |
415 | However, if you cease all violation of this License, then your
416 | license from a particular copyright holder is reinstated (a)
417 | provisionally, unless and until the copyright holder explicitly and
418 | finally terminates your license, and (b) permanently, if the copyright
419 | holder fails to notify you of the violation by some reasonable means
420 | prior to 60 days after the cessation.
421 |
422 | Moreover, your license from a particular copyright holder is
423 | reinstated permanently if the copyright holder notifies you of the
424 | violation by some reasonable means, this is the first time you have
425 | received notice of violation of this License (for any work) from that
426 | copyright holder, and you cure the violation prior to 30 days after
427 | your receipt of the notice.
428 |
429 | Termination of your rights under this section does not terminate the
430 | licenses of parties who have received copies or rights from you under
431 | this License. If your rights have been terminated and not permanently
432 | reinstated, you do not qualify to receive new licenses for the same
433 | material under section 10.
434 |
435 | 9. Acceptance Not Required for Having Copies.
436 |
437 | You are not required to accept this License in order to receive or
438 | run a copy of the Program. Ancillary propagation of a covered work
439 | occurring solely as a consequence of using peer-to-peer transmission
440 | to receive a copy likewise does not require acceptance. However,
441 | nothing other than this License grants you permission to propagate or
442 | modify any covered work. These actions infringe copyright if you do
443 | not accept this License. Therefore, by modifying or propagating a
444 | covered work, you indicate your acceptance of this License to do so.
445 |
446 | 10. Automatic Licensing of Downstream Recipients.
447 |
448 | Each time you convey a covered work, the recipient automatically
449 | receives a license from the original licensors, to run, modify and
450 | propagate that work, subject to this License. You are not responsible
451 | for enforcing compliance by third parties with this License.
452 |
453 | An "entity transaction" is a transaction transferring control of an
454 | organization, or substantially all assets of one, or subdividing an
455 | organization, or merging organizations. If propagation of a covered
456 | work results from an entity transaction, each party to that
457 | transaction who receives a copy of the work also receives whatever
458 | licenses to the work the party's predecessor in interest had or could
459 | give under the previous paragraph, plus a right to possession of the
460 | Corresponding Source of the work from the predecessor in interest, if
461 | the predecessor has it or can get it with reasonable efforts.
462 |
463 | You may not impose any further restrictions on the exercise of the
464 | rights granted or affirmed under this License. For example, you may
465 | not impose a license fee, royalty, or other charge for exercise of
466 | rights granted under this License, and you may not initiate litigation
467 | (including a cross-claim or counterclaim in a lawsuit) alleging that
468 | any patent claim is infringed by making, using, selling, offering for
469 | sale, or importing the Program or any portion of it.
470 |
471 | 11. Patents.
472 |
473 | A "contributor" is a copyright holder who authorizes use under this
474 | License of the Program or a work on which the Program is based. The
475 | work thus licensed is called the contributor's "contributor version".
476 |
477 | A contributor's "essential patent claims" are all patent claims
478 | owned or controlled by the contributor, whether already acquired or
479 | hereafter acquired, that would be infringed by some manner, permitted
480 | by this License, of making, using, or selling its contributor version,
481 | but do not include claims that would be infringed only as a
482 | consequence of further modification of the contributor version. For
483 | purposes of this definition, "control" includes the right to grant
484 | patent sublicenses in a manner consistent with the requirements of
485 | this License.
486 |
487 | Each contributor grants you a non-exclusive, worldwide, royalty-free
488 | patent license under the contributor's essential patent claims, to
489 | make, use, sell, offer for sale, import and otherwise run, modify and
490 | propagate the contents of its contributor version.
491 |
492 | In the following three paragraphs, a "patent license" is any express
493 | agreement or commitment, however denominated, not to enforce a patent
494 | (such as an express permission to practice a patent or covenant not to
495 | sue for patent infringement). To "grant" such a patent license to a
496 | party means to make such an agreement or commitment not to enforce a
497 | patent against the party.
498 |
499 | If you convey a covered work, knowingly relying on a patent license,
500 | and the Corresponding Source of the work is not available for anyone
501 | to copy, free of charge and under the terms of this License, through a
502 | publicly available network server or other readily accessible means,
503 | then you must either (1) cause the Corresponding Source to be so
504 | available, or (2) arrange to deprive yourself of the benefit of the
505 | patent license for this particular work, or (3) arrange, in a manner
506 | consistent with the requirements of this License, to extend the patent
507 | license to downstream recipients. "Knowingly relying" means you have
508 | actual knowledge that, but for the patent license, your conveying the
509 | covered work in a country, or your recipient's use of the covered work
510 | in a country, would infringe one or more identifiable patents in that
511 | country that you have reason to believe are valid.
512 |
513 | If, pursuant to or in connection with a single transaction or
514 | arrangement, you convey, or propagate by procuring conveyance of, a
515 | covered work, and grant a patent license to some of the parties
516 | receiving the covered work authorizing them to use, propagate, modify
517 | or convey a specific copy of the covered work, then the patent license
518 | you grant is automatically extended to all recipients of the covered
519 | work and works based on it.
520 |
521 | A patent license is "discriminatory" if it does not include within
522 | the scope of its coverage, prohibits the exercise of, or is
523 | conditioned on the non-exercise of one or more of the rights that are
524 | specifically granted under this License. You may not convey a covered
525 | work if you are a party to an arrangement with a third party that is
526 | in the business of distributing software, under which you make payment
527 | to the third party based on the extent of your activity of conveying
528 | the work, and under which the third party grants, to any of the
529 | parties who would receive the covered work from you, a discriminatory
530 | patent license (a) in connection with copies of the covered work
531 | conveyed by you (or copies made from those copies), or (b) primarily
532 | for and in connection with specific products or compilations that
533 | contain the covered work, unless you entered into that arrangement,
534 | or that patent license was granted, prior to 28 March 2007.
535 |
536 | Nothing in this License shall be construed as excluding or limiting
537 | any implied license or other defenses to infringement that may
538 | otherwise be available to you under applicable patent law.
539 |
540 | 12. No Surrender of Others' Freedom.
541 |
542 | If conditions are imposed on you (whether by court order, agreement or
543 | otherwise) that contradict the conditions of this License, they do not
544 | excuse you from the conditions of this License. If you cannot convey a
545 | covered work so as to satisfy simultaneously your obligations under this
546 | License and any other pertinent obligations, then as a consequence you may
547 | not convey it at all. For example, if you agree to terms that obligate you
548 | to collect a royalty for further conveying from those to whom you convey
549 | the Program, the only way you could satisfy both those terms and this
550 | License would be to refrain entirely from conveying the Program.
551 |
552 | 13. Use with the GNU Affero General Public License.
553 |
554 | Notwithstanding any other provision of this License, you have
555 | permission to link or combine any covered work with a work licensed
556 | under version 3 of the GNU Affero General Public License into a single
557 | combined work, and to convey the resulting work. The terms of this
558 | License will continue to apply to the part which is the covered work,
559 | but the special requirements of the GNU Affero General Public License,
560 | section 13, concerning interaction through a network will apply to the
561 | combination as such.
562 |
563 | 14. Revised Versions of this License.
564 |
565 | The Free Software Foundation may publish revised and/or new versions of
566 | the GNU General Public License from time to time. Such new versions will
567 | be similar in spirit to the present version, but may differ in detail to
568 | address new problems or concerns.
569 |
570 | Each version is given a distinguishing version number. If the
571 | Program specifies that a certain numbered version of the GNU General
572 | Public License "or any later version" applies to it, you have the
573 | option of following the terms and conditions either of that numbered
574 | version or of any later version published by the Free Software
575 | Foundation. If the Program does not specify a version number of the
576 | GNU General Public License, you may choose any version ever published
577 | by the Free Software Foundation.
578 |
579 | If the Program specifies that a proxy can decide which future
580 | versions of the GNU General Public License can be used, that proxy's
581 | public statement of acceptance of a version permanently authorizes you
582 | to choose that version for the Program.
583 |
584 | Later license versions may give you additional or different
585 | permissions. However, no additional obligations are imposed on any
586 | author or copyright holder as a result of your choosing to follow a
587 | later version.
588 |
589 | 15. Disclaimer of Warranty.
590 |
591 | THERE IS NO WARRANTY FOR THE PROGRAM, TO THE EXTENT PERMITTED BY
592 | APPLICABLE LAW. EXCEPT WHEN OTHERWISE STATED IN WRITING THE COPYRIGHT
593 | HOLDERS AND/OR OTHER PARTIES PROVIDE THE PROGRAM "AS IS" WITHOUT WARRANTY
594 | OF ANY KIND, EITHER EXPRESSED OR IMPLIED, INCLUDING, BUT NOT LIMITED TO,
595 | THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR
596 | PURPOSE. THE ENTIRE RISK AS TO THE QUALITY AND PERFORMANCE OF THE PROGRAM
597 | IS WITH YOU. SHOULD THE PROGRAM PROVE DEFECTIVE, YOU ASSUME THE COST OF
598 | ALL NECESSARY SERVICING, REPAIR OR CORRECTION.
599 |
600 | 16. Limitation of Liability.
601 |
602 | IN NO EVENT UNLESS REQUIRED BY APPLICABLE LAW OR AGREED TO IN WRITING
603 | WILL ANY COPYRIGHT HOLDER, OR ANY OTHER PARTY WHO MODIFIES AND/OR CONVEYS
604 | THE PROGRAM AS PERMITTED ABOVE, BE LIABLE TO YOU FOR DAMAGES, INCLUDING ANY
605 | GENERAL, SPECIAL, INCIDENTAL OR CONSEQUENTIAL DAMAGES ARISING OUT OF THE
606 | USE OR INABILITY TO USE THE PROGRAM (INCLUDING BUT NOT LIMITED TO LOSS OF
607 | DATA OR DATA BEING RENDERED INACCURATE OR LOSSES SUSTAINED BY YOU OR THIRD
608 | PARTIES OR A FAILURE OF THE PROGRAM TO OPERATE WITH ANY OTHER PROGRAMS),
609 | EVEN IF SUCH HOLDER OR OTHER PARTY HAS BEEN ADVISED OF THE POSSIBILITY OF
610 | SUCH DAMAGES.
611 |
612 | 17. Interpretation of Sections 15 and 16.
613 |
614 | If the disclaimer of warranty and limitation of liability provided
615 | above cannot be given local legal effect according to their terms,
616 | reviewing courts shall apply local law that most closely approximates
617 | an absolute waiver of all civil liability in connection with the
618 | Program, unless a warranty or assumption of liability accompanies a
619 | copy of the Program in return for a fee.
620 |
621 | END OF TERMS AND CONDITIONS
622 |
623 | LiveFlight Connect is a desktop-based Infinite Flight Live companion.
624 | Copyright (C) 2016 Cameron Carmichael Alonso
625 |
626 | This program is free software: you can redistribute it and/or modify
627 | it under the terms of the GNU General Public License as published by
628 | the Free Software Foundation, either version 3 of the License, or
629 | (at your option) any later version.
630 |
631 | This program is distributed in the hope that it will be useful,
632 | but WITHOUT ANY WARRANTY; without even the implied warranty of
633 | MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
634 | GNU General Public License for more details.
635 |
636 | You should have received a copy of the GNU General Public License
637 | along with this program. If not, see .
638 |
639 | For more information, please email cameron[at]liveflightapp[dot]com.
640 |
--------------------------------------------------------------------------------
/LiveFlight.xcodeproj/project.pbxproj:
--------------------------------------------------------------------------------
1 | // !$*UTF8*$!
2 | {
3 | archiveVersion = 1;
4 | classes = {
5 | };
6 | objectVersion = 46;
7 | objects = {
8 |
9 | /* Begin PBXBuildFile section */
10 | 7E2045951BCAF95A00A03F11 /* Credits.rtf in Resources */ = {isa = PBXBuildFile; fileRef = 7E2045941BCAF95A00A03F11 /* Credits.rtf */; };
11 | 7E36469E1C3454EF003117A5 /* Reachability.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E36469D1C3454EF003117A5 /* Reachability.swift */; };
12 | 7E3646A11C34557A003117A5 /* KeyboardListenerWindow.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E3646A01C34557A003117A5 /* KeyboardListenerWindow.swift */; };
13 | 7E3646A61C34558D003117A5 /* KeyboardCommandsView.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E3646A31C34558D003117A5 /* KeyboardCommandsView.swift */; };
14 | 7E3646A71C34558D003117A5 /* ViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E3646A41C34558D003117A5 /* ViewController.swift */; };
15 | 7E3646A91C3455AF003117A5 /* JoystickHelper.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E3646A81C3455AF003117A5 /* JoystickHelper.swift */; };
16 | 7E3646AB1C3455BB003117A5 /* JoystickViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E3646AA1C3455BB003117A5 /* JoystickViewController.swift */; };
17 | 7E3646AD1C3455D9003117A5 /* Status.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E3646AC1C3455D9003117A5 /* Status.swift */; };
18 | 7E3646AF1C345610003117A5 /* JoystickMapping in Resources */ = {isa = PBXBuildFile; fileRef = 7E3646AE1C345610003117A5 /* JoystickMapping */; };
19 | 7E3646B11C345668003117A5 /* Main.storyboard in Resources */ = {isa = PBXBuildFile; fileRef = 7E3646B01C345668003117A5 /* Main.storyboard */; };
20 | 7E5378091C34A4BC006D86F0 /* FlightControls.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E5378081C34A4BC006D86F0 /* FlightControls.swift */; };
21 | 7E53780B1C3548C9006D86F0 /* OptionsViewController.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E53780A1C3548C9006D86F0 /* OptionsViewController.swift */; };
22 | 7E5585D71BD2CD7D0028D9FD /* ControlPadViewController.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E5585D61BD2CD7D0028D9FD /* ControlPadViewController.m */; };
23 | 7E5585DB1BD2CDF20028D9FD /* ControlPad.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E5585DA1BD2CDF20028D9FD /* ControlPad.m */; };
24 | 7E62A5711B98B9B800D8D2D5 /* InfiniteFlightAPIConnector.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E62A5701B98B9B800D8D2D5 /* InfiniteFlightAPIConnector.m */; };
25 | 7E74516F1BC9D20000FB1069 /* HTTPSecurity.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E7451691BC9D20000FB1069 /* HTTPSecurity.swift */; };
26 | 7E7451701BC9D20000FB1069 /* Operation.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E74516A1BC9D20000FB1069 /* Operation.swift */; };
27 | 7E7451711BC9D20000FB1069 /* Request.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E74516B1BC9D20000FB1069 /* Request.swift */; };
28 | 7E7451721BC9D20000FB1069 /* StatusCode.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E74516C1BC9D20000FB1069 /* StatusCode.swift */; };
29 | 7E7451731BC9D20000FB1069 /* Upload.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E74516E1BC9D20000FB1069 /* Upload.swift */; };
30 | 7E7BA5F51B89DA5200C73DA0 /* AppDelegate.swift in Sources */ = {isa = PBXBuildFile; fileRef = 7E7BA5F41B89DA5200C73DA0 /* AppDelegate.swift */; };
31 | 7E7BA5F91B89DA5200C73DA0 /* Images.xcassets in Resources */ = {isa = PBXBuildFile; fileRef = 7E7BA5F81B89DA5200C73DA0 /* Images.xcassets */; };
32 | 7E7BA61B1B8A60FC00C73DA0 /* Joystick.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7BA6141B8A60FC00C73DA0 /* Joystick.m */; };
33 | 7E7BA61C1B8A60FC00C73DA0 /* JoystickHatswitch.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7BA6161B8A60FC00C73DA0 /* JoystickHatswitch.m */; };
34 | 7E7BA61D1B8A60FC00C73DA0 /* JoystickManager.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E7BA6191B8A60FC00C73DA0 /* JoystickManager.m */; };
35 | 7E80A4081BC6BE5100CF70FA /* GCDAsyncUdpSocket.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E80A4071BC6BE5100CF70FA /* GCDAsyncUdpSocket.m */; };
36 | 7E80A40B1BC6C19E00CF70FA /* UDPReceiver.m in Sources */ = {isa = PBXBuildFile; fileRef = 7E80A40A1BC6C19E00CF70FA /* UDPReceiver.m */; };
37 | 7E898E141B936AFD00208F54 /* RoundedIcon.icns in Resources */ = {isa = PBXBuildFile; fileRef = 7E898E131B936AFD00208F54 /* RoundedIcon.icns */; };
38 | /* End PBXBuildFile section */
39 |
40 | /* Begin PBXCopyFilesBuildPhase section */
41 | 7E0FCBEE1B957B3800403E57 /* Embed Frameworks */ = {
42 | isa = PBXCopyFilesBuildPhase;
43 | buildActionMask = 2147483647;
44 | dstPath = "";
45 | dstSubfolderSpec = 10;
46 | files = (
47 | );
48 | name = "Embed Frameworks";
49 | runOnlyForDeploymentPostprocessing = 0;
50 | };
51 | 7EA3C8271C2E0D9B00B6C5AC /* CopyFiles */ = {
52 | isa = PBXCopyFilesBuildPhase;
53 | buildActionMask = 2147483647;
54 | dstPath = "";
55 | dstSubfolderSpec = 10;
56 | files = (
57 | );
58 | runOnlyForDeploymentPostprocessing = 0;
59 | };
60 | /* End PBXCopyFilesBuildPhase section */
61 |
62 | /* Begin PBXFileReference section */
63 | 7E2045941BCAF95A00A03F11 /* Credits.rtf */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = text.rtf; path = Credits.rtf; sourceTree = ""; };
64 | 7E36469D1C3454EF003117A5 /* Reachability.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Reachability.swift; sourceTree = ""; };
65 | 7E3646A01C34557A003117A5 /* KeyboardListenerWindow.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = KeyboardListenerWindow.swift; path = Keyboard/KeyboardListenerWindow.swift; sourceTree = ""; };
66 | 7E3646A31C34558D003117A5 /* KeyboardCommandsView.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = KeyboardCommandsView.swift; path = Controllers/KeyboardCommandsView.swift; sourceTree = ""; };
67 | 7E3646A41C34558D003117A5 /* ViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = ViewController.swift; path = Controllers/ViewController.swift; sourceTree = ""; };
68 | 7E3646A81C3455AF003117A5 /* JoystickHelper.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = JoystickHelper.swift; sourceTree = ""; };
69 | 7E3646AA1C3455BB003117A5 /* JoystickViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = JoystickViewController.swift; path = Controllers/JoystickViewController.swift; sourceTree = ""; };
70 | 7E3646AC1C3455D9003117A5 /* Status.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = Status.swift; path = ViewSubclasses/StatusMessages/Status.swift; sourceTree = ""; };
71 | 7E3646AE1C345610003117A5 /* JoystickMapping */ = {isa = PBXFileReference; lastKnownFileType = folder; name = JoystickMapping; path = LiveFlight/libs/JoystickMapping; sourceTree = SOURCE_ROOT; };
72 | 7E3646B01C345668003117A5 /* Main.storyboard */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = file.storyboard; name = Main.storyboard; path = Resources/Main.storyboard; sourceTree = ""; };
73 | 7E5378081C34A4BC006D86F0 /* FlightControls.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = FlightControls.swift; path = Controllers/FlightControls.swift; sourceTree = ""; };
74 | 7E53780A1C3548C9006D86F0 /* OptionsViewController.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; name = OptionsViewController.swift; path = Controllers/OptionsViewController.swift; sourceTree = ""; };
75 | 7E5585D51BD2CD7D0028D9FD /* ControlPadViewController.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ControlPadViewController.h; path = Controllers/ControlPadViewController.h; sourceTree = ""; };
76 | 7E5585D61BD2CD7D0028D9FD /* ControlPadViewController.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ControlPadViewController.m; path = Controllers/ControlPadViewController.m; sourceTree = ""; };
77 | 7E5585D91BD2CDF20028D9FD /* ControlPad.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; name = ControlPad.h; path = ViewSubclasses/ControlPad/ControlPad.h; sourceTree = ""; };
78 | 7E5585DA1BD2CDF20028D9FD /* ControlPad.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; name = ControlPad.m; path = ViewSubclasses/ControlPad/ControlPad.m; sourceTree = ""; };
79 | 7E5764221FDCA8CF0069A489 /* LiveFlight Connect.entitlements */ = {isa = PBXFileReference; lastKnownFileType = text.plist.entitlements; path = "LiveFlight Connect.entitlements"; sourceTree = ""; };
80 | 7E62A56F1B98B9B800D8D2D5 /* InfiniteFlightAPIConnector.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = InfiniteFlightAPIConnector.h; sourceTree = ""; };
81 | 7E62A5701B98B9B800D8D2D5 /* InfiniteFlightAPIConnector.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = InfiniteFlightAPIConnector.m; sourceTree = ""; };
82 | 7E7451691BC9D20000FB1069 /* HTTPSecurity.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = HTTPSecurity.swift; sourceTree = ""; };
83 | 7E74516A1BC9D20000FB1069 /* Operation.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Operation.swift; sourceTree = ""; };
84 | 7E74516B1BC9D20000FB1069 /* Request.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Request.swift; sourceTree = ""; };
85 | 7E74516C1BC9D20000FB1069 /* StatusCode.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = StatusCode.swift; sourceTree = ""; };
86 | 7E74516D1BC9D20000FB1069 /* SwiftHTTP.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = SwiftHTTP.h; sourceTree = ""; };
87 | 7E74516E1BC9D20000FB1069 /* Upload.swift */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.swift; path = Upload.swift; sourceTree = ""; };
88 | 7E7BA5EF1B89DA5200C73DA0 /* LiveFlight Connect.app */ = {isa = PBXFileReference; explicitFileType = wrapper.application; includeInIndex = 0; path = "LiveFlight Connect.app"; sourceTree = BUILT_PRODUCTS_DIR; };
89 | 7E7BA5F31B89DA5200C73DA0 /* Info.plist */ = {isa = PBXFileReference; lastKnownFileType = text.plist.xml; path = Info.plist; sourceTree = ""; };
90 | 7E7BA5F41B89DA5200C73DA0 /* AppDelegate.swift */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.swift; path = AppDelegate.swift; sourceTree = ""; };
91 | 7E7BA5F81B89DA5200C73DA0 /* Images.xcassets */ = {isa = PBXFileReference; lastKnownFileType = folder.assetcatalog; name = Images.xcassets; path = Resources/Images.xcassets; sourceTree = ""; };
92 | 7E7BA6111B8A60FA00C73DA0 /* LiveFlight-Bridging-Header.h */ = {isa = PBXFileReference; lastKnownFileType = sourcecode.c.h; path = "LiveFlight-Bridging-Header.h"; sourceTree = ""; };
93 | 7E7BA6131B8A60FC00C73DA0 /* Joystick.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = Joystick.h; sourceTree = ""; };
94 | 7E7BA6141B8A60FC00C73DA0 /* Joystick.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = Joystick.m; sourceTree = ""; };
95 | 7E7BA6151B8A60FC00C73DA0 /* JoystickHatswitch.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JoystickHatswitch.h; sourceTree = ""; };
96 | 7E7BA6161B8A60FC00C73DA0 /* JoystickHatswitch.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JoystickHatswitch.m; sourceTree = ""; };
97 | 7E7BA6171B8A60FC00C73DA0 /* JoystickNotificationDelegate.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JoystickNotificationDelegate.h; sourceTree = ""; };
98 | 7E7BA6181B8A60FC00C73DA0 /* JoystickManager.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = JoystickManager.h; sourceTree = ""; };
99 | 7E7BA6191B8A60FC00C73DA0 /* JoystickManager.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = JoystickManager.m; sourceTree = ""; };
100 | 7E80A4061BC6BE5100CF70FA /* GCDAsyncUdpSocket.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = GCDAsyncUdpSocket.h; sourceTree = ""; };
101 | 7E80A4071BC6BE5100CF70FA /* GCDAsyncUdpSocket.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = GCDAsyncUdpSocket.m; sourceTree = ""; };
102 | 7E80A4091BC6C19E00CF70FA /* UDPReceiver.h */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.h; path = UDPReceiver.h; sourceTree = ""; };
103 | 7E80A40A1BC6C19E00CF70FA /* UDPReceiver.m */ = {isa = PBXFileReference; fileEncoding = 4; lastKnownFileType = sourcecode.c.objc; path = UDPReceiver.m; sourceTree = ""; };
104 | 7E898E131B936AFD00208F54 /* RoundedIcon.icns */ = {isa = PBXFileReference; lastKnownFileType = image.icns; path = RoundedIcon.icns; sourceTree = ""; };
105 | /* End PBXFileReference section */
106 |
107 | /* Begin PBXFrameworksBuildPhase section */
108 | 7E7BA5EC1B89DA5200C73DA0 /* Frameworks */ = {
109 | isa = PBXFrameworksBuildPhase;
110 | buildActionMask = 2147483647;
111 | files = (
112 | );
113 | runOnlyForDeploymentPostprocessing = 0;
114 | };
115 | /* End PBXFrameworksBuildPhase section */
116 |
117 | /* Begin PBXGroup section */
118 | 7E3646991C3453A6003117A5 /* View Subclasses */ = {
119 | isa = PBXGroup;
120 | children = (
121 | 7E36469A1C3453B3003117A5 /* Status Messages */,
122 | 7E5585DC1BD2CDF50028D9FD /* ControlPad */,
123 | );
124 | name = "View Subclasses";
125 | sourceTree = "";
126 | };
127 | 7E36469A1C3453B3003117A5 /* Status Messages */ = {
128 | isa = PBXGroup;
129 | children = (
130 | 7E3646AC1C3455D9003117A5 /* Status.swift */,
131 | );
132 | name = "Status Messages";
133 | sourceTree = "";
134 | };
135 | 7E36469F1C345540003117A5 /* Keyboard */ = {
136 | isa = PBXGroup;
137 | children = (
138 | 7E3646A01C34557A003117A5 /* KeyboardListenerWindow.swift */,
139 | );
140 | name = Keyboard;
141 | sourceTree = "";
142 | };
143 | 7E5378071C34A4A2006D86F0 /* Controllers */ = {
144 | isa = PBXGroup;
145 | children = (
146 | 7E5378081C34A4BC006D86F0 /* FlightControls.swift */,
147 | );
148 | name = Controllers;
149 | sourceTree = "";
150 | };
151 | 7E5585D81BD2CD8F0028D9FD /* Infinite Flight Connect */ = {
152 | isa = PBXGroup;
153 | children = (
154 | 7E62A56F1B98B9B800D8D2D5 /* InfiniteFlightAPIConnector.h */,
155 | 7E62A5701B98B9B800D8D2D5 /* InfiniteFlightAPIConnector.m */,
156 | 7E80A4091BC6C19E00CF70FA /* UDPReceiver.h */,
157 | 7E80A40A1BC6C19E00CF70FA /* UDPReceiver.m */,
158 | );
159 | path = "Infinite Flight Connect";
160 | sourceTree = "";
161 | };
162 | 7E5585DC1BD2CDF50028D9FD /* ControlPad */ = {
163 | isa = PBXGroup;
164 | children = (
165 | 7E5585D51BD2CD7D0028D9FD /* ControlPadViewController.h */,
166 | 7E5585D61BD2CD7D0028D9FD /* ControlPadViewController.m */,
167 | 7E5585D91BD2CDF20028D9FD /* ControlPad.h */,
168 | 7E5585DA1BD2CDF20028D9FD /* ControlPad.m */,
169 | );
170 | name = ControlPad;
171 | sourceTree = "";
172 | };
173 | 7E7451671BC9D1E400FB1069 /* GCDAsyncUDPSocket */ = {
174 | isa = PBXGroup;
175 | children = (
176 | 7E80A4061BC6BE5100CF70FA /* GCDAsyncUdpSocket.h */,
177 | 7E80A4071BC6BE5100CF70FA /* GCDAsyncUdpSocket.m */,
178 | );
179 | name = GCDAsyncUDPSocket;
180 | path = ../libs/CocoaAsyncSocket/Source/GCD;
181 | sourceTree = "";
182 | };
183 | 7E7451741BC9D20600FB1069 /* SwiftHTTP */ = {
184 | isa = PBXGroup;
185 | children = (
186 | 7E7451691BC9D20000FB1069 /* HTTPSecurity.swift */,
187 | 7E74516A1BC9D20000FB1069 /* Operation.swift */,
188 | 7E74516B1BC9D20000FB1069 /* Request.swift */,
189 | 7E74516C1BC9D20000FB1069 /* StatusCode.swift */,
190 | 7E74516D1BC9D20000FB1069 /* SwiftHTTP.h */,
191 | 7E74516E1BC9D20000FB1069 /* Upload.swift */,
192 | );
193 | name = SwiftHTTP;
194 | path = ../libs/SwiftHTTP/Source;
195 | sourceTree = "";
196 | };
197 | 7E7BA5E61B89DA5200C73DA0 = {
198 | isa = PBXGroup;
199 | children = (
200 | 7E7BA5F11B89DA5200C73DA0 /* LiveFlight */,
201 | 7E7BA5F01B89DA5200C73DA0 /* Products */,
202 | );
203 | sourceTree = "";
204 | };
205 | 7E7BA5F01B89DA5200C73DA0 /* Products */ = {
206 | isa = PBXGroup;
207 | children = (
208 | 7E7BA5EF1B89DA5200C73DA0 /* LiveFlight Connect.app */,
209 | );
210 | name = Products;
211 | sourceTree = "";
212 | };
213 | 7E7BA5F11B89DA5200C73DA0 /* LiveFlight */ = {
214 | isa = PBXGroup;
215 | children = (
216 | 7E5764221FDCA8CF0069A489 /* LiveFlight Connect.entitlements */,
217 | 7E7BA5F41B89DA5200C73DA0 /* AppDelegate.swift */,
218 | 7E3646A41C34558D003117A5 /* ViewController.swift */,
219 | 7E3646AA1C3455BB003117A5 /* JoystickViewController.swift */,
220 | 7E3646A31C34558D003117A5 /* KeyboardCommandsView.swift */,
221 | 7E53780A1C3548C9006D86F0 /* OptionsViewController.swift */,
222 | 7E3646B01C345668003117A5 /* Main.storyboard */,
223 | 7E7BA5F81B89DA5200C73DA0 /* Images.xcassets */,
224 | 7E5378071C34A4A2006D86F0 /* Controllers */,
225 | 7E3646991C3453A6003117A5 /* View Subclasses */,
226 | 7E36469F1C345540003117A5 /* Keyboard */,
227 | 7EC762AA1C2DF315006FF9B8 /* Joystick */,
228 | 7E5585D81BD2CD8F0028D9FD /* Infinite Flight Connect */,
229 | 7E7BA5F21B89DA5200C73DA0 /* Supporting Files */,
230 | 7E7BA6111B8A60FA00C73DA0 /* LiveFlight-Bridging-Header.h */,
231 | );
232 | path = LiveFlight;
233 | sourceTree = "";
234 | };
235 | 7E7BA5F21B89DA5200C73DA0 /* Supporting Files */ = {
236 | isa = PBXGroup;
237 | children = (
238 | 7E2045941BCAF95A00A03F11 /* Credits.rtf */,
239 | 7E3646AE1C345610003117A5 /* JoystickMapping */,
240 | 7E7451671BC9D1E400FB1069 /* GCDAsyncUDPSocket */,
241 | 7E7451741BC9D20600FB1069 /* SwiftHTTP */,
242 | 7E36469D1C3454EF003117A5 /* Reachability.swift */,
243 | 7E898E131B936AFD00208F54 /* RoundedIcon.icns */,
244 | 7E7BA5F31B89DA5200C73DA0 /* Info.plist */,
245 | );
246 | name = "Supporting Files";
247 | path = Resources;
248 | sourceTree = "";
249 | };
250 | 7EC762AA1C2DF315006FF9B8 /* Joystick */ = {
251 | isa = PBXGroup;
252 | children = (
253 | 7E3646A81C3455AF003117A5 /* JoystickHelper.swift */,
254 | 7E7BA6131B8A60FC00C73DA0 /* Joystick.h */,
255 | 7E7BA6141B8A60FC00C73DA0 /* Joystick.m */,
256 | 7E7BA6151B8A60FC00C73DA0 /* JoystickHatswitch.h */,
257 | 7E7BA6161B8A60FC00C73DA0 /* JoystickHatswitch.m */,
258 | 7E7BA6171B8A60FC00C73DA0 /* JoystickNotificationDelegate.h */,
259 | 7E7BA6181B8A60FC00C73DA0 /* JoystickManager.h */,
260 | 7E7BA6191B8A60FC00C73DA0 /* JoystickManager.m */,
261 | );
262 | path = Joystick;
263 | sourceTree = "";
264 | };
265 | /* End PBXGroup section */
266 |
267 | /* Begin PBXNativeTarget section */
268 | 7E7BA5EE1B89DA5200C73DA0 /* LiveFlight */ = {
269 | isa = PBXNativeTarget;
270 | buildConfigurationList = 7E7BA60B1B89DA5200C73DA0 /* Build configuration list for PBXNativeTarget "LiveFlight" */;
271 | buildPhases = (
272 | 7E7BA5EB1B89DA5200C73DA0 /* Sources */,
273 | 7E7BA5EC1B89DA5200C73DA0 /* Frameworks */,
274 | 7E7BA5ED1B89DA5200C73DA0 /* Resources */,
275 | 7E0FCBEE1B957B3800403E57 /* Embed Frameworks */,
276 | 7EA3C8271C2E0D9B00B6C5AC /* CopyFiles */,
277 | );
278 | buildRules = (
279 | );
280 | dependencies = (
281 | );
282 | name = LiveFlight;
283 | productName = LiveFlight;
284 | productReference = 7E7BA5EF1B89DA5200C73DA0 /* LiveFlight Connect.app */;
285 | productType = "com.apple.product-type.application";
286 | };
287 | /* End PBXNativeTarget section */
288 |
289 | /* Begin PBXProject section */
290 | 7E7BA5E71B89DA5200C73DA0 /* Project object */ = {
291 | isa = PBXProject;
292 | attributes = {
293 | LastSwiftMigration = 0700;
294 | LastSwiftUpdateCheck = 0700;
295 | LastUpgradeCheck = 0700;
296 | ORGANIZATIONNAME = "Cameron Carmichael Alonso";
297 | TargetAttributes = {
298 | 7E7BA5EE1B89DA5200C73DA0 = {
299 | CreatedOnToolsVersion = 6.4;
300 | DevelopmentTeam = 56U9FMKHJR;
301 | SystemCapabilities = {
302 | com.apple.Sandbox = {
303 | enabled = 1;
304 | };
305 | };
306 | };
307 | };
308 | };
309 | buildConfigurationList = 7E7BA5EA1B89DA5200C73DA0 /* Build configuration list for PBXProject "LiveFlight" */;
310 | compatibilityVersion = "Xcode 3.2";
311 | developmentRegion = English;
312 | hasScannedForEncodings = 0;
313 | knownRegions = (
314 | en,
315 | Base,
316 | );
317 | mainGroup = 7E7BA5E61B89DA5200C73DA0;
318 | productRefGroup = 7E7BA5F01B89DA5200C73DA0 /* Products */;
319 | projectDirPath = "";
320 | projectRoot = "";
321 | targets = (
322 | 7E7BA5EE1B89DA5200C73DA0 /* LiveFlight */,
323 | );
324 | };
325 | /* End PBXProject section */
326 |
327 | /* Begin PBXResourcesBuildPhase section */
328 | 7E7BA5ED1B89DA5200C73DA0 /* Resources */ = {
329 | isa = PBXResourcesBuildPhase;
330 | buildActionMask = 2147483647;
331 | files = (
332 | 7E7BA5F91B89DA5200C73DA0 /* Images.xcassets in Resources */,
333 | 7E3646B11C345668003117A5 /* Main.storyboard in Resources */,
334 | 7E3646AF1C345610003117A5 /* JoystickMapping in Resources */,
335 | 7E898E141B936AFD00208F54 /* RoundedIcon.icns in Resources */,
336 | 7E2045951BCAF95A00A03F11 /* Credits.rtf in Resources */,
337 | );
338 | runOnlyForDeploymentPostprocessing = 0;
339 | };
340 | /* End PBXResourcesBuildPhase section */
341 |
342 | /* Begin PBXSourcesBuildPhase section */
343 | 7E7BA5EB1B89DA5200C73DA0 /* Sources */ = {
344 | isa = PBXSourcesBuildPhase;
345 | buildActionMask = 2147483647;
346 | files = (
347 | 7E3646A11C34557A003117A5 /* KeyboardListenerWindow.swift in Sources */,
348 | 7E5585DB1BD2CDF20028D9FD /* ControlPad.m in Sources */,
349 | 7E53780B1C3548C9006D86F0 /* OptionsViewController.swift in Sources */,
350 | 7E74516F1BC9D20000FB1069 /* HTTPSecurity.swift in Sources */,
351 | 7E80A4081BC6BE5100CF70FA /* GCDAsyncUdpSocket.m in Sources */,
352 | 7E62A5711B98B9B800D8D2D5 /* InfiniteFlightAPIConnector.m in Sources */,
353 | 7E3646A91C3455AF003117A5 /* JoystickHelper.swift in Sources */,
354 | 7E80A40B1BC6C19E00CF70FA /* UDPReceiver.m in Sources */,
355 | 7E3646AD1C3455D9003117A5 /* Status.swift in Sources */,
356 | 7E3646A71C34558D003117A5 /* ViewController.swift in Sources */,
357 | 7E7BA61C1B8A60FC00C73DA0 /* JoystickHatswitch.m in Sources */,
358 | 7E3646AB1C3455BB003117A5 /* JoystickViewController.swift in Sources */,
359 | 7E7BA61B1B8A60FC00C73DA0 /* Joystick.m in Sources */,
360 | 7E7BA61D1B8A60FC00C73DA0 /* JoystickManager.m in Sources */,
361 | 7E5585D71BD2CD7D0028D9FD /* ControlPadViewController.m in Sources */,
362 | 7E7451701BC9D20000FB1069 /* Operation.swift in Sources */,
363 | 7E36469E1C3454EF003117A5 /* Reachability.swift in Sources */,
364 | 7E7451721BC9D20000FB1069 /* StatusCode.swift in Sources */,
365 | 7E3646A61C34558D003117A5 /* KeyboardCommandsView.swift in Sources */,
366 | 7E7451731BC9D20000FB1069 /* Upload.swift in Sources */,
367 | 7E5378091C34A4BC006D86F0 /* FlightControls.swift in Sources */,
368 | 7E7451711BC9D20000FB1069 /* Request.swift in Sources */,
369 | 7E7BA5F51B89DA5200C73DA0 /* AppDelegate.swift in Sources */,
370 | );
371 | runOnlyForDeploymentPostprocessing = 0;
372 | };
373 | /* End PBXSourcesBuildPhase section */
374 |
375 | /* Begin XCBuildConfiguration section */
376 | 7E7BA6091B89DA5200C73DA0 /* Debug */ = {
377 | isa = XCBuildConfiguration;
378 | buildSettings = {
379 | ALWAYS_SEARCH_USER_PATHS = NO;
380 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
381 | CLANG_CXX_LIBRARY = "libc++";
382 | CLANG_ENABLE_MODULES = YES;
383 | CLANG_ENABLE_OBJC_ARC = YES;
384 | CLANG_WARN_BOOL_CONVERSION = YES;
385 | CLANG_WARN_CONSTANT_CONVERSION = YES;
386 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
387 | CLANG_WARN_EMPTY_BODY = YES;
388 | CLANG_WARN_ENUM_CONVERSION = YES;
389 | CLANG_WARN_INT_CONVERSION = YES;
390 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
391 | CLANG_WARN_UNREACHABLE_CODE = YES;
392 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
393 | CODE_SIGN_IDENTITY = "-";
394 | COPY_PHASE_STRIP = NO;
395 | DEBUG_INFORMATION_FORMAT = dwarf;
396 | ENABLE_STRICT_OBJC_MSGSEND = YES;
397 | ENABLE_TESTABILITY = YES;
398 | GCC_C_LANGUAGE_STANDARD = gnu99;
399 | GCC_DYNAMIC_NO_PIC = NO;
400 | GCC_NO_COMMON_BLOCKS = YES;
401 | GCC_OPTIMIZATION_LEVEL = 0;
402 | GCC_PREPROCESSOR_DEFINITIONS = (
403 | "DEBUG=1",
404 | "$(inherited)",
405 | );
406 | GCC_SYMBOLS_PRIVATE_EXTERN = NO;
407 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
408 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
409 | GCC_WARN_UNDECLARED_SELECTOR = YES;
410 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
411 | GCC_WARN_UNUSED_FUNCTION = YES;
412 | GCC_WARN_UNUSED_VARIABLE = YES;
413 | MACOSX_DEPLOYMENT_TARGET = 10.10;
414 | MTL_ENABLE_DEBUG_INFO = YES;
415 | ONLY_ACTIVE_ARCH = YES;
416 | SDKROOT = macosx;
417 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
418 | };
419 | name = Debug;
420 | };
421 | 7E7BA60A1B89DA5200C73DA0 /* Release */ = {
422 | isa = XCBuildConfiguration;
423 | buildSettings = {
424 | ALWAYS_SEARCH_USER_PATHS = NO;
425 | CLANG_CXX_LANGUAGE_STANDARD = "gnu++0x";
426 | CLANG_CXX_LIBRARY = "libc++";
427 | CLANG_ENABLE_MODULES = YES;
428 | CLANG_ENABLE_OBJC_ARC = YES;
429 | CLANG_WARN_BOOL_CONVERSION = YES;
430 | CLANG_WARN_CONSTANT_CONVERSION = YES;
431 | CLANG_WARN_DIRECT_OBJC_ISA_USAGE = YES_ERROR;
432 | CLANG_WARN_EMPTY_BODY = YES;
433 | CLANG_WARN_ENUM_CONVERSION = YES;
434 | CLANG_WARN_INT_CONVERSION = YES;
435 | CLANG_WARN_OBJC_ROOT_CLASS = YES_ERROR;
436 | CLANG_WARN_UNREACHABLE_CODE = YES;
437 | CLANG_WARN__DUPLICATE_METHOD_MATCH = YES;
438 | CODE_SIGN_IDENTITY = "-";
439 | COPY_PHASE_STRIP = NO;
440 | DEBUG_INFORMATION_FORMAT = "dwarf-with-dsym";
441 | ENABLE_NS_ASSERTIONS = NO;
442 | ENABLE_STRICT_OBJC_MSGSEND = YES;
443 | GCC_C_LANGUAGE_STANDARD = gnu99;
444 | GCC_NO_COMMON_BLOCKS = YES;
445 | GCC_WARN_64_TO_32_BIT_CONVERSION = YES;
446 | GCC_WARN_ABOUT_RETURN_TYPE = YES_ERROR;
447 | GCC_WARN_UNDECLARED_SELECTOR = YES;
448 | GCC_WARN_UNINITIALIZED_AUTOS = YES_AGGRESSIVE;
449 | GCC_WARN_UNUSED_FUNCTION = YES;
450 | GCC_WARN_UNUSED_VARIABLE = YES;
451 | MACOSX_DEPLOYMENT_TARGET = 10.10;
452 | MTL_ENABLE_DEBUG_INFO = NO;
453 | SDKROOT = macosx;
454 | };
455 | name = Release;
456 | };
457 | 7E7BA60C1B89DA5200C73DA0 /* Debug */ = {
458 | isa = XCBuildConfiguration;
459 | buildSettings = {
460 | CLANG_ENABLE_MODULES = YES;
461 | CODE_SIGN_ENTITLEMENTS = "LiveFlight/LiveFlight Connect.entitlements";
462 | CODE_SIGN_IDENTITY = "Mac Developer";
463 | COMBINE_HIDPI_IMAGES = YES;
464 | DEVELOPMENT_TEAM = 56U9FMKHJR;
465 | FRAMEWORK_SEARCH_PATHS = (
466 | "$(inherited)",
467 | "$(PROJECT_DIR)",
468 | "$(PROJECT_DIR)/LiveFlight",
469 | );
470 | INFOPLIST_FILE = "$(SRCROOT)/LiveFlight/Resources/Info.plist";
471 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
472 | MACOSX_DEPLOYMENT_TARGET = 10.10;
473 | PRODUCT_BUNDLE_IDENTIFIER = com.liveflight.connect.mac;
474 | PRODUCT_NAME = "LiveFlight Connect";
475 | SWIFT_OBJC_BRIDGING_HEADER = "LiveFlight/LiveFlight-Bridging-Header.h";
476 | SWIFT_OBJC_INTERFACE_HEADER_NAME = "Connect-Swift.h";
477 | SWIFT_OPTIMIZATION_LEVEL = "-Onone";
478 | SWIFT_VERSION = 4.0;
479 | };
480 | name = Debug;
481 | };
482 | 7E7BA60D1B89DA5200C73DA0 /* Release */ = {
483 | isa = XCBuildConfiguration;
484 | buildSettings = {
485 | CLANG_ENABLE_MODULES = YES;
486 | CODE_SIGN_ENTITLEMENTS = "LiveFlight/LiveFlight Connect.entitlements";
487 | CODE_SIGN_IDENTITY = "Mac Developer";
488 | COMBINE_HIDPI_IMAGES = YES;
489 | DEVELOPMENT_TEAM = 56U9FMKHJR;
490 | FRAMEWORK_SEARCH_PATHS = (
491 | "$(inherited)",
492 | "$(PROJECT_DIR)",
493 | "$(PROJECT_DIR)/LiveFlight",
494 | );
495 | INFOPLIST_FILE = "$(SRCROOT)/LiveFlight/Resources/Info.plist";
496 | LD_RUNPATH_SEARCH_PATHS = "$(inherited) @executable_path/../Frameworks";
497 | MACOSX_DEPLOYMENT_TARGET = 10.10;
498 | PRODUCT_BUNDLE_IDENTIFIER = com.liveflight.connect.mac;
499 | PRODUCT_NAME = "LiveFlight Connect";
500 | SWIFT_OBJC_BRIDGING_HEADER = "LiveFlight/LiveFlight-Bridging-Header.h";
501 | SWIFT_OBJC_INTERFACE_HEADER_NAME = "Connect-Swift.h";
502 | SWIFT_VERSION = 4.0;
503 | };
504 | name = Release;
505 | };
506 | /* End XCBuildConfiguration section */
507 |
508 | /* Begin XCConfigurationList section */
509 | 7E7BA5EA1B89DA5200C73DA0 /* Build configuration list for PBXProject "LiveFlight" */ = {
510 | isa = XCConfigurationList;
511 | buildConfigurations = (
512 | 7E7BA6091B89DA5200C73DA0 /* Debug */,
513 | 7E7BA60A1B89DA5200C73DA0 /* Release */,
514 | );
515 | defaultConfigurationIsVisible = 0;
516 | defaultConfigurationName = Release;
517 | };
518 | 7E7BA60B1B89DA5200C73DA0 /* Build configuration list for PBXNativeTarget "LiveFlight" */ = {
519 | isa = XCConfigurationList;
520 | buildConfigurations = (
521 | 7E7BA60C1B89DA5200C73DA0 /* Debug */,
522 | 7E7BA60D1B89DA5200C73DA0 /* Release */,
523 | );
524 | defaultConfigurationIsVisible = 0;
525 | defaultConfigurationName = Release;
526 | };
527 | /* End XCConfigurationList section */
528 | };
529 | rootObject = 7E7BA5E71B89DA5200C73DA0 /* Project object */;
530 | }
531 |
--------------------------------------------------------------------------------
/LiveFlight.xcodeproj/project.xcworkspace/contents.xcworkspacedata:
--------------------------------------------------------------------------------
1 |
2 |
4 |
6 |
7 |
8 |
--------------------------------------------------------------------------------
/LiveFlight.xcodeproj/project.xcworkspace/xcshareddata/LiveFlight.xcscmblueprint:
--------------------------------------------------------------------------------
1 | {
2 | "DVTSourceControlWorkspaceBlueprintPrimaryRemoteRepositoryKey" : "BC2670E18992FD8F65B0857F9F403780F58342B7",
3 | "DVTSourceControlWorkspaceBlueprintWorkingCopyRepositoryLocationsKey" : {
4 |
5 | },
6 | "DVTSourceControlWorkspaceBlueprintWorkingCopyStatesKey" : {
7 | "BE6F11D2B0F7EBDD3A2A4B2F7B7F7393B556F9B2" : 0,
8 | "BC2670E18992FD8F65B0857F9F403780F58342B7" : 0,
9 | "1C75F1C5CFCB95B3702F6F632FA05ED5244B519E" : 0,
10 | "E212CE6A13F37CE1A577B6EE0BE9609B0AA640C7" : 0,
11 | "38D9009B322140394B9DA7467F68950B56B35FF5" : 0,
12 | "C80AFB7225A37FEAFA1F491650DBF487A76F4002" : 0,
13 | "E927118175B406BA97482F6E559E9F24FC1101D6" : 0
14 | },
15 | "DVTSourceControlWorkspaceBlueprintIdentifierKey" : "20201EAB-DCDD-4212-B3A9-A220C1FE8F2A",
16 | "DVTSourceControlWorkspaceBlueprintWorkingCopyPathsKey" : {
17 | "BE6F11D2B0F7EBDD3A2A4B2F7B7F7393B556F9B2" : "src\/LiveFlight\/libs\/Reachability.swift\/",
18 | "BC2670E18992FD8F65B0857F9F403780F58342B7" : "Connect-OSX\/",
19 | "1C75F1C5CFCB95B3702F6F632FA05ED5244B519E" : "Connect-OSX\/LiveFlight\/libs\/CocoaAsyncSocket\/",
20 | "E212CE6A13F37CE1A577B6EE0BE9609B0AA640C7" : "src\/LiveFlight\/countly-sdk-ios\/",
21 | "38D9009B322140394B9DA7467F68950B56B35FF5" : "Connect-OSX\/LiveFlight\/libs\/SwiftHTTP\/",
22 | "C80AFB7225A37FEAFA1F491650DBF487A76F4002" : "Connect-OSX\/LiveFlight\/libs\/JoystickMapping\/",
23 | "E927118175B406BA97482F6E559E9F24FC1101D6" : "..\/.."
24 | },
25 | "DVTSourceControlWorkspaceBlueprintNameKey" : "LiveFlight",
26 | "DVTSourceControlWorkspaceBlueprintVersion" : 204,
27 | "DVTSourceControlWorkspaceBlueprintRelativePathToProjectKey" : "LiveFlight.xcodeproj",
28 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoriesKey" : [
29 | {
30 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/robbiehanson\/CocoaAsyncSocket",
31 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
32 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "1C75F1C5CFCB95B3702F6F632FA05ED5244B519E"
33 | },
34 | {
35 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/daltoniam\/SwiftHTTP",
36 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
37 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "38D9009B322140394B9DA7467F68950B56B35FF5"
38 | },
39 | {
40 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/LiveFlightApp\/Connect-OSX.git",
41 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
42 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BC2670E18992FD8F65B0857F9F403780F58342B7"
43 | },
44 | {
45 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/ashleymills\/Reachability.swift",
46 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
47 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "BE6F11D2B0F7EBDD3A2A4B2F7B7F7393B556F9B2"
48 | },
49 | {
50 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/LiveFlightApp\/JoystickMapping",
51 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
52 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "C80AFB7225A37FEAFA1F491650DBF487A76F4002"
53 | },
54 | {
55 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/countly\/countly-sdk-ios",
56 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
57 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "E212CE6A13F37CE1A577B6EE0BE9609B0AA640C7"
58 | },
59 | {
60 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryURLKey" : "https:\/\/github.com\/carmichaelalonso\/LiveFlight.git",
61 | "DVTSourceControlWorkspaceBlueprintRemoteRepositorySystemKey" : "com.apple.dt.Xcode.sourcecontrol.Git",
62 | "DVTSourceControlWorkspaceBlueprintRemoteRepositoryIdentifierKey" : "E927118175B406BA97482F6E559E9F24FC1101D6"
63 | }
64 | ]
65 | }
--------------------------------------------------------------------------------
/LiveFlight/AppDelegate.swift:
--------------------------------------------------------------------------------
1 | //
2 | // AppDelegate.swift
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 23/08/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | @NSApplicationMain
12 | class AppDelegate: NSObject, NSApplicationDelegate {
13 |
14 | @IBOutlet weak var window: NSWindow!
15 | @IBOutlet var gamepadModeButton: NSMenuItem!
16 | @IBOutlet var logButton: NSMenuItem!
17 | @IBOutlet var packetSpacingButton: NSMenuItem!
18 | var optionsWindow: NSWindowController!
19 | var reachability: Reachability?
20 | var receiver = UDPReceiver()
21 | @objc var connector = InfiniteFlightAPIConnector()
22 | var joystickHelper = JoystickHelper()
23 |
24 | func applicationWillFinishLaunching(_ notification: Notification) {
25 |
26 | /*
27 | Load Settings
28 | ========================
29 | */
30 |
31 |
32 | // we always save to app sandbox
33 | if let dir : String = NSSearchPathForDirectoriesInDomains(FileManager.SearchPathDirectory.libraryDirectory, FileManager.SearchPathDomainMask.allDomainsMask, true).first {
34 |
35 | let logDir = "\(dir)/Logs"
36 | UserDefaults.standard.set(String(logDir), forKey: "logPath")
37 |
38 | }
39 |
40 |
41 | if UserDefaults.standard.bool(forKey: "logging") == true {
42 |
43 | //output to file
44 | let file = "LiveFlight_Connect.log"
45 |
46 | if let dir : String = UserDefaults.standard.string(forKey: "logPath") {
47 |
48 | NSLog("Logging enabled to directory: %@", dir)
49 |
50 | let path = String(describing: URL(string: dir)!.appendingPathComponent(file));
51 |
52 | //remove old file
53 | do {
54 | try FileManager.default.removeItem(atPath: path)
55 | }
56 | catch let error as NSError {
57 | error.description
58 | }
59 |
60 | freopen(path.cString(using: String.Encoding.ascii)!, "a+", stderr)
61 |
62 | }
63 |
64 | UserDefaults.standard.set(true, forKey: "logging")
65 | logButton.state = NSControl.StateValue(rawValue: 1)
66 |
67 | } else {
68 |
69 | UserDefaults.standard.set(false, forKey: "logging")
70 | logButton.state = NSControl.StateValue(rawValue: 0)
71 | }
72 |
73 | // set gamepad mode toggle
74 | if UserDefaults.standard.bool(forKey: "gamepadMode") == true {
75 |
76 | gamepadModeButton.state = NSControl.StateValue(rawValue: 1)
77 |
78 | } else {
79 |
80 | gamepadModeButton.state = NSControl.StateValue(rawValue: 0)
81 |
82 | }
83 |
84 |
85 | //set delay button appropriately
86 | let currentDelay = UserDefaults.standard.integer(forKey: "packetDelay")
87 | let currentDelaySetup = UserDefaults.standard.bool(forKey: "packetDelaySetup")
88 |
89 |
90 | if currentDelaySetup == false {
91 | //set to 10ms as default
92 | UserDefaults.standard.set(10, forKey: "packetDelay")
93 | UserDefaults.standard.set(true, forKey: "packetDelaySetup")
94 | packetSpacingButton.title = "Toggle Delay Between Packets (10ms)"
95 |
96 | //set all axes to -2
97 | UserDefaults.standard.set(-2, forKey: "pitch")
98 | UserDefaults.standard.set(-2, forKey: "roll")
99 | UserDefaults.standard.set(-2, forKey: "throttle")
100 | UserDefaults.standard.set(-2, forKey: "rudder")
101 |
102 |
103 | } else {
104 | packetSpacingButton.title = "Toggle Delay Between Packets (\(currentDelay)ms)"
105 |
106 | }
107 |
108 |
109 | logAppInfo()
110 | }
111 |
112 | func applicationDidFinishLaunching(_ notification: Notification) {
113 |
114 | /*
115 | Check Networking Status
116 | ========================
117 | */
118 |
119 | do {
120 | reachability = try Reachability(hostname: "http://www.liveflightapp.com/")
121 | } catch ReachabilityError.FailedToCreateWithAddress(_) {
122 | NSLog("Failed to create connection")
123 | return
124 | } catch {}
125 |
126 |
127 | #if RELEASE
128 |
129 | /*
130 | App Store Release
131 | ========================
132 | */
133 | Release().setupReleaseFrameworks()
134 |
135 | #endif
136 |
137 |
138 | /*
139 | Init Networking
140 | ========================
141 | */
142 |
143 | receiver = UDPReceiver()
144 | receiver.startUDPListener()
145 |
146 |
147 | }
148 |
149 | func applicationWillTerminate(aNotification: NSNotification) {
150 | // Insert code here to tear down your application
151 | }
152 |
153 | func applicationShouldTerminateAfterLastWindowClosed(_ sender: NSApplication) -> Bool {
154 | return true
155 | }
156 |
157 | func logAppInfo() {
158 |
159 | let nsObject = Bundle.main.infoDictionary!["CFBundleShortVersionString"]
160 | let bundleVersion = nsObject as! String
161 | NSLog("LiveFlight Connect version \(bundleVersion)")
162 | NSLog("OS: \(ProcessInfo().operatingSystemVersionString)")
163 | NSLog("AppKit: \(NSAppKitVersion.current)")
164 | NSLog("IFAddresses: \(getIFAddresses())")
165 |
166 | NSLog("\n\n")
167 | }
168 |
169 |
170 | /*
171 | Menu Settings
172 | ========================
173 | */
174 |
175 | @IBAction func openJoystickGuide(sender: AnyObject) {
176 |
177 | let forumURL = "https://help.liveflightapp.com/hc/en-us/sections/115000759493-LiveFlight-Connect"
178 | NSWorkspace.shared.open(URL(string: forumURL)!)
179 |
180 | }
181 |
182 | @IBAction func openTerms(sender: AnyObject) {
183 |
184 | let forumURL = "https://help.liveflightapp.com/hc/en-us/articles/115003332994-Terms-of-Service"
185 | NSWorkspace.shared.open(URL(string: forumURL)!)
186 |
187 | }
188 |
189 | @IBAction func openPrivacyPolicy(sender: AnyObject) {
190 |
191 | let forumURL = "https://help.liveflightapp.com/hc/en-us/articles/115003327793-Privacy-Policy"
192 | NSWorkspace.shared.open(URL(string: forumURL)!)
193 |
194 | }
195 |
196 | @IBAction func openGitHub(sender: AnyObject) {
197 |
198 | let githubURL = "https://github.com/LiveFlightApp/Connect-OSX"
199 | NSWorkspace.shared.open(URL(string: githubURL)!)
200 |
201 | }
202 |
203 | @IBAction func openForum(sender: AnyObject) {
204 |
205 | let forumURL = "https://community.infinite-flight.com/"
206 | NSWorkspace.shared.open(URL(string: forumURL)!)
207 |
208 | }
209 |
210 | @IBAction func openLiveFlight(sender: AnyObject) {
211 |
212 | let liveFlightURL = "http://www.liveflightapp.com"
213 | NSWorkspace.shared.open(URL(string: liveFlightURL)!)
214 |
215 | }
216 |
217 | @IBAction func openLiveFlightFacebook(sender: AnyObject) {
218 |
219 | let liveFlightURL = "http://www.facebook.com/liveflightapp"
220 | NSWorkspace.shared.open(URL(string: liveFlightURL)!)
221 |
222 | }
223 |
224 | @IBAction func openLiveFlightTwitter(sender: AnyObject) {
225 |
226 | let liveFlightURL = "http://www.twitter.com/liveflightapp"
227 | NSWorkspace.shared.open(URL(string: liveFlightURL)!)
228 |
229 | }
230 |
231 | @IBAction func toggleGamepadMode(sender: AnyObject) {
232 | // enable/disable gamepad mode
233 |
234 | if gamepadModeButton.state.rawValue == 0 {
235 | //enable
236 | gamepadModeButton.state = NSControl.StateValue(rawValue: 1)
237 | UserDefaults.standard.set(true, forKey: "gamepadMode")
238 | } else {
239 | gamepadModeButton.state = NSControl.StateValue(rawValue: 0)
240 | UserDefaults.standard.set(false, forKey: "gamepadMode")
241 | }
242 |
243 | }
244 |
245 | @IBAction func toggleLogging(sender: AnyObject) {
246 | //enable/disable logging
247 |
248 | if logButton.state.rawValue == 0 {
249 | //enable
250 | logButton.state = NSControl.StateValue(rawValue: 1)
251 | UserDefaults.standard.set(true, forKey: "logging")
252 | } else {
253 | logButton.state = NSControl.StateValue(rawValue: 0)
254 | UserDefaults.standard.set(false, forKey: "logging")
255 | }
256 |
257 | }
258 |
259 | @IBAction func togglePacketSpacing(sender: AnyObject) {
260 | //change delay between sending packets
261 | //0, 10, 20, 50ms.
262 |
263 | let currentDelay = UserDefaults.standard.integer(forKey: "packetDelay")
264 |
265 | if currentDelay == 0 {
266 | //set to 10
267 | UserDefaults.standard.set(10, forKey: "packetDelay")
268 | packetSpacingButton.title = "Toggle Delay Between Packets (10ms)"
269 |
270 | } else if currentDelay == 10 {
271 | //set to 20
272 | UserDefaults.standard.set(20, forKey: "packetDelay")
273 | packetSpacingButton.title = "Toggle Delay Between Packets (20ms)"
274 |
275 | } else if currentDelay == 20 {
276 | //set to 50
277 | UserDefaults.standard.set(50, forKey: "packetDelay")
278 | packetSpacingButton.title = "Toggle Delay Between Packets (50ms)"
279 |
280 | } else {
281 | //set to 0
282 | UserDefaults.standard.set(0, forKey: "packetDelay")
283 | packetSpacingButton.title = "Toggle Delay Between Packets (0ms)"
284 |
285 | }
286 |
287 | }
288 |
289 | @IBAction func openOptionsWindow(sender: AnyObject) {
290 | let storyboard = NSStoryboard(name: NSStoryboard.Name(rawValue: "Main"), bundle: nil)
291 | optionsWindow = storyboard.instantiateController(withIdentifier: NSStoryboard.SceneIdentifier(rawValue: "optionsWindow")) as! NSWindowController
292 |
293 | optionsWindow.showWindow(self)
294 |
295 | }
296 |
297 | @IBAction func nextCamera(sender: AnyObject) {
298 | connector.nextCamera()
299 | }
300 |
301 | @IBAction func previousCamera(sender: AnyObject) {
302 | connector.previousCamera()
303 | }
304 |
305 | @IBAction func cockpitCamera(sender: AnyObject) {
306 | connector.cockpitCamera()
307 | }
308 |
309 | @IBAction func vcCamera(sender: AnyObject) {
310 | connector.vcCamera()
311 | }
312 |
313 | @IBAction func followCamera(sender: AnyObject) {
314 | connector.followCamera()
315 | }
316 |
317 | @IBAction func onBoardCamera(sender: AnyObject) {
318 | connector.onboardCamera()
319 | }
320 |
321 | @IBAction func flybyCamera(sender: AnyObject) {
322 | connector.flybyCamera()
323 | }
324 |
325 | @IBAction func towerCamera(sender: AnyObject) {
326 | connector.towerCamera()
327 | }
328 |
329 | @IBAction func landingGear(sender: AnyObject) {
330 | connector.landingGear()
331 | }
332 |
333 | @IBAction func spoilers(sender: AnyObject) {
334 | connector.spoilers()
335 | }
336 |
337 | @IBAction func flapsUp(sender: AnyObject) {
338 | connector.flapsUp()
339 | }
340 |
341 | @IBAction func flapsDown(sender: AnyObject) {
342 | connector.flapsDown()
343 | }
344 |
345 | @IBAction func brakes(sender: AnyObject) {
346 | connector.parkingBrakes()
347 | }
348 |
349 | @IBAction func autopilot(sender: AnyObject) {
350 | connector.autopilot()
351 | }
352 |
353 | @IBAction func pushback(sender: AnyObject) {
354 | connector.pushback()
355 | }
356 |
357 | @IBAction func pause(sender: AnyObject) {
358 | connector.togglePause()
359 | }
360 |
361 | @IBAction func landingLight(sender: AnyObject) {
362 | connector.landing()
363 | }
364 |
365 | @IBAction func strobeLight(sender: AnyObject) {
366 | connector.strobe()
367 | }
368 |
369 | @IBAction func beaconLight(sender: AnyObject) {
370 | connector.beacon()
371 | }
372 |
373 | @IBAction func navLight(sender: AnyObject) {
374 | connector.nav()
375 | }
376 |
377 | @IBAction func atcMenu(sender: AnyObject) {
378 | connector.atcMenu()
379 | }
380 |
381 | func getIFAddresses() -> [String] {
382 | /*var addresses = [String]()
383 |
384 | // Get list of all interfaces on the local machine:
385 | var ifaddr : UnsafeMutablePointer? = nil
386 | if getifaddrs(&ifaddr) == 0 {
387 |
388 | // For each interface ...
389 | for (var ptr = ifaddr; ptr != nil; ptr = ptr.memory.ifa_next) {
390 | let flags = Int32(ptr.memory.ifa_flags)
391 | var addr = ptr.memory.ifa_addr.memory
392 |
393 | // Check for running IPv4, IPv6 interfaces. Skip the loopback interface.
394 | if (flags & (IFF_UP|IFF_RUNNING|IFF_LOOPBACK)) == (IFF_UP|IFF_RUNNING) {
395 | if addr.sa_family == UInt8(AF_INET) || addr.sa_family == UInt8(AF_INET6) {
396 |
397 | // Convert interface address to a human readable string:
398 | var hostname = [CChar](count: Int(NI_MAXHOST), repeatedValue: 0)
399 | if (getnameinfo(&addr, socklen_t(addr.sa_len), &hostname, socklen_t(hostname.count),
400 | nil, socklen_t(0), NI_NUMERICHOST) == 0) {
401 | if let address = String.fromCString(hostname) {
402 | addresses.append(address)
403 | }
404 | }
405 | }
406 | }
407 | }
408 | freeifaddrs(ifaddr)
409 | }*/
410 |
411 | return []
412 | }
413 |
414 | }
415 |
416 |
417 | class WindowController: NSWindowController {
418 |
419 |
420 | override func windowDidLoad() {
421 | super.windowDidLoad()
422 | }
423 |
424 | }
425 |
426 |
427 |
--------------------------------------------------------------------------------
/LiveFlight/Controllers/ControlPadViewController.h:
--------------------------------------------------------------------------------
1 | //
2 | // ControlPadViewController.h
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 17/10/15.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface ControlPadViewController : NSViewController
12 |
13 | @property (weak) IBOutlet NSView *controlPad;
14 |
15 | @end
16 |
--------------------------------------------------------------------------------
/LiveFlight/Controllers/ControlPadViewController.m:
--------------------------------------------------------------------------------
1 | //
2 | // ControlPadViewController.m
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 17/10/15.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import "ControlPadViewController.h"
10 |
11 | @implementation ControlPadViewController
12 |
13 | @end
14 |
--------------------------------------------------------------------------------
/LiveFlight/Controllers/FlightControls.swift:
--------------------------------------------------------------------------------
1 | //
2 | // FlightControls.swift
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 31/12/2015.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | class FlightControls: NSObject {
12 |
13 | // init connector
14 | var connector = InfiniteFlightAPIConnector()
15 |
16 | /*
17 | // for reference - axes
18 | 0 - pitch
19 | 1 - roll
20 | 2 - rudder
21 | 3 - throttle
22 | */
23 |
24 | var pitchValue:Int32 = 0
25 | var rollValue:Int32 = 0
26 | var rudderValue:Int32 = 0
27 | var throttleValue:Int32 = 0
28 |
29 | // delta when key is pressed
30 | var deltaForKeyPress:Int32 = 100
31 | var deltaThrottleForKeyPress:Int32 = 50
32 |
33 | func pitchChanged(value:Int32) {
34 |
35 | pitchValue = value
36 | connector.didMoveAxis(0, value: value)
37 |
38 | }
39 |
40 | func rollChanged(value:Int32) {
41 |
42 | rollValue = value
43 | connector.didMoveAxis(1, value: value)
44 |
45 | }
46 |
47 | func rudderChanged(value:Int32) {
48 |
49 | rudderValue = value
50 | connector.didMoveAxis(2, value: value)
51 |
52 | }
53 |
54 | func throttleChanged(value:Int32) {
55 |
56 | throttleValue = value
57 | connector.didMoveAxis(3, value: value)
58 |
59 | }
60 |
61 | func upArrow() {
62 | // decrease pitch
63 |
64 | if pitchValue > -1024 {
65 |
66 | // subtract delta
67 | pitchValue -= deltaForKeyPress
68 |
69 | // pass command with new value
70 | connector.didMoveAxis(0, value: pitchValue)
71 |
72 | }
73 |
74 | }
75 |
76 | func downArrow() {
77 | // increase pitch
78 |
79 | if pitchValue < 1024 {
80 |
81 | // subtract delta
82 | pitchValue += deltaForKeyPress
83 |
84 | // pass command with new value
85 | connector.didMoveAxis(0, value: pitchValue)
86 |
87 | }
88 |
89 | }
90 |
91 | func leftArrow() {
92 | // left roll
93 |
94 | if rollValue > -1024 {
95 |
96 | // subtract delta
97 | rollValue -= deltaForKeyPress
98 |
99 | // pass command with new value
100 | connector.didMoveAxis(1, value: rollValue)
101 |
102 | }
103 |
104 | }
105 |
106 | func rightArrow() {
107 | // increase pitch
108 |
109 | if rollValue < 1024 {
110 |
111 | // subtract delta
112 | rollValue += deltaForKeyPress
113 |
114 | // pass command with new value
115 | connector.didMoveAxis(1, value: rollValue)
116 |
117 | }
118 |
119 | }
120 |
121 | func throttleUpArrow() {
122 | // increase pitch
123 |
124 | if throttleValue > -1024 {
125 |
126 | // subtract delta
127 | throttleValue -= deltaThrottleForKeyPress
128 |
129 | // pass command with new value
130 | connector.didMoveAxis(3, value: throttleValue)
131 |
132 | }
133 |
134 | }
135 |
136 | func throttleDownArrow() {
137 | // decrease throttle
138 |
139 | if throttleValue < 1024 {
140 |
141 | // subtract delta
142 | throttleValue += deltaThrottleForKeyPress
143 |
144 | // pass command with new value
145 | connector.didMoveAxis(3, value: throttleValue)
146 |
147 | }
148 |
149 | }
150 |
151 | }
152 |
--------------------------------------------------------------------------------
/LiveFlight/Controllers/JoystickViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickViewController.swift
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 11/10/15.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | class JoystickViewController: NSViewController {
12 |
13 | @IBOutlet weak var pitchLabel: NSTextField!
14 | @IBOutlet weak var rollLabel: NSTextField!
15 | @IBOutlet weak var throttleLabel: NSTextField!
16 | @IBOutlet weak var rudderLabel: NSTextField!
17 | @IBOutlet weak var joystickName: NSTextField!
18 | @IBOutlet weak var joystickRecognised: NSTextField!
19 | @IBOutlet var allClearView: Status!
20 |
21 | override func viewDidLoad() {
22 | super.viewDidLoad()
23 |
24 |
25 | NotificationCenter.default.addObserver(self, selector: #selector(changeLabelValues(notification:)), name:NSNotification.Name(rawValue: "changeLabelValues"), object: nil)
26 |
27 | //this is a hack, to avoid having to create a new NSNotification object
28 | NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeLabelValues"), object: nil)
29 |
30 | }
31 |
32 | @objc func changeLabelValues(notification:NSNotification) {
33 |
34 | allClearView!.isHidden = true
35 |
36 | let pitch = UserDefaults.standard.integer(forKey: "pitch")
37 | let roll = UserDefaults.standard.integer(forKey: "roll")
38 | let throttle = UserDefaults.standard.integer(forKey: "throttle")
39 | let rudder = UserDefaults.standard.integer(forKey: "rudder")
40 |
41 | if pitch != -2 {
42 | pitchLabel.stringValue = "Axis \(String(pitch))"
43 | }
44 |
45 | if roll != -2 {
46 | rollLabel.stringValue = "Axis \(String(roll))"
47 | }
48 |
49 | if throttle != -2 {
50 | throttleLabel.stringValue = "Axis \(String(throttle))"
51 | }
52 |
53 | if rudder != -2 {
54 | rudderLabel.stringValue = "Axis \(String(rudder))"
55 | }
56 |
57 |
58 | if joystickConfig.joystickConnected == true {
59 |
60 | // remove duplicate words from name
61 | // some manufacturers include name in product name too
62 | var joystickNameArray = joystickConfig.connectedJoystickName.characters.split{$0 == " "}.map(String.init)
63 |
64 | var filter = Dictionary()
65 | var len = joystickNameArray.count
66 | for index in 0.. Int {
22 | let numberOfRows:Int = getDataArray().count
23 | return numberOfRows
24 | }
25 |
26 | //set values
27 | func tableView(_ tableView: NSTableView, objectValueFor tableColumn: NSTableColumn?, row: Int) -> Any? {
28 | return getDataArray()[row].object(forKey: tableColumn!.identifier)
29 | }
30 |
31 |
32 |
33 | func getDataArray() -> [NSDictionary] {
34 | let dataArray:[NSDictionary] =
35 | [
36 | ["Command": "Pitch Up", "Key": "Down Arrow"],
37 | ["Command": "Pitch Down", "Key": "Up Arrow"],
38 | ["Command": "Roll Left", "Key": "Left Arrow"],
39 | ["Command": "Roll Right", "Key": "Right Arrow"],
40 | ["Command": "Increase Throttle", "Key": "D"],
41 | ["Command": "Decrease Throttle", "Key": "C"],
42 | ["Command": "", "Key": ""],
43 | ["Command": "Landing Gear Toggle", "Key": "G"],
44 | ["Command": "Spoilers Toggle", "Key": "/"],
45 | ["Command": "Flaps Up", "Key": "["],
46 | ["Command": "Flaps Down", "Key": "]"],
47 | ["Command": "Parking Brakes", "Key":"."],
48 | ["Command": "", "Key": ""],
49 | ["Command": "Previous Camera", "Key": "Q"],
50 | ["Command": "Next Camera", "Key": "E"],
51 | ["Command": "Move Camera Up", "Key": "Shift + Up Arrow"],
52 | ["Command": "Move Camera Down", "Key": "Shift + Down Arrow"],
53 | ["Command": "Move Camera Left", "Key": "Shift + Left Arrow"],
54 | ["Command": "Move Camera Right", "Key": "Shift + Right Arrow"],
55 | //["Command": "Zoom In", "Key":"="], <- these two don't work yet properly
56 | //["Command": "Zoom Out", "Key":"-"],
57 | ["Command": "", "Key": ""],
58 | ["Command": "Landing Light Toggle", "Key":"L"],
59 | ["Command": "Nav Light Toggle", "Key":"N"],
60 | ["Command": "Beacon Light Toggle", "Key":"B"],
61 | ["Command": "Strobe Toggle", "Key":"S"],
62 | ["Command": "", "Key": ""],
63 | ["Command": "Autopilot Toggle", "Key":"Z"],
64 | ["Command": "Pushback Toggle", "Key":"P"],
65 | ["Command": "Pause Toggle", "Key":"␣ [Space]"],
66 | ["Command": "", "Key": ""],
67 | ["Command": "ATC Window Toggle", "Key":"A"],
68 | ["Command": "ATC Commands", "Key":"Numbers [1-0]"]
69 | ];
70 |
71 | return dataArray
72 | }
73 |
74 | }
75 |
--------------------------------------------------------------------------------
/LiveFlight/Controllers/OptionsViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // OptionsViewController.swift
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 31/12/2015.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | class OptionsViewController: NSViewController, NSTextFieldDelegate {
12 |
13 | @IBOutlet weak var logLocationLabel:NSTextField!
14 | @IBOutlet weak var manualIpValue:NSTextField!
15 | @IBOutlet weak var manualIpToggle:NSButton!
16 |
17 | override func viewDidLoad() {
18 | super.viewDidLoad()
19 |
20 | self.logLocationLabel!.stringValue = UserDefaults.standard.string(forKey: "logPath") as! String
21 |
22 |
23 | /*
24 |
25 | // manual IP is deprecated
26 |
27 | self.manualIpToggle.state = Int(UserDefaults.standard.bool(forKey: "manualIP"))
28 |
29 | if UserDefaults.standard.string(forKey: "manualIPValue") != nil {
30 |
31 | self.manualIpValue!.stringValue = UserDefaults.standard.string(forKey: "manualIPValue") as! String
32 |
33 | }
34 |
35 | self.manualIpValue.delegate = self*/
36 |
37 | }
38 |
39 | @IBAction func selectLogFolder(sender:AnyObject) {
40 |
41 | NSWorkspace.shared.selectFile(nil, inFileViewerRootedAtPath: UserDefaults.standard.string(forKey: "logPath") as! String)
42 |
43 | /*
44 |
45 | // this doesn't work well with app sandboxing
46 |
47 | let panel = NSOpenPanel()
48 | panel.canChooseDirectories = true
49 | panel.canCreateDirectories = true
50 | panel.canChooseFiles = false
51 |
52 | panel.beginSheetModalForWindow(self.view.window!) { (result:Int) -> Void in
53 |
54 | if result == NSFileHandlingPanelOKButton {
55 | let urls = panel.URLs
56 |
57 | for url in urls {
58 |
59 | // remove file://
60 | let folderPath = url.absoluteString.stringByReplacingOccurrencesOfString("file://", withString: "")
61 |
62 | self.logLocationLabel!.stringValue = folderPath
63 | UserDefaults.standard.set(folderPath, forKey: "logPath")
64 |
65 | self.showRestartPrompt()
66 |
67 | }
68 |
69 | }
70 |
71 | }*/
72 |
73 | }
74 |
75 | @IBAction func resetSettings(sender: AnyObject) {
76 |
77 | for key in UserDefaults.standard.dictionaryRepresentation().keys {
78 | UserDefaults.standard.removeObject(forKey: key)
79 | }
80 |
81 | showRestartPrompt()
82 |
83 | }
84 |
85 | /*
86 | @IBAction func toggleManualIP(sender: AnyObject) {
87 |
88 | if manualIpToggle.state == 0 {
89 | //manualIpToggle.enabled = false
90 | UserDefaults.standard.set(false, forKey: "manualIP")
91 | } else if manualIpToggle.state == 1 {
92 | //manualIpToggle.enabled = true
93 | UserDefaults.standard.set(true, forKey: "manualIP")
94 | }
95 |
96 | showRestartPrompt()
97 |
98 | }
99 | */
100 |
101 | override func controlTextDidBeginEditing(_ obj: Notification) {
102 |
103 | // enter pressed, save new IP
104 | UserDefaults.standard.set(manualIpValue.stringValue, forKey: "manualIPValue")
105 |
106 | }
107 |
108 | func showRestartPrompt() {
109 |
110 | let alert = NSAlert()
111 | alert.messageText = "Changes saved!"
112 | alert.addButton(withTitle: "OK")
113 | alert.informativeText = "Restart LiveFlight Connect for the changes to take effect."
114 |
115 | alert.beginSheetModal(for: self.view.window!, completionHandler: { [unowned self] (returnCode) -> Void in
116 |
117 | NSLog("Restart prompt shown and closed.")
118 |
119 | })
120 |
121 | }
122 |
123 |
124 | }
125 |
--------------------------------------------------------------------------------
/LiveFlight/Controllers/ViewController.swift:
--------------------------------------------------------------------------------
1 | //
2 | // ViewController.swift
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 23/08/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 |
12 |
13 | class ViewController: NSViewController {
14 |
15 | @IBOutlet weak var connectingView:NSView!
16 | @IBOutlet var ipLabel:NSTextField!
17 |
18 | var alertIsShown = false
19 |
20 | var connector = InfiniteFlightAPIConnector()
21 |
22 | override func viewDidLoad() {
23 | super.viewDidLoad()
24 |
25 | NotificationCenter.default.addObserver(self, selector: #selector(removeView(notification:)), name:NSNotification.Name(rawValue: "connectionStarted"), object: nil)
26 | NotificationCenter.default.addObserver(self, selector: #selector(unsupportedInfiniteFlight(notification:)), name:NSNotification.Name(rawValue: "unsupportedVersion"), object: nil)
27 |
28 | }
29 |
30 |
31 | override var representedObject: Any? {
32 | didSet {
33 | // Update the view, if already loaded.
34 | }
35 | }
36 |
37 | @objc func removeView(notification: NSNotification) {
38 |
39 | // add observer for connection errors
40 | NotificationCenter.default.addObserver(self, selector: #selector(tcpError(notification:)), name:NSNotification.Name(rawValue: "tcpError"), object: nil)
41 |
42 | NSLog("Removing view...")
43 | DispatchQueue.main.sync {
44 |
45 | self.connectingView.isHidden = true
46 | if let ip = notification.userInfo!["ip"] as? String {
47 | self.ipLabel.stringValue = "Infinite Flight is at \(ip)" // this is passed in notification
48 | } else {
49 | self.ipLabel.stringValue = "Infinite Flight is connected, yet the connection seems unreliable"
50 | }
51 |
52 | }
53 |
54 | }
55 |
56 | @objc func tcpError(notification: NSNotification) {
57 |
58 | // remove to stop duplicates
59 | NotificationCenter.default.removeObserver(self, name: NSNotification.Name(rawValue: "tcpError"), object: nil)
60 |
61 | DispatchQueue.main.async {
62 |
63 | if self.alertIsShown == false {
64 |
65 | self.alertIsShown = true
66 |
67 | let alert = NSAlert()
68 | alert.messageText = "There was a problem"
69 | alert.addButton(withTitle: "OK")
70 | alert.informativeText = "LiveFlight Connect has lost connection to Infinite Flight.\n\nMake sure it is connected via the same network as this Mac. Try restarting Infinite Flight if issues persist."
71 |
72 | alert.beginSheetModal(for: self.view.window!, completionHandler: { [unowned self] (returnCode) -> Void in
73 | if returnCode == NSApplication.ModalResponse.alertFirstButtonReturn {
74 | DispatchQueue.main.async {
75 |
76 | self.connectingView.isHidden = false
77 |
78 | }
79 |
80 | self.alertIsShown = false
81 |
82 | if UserDefaults.standard.bool(forKey: "manualIP") != true {
83 |
84 | //start UDP listener
85 | var receiver = UDPReceiver()
86 | receiver = UDPReceiver()
87 | receiver.startUDPListener()
88 |
89 | }
90 | }
91 | })
92 |
93 | }
94 |
95 | }
96 |
97 | }
98 |
99 | @objc func unsupportedInfiniteFlight(notification: NSNotification) {
100 |
101 | DispatchQueue.main.async {
102 |
103 | let alert = NSAlert()
104 | alert.messageText = "There was a problem"
105 | alert.addButton(withTitle: "OK")
106 | alert.informativeText = "The version of Infinite Flight you are trying to connect to is no longer supported. Please update Infinite Flight in the App Store or the Google Play Store to the latest version."
107 |
108 | alert.beginSheetModal(for: self.view.window!, completionHandler: { [unowned self] (returnCode) -> Void in
109 | if returnCode == NSApplication.ModalResponse.alertFirstButtonReturn {
110 | NSApplication.shared.terminate(self)
111 | }
112 | })
113 |
114 | }
115 |
116 | }
117 |
118 | @IBAction func openJoystickGuide(sender: AnyObject) {
119 |
120 | let forumURL = "https://help.liveflightapp.com/hc/en-us/articles/115003328053-Setup-Guide"
121 | NSWorkspace.shared.open(URL(string: forumURL)!)
122 |
123 | }
124 |
125 |
126 | }
127 |
128 | extension NSView {
129 |
130 | var backgroundColor: NSColor? {
131 | get {
132 | if let colorRef = self.layer?.backgroundColor {
133 | return NSColor(cgColor: colorRef)
134 | } else {
135 | return nil
136 | }
137 | }
138 | set {
139 | self.wantsLayer = true
140 | self.layer?.backgroundColor = newValue?.cgColor
141 | }
142 | }
143 | }
144 |
145 |
--------------------------------------------------------------------------------
/LiveFlight/Infinite Flight Connect/InfiniteFlightAPIConnector.h:
--------------------------------------------------------------------------------
1 | //
2 | // InfiniteFlightAPIConnector.h
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 03/09/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @interface InfiniteFlightAPIConnector:NSObject {
12 | @public
13 | NSString *host;
14 | int port;
15 | NSDate *lastSend;
16 | }
17 |
18 | - (void)open;
19 | - (void)close;
20 | - (void)readIn:(NSString *)s;
21 |
22 | -(void)connectToInfiniteFlightWithIP:(NSString *)ip;
23 |
24 | //joystick
25 | -(void)didMoveAxis:(int)axis value:(int)value;
26 | -(void)didPressButton:(int)button state:(int)state;
27 |
28 | //commands
29 | -(void)previousCamera;
30 | -(void)nextCamera;
31 | -(void)cockpitCamera;
32 | -(void)vcCamera;
33 | -(void)followCamera;
34 | -(void)onboardCamera;
35 | -(void)towerCamera;
36 | -(void)flybyCamera;
37 | -(void)movePOVWithValue:(int)value;
38 | -(void)zoomOut;
39 | -(void)zoomIn;
40 | -(void)flapsDown;
41 | -(void)flapsUp;
42 | -(void)landingGear;
43 | -(void)spoilers;
44 | -(void)reverseThrust;
45 | -(void)autopilot;
46 | -(void)hud;
47 | -(void)parkingBrakes;
48 | -(void)togglePause;
49 | -(void)pushback;
50 | -(void)trimUp;
51 | -(void)trimDown;
52 | -(void)rollLeft;
53 | -(void)rollRight;
54 | -(void)pitchUp;
55 | -(void)pitchDown;
56 | -(void)atcMenu;
57 | -(void)atc1;
58 | -(void)atc2;
59 | -(void)atc3;
60 | -(void)atc4;
61 | -(void)atc5;
62 | -(void)atc6;
63 | -(void)atc7;
64 | -(void)atc8;
65 | -(void)atc9;
66 | -(void)atc10;
67 | -(void)landing;
68 | -(void)nav;
69 | -(void)strobe;
70 | -(void)beacon;
71 |
72 | @end
73 |
--------------------------------------------------------------------------------
/LiveFlight/Infinite Flight Connect/InfiniteFlightAPIConnector.m:
--------------------------------------------------------------------------------
1 | //
2 | // InfiniteFlightAPIConnector.m
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 03/09/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import "InfiniteFlightAPIConnector.h"
10 |
11 | CFReadStreamRef readStream;
12 | CFWriteStreamRef writeStream;
13 |
14 | NSInputStream *inputStream;
15 | NSOutputStream *outputStream;
16 |
17 | @implementation InfiniteFlightAPIConnector
18 |
19 | - (void)connectToInfiniteFlightWithIP:(NSString *)ip {
20 |
21 | port = 10111;
22 | NSURL *url = [NSURL URLWithString:ip];
23 |
24 | NSLog(@"Setting up connection to %@ : %i", [url absoluteString], port);
25 |
26 | CFStreamCreatePairWithSocketToHost(kCFAllocatorDefault, (__bridge CFStringRef)ip, port, &readStream, &writeStream);
27 |
28 | if(!CFWriteStreamOpen(writeStream)) {
29 | NSLog(@"Error, writeStream not open");
30 |
31 | return;
32 | }
33 | [self open];
34 |
35 | NSLog(@"Status of outputStream: %lu", (unsigned long)[outputStream streamStatus]);
36 |
37 | lastSend = [NSDate date];
38 |
39 | //send notification to hide loading view
40 | [[NSNotificationCenter defaultCenter] postNotificationName:@"connectionStarted" object:nil userInfo:[NSDictionary dictionaryWithObjectsAndKeys:ip, @"ip", nil]];
41 |
42 | return;
43 |
44 | }
45 |
46 | #pragma mark NSStream delegate
47 |
48 | - (void)open {
49 | NSLog(@"Opening streams.");
50 |
51 | inputStream = (__bridge NSInputStream *)readStream;
52 | outputStream = (__bridge NSOutputStream *)writeStream;
53 |
54 | [inputStream setDelegate:self];
55 | [outputStream setDelegate:self];
56 |
57 | [inputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
58 | [outputStream scheduleInRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
59 |
60 | [inputStream open];
61 | [outputStream open];
62 | }
63 |
64 | - (void)close {
65 | NSLog(@"Closing streams.");
66 |
67 | [inputStream close];
68 | [outputStream close];
69 |
70 | [inputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
71 | [outputStream removeFromRunLoop:[NSRunLoop currentRunLoop] forMode:NSDefaultRunLoopMode];
72 |
73 | [inputStream setDelegate:nil];
74 | [outputStream setDelegate:nil];
75 |
76 | inputStream = nil;
77 | outputStream = nil;
78 | }
79 |
80 | - (void)stream:(NSStream *)stream handleEvent:(NSStreamEvent)event {
81 | NSLog(@"Stream triggered.");
82 |
83 | switch(event) {
84 | case NSStreamEventHasSpaceAvailable: {
85 | if(stream == outputStream) {
86 | NSLog(@"outputStream is ready.");
87 | }
88 | break;
89 | }
90 | case NSStreamEventHasBytesAvailable: {
91 | if(stream == inputStream) {
92 | NSLog(@"inputStream is ready.");
93 |
94 | uint8_t buf[1024];
95 | NSInteger len = 0;
96 |
97 | len = [inputStream read:buf maxLength:1024];
98 |
99 | if(len > 0) {
100 | NSMutableData* data=[[NSMutableData alloc] initWithLength:0];
101 |
102 | [data appendBytes: (const void *)buf length:len];
103 |
104 | NSString *s = [[NSString alloc] initWithData:data encoding:NSASCIIStringEncoding];
105 |
106 | [self readIn:s];
107 |
108 | }
109 | }
110 | break;
111 | }
112 | case NSStreamEventErrorOccurred: {
113 | NSLog(@"A stream error occurred");
114 | break;
115 | }
116 | case NSStreamEventEndEncountered: {
117 | NSLog(@"Stream end encountered");
118 | break;
119 | }
120 | case NSStreamEventOpenCompleted: {
121 | NSLog(@"Stream successfully opened");
122 | break;
123 | }
124 | case NSStreamEventNone: {
125 | break;
126 | }
127 | }
128 | }
129 |
130 |
131 | - (void)readIn:(NSString *)s {
132 | NSLog(@"Reading: %@", s);
133 | }
134 |
135 | -(void)sendWithString:(NSString *)string params:(NSArray *)params isJoystick:(BOOL)isJoystick {
136 |
137 | if (params == nil) {
138 | params = [NSArray array];
139 | }
140 |
141 | NSData *arrayData = [NSJSONSerialization dataWithJSONObject:params options:0 error:nil];
142 | NSString *arrayString = [[NSString alloc] initWithData:arrayData encoding:NSUTF8StringEncoding];
143 |
144 | string = [NSString stringWithFormat:@"{\"Command\":\"%@\",\"Parameters\":%@}\n", string, arrayString];
145 | NSLog(@"Command: %@", string);
146 |
147 | NSData * stringData;
148 | NSUInteger stringLength;
149 | union {
150 | uint32_t u32;
151 | uint8_t u8s[4];
152 | } lengthConverter;
153 |
154 | NSMutableData * result;
155 | __Check_Compile_Time(sizeof(lengthConverter) == 4);
156 |
157 | stringData = [string dataUsingEncoding:NSUTF8StringEncoding];
158 | stringLength = stringData.length;
159 | assert(stringLength < ((NSUInteger) 1 * 1024 * 1024 * 1024)); // 1 GiB
160 | lengthConverter.u32 = OSSwapHostToLittleInt32(stringLength);
161 |
162 | result = [[NSMutableData alloc] init];
163 | [result appendBytes:&lengthConverter.u8s length:sizeof(lengthConverter.u8s)];
164 | [result appendData:stringData];
165 |
166 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
167 | //calculate time since last packet sent
168 | double timePassed = [lastSend timeIntervalSinceNow] * -1000.0;
169 | double timeToPass = [[NSUserDefaults standardUserDefaults] integerForKey:@"packetDelay"];
170 |
171 | //check if is joystick command
172 | if (isJoystick == true) {
173 | //joystick command - time check enabled
174 |
175 | if (timePassed > timeToPass) {
176 |
177 | //been longer than 20ms, send with less risk of overloading server
178 | [self writeResult:result];
179 |
180 | } else {
181 | //NSLog(@"Ignoring packet, too soon since previous...");
182 | }
183 |
184 | } else {
185 | //standard button, time check disabled
186 | [self writeResult:result];
187 | }
188 |
189 | lastSend = [NSDate date];
190 |
191 | });
192 |
193 | }
194 |
195 | -(void)writeResult:(NSMutableData *)result {
196 |
197 | // check to see if output stream is open
198 |
199 | NSLog(@"%lu", (unsigned long)outputStream.streamStatus);
200 |
201 | if (outputStream.streamStatus == NSStreamStatusError) {
202 |
203 | NSLog(@"Output stream error");
204 |
205 | // error with output stream
206 |
207 | // close TCP connection
208 | [self close];
209 |
210 | [[NSUserDefaults standardUserDefaults] setBool:false forKey:@"manualIP"]; // disable manual IP - the user can re-enable if necessary
211 |
212 | [[NSNotificationCenter defaultCenter] postNotificationName:@"tcpError" object:nil]; // present TCP error window
213 |
214 |
215 | } else {
216 |
217 | // stream is open, we can write to it
218 |
219 | NSInteger sent = [outputStream write:result.bytes maxLength:result.length];
220 | NSLog(@"Write result: %ld", (long)sent);
221 |
222 | // check that there is no error
223 | if (sent == -1) {
224 |
225 | // close TCP connection
226 | [self close];
227 |
228 | //error. probably disconnected
229 | [[NSNotificationCenter defaultCenter] postNotificationName:@"tcpError" object:nil];
230 |
231 |
232 | }
233 |
234 | }
235 |
236 | }
237 |
238 |
239 |
240 | #pragma mark joystick actions
241 | -(void)didMoveAxis:(int)axis value:(int)value {
242 |
243 | NSString *param = [NSString stringWithFormat:@"{\"Name\":\"%d\",\"Value\":\"%d\"}", axis, value];
244 |
245 | NSData *data = [param dataUsingEncoding:NSUTF8StringEncoding];
246 | id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
247 |
248 | NSArray *params = [NSArray arrayWithObjects:json, nil];
249 |
250 | [self sendWithString:@"NetworkJoystick.SetAxisValue" params:params isJoystick:true];
251 |
252 | }
253 |
254 | -(void)didPressButton:(int)button state:(int)state {
255 |
256 | NSString *stateString;
257 | if (state != 0) {
258 | stateString = @"Up";
259 | } else {
260 | stateString = @"Down";
261 | }
262 |
263 | NSString *param = [NSString stringWithFormat:@"{\"Name\":\"%d\",\"Value\":\"%@\"}", button, stateString];
264 | NSData *data = [param dataUsingEncoding:NSUTF8StringEncoding];
265 | id json = [NSJSONSerialization JSONObjectWithData:data options:0 error:nil];
266 |
267 | NSArray *params = [NSArray arrayWithObjects:json, nil];
268 |
269 | [self sendWithString:@"NetworkJoystick.SetButtonState" params:params isJoystick:false];
270 |
271 |
272 | }
273 |
274 | #pragma mark commands
275 |
276 | /*
277 | Cameras
278 | ========================
279 | */
280 |
281 | -(void)previousCamera {
282 | [self sendWithString:@"Commands.PrevCamera" params:nil isJoystick:false];
283 | }
284 |
285 | -(void)nextCamera {
286 | [self sendWithString:@"Commands.NextCamera" params:nil isJoystick:false];
287 | }
288 |
289 | -(void)cockpitCamera {
290 | [self sendWithString:@"Commands.SetCockpitCamera" params:nil isJoystick:false];
291 | }
292 |
293 | -(void)vcCamera {
294 | [self sendWithString:@"Commands.SetVirtualCockpitCameraCommand" params:nil isJoystick:false];
295 | }
296 |
297 | -(void)followCamera{
298 | [self sendWithString:@"Commands.SetFollowCameraCommand" params:nil isJoystick:false];
299 | }
300 |
301 | -(void)onboardCamera {
302 | [self sendWithString:@"Commands.SetOnboardCameraCommand" params:nil isJoystick:false];
303 | }
304 |
305 | -(void)towerCamera {
306 | [self sendWithString:@"Commands.SetTowerCameraCommand" params:nil isJoystick:false];
307 | }
308 |
309 | -(void)flybyCamera {
310 | [self sendWithString:@"Commands.SetFlyByCamera" params:nil isJoystick:false];
311 | }
312 |
313 | -(void)zoomOut {
314 | [self sendWithString:@"Commands.CameraZoomOut" params:nil isJoystick:false];
315 | }
316 |
317 | -(void)zoomIn {
318 | [self sendWithString:@"Commands.CameraZoomIn" params:nil isJoystick:false];
319 | }
320 |
321 | -(void)movePOVWithValue:(int)value {
322 |
323 | // constants
324 | int viewUpId = 0;
325 | int viewDownId = 180;
326 | int viewLeftId = 270;
327 | int viewRightId = 90;
328 | int neutralId = -2;
329 |
330 | //POV axis
331 | int xValue = 0;
332 | int yValue = 0;
333 |
334 | if (value == viewUpId) {
335 | xValue = 0;
336 | yValue = -1;
337 |
338 | } else if (value == viewDownId) {
339 | xValue = 0;
340 | yValue = 1;
341 |
342 | } else if (value == viewLeftId) {
343 | xValue = -1;
344 | yValue = 0;
345 |
346 | } else if (value == viewRightId) {
347 | xValue = 1;
348 | yValue = 0;
349 |
350 | } else if (value == neutralId) {
351 | xValue = 0;
352 | yValue = 0;
353 |
354 | }
355 |
356 | NSString *xParam = [NSString stringWithFormat:@"{\"Name\":\"X\",\"Value\":\"%d\"}", xValue];
357 | NSString *yParam = [NSString stringWithFormat:@"{\"Name\":\"Y\",\"Value\":\"%d\"}", yValue];
358 |
359 | NSData *xData = [xParam dataUsingEncoding:NSUTF8StringEncoding];
360 | id xJson = [NSJSONSerialization JSONObjectWithData:xData options:0 error:nil];
361 |
362 | NSData *yData = [yParam dataUsingEncoding:NSUTF8StringEncoding];
363 | id yJson = [NSJSONSerialization JSONObjectWithData:yData options:0 error:nil];
364 |
365 | NSArray *params = [NSArray arrayWithObjects:xJson, yJson, nil];
366 |
367 | [self sendWithString:@"NetworkJoystick.SetPOVState" params:params isJoystick:false];
368 |
369 | }
370 |
371 | /*
372 | Airplane State
373 | ========================
374 | */
375 |
376 | -(void)flapsDown {
377 | [self sendWithString:@"Commands.FlapsDown" params:nil isJoystick:false];
378 | }
379 |
380 | -(void)flapsUp {
381 | [self sendWithString:@"Commands.FlapsUp" params:nil isJoystick:false];
382 | }
383 |
384 | -(void)landingGear {
385 | [self sendWithString:@"Commands.LandingGear" params:nil isJoystick:false];
386 | }
387 |
388 | -(void)spoilers {
389 | [self sendWithString:@"Commands.Spoilers" params:nil isJoystick:false];
390 | }
391 |
392 | -(void)reverseThrust {
393 | [self sendWithString:@"Commands.ReverseThrust" params:nil isJoystick:false];
394 | }
395 |
396 | -(void)parkingBrakes {
397 | [self sendWithString:@"Commands.ParkingBrakes" params:nil isJoystick:false];
398 | }
399 |
400 | -(void)pushback {
401 | [self sendWithString:@"Commands.Pushback" params:nil isJoystick:false];
402 | }
403 |
404 |
405 | /*
406 | Autopilot
407 | ========================
408 | */
409 |
410 | -(void)autopilot {
411 | [self sendWithString:@"Commands.Autopilot.Toggle" params:nil isJoystick:false];
412 | }
413 |
414 |
415 | /*
416 | General
417 | ========================
418 | */
419 |
420 | -(void)hud {
421 | [self sendWithString:@"Commands.ToggleHUD" params:nil isJoystick:false];
422 | }
423 |
424 | -(void)togglePause {
425 | [self sendWithString:@"Commands.TogglePause" params:nil isJoystick:false];
426 | }
427 |
428 |
429 | /*
430 | Control Surfaces
431 | ========================
432 | */
433 |
434 | -(void)trimUp {
435 | [self sendWithString:@"Commands.ElevatorTrimUp" params:nil isJoystick:false];
436 | }
437 |
438 | -(void)trimDown {
439 | [self sendWithString:@"Commands.ElevatorTrimDown" params:nil isJoystick:false];
440 | }
441 |
442 | -(void)rollLeft {
443 | [self sendWithString:@"Commands.RollLeft" params:nil isJoystick:false];
444 | }
445 |
446 | -(void)rollRight {
447 | [self sendWithString:@"Commands.RollRight" params:nil isJoystick:false];
448 | }
449 |
450 | -(void)pitchUp {
451 | [self sendWithString:@"Commands.PitchUp" params:nil isJoystick:false];
452 | }
453 |
454 | -(void)pitchDown {
455 | [self sendWithString:@"Commands.PitchDown" params:nil isJoystick:false];
456 | }
457 |
458 | /*
459 | Live
460 | ========================
461 | */
462 |
463 | -(void)atcMenu {
464 | [self sendWithString:@"Commands.ShowATCWindowCommand" params:nil isJoystick:false];
465 | }
466 |
467 | -(void)atc1 {
468 | [self sendWithString:@"Commands.ATCEntry1" params:nil isJoystick:false];
469 | }
470 |
471 | -(void)atc2 {
472 | [self sendWithString:@"Commands.ATCEntry2" params:nil isJoystick:false];
473 | }
474 |
475 |
476 | -(void)atc3 {
477 | [self sendWithString:@"Commands.ATCEntry3" params:nil isJoystick:false];
478 | }
479 |
480 |
481 | -(void)atc4 {
482 | [self sendWithString:@"Commands.ATCEntry4" params:nil isJoystick:false];
483 | }
484 |
485 |
486 | -(void)atc5 {
487 | [self sendWithString:@"Commands.ATCEntry5" params:nil isJoystick:false];
488 | }
489 |
490 |
491 | -(void)atc6 {
492 | [self sendWithString:@"Commands.ATCEntry6" params:nil isJoystick:false];
493 | }
494 |
495 |
496 | -(void)atc7 {
497 | [self sendWithString:@"Commands.ATCEntry7" params:nil isJoystick:false];
498 | }
499 |
500 |
501 | -(void)atc8 {
502 | [self sendWithString:@"Commands.ATCEntry8" params:nil isJoystick:false];
503 | }
504 |
505 |
506 | -(void)atc9 {
507 | [self sendWithString:@"Commands.ATCEntry9" params:nil isJoystick:false];
508 | }
509 |
510 |
511 | -(void)atc10 {
512 | [self sendWithString:@"Commands.ATCEntry10" params:nil isJoystick:false];
513 | }
514 |
515 | /*
516 | Lighting
517 | ========================
518 | */
519 |
520 | -(void)landing {
521 | [self sendWithString:@"Commands.LandingLights" params:nil isJoystick:false];
522 | }
523 |
524 | -(void)nav {
525 | [self sendWithString:@"Commands.NavLights" params:nil isJoystick:false];
526 | }
527 |
528 | -(void)strobe {
529 | [self sendWithString:@"Commands.StrobeLights" params:nil isJoystick:false];
530 | }
531 |
532 | -(void)beacon {
533 | [self sendWithString:@"Commands.BeaconLights" params:nil isJoystick:false];
534 | }
535 |
536 |
537 | @end
538 |
--------------------------------------------------------------------------------
/LiveFlight/Infinite Flight Connect/UDPReceiver.h:
--------------------------------------------------------------------------------
1 | //
2 | // UDPReceiver.h
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 08/10/15.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "GCDAsyncUdpSocket.h"
11 | #import "InfiniteFlightAPIConnector.h"
12 |
13 | @interface UDPReceiver : NSObject
14 |
15 |
16 | @property (nonatomic, retain) GCDAsyncUdpSocket *udpSocket;
17 | @property bool connected;
18 |
19 | -(void)startUDPListener;
20 | -(void)didReceiveData:(NSData *)data fromAddress:(NSData *)address withFilterContext:(id)filterContext;
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/LiveFlight/Infinite Flight Connect/UDPReceiver.m:
--------------------------------------------------------------------------------
1 | //
2 | // UDPReceiver.m
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 08/10/15.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import "UDPReceiver.h"
10 |
11 | @implementation UDPReceiver
12 | @synthesize udpSocket = udpSocket_;
13 | @synthesize connected;
14 |
15 | -(id)copyWithZone:(NSZone*) zone {
16 |
17 | return self;
18 | }
19 |
20 | -(void)startUDPListener {
21 |
22 |
23 | if (udpSocket_ == nil) {
24 |
25 | [self setupSocket];
26 |
27 | }
28 |
29 |
30 | }
31 |
32 | - (void)setupSocket {
33 |
34 | int port = 15000; //IF broadcasts on 15000
35 |
36 | if ([[NSUserDefaults standardUserDefaults] boolForKey:@"manualIP"] == true) {
37 |
38 | // manual IP mode is enabled, ignore UDP search
39 |
40 | InfiniteFlightAPIConnector *apiConnector = [[InfiniteFlightAPIConnector alloc] init];
41 | [apiConnector connectToInfiniteFlightWithIP:[[NSUserDefaults standardUserDefaults] valueForKey:@"manualIPValue"]];
42 |
43 |
44 | } else {
45 |
46 | NSLog(@"Starting UDP listener on port %d", port);
47 |
48 | udpSocket_ = [[GCDAsyncUdpSocket alloc] initWithDelegate:self delegateQueue:dispatch_get_main_queue()];
49 |
50 | // disable IPV6
51 | [udpSocket_ setIPv4Enabled:true];
52 | [udpSocket_ setIPv6Enabled:false];
53 |
54 | NSError *error = nil;
55 |
56 | if (![udpSocket_ bindToPort:port error:&error])
57 | {
58 | NSLog(@"Error binding: %@", error);
59 | return;
60 | }
61 | if (![udpSocket_ beginReceiving:&error])
62 | {
63 | NSLog(@"Error starting server: %@", error);
64 | return;
65 | }
66 |
67 | NSError *receivingError;
68 | [udpSocket_ beginReceiving:&receivingError];
69 |
70 | }
71 | }
72 |
73 | - (void)udpSocket:(GCDAsyncUdpSocket *)sock didReceiveData:(NSData *)data fromAddress:(NSData *)address withFilterContext:(id)filterContext {
74 | //received packet on port 15000
75 |
76 | NSString *packet = [[NSString alloc] initWithData:data encoding:NSUTF8StringEncoding];
77 | if (packet) {
78 |
79 | NSLog(@"Received packet: %@", packet);
80 |
81 | //read json
82 | NSError *error = nil;
83 | id object = [NSJSONSerialization
84 | JSONObjectWithData:data
85 | options:0
86 | error:&error];
87 |
88 | if(!error) {
89 |
90 | if([object isKindOfClass:[NSDictionary class]])
91 | {
92 | NSDictionary *results = object;
93 |
94 | if (connected != true) {
95 |
96 | // Check to make sure the response from Infinite Flight is one we support
97 | if ([results objectForKey:@"Address"] != nil) {
98 | [[NSNotificationCenter defaultCenter] postNotificationName:@"unsupportedVersion" object:nil];
99 | return;
100 | }
101 |
102 | NSLog(@"Can connect to one of these: %@", [results valueForKey:@"Addresses"]);
103 |
104 | NSArray *possibleAddresses = [results mutableArrayValueForKey:@"Addresses"];
105 | NSString *ipToConnectTo;
106 |
107 | // Prioritise IPv4 if possible
108 | // Regex thanks to https://www.mkyong.com/regular-expressions/how-to-validate-ip-address-with-regular-expression/
109 | NSString *regex = [NSString stringWithFormat:@"^([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])\\.([01]?\\d\\d?|2[0-4]\\d|25[0-5])$"];
110 | NSPredicate *filter = [NSPredicate predicateWithFormat:@"SELF MATCHES %@", regex];
111 | NSArray *matches = [possibleAddresses filteredArrayUsingPredicate:filter];
112 |
113 | NSLog(@"IPv4 priority chooses one of these: %@", matches);
114 |
115 | if (matches.count) {
116 | ipToConnectTo = [matches firstObject];
117 | } else {
118 | if (possibleAddresses.count) {
119 | ipToConnectTo = [possibleAddresses firstObject];
120 | } else {
121 | [[NSNotificationCenter defaultCenter] postNotificationName:@"tcpError" object:nil];
122 | }
123 | }
124 |
125 | dispatch_async(dispatch_get_global_queue(DISPATCH_QUEUE_PRIORITY_DEFAULT, 0), ^{
126 | [self connectIF:ipToConnectTo];
127 | });
128 |
129 | connected = true;
130 |
131 | [udpSocket_ close];
132 | udpSocket_.delegate = nil;
133 |
134 | }
135 |
136 | }
137 |
138 | }
139 |
140 | } else {
141 | NSString *host = nil;
142 | uint16_t port = 0;
143 | [GCDAsyncUdpSocket getHost:&host port:&port fromAddress:address];
144 |
145 | NSLog(@"Unknown message on port %d", port);
146 | }
147 | }
148 |
149 | -(void)connectIF:(NSString *)string {
150 |
151 | InfiniteFlightAPIConnector *apiConnector = [[InfiniteFlightAPIConnector alloc] init];
152 | [apiConnector connectToInfiniteFlightWithIP:string];
153 |
154 |
155 | }
156 |
157 | @end
158 |
159 |
--------------------------------------------------------------------------------
/LiveFlight/Joystick/Joystick.h:
--------------------------------------------------------------------------------
1 | //
2 | // Joystick.h
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 23/08/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "JoystickNotificationDelegate.h"
12 |
13 | @interface Joystick : NSObject {
14 | IOHIDDeviceRef device;
15 | NSArray *elements;
16 | NSArray *axes;
17 | NSArray *buttons;
18 | NSArray *hats;
19 | NSMutableArray *delegates;
20 | NSString *productName;
21 | int productId;
22 | }
23 |
24 | @property(readwrite) IOHIDDeviceRef device;
25 | @property(readonly) unsigned int numButtons;
26 | @property(readonly) unsigned int numAxes;
27 | @property(readonly) unsigned int numHats;
28 | @property(readwrite) NSString *manufacturerName;
29 | @property(readwrite) NSString *productName;
30 | @property(readwrite) int productId;
31 |
32 | - (id)initWithDevice:(IOHIDDeviceRef)theDevice;
33 | - (int)getElementIndex:(IOHIDElementRef)theElement;
34 | - (double)getRelativeValueOfAxesIndex:(int)index;
35 | - (void)elementReportedChange:(IOHIDElementRef)theElement;
36 | - (void)registerForNotications:(id )delegate;
37 | - (void)deregister:(id)delegate;
38 |
39 | @end
40 |
--------------------------------------------------------------------------------
/LiveFlight/Joystick/Joystick.m:
--------------------------------------------------------------------------------
1 | //
2 | // Joystick.m
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 23/08/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import "Joystick.h"
10 | #import "JoystickHatswitch.h"
11 |
12 | @implementation Joystick
13 |
14 | @synthesize device, productName, productId, manufacturerName;
15 |
16 | - (id)initWithDevice:(IOHIDDeviceRef)theDevice
17 | {
18 | self = [super init];
19 | if (self) {
20 | device = theDevice;
21 |
22 | // metadata first
23 | self.manufacturerName = [NSString stringWithFormat:@"%@", (CFStringRef)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDManufacturerKey))];
24 | self.productName = [NSString stringWithFormat:@"%@", (CFStringRef)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductKey))];
25 | self.productId = (int)IOHIDDeviceGetProperty(device, CFSTR(kIOHIDProductIDKey));
26 |
27 | delegates = [[NSMutableArray alloc] initWithCapacity:0];
28 |
29 | elements = (__bridge NSArray *)IOHIDDeviceCopyMatchingElements(theDevice, NULL, kIOHIDOptionsTypeNone);
30 |
31 | NSMutableArray *tempButtons = [NSMutableArray array];
32 | NSMutableArray *tempAxes = [NSMutableArray arrayWithCapacity:100];
33 | NSMutableArray *tempHats = [NSMutableArray array];
34 |
35 | for (int i = 0; i < 512; i++) {
36 | [tempAxes addObject:@""];
37 | }
38 |
39 | int i;
40 | for (i=0; i delegate = [delegates objectAtIndex:i];
105 | int valueInt = (int)value;
106 | [hatswitch checkValue:valueInt andDispatchButtonPressesWithIndexOffset:offset toDelegate:delegate];
107 | }
108 |
109 | return;
110 | }
111 |
112 |
113 | if (elementType != kIOHIDElementTypeInput_Axis && elementType != kIOHIDElementTypeInput_Misc) {
114 |
115 |
116 | for (i=0; i delegate = [delegates objectAtIndex:i];
118 |
119 | if (value==1)
120 | [delegate joystickButtonPushed:[self getElementIndex:theElement] onJoystick:self];
121 | else
122 | [delegate joystickButtonReleased:[self getElementIndex:theElement] onJoystick:self];
123 |
124 | }
125 |
126 | NSLog(@"Non-axis reported value of %ld",value);
127 | return;
128 | }
129 |
130 |
131 | NSLog(@"Axis %d reported value of %ld", elementUsage,value);
132 |
133 |
134 | for (i=0; i delegate = [delegates objectAtIndex:i];
136 |
137 | [delegate joystickStateChanged:self axis:elementUsage];
138 | }
139 | }
140 |
141 | - (void)registerForNotications:(id )delegate {
142 | [delegates addObject:delegate];
143 | }
144 |
145 | - (void)deregister:(id)delegate {
146 | [delegates removeObject:delegate];
147 | }
148 |
149 | - (int)getElementIndex:(IOHIDElementRef)theElement {
150 | int elementType = IOHIDElementGetType(theElement);
151 |
152 | NSArray *searchArray;
153 | NSString *returnString = @"";
154 |
155 | if (elementType == kIOHIDElementTypeInput_Button) {
156 | searchArray = buttons;
157 | returnString = @"Button";
158 | } else {
159 | searchArray = axes;
160 | returnString = @"Axis";
161 | }
162 |
163 | int i;
164 |
165 | for (i=0; i
10 | #import
11 | #import "JoystickNotificationDelegate.h"
12 |
13 | @interface JoystickHatswitch : NSObject {
14 | IOHIDElementRef element;
15 | Joystick *owner;
16 |
17 | int directions;
18 | BOOL buttonStates[4];
19 | }
20 |
21 | @property(readonly) IOHIDElementRef element;
22 |
23 | -(id)initWithElement:(IOHIDElementRef)theElement andOwner:(Joystick *)theOwner;
24 | - (void)checkValue:(int)value andDispatchButtonPressesWithIndexOffset:(int)offset toDelegate:(id)delegate;
25 |
26 | @end
27 |
--------------------------------------------------------------------------------
/LiveFlight/Joystick/JoystickHatswitch.m:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickHatswitch.m
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 23/08/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 | #import "JoystickHatswitch.h"
9 |
10 | @implementation JoystickHatswitch
11 |
12 | @synthesize element;
13 |
14 | -(id)initWithElement:(IOHIDElementRef)theElement andOwner:(Joystick *)theOwner {
15 |
16 | self = [super init];
17 |
18 | if (!self)
19 | return nil;
20 |
21 | int usage = IOHIDElementGetUsage(theElement);
22 |
23 | if (usage != kHIDUsage_GD_Hatswitch)
24 | NSLog(@"WARN: Invalid element given to JoystickHatswitch object");
25 |
26 | element = theElement;
27 | owner = theOwner;
28 |
29 | int logicalMax = (int)IOHIDElementGetLogicalMax(theElement);
30 | int logicalMin = (int)IOHIDElementGetLogicalMin(theElement);
31 |
32 | directions = logicalMax-logicalMin;
33 |
34 | NSLog(@"HatSwitch found. lMax: %d , lMin: %d",logicalMax,logicalMin);
35 |
36 | return self;
37 | }
38 |
39 | - (void)checkValue:(int)value andDispatchButtonPressesWithIndexOffset:(int)offset toDelegate:(id)delegate {
40 |
41 | BOOL newButtonStates[4] = {NO,NO,NO,NO};
42 | // UP, RIGHT, DOWN, LEFT.
43 |
44 | if (directions > 4) {
45 | newButtonStates[0] = (value == 0 || value == 1 || value == 7);
46 | newButtonStates[1] = (value == 1 || value == 2 || value == 3);
47 | newButtonStates[2] = (value == 3 || value == 4 || value == 5);
48 | newButtonStates[3] = (value == 5 || value == 6 || value == 7);
49 | } else {
50 | newButtonStates[0] = (value == 0);
51 | newButtonStates[1] = (value == 1);
52 | newButtonStates[2] = (value == 2);
53 | newButtonStates[3] = (value == 3);
54 | }
55 |
56 | int i;
57 |
58 | for (i=0; i<4; ++i) {
59 | if (newButtonStates[i] != buttonStates[i]) {
60 | // dispatch a button change event
61 | if (newButtonStates[i])
62 | [delegate joystickButtonPushed:offset+i onJoystick:owner];
63 | else
64 | [delegate joystickButtonReleased:offset+i onJoystick:owner];
65 | }
66 |
67 | buttonStates[i] = newButtonStates[i];
68 | }
69 | }
70 |
71 | @end
72 |
--------------------------------------------------------------------------------
/LiveFlight/Joystick/JoystickHelper.swift:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickHelper.swift
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 29/12/2015.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | class JoystickConfig {
12 | var joystickConnected:Bool = false
13 | var connectedJoystickName:String = ""
14 | init(connected:Bool, name:String) {
15 | self.joystickConnected = connected
16 | self.connectedJoystickName = name
17 | }
18 | }
19 |
20 | var joystickConfig = JoystickConfig(connected: false, name: "")
21 |
22 | class JoystickHelper: NSObject, JoystickNotificationDelegate {
23 |
24 | let connector = InfiniteFlightAPIConnector()
25 | let controls = FlightControls()
26 |
27 | //joystick values
28 | var rollValue = 0;
29 | var pitchValue = 0;
30 | var rudderValue = 0;
31 | var throttleValue = 0;
32 |
33 | var tryPitch = false
34 | var tryRoll = false
35 | var tryThrottle = false
36 | var tryRudder = false
37 |
38 | override init() {
39 | super.init()
40 |
41 | /*
42 | Init Joystick Manager
43 | ========================
44 | */
45 |
46 | let joystick:JoystickManager = JoystickManager.sharedInstance()
47 | joystick.joystickAddedDelegate = self;
48 |
49 |
50 | /*
51 | NotificationCenter setup
52 | ========================
53 | */
54 |
55 | NotificationCenter.default.addObserver(self, selector: #selector(tryPitch(notification:)), name:NSNotification.Name(rawValue: "tryPitch"), object: nil)
56 | NotificationCenter.default.addObserver(self, selector: #selector(tryRoll(notification:)), name:NSNotification.Name(rawValue: "tryRoll"), object: nil)
57 | NotificationCenter.default.addObserver(self, selector: #selector(tryThrottle(notification:)), name:NSNotification.Name(rawValue: "tryThrottle"), object: nil)
58 | NotificationCenter.default.addObserver(self, selector: #selector(tryRudder(notification:)), name:NSNotification.Name(rawValue: "tryRudder"), object: nil)
59 |
60 | }
61 |
62 | @objc func tryPitch(notification: NSNotification) {
63 | tryPitch = true
64 | }
65 |
66 | @objc func tryRoll(notification: NSNotification) {
67 | tryRoll = true
68 | }
69 |
70 | @objc func tryThrottle(notification: NSNotification) {
71 | tryThrottle = true
72 | }
73 |
74 | @objc func tryRudder(notification: NSNotification) {
75 | tryRudder = true
76 | }
77 |
78 | //joystick work
79 | func joystickAdded(_ joystick: Joystick!) {
80 | joystick.register(forNotications: self)
81 |
82 | if UserDefaults.standard.integer(forKey: "lastJoystick") != Int(joystick.productId) {
83 | // different joystick. Reset
84 |
85 | // remove last map
86 | UserDefaults.standard.removeObject(forKey: "mapStatus")
87 |
88 | // set axesSet to false
89 | UserDefaults.standard.set(false, forKey: "axesSet")
90 |
91 | }
92 |
93 |
94 | // set last joystick name and connected
95 | joystickConfig = JoystickConfig(connected: true, name: ("\(joystick.manufacturerName) \(joystick.productName)"))
96 |
97 |
98 | let axesSet = UserDefaults.standard.bool(forKey: "axesSet")
99 |
100 | // this is to reset axes when upgrading. Since there is a common pattern, there shouldn't be much impact.
101 | let axesSet11 = UserDefaults.standard.bool(forKey: "axesSet11")
102 |
103 | if axesSet != true || axesSet11 != true {
104 | // axes haven't been set yet
105 |
106 | // check to see if json exists with joystick name
107 | guard let path = Bundle.main.path(forResource: "JoystickMapping/\(joystick.manufacturerName) \(joystick.productName)", ofType: "json") else {
108 |
109 | // No map found
110 | NSLog("No map found - setting default values...")
111 |
112 | // Default values
113 | UserDefaults.standard.set(49, forKey: "pitch")
114 | UserDefaults.standard.set(48, forKey: "roll")
115 | UserDefaults.standard.set(50, forKey: "throttle")
116 | UserDefaults.standard.set(53, forKey: "rudder")
117 |
118 | // using generic values
119 | UserDefaults.standard.set(0, forKey: "mapStatus")
120 |
121 | return
122 | }
123 |
124 | // if this point is reached, a map exists
125 | let fileData = NSData(contentsOfFile: path)
126 |
127 | do {
128 | if let response:NSDictionary = try JSONSerialization.jsonObject(with: fileData! as Data, options:JSONSerialization.ReadingOptions.mutableContainers) as? Dictionary as! NSDictionary {
129 |
130 | let pitchAxis = response.value(forKey: "Pitch-OSX") as! Int
131 | let rollAxis = response.value(forKey: "Roll-OSX") as! Int
132 | let throttleAxis = response.value(forKey: "Throttle-OSX") as! Int
133 | let rudderAxis = response.value(forKey: "Rudder-OSX") as! Int
134 |
135 | //save values
136 | UserDefaults.standard.set(pitchAxis, forKey: "pitch")
137 | UserDefaults.standard.set(rollAxis, forKey: "roll")
138 | UserDefaults.standard.set(throttleAxis, forKey: "throttle")
139 | UserDefaults.standard.set(rudderAxis, forKey: "rudder")
140 |
141 | // using mapped values
142 | UserDefaults.standard.set(1, forKey: "mapStatus")
143 |
144 | } else {
145 | NSLog("Failed to parse JSON")
146 | }
147 | } catch let serializationError as NSError {
148 | NSLog(String(describing: serializationError))
149 | }
150 |
151 | }
152 |
153 | // change labels and mark as axes set
154 | NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeLabelValues"), object:nil)
155 | UserDefaults.standard.set(true, forKey: "axesSet")
156 | UserDefaults.standard.set(true, forKey: "axesSet11")
157 |
158 | UserDefaults.standard.set(Int(joystick.productId), forKey: "lastJoystick")
159 |
160 | }
161 |
162 | func joystickRemoved(_ joystick: Joystick!) {
163 |
164 | joystickConfig = JoystickConfig(connected: false, name: "")
165 |
166 |
167 | // change label values
168 | NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeLabelValues"), object:nil)
169 |
170 | }
171 |
172 | func joystickStateChanged(_ joystick: Joystick!, axis:Int32) {
173 |
174 | //check to see if calibrating
175 | if (tryPitch == true) {
176 | //detect axis then save
177 | UserDefaults.standard.set(Int(axis), forKey: "pitch")
178 | tryPitch = false
179 |
180 | NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeLabelValues"), object:nil)
181 |
182 | } else if (tryRoll == true) {
183 | //detect axis then save
184 | UserDefaults.standard.set(Int(axis), forKey: "roll")
185 | tryRoll = false
186 |
187 | NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeLabelValues"), object:nil)
188 |
189 | } else if (tryThrottle == true) {
190 | //detect axis then save
191 | UserDefaults.standard.set(Int(axis), forKey: "throttle")
192 | tryThrottle = false
193 |
194 | NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeLabelValues"), object:nil)
195 |
196 | } else if (tryRudder == true) {
197 | //detect axis then save
198 | UserDefaults.standard.set(Int(axis), forKey: "rudder")
199 | tryRudder = false
200 |
201 | NotificationCenter.default.post(name: NSNotification.Name(rawValue: "changeLabelValues"), object:nil)
202 |
203 | }
204 |
205 |
206 | var value:Int32 = 0
207 |
208 | // print relVal - this is useful for debugging
209 | let relVal = joystick.getRelativeValue(ofAxesIndex: axis)
210 | NSLog("RelVal: \(relVal)")
211 |
212 | if UserDefaults.standard.bool(forKey: "gamepadMode") == true {
213 |
214 | // is a gamepad
215 | // values are [-128, 128]
216 |
217 | value = Int32(joystick.getRelativeValue(ofAxesIndex: axis) * 2048)
218 |
219 | } else {
220 |
221 | // raw values are [0, 1024]
222 | value = Int32(((joystick.getRelativeValue(ofAxesIndex: axis) * 2) - 1) * 1024)
223 |
224 | }
225 |
226 | if (Int(axis) == UserDefaults.standard.integer(forKey: "pitch")) {
227 | controls.pitchChanged(value: value)
228 |
229 | } else if (Int(axis) == UserDefaults.standard.integer(forKey: "roll")) {
230 | controls.rollChanged(value: value)
231 |
232 | } else if (Int(axis) == UserDefaults.standard.integer(forKey: "throttle")) {
233 | controls.throttleChanged(value: value)
234 |
235 | } else if (Int(axis) == UserDefaults.standard.integer(forKey: "rudder")) {
236 | controls.rudderChanged(value: value)
237 |
238 | }
239 |
240 | }
241 |
242 | func joystickButtonReleased(_ buttonIndex: Int32, on joystick: Joystick!) {
243 | NSLog("Button --> Released \(buttonIndex)")
244 | connector.didPressButton(buttonIndex, state: 1)
245 |
246 | }
247 |
248 | func joystickButtonPushed(_ buttonIndex: Int32, on joystick: Joystick!) {
249 |
250 | NSLog("Button --> Pressed \(buttonIndex)")
251 | connector.didPressButton(buttonIndex, state: 0)
252 | }
253 |
254 | }
255 |
--------------------------------------------------------------------------------
/LiveFlight/Joystick/JoystickManager.h:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickManager.h
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 23/08/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import
10 | #import
11 | #import "Joystick.h"
12 |
13 | @interface JoystickManager : NSObject {
14 |
15 | @private
16 | IOHIDManagerRef hidManager;
17 |
18 | NSMutableDictionary *joysticks;
19 |
20 | int joystickIDIndex;
21 | }
22 |
23 | @property (assign) id joystickAddedDelegate;
24 |
25 | + (JoystickManager *)sharedInstance;
26 | - (unsigned long)connectedJoysticks;
27 | - (void)registerNewJoystick:(Joystick *)joystick;
28 | - (void)joystickRemoved:(Joystick *)joystick;
29 | - (int)deviceIDByReference:(IOHIDDeviceRef)deviceRef;
30 | - (Joystick *)joystickByID:(int)joystickID;
31 |
32 | @end
33 |
--------------------------------------------------------------------------------
/LiveFlight/Joystick/JoystickManager.m:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickManager.m
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 23/08/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import "JoystickManager.h"
10 |
11 | @implementation JoystickManager
12 |
13 | @synthesize joystickAddedDelegate;
14 |
15 | static JoystickManager *instance;
16 |
17 | - (id)init {
18 | self = [super init];
19 |
20 | if (self) {
21 | joysticks = [[NSMutableDictionary alloc] init];
22 | joystickIDIndex = 0;
23 | [self setupGamepads];
24 | }
25 |
26 | return self;
27 | }
28 |
29 | + (void)initialize
30 | {
31 | static BOOL initialized = NO;
32 |
33 | if (!initialized) {
34 | initialized = YES;
35 | instance = [[JoystickManager alloc] init];
36 | }
37 | }
38 |
39 | + (JoystickManager *)sharedInstance {
40 | return instance;
41 | }
42 |
43 | - (unsigned long)connectedJoysticks {
44 | return [joysticks count];
45 | }
46 |
47 | - (int)deviceIDByReference:(IOHIDDeviceRef)deviceRef {
48 | for (id key in joysticks) {
49 | Joystick *thisJoystick = [joysticks objectForKey:key];
50 |
51 | if ([thisJoystick device] == deviceRef) {
52 | return [((NSNumber *)key) intValue];
53 | }
54 | }
55 |
56 | return -1;
57 | }
58 |
59 | - (Joystick *)joystickByID:(int)joystickID {
60 | return [joysticks objectForKey:[NSNumber numberWithInt:joystickID]];
61 | }
62 |
63 | - (void)registerNewJoystick:(Joystick *)joystick {
64 | [joysticks setObject:joystick forKey:[NSNumber numberWithInt:joystickIDIndex++]];
65 | NSLog(@"Gamepads registered: %lu", joysticks.count);
66 |
67 | [joystickAddedDelegate joystickAdded:joystick];
68 | }
69 |
70 |
71 | -(void)joystickRemoved:(Joystick *)joystick {
72 | [joysticks removeAllObjects];
73 | [joystickAddedDelegate joystickRemoved:joystick];
74 |
75 | [self setupGamepads];
76 |
77 | }
78 |
79 | void gamepadWasRemoved(void* inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef device) {
80 | NSLog(@"Gamepad was unplugged");
81 |
82 | IOHIDDeviceOpen(device, kIOHIDOptionsTypeNone);
83 | IOHIDDeviceRegisterInputValueCallback(device, gamepadAction, inContext);
84 |
85 | Joystick *joystick = [[Joystick alloc] initWithDevice:device];
86 | [[JoystickManager sharedInstance] joystickRemoved:joystick];
87 |
88 |
89 | }
90 |
91 | void gamepadAction(void* inContext, IOReturn inResult, void* inSender, IOHIDValueRef value) {
92 |
93 |
94 | IOHIDElementRef element = IOHIDValueGetElement(value);
95 | IOHIDDeviceRef device = IOHIDElementGetDevice(element);
96 |
97 | int joystickID = [[JoystickManager sharedInstance] deviceIDByReference:device];
98 |
99 | if (joystickID == -1) {
100 | NSLog(@"Invalid device reported.");
101 | return;
102 | }
103 |
104 | Joystick *joystick = [[JoystickManager sharedInstance] joystickByID:joystickID];
105 | [joystick elementReportedChange:element];
106 |
107 | }
108 |
109 | void gamepadWasAdded(void* inContext, IOReturn inResult, void* inSender, IOHIDDeviceRef device) {
110 | IOHIDDeviceOpen(device, kIOHIDOptionsTypeNone);
111 | IOHIDDeviceRegisterInputValueCallback(device, gamepadAction, inContext);
112 |
113 | Joystick *newJoystick = [[Joystick alloc] initWithDevice:device];
114 | [[JoystickManager sharedInstance] registerNewJoystick:newJoystick];
115 |
116 | NSLog(@"\nJoystick metadata:\n%@\n%d", newJoystick.productName, newJoystick.productId);
117 |
118 | }
119 |
120 |
121 | -(void)setupGamepads {
122 | hidManager = IOHIDManagerCreate( kCFAllocatorDefault, kIOHIDOptionsTypeNone);
123 |
124 | int usageKeys[] = { kHIDUsage_GD_GamePad,kHIDUsage_GD_Joystick,kHIDUsage_GD_MultiAxisController };
125 |
126 | int i;
127 |
128 | NSMutableArray *criterionSets = [NSMutableArray arrayWithCapacity:3];
129 |
130 | for (i=0; i<3; ++i) {
131 | int usageKeyConstant = usageKeys[i];
132 | NSMutableDictionary* criterion = [[NSMutableDictionary alloc] init];
133 | [criterion setObject: [NSNumber numberWithInt: kHIDPage_GenericDesktop] forKey: (NSString*)CFSTR(kIOHIDDeviceUsagePageKey)];
134 | [criterion setObject: [NSNumber numberWithInt: usageKeyConstant] forKey: (NSString*)CFSTR(kIOHIDDeviceUsageKey)];
135 | [criterionSets addObject:criterion];
136 |
137 | }
138 |
139 | IOHIDManagerSetDeviceMatchingMultiple(hidManager, (__bridge CFArrayRef)criterionSets);
140 | IOHIDManagerRegisterDeviceMatchingCallback(hidManager, gamepadWasAdded, (__bridge void*)self);
141 | IOHIDManagerRegisterDeviceRemovalCallback(hidManager, gamepadWasRemoved, (__bridge void*)self);
142 | IOHIDManagerScheduleWithRunLoop(hidManager, CFRunLoopGetCurrent(), kCFRunLoopDefaultMode);
143 | IOReturn tIOReturn = IOHIDManagerOpen(hidManager, kIOHIDOptionsTypeNone);
144 | (void)tIOReturn;
145 |
146 | }
147 |
148 |
149 | @end
150 |
--------------------------------------------------------------------------------
/LiveFlight/Joystick/JoystickNotificationDelegate.h:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickNotificationDelegate.h
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 23/08/15.
6 | // Copyright (c) 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import
10 |
11 | @class Joystick;
12 |
13 | @protocol JoystickNotificationDelegate
14 |
15 | - (void)joystickAdded:(Joystick*)joystick;
16 | - (void)joystickRemoved:(Joystick*)joystick;
17 | - (void)joystickStateChanged:(Joystick*)joystick axis:(int)axis;
18 | - (void)joystickButtonPushed:(int)buttonIndex onJoystick:(Joystick*)joystick;
19 | - (void)joystickButtonReleased:(int)buttonIndex onJoystick:(Joystick*)joystick;
20 |
21 | @end
22 |
--------------------------------------------------------------------------------
/LiveFlight/Keyboard/KeyboardListenerWindow.swift:
--------------------------------------------------------------------------------
1 | //
2 | // KeyboardListenerWindow.swift
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 26/12/2015.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | //
12 | // List of Apple keyboard keyCodes
13 | // http://macbiblioblog.blogspot.com.es/2014/12/key-codes-for-function-and-special-keys.html
14 | //
15 |
16 | class KeyboardListenerWindow: NSWindow {
17 | var connector = InfiniteFlightAPIConnector()
18 | let controls = FlightControls()
19 | var keydown = false
20 |
21 | var shiftPressed = false
22 |
23 | //MARK - keyboard events
24 | override func keyDown(with event: NSEvent)
25 | {
26 | NSLog("keyDown: \(event.keyCode)!")
27 |
28 | if (event.keyCode == 0) {
29 | //A key
30 | if (keydown != true) {
31 | connector.atcMenu()
32 | }
33 | keydown = true
34 | } else if (event.keyCode == 18) {
35 | //1 key
36 | if (keydown != true) {
37 | connector.atc1()
38 | }
39 | keydown = true
40 | } else if (event.keyCode == 19) {
41 | //2 key
42 | if (keydown != true) {
43 | connector.atc2()
44 | }
45 | keydown = true
46 | } else if (event.keyCode == 20) {
47 | //3 key
48 | if (keydown != true) {
49 | connector.atc3()
50 | }
51 | keydown = true
52 | } else if (event.keyCode == 21) {
53 | //4 key
54 | if (keydown != true) {
55 | connector.atc4()
56 | }
57 | keydown = true
58 | } else if (event.keyCode == 23) {
59 | //5 key
60 | if (keydown != true) {
61 | connector.atc5()
62 | }
63 | keydown = true
64 | } else if (event.keyCode == 22) {
65 | //6 key
66 | if (keydown != true) {
67 | connector.atc6()
68 | }
69 | keydown = true
70 | } else if (event.keyCode == 26) {
71 | //7 key
72 | if (keydown != true) {
73 | connector.atc7()
74 | }
75 | keydown = true
76 | } else if (event.keyCode == 28) {
77 | //8 key
78 | if (keydown != true) {
79 | connector.atc8()
80 | }
81 | keydown = true
82 | } else if (event.keyCode == 25) {
83 | //9 key
84 | if (keydown != true) {
85 | connector.atc9()
86 | }
87 | keydown = true
88 | } else if (event.keyCode == 29) {
89 | //0 key
90 | if (keydown != true) {
91 | connector.atc10()
92 | }
93 | keydown = true
94 | } else if (event.keyCode == 12) {
95 | //A key
96 | if (keydown != true) {
97 | connector.previousCamera()
98 | }
99 | keydown = true
100 | } else if (event.keyCode == 14) {
101 | //D key
102 | if (keydown != true) {
103 | connector.nextCamera()
104 | }
105 | keydown = true
106 | } else if (event.keyCode == 5) {
107 | //G key
108 | if (keydown != true) {
109 | connector.landingGear()
110 | }
111 | keydown = true
112 | } else if (event.keyCode == 47) {
113 | //. key
114 | if (keydown != true) {
115 | connector.parkingBrakes()
116 | }
117 | keydown = true
118 | } else if (event.keyCode == 44) {
119 | // / key
120 | if (keydown != true) {
121 | connector.spoilers()
122 | }
123 | keydown = true
124 | } else if (event.keyCode == 35) {
125 | // P key
126 | if (keydown != true) {
127 | connector.pushback()
128 | }
129 | keydown = true
130 | } else if (event.keyCode == 49) {
131 | // space key
132 | if (keydown != true) {
133 | connector.togglePause()
134 | }
135 | keydown = true
136 | } else if (event.keyCode == 6) {
137 | // Z key
138 | if (keydown != true) {
139 | connector.autopilot()
140 | }
141 | keydown = true
142 | } else if (event.keyCode == 24) {
143 | // = key
144 | if (keydown != true) {
145 | connector.zoomIn()
146 | }
147 | keydown = true
148 | } else if (event.keyCode == 27) {
149 | // - key
150 | if (keydown != true) {
151 | connector.zoomOut()
152 | }
153 | keydown = true
154 | } else if (event.keyCode == 30) {
155 | // ] key
156 | if (keydown != true) {
157 | connector.flapsDown()
158 | }
159 | keydown = true
160 | } else if (event.keyCode == 33) {
161 | // [ key
162 | if (keydown != true) {
163 | connector.flapsUp()
164 | }
165 | keydown = true
166 | } else if (event.keyCode == 37) {
167 | // L key
168 | if (keydown != true) {
169 | connector.landing()
170 | }
171 | keydown = true
172 | } else if (event.keyCode == 45) {
173 | // N key
174 | if (keydown != true) {
175 | connector.nav()
176 | }
177 | keydown = true
178 | } else if (event.keyCode == 11) {
179 | // B key
180 | if (keydown != true) {
181 | connector.beacon()
182 | }
183 | keydown = true
184 | } else if (event.keyCode == 1) {
185 | // S key
186 | if (keydown != true) {
187 | connector.strobe()
188 | }
189 | keydown = true
190 | } else if (event.keyCode == 123) {
191 |
192 | // - The following don't need the keyDown bool; timing is handled by InfiniteFlightAPIConnector
193 |
194 | // left arrow key
195 |
196 | if shiftPressed != true {
197 |
198 | controls.leftArrow()
199 |
200 | } else {
201 |
202 | // move camera left
203 | connector.movePOV(withValue: 270)
204 |
205 | }
206 |
207 | } else if (event.keyCode == 124) {
208 | // right arrow key
209 |
210 | if shiftPressed != true {
211 |
212 | controls.rightArrow()
213 |
214 | } else {
215 |
216 | // move camera right
217 | connector.movePOV(withValue: 90)
218 |
219 | }
220 |
221 | } else if (event.keyCode == 126) {
222 | // up arrow key
223 |
224 | if shiftPressed != true {
225 |
226 | controls.upArrow()
227 |
228 |
229 | } else {
230 |
231 | // move camera up
232 | connector.movePOV(withValue: 0)
233 |
234 | }
235 |
236 | } else if (event.keyCode == 125) {
237 | // down arrow key
238 |
239 | if shiftPressed != true {
240 |
241 | controls.downArrow()
242 |
243 | } else {
244 |
245 | // move camera down
246 | connector.movePOV(withValue: 180)
247 |
248 | }
249 |
250 | } else if (event.keyCode == 2) {
251 | // D key
252 |
253 | controls.throttleUpArrow()
254 |
255 | } else if (event.keyCode == 8) {
256 | // C arrow key
257 |
258 | controls.throttleDownArrow()
259 |
260 | }
261 |
262 |
263 | /*
264 | // TODO - send keyboard commands as buttons. issue with alternate cmds.
265 | connector.didPressButton(Int32(event.keyCode), state: 0)
266 | keydown = true
267 | */
268 |
269 | }
270 |
271 | override func keyUp(with event: NSEvent) {
272 | //connector.didPressButton(Int32(event.keyCode), state: 1)
273 | connector.movePOV(withValue: -2)
274 | keydown = false
275 | }
276 |
277 | override func flagsChanged(with event: NSEvent) {
278 | switch event.modifierFlags.intersection(.deviceIndependentFlagsMask) {
279 | case NSEvent.ModifierFlags.shift:
280 | NSLog("Shift key pressed")
281 | shiftPressed = true
282 | case NSEvent.ModifierFlags.control:
283 | NSLog("Control Pressed..")
284 | case NSEvent.ModifierFlags.option:
285 | NSLog("Option pressend...")
286 | case NSEvent.ModifierFlags.command:
287 | NSLog("Command key pressed..")
288 | default:
289 | NSLog("No modifier keys pressed")
290 | shiftPressed = false
291 | }
292 | }
293 |
294 | }
295 |
--------------------------------------------------------------------------------
/LiveFlight/LiveFlight Connect.entitlements:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | com.apple.security.app-sandbox
6 |
7 | com.apple.security.device.usb
8 |
9 | com.apple.security.network.client
10 |
11 | com.apple.security.network.server
12 |
13 |
14 |
15 |
--------------------------------------------------------------------------------
/LiveFlight/LiveFlight-Bridging-Header.h:
--------------------------------------------------------------------------------
1 | //
2 | // Use this file to import your target's public headers that you would like to expose to Swift.
3 | //
4 |
5 | #import "JoystickManager.h"
6 | #import "InfiniteFlightAPIConnector.h"
7 | #import "UDPReceiver.h"
8 | #include
--------------------------------------------------------------------------------
/LiveFlight/Resources/Credits.rtf:
--------------------------------------------------------------------------------
1 | {\rtf1\ansi\ansicpg1252\cocoartf1404\cocoasubrtf340
2 | {\fonttbl\f0\fswiss\fcharset0 Helvetica;}
3 | {\colortbl;\red255\green255\blue255;}
4 | \paperw11900\paperh16840\margl1440\margr1440\vieww10800\viewh8400\viewkind0
5 | \pard\tx566\tx1133\tx1700\tx2267\tx2834\tx3401\tx3968\tx4535\tx5102\tx5669\tx6236\tx6803\pardirnatural\partightenfactor0
6 |
7 | \f0\b\fs24 \cf0 Developed by {\field{\*\fldinst{HYPERLINK "http://www.carmichaelalonso.co.uk"}}{\fldrslt Cameron Carmichael Alonso}}.
8 | \b0 \
9 | \
10 | LiveFlight Connect is licensed under the GPL-V3 license:\
11 | {\field{\*\fldinst{HYPERLINK "https://github.com/LiveFlightApp/Connect-OSX"}}{\fldrslt https://github.com/LiveFlightApp/Connect-OSX}}\
12 | \
13 | Check out LiveFlight Tracker:\
14 | {\field{\*\fldinst{HYPERLINK "http://www.liveflightapp.com"}}{\fldrslt www.liveflightapp.com}}}
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_128x128.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_128x128.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_128x128@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_128x128@2x.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_16x16.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_16x16.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_16x16@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_16x16@2x.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_256x256.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_256x256.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_256x256@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_256x256@2x.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_32x32.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_32x32.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_32x32@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_32x32@2x.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_512x512.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_512x512.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_512x512@2x.png:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/AppIcon_mac_512x512@2x.png
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/AppIcon.appiconset/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "images" : [
3 | {
4 | "size" : "16x16",
5 | "idiom" : "mac",
6 | "filename" : "AppIcon_mac_16x16.png",
7 | "scale" : "1x"
8 | },
9 | {
10 | "size" : "16x16",
11 | "idiom" : "mac",
12 | "filename" : "AppIcon_mac_16x16@2x.png",
13 | "scale" : "2x"
14 | },
15 | {
16 | "size" : "32x32",
17 | "idiom" : "mac",
18 | "filename" : "AppIcon_mac_32x32.png",
19 | "scale" : "1x"
20 | },
21 | {
22 | "size" : "32x32",
23 | "idiom" : "mac",
24 | "filename" : "AppIcon_mac_32x32@2x.png",
25 | "scale" : "2x"
26 | },
27 | {
28 | "size" : "128x128",
29 | "idiom" : "mac",
30 | "filename" : "AppIcon_mac_128x128.png",
31 | "scale" : "1x"
32 | },
33 | {
34 | "size" : "128x128",
35 | "idiom" : "mac",
36 | "filename" : "AppIcon_mac_128x128@2x.png",
37 | "scale" : "2x"
38 | },
39 | {
40 | "size" : "256x256",
41 | "idiom" : "mac",
42 | "filename" : "AppIcon_mac_256x256.png",
43 | "scale" : "1x"
44 | },
45 | {
46 | "size" : "256x256",
47 | "idiom" : "mac",
48 | "filename" : "AppIcon_mac_256x256@2x.png",
49 | "scale" : "2x"
50 | },
51 | {
52 | "size" : "512x512",
53 | "idiom" : "mac",
54 | "filename" : "AppIcon_mac_512x512.png",
55 | "scale" : "1x"
56 | },
57 | {
58 | "size" : "512x512",
59 | "idiom" : "mac",
60 | "filename" : "AppIcon_mac_512x512@2x.png",
61 | "scale" : "2x"
62 | }
63 | ],
64 | "info" : {
65 | "version" : 1,
66 | "author" : "xcode"
67 | }
68 | }
--------------------------------------------------------------------------------
/LiveFlight/Resources/Images.xcassets/Contents.json:
--------------------------------------------------------------------------------
1 | {
2 | "info" : {
3 | "version" : 1,
4 | "author" : "xcode"
5 | }
6 | }
--------------------------------------------------------------------------------
/LiveFlight/Resources/Info.plist:
--------------------------------------------------------------------------------
1 |
2 |
3 |
4 |
5 | CFBundleDevelopmentRegion
6 | en
7 | CFBundleExecutable
8 | $(EXECUTABLE_NAME)
9 | CFBundleIconFile
10 | RoundedIcon
11 | CFBundleIdentifier
12 | $(PRODUCT_BUNDLE_IDENTIFIER)
13 | CFBundleInfoDictionaryVersion
14 | 6.0
15 | CFBundleName
16 | $(PRODUCT_NAME)
17 | CFBundlePackageType
18 | APPL
19 | CFBundleShortVersionString
20 | 1.5
21 | CFBundleSignature
22 | ????
23 | CFBundleVersion
24 | 6
25 | LSApplicationCategoryType
26 | public.app-category.utilities
27 | LSMinimumSystemVersion
28 | $(MACOSX_DEPLOYMENT_TARGET)
29 | NSAppTransportSecurity
30 |
31 | NSExceptionDomains
32 |
33 | connect.liveflightapp.com
34 |
35 | NSExceptionAllowsInsecureHTTPLoads
36 |
37 | NSExceptionMinimumTLSVersion
38 | TLSv1.1
39 | NSIncludesSubdomains
40 |
41 |
42 | www.google-analytics.com
43 |
44 | NSExceptionAllowsInsecureHTTPLoads
45 |
46 | NSExceptionMinimumTLSVersion
47 | TLSv1.1
48 | NSIncludesSubdomains
49 |
50 |
51 |
52 |
53 | NSHumanReadableCopyright
54 | Copyright © 2016 Cameron Carmichael Alonso. All rights reserved.
55 | NSMainStoryboardFile
56 | Main
57 | NSPrincipalClass
58 | NSApplication
59 |
60 |
61 |
--------------------------------------------------------------------------------
/LiveFlight/Resources/Reachability.swift:
--------------------------------------------------------------------------------
1 | /*
2 | Copyright (c) 2014, Ashley Mills
3 | All rights reserved.
4 |
5 | Redistribution and use in source and binary forms, with or without
6 | modification, are permitted provided that the following conditions are met:
7 |
8 | 1. Redistributions of source code must retain the above copyright notice, this
9 | list of conditions and the following disclaimer.
10 |
11 | 2. Redistributions in binary form must reproduce the above copyright notice,
12 | this list of conditions and the following disclaimer in the documentation
13 | and/or other materials provided with the distribution.
14 |
15 | THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS "AS IS"
16 | AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
17 | IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
18 | ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT HOLDER OR CONTRIBUTORS BE
19 | LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR
20 | CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF
21 | SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS
22 | INTERRUPTION) HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN
23 | CONTRACT, STRICT LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE)
24 | ARISING IN ANY WAY OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE
25 | POSSIBILITY OF SUCH DAMAGE.
26 | */
27 |
28 | import SystemConfiguration
29 | import Foundation
30 |
31 | public enum ReachabilityError: Error {
32 | case FailedToCreateWithAddress(sockaddr_in)
33 | case FailedToCreateWithHostname(String)
34 | case UnableToSetCallback
35 | case UnableToSetDispatchQueue
36 | }
37 |
38 | @available(*, unavailable, renamed: "Notification.Name.reachabilityChanged")
39 | public let ReachabilityChangedNotification = NSNotification.Name("ReachabilityChangedNotification")
40 |
41 | extension Notification.Name {
42 | public static let reachabilityChanged = Notification.Name("reachabilityChanged")
43 | }
44 |
45 | func callback(reachability:SCNetworkReachability, flags: SCNetworkReachabilityFlags, info: UnsafeMutableRawPointer?) {
46 |
47 | guard let info = info else { return }
48 |
49 | let reachability = Unmanaged.fromOpaque(info).takeUnretainedValue()
50 | reachability.reachabilityChanged()
51 | }
52 |
53 | public class Reachability {
54 |
55 | public typealias NetworkReachable = (Reachability) -> ()
56 | public typealias NetworkUnreachable = (Reachability) -> ()
57 |
58 | @available(*, unavailable, renamed: "Conection")
59 | public enum NetworkStatus: CustomStringConvertible {
60 | case notReachable, reachableViaWiFi, reachableViaWWAN
61 | public var description: String {
62 | switch self {
63 | case .reachableViaWWAN: return "Cellular"
64 | case .reachableViaWiFi: return "WiFi"
65 | case .notReachable: return "No Connection"
66 | }
67 | }
68 | }
69 |
70 | public enum Connection: CustomStringConvertible {
71 | case none, wifi, cellular
72 | public var description: String {
73 | switch self {
74 | case .cellular: return "Cellular"
75 | case .wifi: return "WiFi"
76 | case .none: return "No Connection"
77 | }
78 | }
79 | }
80 |
81 | public var whenReachable: NetworkReachable?
82 | public var whenUnreachable: NetworkUnreachable?
83 |
84 | @available(*, deprecated: 4.0, renamed: "allowsCellularConnection")
85 | public let reachableOnWWAN: Bool = true
86 |
87 | /// Set to `false` to force Reachability.connection to .none when on cellular connection (default value `true`)
88 | public var allowsCellularConnection: Bool
89 |
90 | // The notification center on which "reachability changed" events are being posted
91 | public var notificationCenter: NotificationCenter = NotificationCenter.default
92 |
93 | @available(*, deprecated: 4.0, renamed: "connection.description")
94 | public var currentReachabilityString: String {
95 | return "\(connection)"
96 | }
97 |
98 | @available(*, unavailable, renamed: "connection")
99 | public var currentReachabilityStatus: Connection {
100 | return connection
101 | }
102 |
103 | public var connection: Connection {
104 |
105 | guard isReachableFlagSet else { return .none }
106 |
107 | // If we're reachable, but not on an iOS device (i.e. simulator), we must be on WiFi
108 | guard isRunningOnDevice else { return .wifi }
109 |
110 | var connection = Connection.none
111 |
112 | if !isConnectionRequiredFlagSet {
113 | connection = .wifi
114 | }
115 |
116 | if isConnectionOnTrafficOrDemandFlagSet {
117 | if !isInterventionRequiredFlagSet {
118 | connection = .wifi
119 | }
120 | }
121 |
122 | if isOnWWANFlagSet {
123 | if !allowsCellularConnection {
124 | connection = .none
125 | } else {
126 | connection = .cellular
127 | }
128 | }
129 |
130 | return connection
131 | }
132 |
133 | fileprivate var previousFlags: SCNetworkReachabilityFlags?
134 |
135 | fileprivate var isRunningOnDevice: Bool = {
136 | #if (arch(i386) || arch(x86_64)) && os(iOS)
137 | return false
138 | #else
139 | return true
140 | #endif
141 | }()
142 |
143 | fileprivate var notifierRunning = false
144 | fileprivate let reachabilityRef: SCNetworkReachability
145 |
146 | fileprivate let reachabilitySerialQueue = DispatchQueue(label: "uk.co.ashleymills.reachability")
147 |
148 | required public init(reachabilityRef: SCNetworkReachability) {
149 | allowsCellularConnection = true
150 | self.reachabilityRef = reachabilityRef
151 | }
152 |
153 | public convenience init?(hostname: String) {
154 |
155 | guard let ref = SCNetworkReachabilityCreateWithName(nil, hostname) else { return nil }
156 |
157 | self.init(reachabilityRef: ref)
158 | }
159 |
160 | public convenience init?() {
161 |
162 | var zeroAddress = sockaddr()
163 | zeroAddress.sa_len = UInt8(MemoryLayout.size)
164 | zeroAddress.sa_family = sa_family_t(AF_INET)
165 |
166 | guard let ref = SCNetworkReachabilityCreateWithAddress(nil, &zeroAddress) else { return nil }
167 |
168 | self.init(reachabilityRef: ref)
169 | }
170 |
171 | deinit {
172 | stopNotifier()
173 | }
174 | }
175 |
176 | public extension Reachability {
177 |
178 | // MARK: - *** Notifier methods ***
179 | func startNotifier() throws {
180 |
181 | guard !notifierRunning else { return }
182 |
183 | var context = SCNetworkReachabilityContext(version: 0, info: nil, retain: nil, release: nil, copyDescription: nil)
184 | context.info = UnsafeMutableRawPointer(Unmanaged.passUnretained(self).toOpaque())
185 | if !SCNetworkReachabilitySetCallback(reachabilityRef, callback, &context) {
186 | stopNotifier()
187 | throw ReachabilityError.UnableToSetCallback
188 | }
189 |
190 | if !SCNetworkReachabilitySetDispatchQueue(reachabilityRef, reachabilitySerialQueue) {
191 | stopNotifier()
192 | throw ReachabilityError.UnableToSetDispatchQueue
193 | }
194 |
195 | // Perform an initial check
196 | reachabilitySerialQueue.async {
197 | self.reachabilityChanged()
198 | }
199 |
200 | notifierRunning = true
201 | }
202 |
203 | func stopNotifier() {
204 | defer { notifierRunning = false }
205 |
206 | SCNetworkReachabilitySetCallback(reachabilityRef, nil, nil)
207 | SCNetworkReachabilitySetDispatchQueue(reachabilityRef, nil)
208 | }
209 |
210 | // MARK: - *** Connection test methods ***
211 | @available(*, deprecated: 4.0, message: "Please use `connection != .none`")
212 | var isReachable: Bool {
213 |
214 | guard isReachableFlagSet else { return false }
215 |
216 | if isConnectionRequiredAndTransientFlagSet {
217 | return false
218 | }
219 |
220 | if isRunningOnDevice {
221 | if isOnWWANFlagSet && !reachableOnWWAN {
222 | // We don't want to connect when on cellular connection
223 | return false
224 | }
225 | }
226 |
227 | return true
228 | }
229 |
230 | @available(*, deprecated: 4.0, message: "Please use `connection == .cellular`")
231 | var isReachableViaWWAN: Bool {
232 | // Check we're not on the simulator, we're REACHABLE and check we're on WWAN
233 | return isRunningOnDevice && isReachableFlagSet && isOnWWANFlagSet
234 | }
235 |
236 | @available(*, deprecated: 4.0, message: "Please use `connection == .wifi`")
237 | var isReachableViaWiFi: Bool {
238 |
239 | // Check we're reachable
240 | guard isReachableFlagSet else { return false }
241 |
242 | // If reachable we're reachable, but not on an iOS device (i.e. simulator), we must be on WiFi
243 | guard isRunningOnDevice else { return true }
244 |
245 | // Check we're NOT on WWAN
246 | return !isOnWWANFlagSet
247 | }
248 |
249 | var description: String {
250 |
251 | let W = isRunningOnDevice ? (isOnWWANFlagSet ? "W" : "-") : "X"
252 | let R = isReachableFlagSet ? "R" : "-"
253 | let c = isConnectionRequiredFlagSet ? "c" : "-"
254 | let t = isTransientConnectionFlagSet ? "t" : "-"
255 | let i = isInterventionRequiredFlagSet ? "i" : "-"
256 | let C = isConnectionOnTrafficFlagSet ? "C" : "-"
257 | let D = isConnectionOnDemandFlagSet ? "D" : "-"
258 | let l = isLocalAddressFlagSet ? "l" : "-"
259 | let d = isDirectFlagSet ? "d" : "-"
260 |
261 | return "\(W)\(R) \(c)\(t)\(i)\(C)\(D)\(l)\(d)"
262 | }
263 | }
264 |
265 | fileprivate extension Reachability {
266 |
267 | func reachabilityChanged() {
268 | guard previousFlags != flags else { return }
269 |
270 | let block = connection != .none ? whenReachable : whenUnreachable
271 |
272 | DispatchQueue.main.async {
273 | block?(self)
274 | self.notificationCenter.post(name: .reachabilityChanged, object:self)
275 | }
276 |
277 | previousFlags = flags
278 | }
279 |
280 | var isOnWWANFlagSet: Bool {
281 | #if os(iOS)
282 | return flags.contains(.isWWAN)
283 | #else
284 | return false
285 | #endif
286 | }
287 | var isReachableFlagSet: Bool {
288 | return flags.contains(.reachable)
289 | }
290 | var isConnectionRequiredFlagSet: Bool {
291 | return flags.contains(.connectionRequired)
292 | }
293 | var isInterventionRequiredFlagSet: Bool {
294 | return flags.contains(.interventionRequired)
295 | }
296 | var isConnectionOnTrafficFlagSet: Bool {
297 | return flags.contains(.connectionOnTraffic)
298 | }
299 | var isConnectionOnDemandFlagSet: Bool {
300 | return flags.contains(.connectionOnDemand)
301 | }
302 | var isConnectionOnTrafficOrDemandFlagSet: Bool {
303 | return !flags.intersection([.connectionOnTraffic, .connectionOnDemand]).isEmpty
304 | }
305 | var isTransientConnectionFlagSet: Bool {
306 | return flags.contains(.transientConnection)
307 | }
308 | var isLocalAddressFlagSet: Bool {
309 | return flags.contains(.isLocalAddress)
310 | }
311 | var isDirectFlagSet: Bool {
312 | return flags.contains(.isDirect)
313 | }
314 | var isConnectionRequiredAndTransientFlagSet: Bool {
315 | return flags.intersection([.connectionRequired, .transientConnection]) == [.connectionRequired, .transientConnection]
316 | }
317 |
318 | var flags: SCNetworkReachabilityFlags {
319 | var flags = SCNetworkReachabilityFlags()
320 | if SCNetworkReachabilityGetFlags(reachabilityRef, &flags) {
321 | return flags
322 | } else {
323 | return SCNetworkReachabilityFlags()
324 | }
325 | }
326 | }
327 |
--------------------------------------------------------------------------------
/LiveFlight/Resources/RoundedIcon.icns:
--------------------------------------------------------------------------------
https://raw.githubusercontent.com/LiveFlightApp/Connect-OSX/f828ba8b51b2034d03557f408e14f133ccc6fe3e/LiveFlight/Resources/RoundedIcon.icns
--------------------------------------------------------------------------------
/LiveFlight/ViewSubclasses/ControlPad/ControlPad.h:
--------------------------------------------------------------------------------
1 | //
2 | // ControlPad.h
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 17/10/15.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import
10 | #import "Connect-Swift.h"
11 | #import "InfiniteFlightAPIConnector.h"
12 |
13 |
14 | @interface ControlPad : NSView {
15 | NSTrackingArea * trackingArea;
16 | bool inArea;
17 | bool selected;
18 | int x;
19 | int y;
20 | }
21 |
22 | @end
23 |
--------------------------------------------------------------------------------
/LiveFlight/ViewSubclasses/ControlPad/ControlPad.m:
--------------------------------------------------------------------------------
1 | //
2 | // ControlPad.m
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 17/10/15.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | #import "ControlPad.h"
10 |
11 |
12 | @implementation ControlPad
13 |
14 |
15 | -(void)updateTrackingAreas
16 | {
17 | if(trackingArea != nil) {
18 | [self removeTrackingArea:trackingArea];
19 | }
20 |
21 | int opts = (NSTrackingMouseEnteredAndExited | NSTrackingActiveAlways);
22 | trackingArea = [ [NSTrackingArea alloc] initWithRect:[self bounds]
23 | options:opts
24 | owner:self
25 | userInfo:nil];
26 | [self addTrackingArea:trackingArea];
27 | }
28 |
29 | -(void)mouseEntered:(NSEvent *)theEvent {
30 |
31 | NSLog(@"Mouse entered area");
32 | inArea = true;
33 |
34 | }
35 |
36 | -(void)mouseExited:(NSEvent *)theEvent {
37 |
38 | NSLog(@"Mouse exited area");
39 | inArea = false;
40 |
41 | }
42 |
43 | - (void)mouseMoved:(NSEvent *)event {
44 |
45 | if (inArea == true) {
46 |
47 | if (selected == true) {
48 |
49 | NSPoint location = [self convertPoint:[event locationInWindow] fromView:nil];
50 |
51 | int locX = ((location.x * 2) - 256) * 4; //bring up to be a total of 1024
52 | int locY = ((location.y * 2) - 256) * 4;
53 |
54 | NSLog(@"Location: %d, %d", locX, locY);
55 |
56 | AppDelegate *delegate = [[NSApplication sharedApplication] delegate];
57 | InfiniteFlightAPIConnector *connector = delegate.connector;
58 | [connector didMoveAxis:0 value:locY];
59 | [connector didMoveAxis:1 value:locX];
60 |
61 | }
62 |
63 | }
64 | }
65 |
66 | -(void)mouseDown:(NSEvent *)theEvent {
67 |
68 | if (selected == true) {
69 | selected = false;
70 | } else if (selected == false) {
71 | selected = true;
72 | }
73 |
74 | }
75 |
76 |
77 | -(void)resizeFrameBy:(int)value {
78 |
79 | NSRect frame = [self frame];
80 | [self setFrame:CGRectMake(frame.origin.x,
81 | frame.origin.x,
82 | frame.size.width + value,
83 | frame.size.height + value
84 | )];
85 | }
86 |
87 | - (void)drawRect:(NSRect)dirtyRect
88 | {
89 | [[NSColor whiteColor] set];
90 | NSRectFill([self bounds]);
91 | [[self window] makeFirstResponder:self];
92 | [[self window] setAcceptsMouseMovedEvents:YES];
93 |
94 |
95 | NSRect thisViewSize = [self bounds];
96 |
97 | // Set the line color
98 |
99 | [[NSColor colorWithDeviceRed:0
100 | green:(255/255.0)
101 | blue:(255/255.0)
102 | alpha:1] set];
103 |
104 | // Draw the vertical lines first
105 |
106 | NSBezierPath * verticalLinePath = [NSBezierPath bezierPath];
107 |
108 | int gridWidth = thisViewSize.size.width;
109 | int gridHeight = thisViewSize.size.height;
110 |
111 | int i;
112 | int currentSpacing = 10;
113 |
114 | while (i < gridWidth)
115 | {
116 | i = i + currentSpacing;
117 |
118 | NSPoint startPoint = {i,0};
119 | NSPoint endPoint = {i, gridHeight};
120 |
121 | [verticalLinePath setLineWidth:0.1];
122 | [verticalLinePath moveToPoint:startPoint];
123 | [verticalLinePath lineToPoint:endPoint];
124 |
125 | }
126 |
127 | // Draw the horizontal lines
128 |
129 | NSBezierPath * horizontalLinePath = [NSBezierPath bezierPath];
130 |
131 | i = 0;
132 | while (i < gridHeight)
133 | {
134 | i = i + currentSpacing;
135 |
136 | NSPoint startPoint = {0,i};
137 | NSPoint endPoint = {gridWidth, i};
138 |
139 | [horizontalLinePath setLineWidth:0.5];
140 | [horizontalLinePath moveToPoint:startPoint];
141 | [horizontalLinePath lineToPoint:endPoint];
142 |
143 | }
144 |
145 | [verticalLinePath stroke];
146 | [horizontalLinePath stroke];
147 |
148 | }
149 |
150 | @end
151 |
--------------------------------------------------------------------------------
/LiveFlight/ViewSubclasses/StatusMessages/Status.swift:
--------------------------------------------------------------------------------
1 | //
2 | // JoystickReady.swift
3 | // LiveFlight
4 | //
5 | // Created by Cameron Carmichael Alonso on 30/12/2015.
6 | // Copyright © 2015 Cameron Carmichael Alonso. All rights reserved.
7 | //
8 |
9 | import Cocoa
10 |
11 | class Status: NSView {
12 |
13 | override init(frame frameRect: NSRect) {
14 | super.init(frame:frameRect)
15 |
16 | }
17 |
18 | required init(coder: NSCoder) {
19 | super.init(coder: coder)!
20 |
21 | // set the background for the all clear view
22 | self.backgroundColor = NSColor(calibratedRed: (50.0/255.0), green: (50.0/255.0), blue: (50.0/255.0), alpha: 0.95)
23 |
24 |
25 | }
26 |
27 | }
28 |
--------------------------------------------------------------------------------
/README.md:
--------------------------------------------------------------------------------
1 | # LiveFlight Connect - OS X
2 | LiveFlight Connect for OS X allows you to control Infinite Flight on an iOS or Android device via your Mac using either joystick, keyboard, or mouse.
3 |
4 | Uses Infinite Flight Connect, a TCP-based API introduced in version 15.10.0.
5 |
6 | ## Deprecated
7 |
8 | **As of 26th February 2020, LiveFlight Connect is no longer officially supported.**
9 |
10 | The apps are still available for download and the source code is available, however, no official updates are planned, nor will support be provided for any issues.
11 |
12 | Modifying Source
13 | ------------
14 | LiveFlight Connect is built in Objective-C/Swift. Objective-C is used for referencing lower-level APIs (IOHIDLib, NSStream for TCP connection, etc.) and Swift is used for manipulating the UI and handling joystick/keyboard events.
15 |
16 | Clone the repo to start with. Connect-OSX uses submodules for third party libs. Run:
17 |
18 | git submodule init
19 | git submodule update
20 |
21 | Open the project in Xcode and build it - you should be good to go!
22 |
23 | Compatible Devices
24 | ------------
25 | There's no guarantee this will play perfectly with your joystick or configuration. Devices which require two USB ports need some work still. These joysticks work fine:
26 | * Thrustmaster T-Flight Hotas X
27 | * Logitech Extreme 3D
28 |
29 | Licenses
30 | -----------
31 | This project uses:
32 | * https://github.com/robbiehanson/CocoaAsyncSocket
33 | * https://github.com/daltoniam/SwiftHTTP
34 | * https://github.com/ashleymills/Reachability.swift
35 |
36 |
37 | LiveFlight Connect License
38 | -----------
39 | Licensed under the GPL-V3 License available here.
40 |
--------------------------------------------------------------------------------