<feed xmlns='http://www.w3.org/2005/Atom'>
<title>DomeKey/DomeKey.xcodeproj/xcuserdata/tw.xcuserdatad, branch bluetooth-headset-compatibility</title>
<subtitle>Control your computer with a pair of headphones</subtitle>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/DomeKey/'/>
<entry>
<title>Random xcodeproj change</title>
<updated>2018-08-16T04:55:02+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-08-16T04:32:09+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/DomeKey/commit/?id=9dd1e0b3b2485484fb89de3a924e9e6aacea5609'/>
<id>9dd1e0b3b2485484fb89de3a924e9e6aacea5609</id>
<content type='text'>
What does it mean?
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
What does it mean?
</pre>
</div>
</content>
</entry>
<entry>
<title>Use an `NSApplication`</title>
<updated>2018-08-16T04:55:02+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-08-16T03:26:40+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/DomeKey/commit/?id=b298df219eb007ea11e6c14a332fd3f4924ff7d2'/>
<id>b298df219eb007ea11e6c14a332fd3f4924ff7d2</id>
<content type='text'>
Previously the `setListenInExclusiveMode:` call did appear to work,
disabling the normal functioning of the headphone buttons. But my
`NSLog`s in `ddhidAppleMikey:press:upOrDown:` didn't get printed, the
method having not been called.

Since all the other applications I found using DDHidLib were GUI apps
using `NSApplication`, I decided to take this approach here. Set up the
`NSApplication` in `main.c` and added a new `AppDelegate` class.

It seems like the reference to my `HeadphoneKey` instance wasn't getting
retained or something. When I moved the:

    HeadphoneKey *h = [[HeadphoneKey alloc] init];

line into `AppDelegate`'s `applicationDidFinishLaunching:`, nothing
changed. However, when I moved all code from `HeadphoneKey` into
`AppDelegate`, my `ddhidAppleMikey:press:upOrDown:` method _did_ get
called.

At that point, it was logical to try adding a `HeadphoneKey` instance
variable and `init`ing into that variable. As a result, we now have a
working `ddhidAppleMikey:press:upOrDown:` delegate method that correctly
logs the headphone key events!

Here are the reference applications I looked at using DDHidLib, found
using a simple GitHub search:

- https://github.com/radiant-player/radiant-player-mac/pull/450/files
- https://github.com/7hil/mac_ear_control/blob/8859ed554517ce798b8ae7c2d0e78610b9994300/mac_ear_control/AppDelegate.m
- https://github.com/7hil/mac_ear_control/blob/8859ed554517ce798b8ae7c2d0e78610b9994300/mac_ear_control/AppDelegate.m
- https://github.com/schrekia/beardedspice-enhanced/blob/a9b78c0dbae6bca2cb0d2ecc362e4b7fe5b02129/BeardedSpiceControllers/BSCService.m
- https://github.com/beardedspice/beardedspice/blob/8e1aea5bda68395e6b0d866bca9289a2a5ba40ed/BeardedSpiceControllers/BSCService.m
- https://github.com/beardedspice/beardedspice/blob/8e1aea5bda68395e6b0d866bca9289a2a5ba40ed/BeardedSpiceControllers/BSCService.m
- https://github.com/BarakaAka1Only/radiant-player-mac-BarakaLyrics/blob/1ce889bbb80f081209aff7936a329a3b426462e9/radiant-player-mac/AppDelegate.m
- https://github.com/zsszatmari/MagicKeys/blob/210015d5da876cd7bb1daf73efa3c775c18e7973/MagicKeys-Agent/SPMediaKeyTap.m

Thanks immensely this Cocoa With Love article from Matt Gallagher, which
was invaluable in showing me how to create a minimal Cocoa application
without needing a nib, Info.plist, or even application bundle (instead
putting everything in a single executable, making it easier to
distribute this as a command-line application with a built-in daemon):
https://www.cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
Previously the `setListenInExclusiveMode:` call did appear to work,
disabling the normal functioning of the headphone buttons. But my
`NSLog`s in `ddhidAppleMikey:press:upOrDown:` didn't get printed, the
method having not been called.

