aboutsummaryrefslogtreecommitdiffstats
AgeCommit message (Collapse)Author
2018-11-04Add `teprintf()` functionTeddy Wing
A new function to print to stderr prefixed with a timestamp. The idea is to make the printed line's format match the Rust logger's. The Rust logger prints timestamps like this: 2018-11-04T03:16:31.938+01:00 `teprintf` does: 2018-11-04T15:02:21+0100 Unfortunately, I wasn't able to reproduce it exactly. It's missing the milliseconds because I didn't want to deal with using `gettimeofday`, and the time zone format isn't right because I didn't know how to format it easily with a colon. Resources: Getting the time in C: https://stackoverflow.com/questions/9596945/how-to-get-appropriate-timestamp-in-c-for-logs#9596994 Variadic functions in C: https://stackoverflow.com/questions/205529/passing-variable-number-of-arguments-around Getting milliseconds in C: https://stackoverflow.com/questions/10192903/time-in-milliseconds#10192994 https://stackoverflow.com/questions/3673226/how-to-print-time-in-format-2009-08-10-181754-811 https://stackoverflow.com/questions/361363/how-to-measure-time-in-milliseconds-using-ansi-c Concatenating strings in C: https://stackoverflow.com/questions/308695/how-do-i-concatenate-const-literal-strings-in-c#308712 https://stackoverflow.com/questions/8465006/how-do-i-concatenate-two-strings-in-c
2018-11-04Update TODOTeddy Wing
2018-11-04Mappings: Print parse error messages when running with `-r`Teddy Wing
Otherwise, the error messages only get printed in the daemon process' output. Much more convenient to print the error messages directly after running the command with `--reload-mappings`.
2018-11-04Get mapping reloader to reload mappings for realTeddy Wing
Previously I got the inter-process communication set up, but left the work of actually reloading the mappings into memory for later. That later is now. Make `Mappings` solely responsible for loading and reloading mappings. What used to be in `HeadphoneKey` for this has now been moved. HeadphoneKey: * Store a reference to a `Mappings` instance * Load mappings using the `Mappings` API instead of calling `dome_key_state_load_map_group()` directly. * Move the call to `observeReloadNotification` here from `main()`. Made more sense to me to have it with the other related mappings setup method calls. * Move the `_state` variable into `Mappings`, since that's where it's used most. Get it from an accessor in the one spot we need it. Mappings: * Make `observeReloadNotification` an instance method. While not necessary, since I decided to call it in `HeadphoneKey` after initialising `_mappings` and calling `reloadMappings`, I figured it made sense to call the method on the instance. * Make `reloadMappings` both an instance method and a class method. Made sense to call it on the instance since we instantiate `Mappings` just before calling it in `HeadphoneKey`. But we also need to be able to call it from `reload_mappings`, the C function, which has no knowledge of the `Mappings` instance. That's why we make it a class method also. * Add a `_state` static variable. Not ideal. Would rather have an instance variable, but this value needs to be accessible from the `reload_mappings` C function, which doesn't have access to instance variables.
2018-11-03Move `dome_key_logger_init` call to `main()`Teddy Wing
Doesn't make sense to have this in the `HeadphoneKey` initialiser. Since it's something that needs to be done near the start of the program, move it into `main()`.
2018-11-03lib/dome-key-map: Update to latestTeddy Wing
New trial encryption key.
2018-11-03lib/dome-key-map: Update to latest, good error messagesTeddy Wing
2018-11-03doc/dome-key.1.txt: Add a rough descriptionTeddy Wing
* Make "OPTIONS" in the Synopsis section lowercase to match other man pages * Add a description of the program. Still not happy with it yet, but it's a start. * Add a "See Also" section that refers to an uncreated man page that should describe the syntax of the dkmap mappings file.
2018-11-03Update TODOTeddy Wing
2018-11-02pkg/dome-key.in.rb: Set dependency on Mac OS X 10.7Teddy Wing
While the Objective-C/Cocoa code is designed to work on at least 10.6, the Rust code requires >=10.7, as something in Rust, maybe the standard library, requires at least that version of Mac OS.
2018-11-02Add the beginning of a man pageTeddy Wing
Copy-pasted options from the `--help` output and reordered them alphabtically. Includes a few stub sections that I think are needed.
2018-11-02Update TODOTeddy Wing
2018-10-30Update TODOTeddy Wing
2018-10-30Update TODOTeddy Wing
2018-10-30Update TODOTeddy Wing
2018-10-30Add a skeleton Homebrew formulaTeddy Wing
The start of a Homebrew formula for the program. Needs a bunch of fields filled out. For now, we're mostly getting it to work as an input template for an accompanying generator script. The script will fill in some values automatically, including the plist file, so that the launchd plist can be activated using Homebrew's services.
2018-10-30Add launchd plistTeddy Wing
2018-10-30Update TODOTeddy Wing
2018-10-30lib/dome-key-map: Update to include default mappingsTeddy Wing
2018-10-29Update TODOTeddy Wing
2018-10-29HeadphoneKey: Play audio only with the `--audio` command line flagTeddy Wing
Allow users to decide whether interface audio (mode activated & deactivated) should play. The flag value is in a `Config`, so to make it easier to pass both the audio flag and the timeout config value to `HeadphoneKey`, rename `initWithTimeout:` to `initWithConfig:`. Only allocate a `Sounds` instance if `--audio` is passed, because there's no reason to allocate memory for it otherwise. Add a `_play_audio` flag as a static variable to make it accessible to the `on_mode_change()` function, just like we did for `sounds_inst`. In `on_mode_change()`, don't play any audio if `_play_audio` is on.
2018-10-29lib/dome-key-map: Update to get `--audio` flag handlingTeddy Wing
2018-10-29HeadphoneKey: Remove unused `_in_mode` instance variableTeddy Wing
This was for when I was trying to store the current mode in this class. It's now stored in a `State` variable.
2018-10-29Play sounds when a mode is activated & deactivatedTeddy Wing
Use the new function pointer argument on `dome_key_run_key_action()` to play our interface sounds. Store the `Sounds` instance in a static constant variable in order to make it accessible to our callback function's scope. At first I had put it in an instance variable, but this obviously didn't work.
2018-10-29lib/dome-key-map: Update to latestTeddy Wing
Includes a small Makefile change, removes audio playing functionality, and introduces a callback function argument that gets called when the current mode changes.
2018-10-29Sounds: Add methods for playing the mode activated & deactivated soundsTeddy Wing
Initialise `NSSound`s using the data arrays in `sound_data.h`. HeadphoneKey: Add a `_sounds` instance variable and test playing the "mode activated" sound. It works.
2018-10-29Add `Sounds` classTeddy Wing
This will be used to play the mode activated & deactivated sounds via `NSSound` (hopefully).
2018-10-29Rename `sounds.h` to `sound_data.h`Teddy Wing
I want to make a Cocoa class called `Sounds`, but `Sounds.h` would conflict with this file.
2018-10-29Add `sounds.h`, C array versions of sound filesTeddy Wing
This enables us to compile the sound files into our binary. Makefile: Add a target to build the `sounds.h` file, by running `xxd -i` on both sound files. Thanks to Matteo Italia (https://stackoverflow.com/users/214671/matteo-italia) on Stack Overflow for describing how to use `xxd -i` to create a C array from a binary file: https://stackoverflow.com/questions/8707183/script-tool-to-convert-file-to-c-c-source-code-array/8707241#8707241 An to John Marshall (https://stackoverflow.com/users/280577/john-marshall) on Stack Overflow for showing me the Make `foreach` function: https://stackoverflow.com/questions/7918511/make-execute-an-action-for-each-prerequisite/7921168#7921168
2018-10-29Add mode activated & deactivated soundsTeddy Wing
Sounds to play when a mode is activated or deactivated. Use the MP3 versions of the audio files because Core Audio doesn't support Ogg/Vorbis: https://developer.apple.com/library/archive/documentation/MusicAudio/Conceptual/CoreAudioOverview/SupportedAudioFormatsMacOSX/SupportedAudioFormatsMacOSX.html#//apple_ref/doc/uid/TP40003577-CH7-SW1
2018-10-29Update TODOTeddy Wing
2018-10-29Update Rust library function calls to new API namesTeddy Wing
Use the new function names.
2018-10-29lib/dome-key-map: Update to latestTeddy Wing
Code cleanups, C function API cleaned up, audio, lots of under the hood code improvements.
2018-10-28Update TODOTeddy Wing
2018-10-28Update TODOTeddy Wing
2018-10-27Update TODOTeddy Wing
2018-10-27HeadphoneKey: Only print `NSLog`s in a debug modeTeddy Wing
Add a new `LogDebug` macro that `NSLog`s when a `DOME_KEY_DEBUG` environment variable is set to "1". This gets rid of the verbose output every time a headphone key is pressed. But it enables you to see it if needed for debugging purposes.
2018-10-27HeadphoneKey: Delete `startMonitoringBluetoothEvents` methodTeddy Wing
From what I could tell, this didn't work for handling Bluetooth button press events. Delete it since it's not being used. We'll have to come back to Bluetooth again later.
2018-10-27AppDelegate: Get rid of `MPRemoteCommandCenter` codeTeddy Wing
This code was a test for Bluetooth event handling. It didn't work for that purpose as far as I could tell. Since it's not being used, delete it.
2018-10-27Delete `KeyboardSimulator`Teddy Wing
We're no longer using this code. Keyboard simulation has been moved since a long while ago to the Rust library using the 'autopilot' library.
2018-10-27Delete `DKApplication`Teddy Wing
This was a test to see if we could get Bluetooth headphone events using media key events. I wasn't successful. Get rid of the code now that it isn't being used.
2018-10-27Mappings: Remove old unused codeTeddy Wing
* The protocol definition was for an `NSXPCConnection` * Remove the XPCConnection method as we're using BSD notifications instead
2018-10-27Mappings: Make `const` `static`Teddy Wing
Ensure it's scoped to this file.
2018-10-27errors.h: Add include guardsTeddy Wing
2018-10-27LicenseHandler,XDG: Remove some unneeded commentsTeddy Wing
2018-10-27LicenseHandler(addLicense:): Delete license file at the startTeddy Wing
Previously, you couldn't replace the existing license file using the `--license` flag. If you somehow got an invalid license installed, you'd get an error message asking you to add your license again: "Try adding your license again using the `--license` flag." But this wouldn't work to replace the existing license. The copy operation would fail complaining about the file already existing. The behaviour of the method now is to always replace the license file, just in case it's necessary. We use the existing "move to trash" method, and make sure we ignore "does not exist" errors, because typically when you run `--license`, you're not going to have a `license.plist` file installed at the start, so for our purposes, that's not an error.
2018-10-27LicenseHandler: Run trial initialiser when license validation failsTeddy Wing
2018-10-27lib/dome-key-map: Update for trial FFI functionTeddy Wing
2018-10-26LicenseHandler: Move trashing code to a new methodTeddy Wing
Make things a bit more organised by splitting off this functionality and giving it a name.
2018-10-26LicenseHandler: Use current date string in file moved to trashTeddy Wing
To prevent errors resulting from trying to move the license file to the trash when a file with the same name already exists there, use a custom file name with a time stamp. Instead of naming the trashed file "license.plist", prepend "dome-key-" to the filename to make it clear to users that the file came from DomeKey. Append the current date in the format "2018-10-26-19.28.13" before the file extension.