Since all the other applications I found using DDHidLib were GUI apps
using `NSApplication`, I decided to take this approach here. Set up the
`NSApplication` in `main.c` and added a new `AppDelegate` class.

It seems like the reference to my `HeadphoneKey` instance wasn't getting
retained or something. When I moved the:

    HeadphoneKey *h = [[HeadphoneKey alloc] init];

line into `AppDelegate`'s `applicationDidFinishLaunching:`, nothing
changed. However, when I moved all code from `HeadphoneKey` into
`AppDelegate`, my `ddhidAppleMikey:press:upOrDown:` method _did_ get
called.

At that point, it was logical to try adding a `HeadphoneKey` instance
variable and `init`ing into that variable. As a result, we now have a
working `ddhidAppleMikey:press:upOrDown:` delegate method that correctly
logs the headphone key events!

Here are the reference applications I looked at using DDHidLib, found
using a simple GitHub search:

- https://github.com/radiant-player/radiant-player-mac/pull/450/files
- https://github.com/7hil/mac_ear_control/blob/8859ed554517ce798b8ae7c2d0e78610b9994300/mac_ear_control/AppDelegate.m
- https://github.com/7hil/mac_ear_control/blob/8859ed554517ce798b8ae7c2d0e78610b9994300/mac_ear_control/AppDelegate.m
- https://github.com/schrekia/beardedspice-enhanced/blob/a9b78c0dbae6bca2cb0d2ecc362e4b7fe5b02129/BeardedSpiceControllers/BSCService.m
- https://github.com/beardedspice/beardedspice/blob/8e1aea5bda68395e6b0d866bca9289a2a5ba40ed/BeardedSpiceControllers/BSCService.m
- https://github.com/beardedspice/beardedspice/blob/8e1aea5bda68395e6b0d866bca9289a2a5ba40ed/BeardedSpiceControllers/BSCService.m
- https://github.com/BarakaAka1Only/radiant-player-mac-BarakaLyrics/blob/1ce889bbb80f081209aff7936a329a3b426462e9/radiant-player-mac/AppDelegate.m
- https://github.com/zsszatmari/MagicKeys/blob/210015d5da876cd7bb1daf73efa3c775c18e7973/MagicKeys-Agent/SPMediaKeyTap.m

Thanks immensely this Cocoa With Love article from Matt Gallagher, which
was invaluable in showing me how to create a minimal Cocoa application
without needing a nib, Info.plist, or even application bundle (instead
putting everything in a single executable, making it easier to
distribute this as a command-line application with a built-in daemon):
https://www.cocoawithlove.com/2010/09/minimalist-cocoa-programming.html
</pre>
</div>
</content>
</entry>
<entry>
<title>Add DDHidLib framework as a target dependency</title>
<updated>2018-08-07T06:54:30+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-08-07T06:54:30+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/DomeKey/commit/?id=43b6f4aa4164c40cd090ce4f5fec917709889355'/>
<id>43b6f4aa4164c40cd090ce4f5fec917709889355</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
<entry>
<title>New Xcode 9.2 command-line tool project</title>
<updated>2018-08-06T21:06:01+00:00</updated>
<author>
<name>Teddy Wing</name>
</author>
<published>2018-08-06T21:05:38+00:00</published>
<link rel='alternate' type='text/html' href='https://git.teddywing.com/DomeKey/commit/?id=8645fbf85382c8ff4fe3befd946d41a62f837184'/>
<id>8645fbf85382c8ff4fe3befd946d41a62f837184</id>
<content type='text'>
</content>
<content type='xhtml'>
<div xmlns='http://www.w3.org/1999/xhtml'>
<pre>
</pre>
</div>
</content>
</entry>
</feed>
