{"id":20693264,"url":"https://github.com/maxakuru/btkb","last_synced_at":"2025-03-11T01:48:33.366Z","repository":{"id":111887990,"uuid":"330584393","full_name":"maxakuru/btkb","owner":"maxakuru","description":"Bluetooth keyboard emulator service and FIFO client for sending keystrokes","archived":false,"fork":false,"pushed_at":"2021-01-25T00:54:53.000Z","size":46,"stargazers_count":2,"open_issues_count":0,"forks_count":0,"subscribers_count":1,"default_branch":"main","last_synced_at":"2025-01-17T17:40:17.768Z","etag":null,"topics":["bluetooth","bluetooth-controller","emulator","fifo","fifo-client","firestick","hid","ir-codes","python"],"latest_commit_sha":null,"homepage":"","language":"Python","has_issues":true,"has_wiki":null,"has_pages":null,"mirror_url":null,"source_name":null,"license":null,"status":null,"scm":"git","pull_requests_enabled":true,"icon_url":"https://github.com/maxakuru.png","metadata":{"files":{"readme":"README.md","changelog":null,"contributing":null,"funding":null,"license":null,"code_of_conduct":null,"threat_model":null,"audit":null,"citation":null,"codeowners":null,"security":null,"support":null,"governance":null,"roadmap":null,"authors":null,"dei":null,"publiccode":null,"codemeta":null}},"created_at":"2021-01-18T07:14:53.000Z","updated_at":"2024-09-02T22:37:36.000Z","dependencies_parsed_at":"2023-03-13T13:32:56.464Z","dependency_job_id":null,"html_url":"https://github.com/maxakuru/btkb","commit_stats":null,"previous_names":[],"tags_count":0,"template":false,"template_full_name":null,"repository_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxakuru%2Fbtkb","tags_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxakuru%2Fbtkb/tags","releases_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxakuru%2Fbtkb/releases","manifests_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories/maxakuru%2Fbtkb/manifests","owner_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners/maxakuru","download_url":"https://codeload.github.com/maxakuru/btkb/tar.gz/refs/heads/main","host":{"name":"GitHub","url":"https://github.com","kind":"github","repositories_count":242956549,"owners_count":20212454,"icon_url":"https://github.com/github.png","version":null,"created_at":"2022-05-30T11:31:42.601Z","updated_at":"2022-07-04T15:15:14.044Z","host_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub","repositories_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repositories","repository_names_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/repository_names","owners_url":"https://repos.ecosyste.ms/api/v1/hosts/GitHub/owners"}},"keywords":["bluetooth","bluetooth-controller","emulator","fifo","fifo-client","firestick","hid","ir-codes","python"],"created_at":"2024-11-16T23:25:58.531Z","updated_at":"2025-03-11T01:48:33.338Z","avatar_url":"https://github.com/maxakuru.png","language":"Python","readme":"# btkb\n\nA bluetooth HID keyboard emulator service and FIFO client.\n\n### Goal\nThe purpose of this project was to create a way to relay messages to control an Amazon Firestick quickly (since it's for a TV remote). It's quite possible this isn't the fastest way, but it's certainly faster than using `adb shell keyinput` or `sendevent`.\n\nI'm currently using this on a Raspberry Pi Zero W to dispatch commands received from IR signals on a TV remote. I went with the FIFO passthrough because the remote's protocol is DirecTV, and either I'm too stupid or lazy to figure out any other way to use it (ie. ir-keytable) than \"raw codes\" with [LIRCD](https://www.lirc.org/html/lircd.html). Ultimately, the `btkb` command in this repo is used by `irexec`. This setup still allows for some IR codes to be \"exchanged\" - for example, specific buttons on a remote can lead to `irexec` emitting different IR codes for devices that have no other way to commmunicate. This story has little to do with the actual code here, but I hope you enjoyed it.\n\n\n### Setup\n1. Get the repo\n```sh\ngit clone git@github.com:maxakuru/btkb.git\n```\n\n2. Enable bluetooth if needed\n```sh\nsudo hciconfig hcio up\n```\n\n3. Copy `config.ini.example` and rename to `config.ini`\n\n4. Configure `config.ini` how you like, at least the device address is needed\n\u003e\u003e Note: To get the bluetooth device address, use `sudo hciconfig hci0 -a` and look for `BD Address`.\n\n5. Run the setup script (or set it up however you want)\n```sh\n/bin/bash setup.sh\n```\n\n6. Pair your device\n```sh\nsudo /usr/bin/bluetoothctl\n```\n\u003e\u003e Then\n```sh\nagent on\ndefault-agent\npairable on\ndiscoverable on\n```\n\u003e\u003e And leave this terminal running.\n\nFind your device in the bluetooth device list, pair, accept\nBack in the terminal, accept the pairing code with `yes`.\n\n7. Send keystrokes via fifo\nA convenience script is installed with the setup script, but really it just pushes whatever the arguments you provide into a fifo.\nThis fifo is then read, line by line, by the FifoClient, converted into HID bytestrings and sent to the connected device.\nThe fifo is owned by uid/gid 1000, but depending on step 2, you may need `sudo`.\n\n#### Sample commands\nPress down \"enter\":\n```sh\nbtkb KEY_ENTER\n```\n\nPress down \"enter\", release all keys:\n```sh\nbtkb KEY_ENTER ACT_RELEASE\n```\n\nPress down \"enter\", hold it for a second, release:\n```sh\nbtkb KEY_ENTER ACT_HOLD_1 ACT_RELEASE\n```\n\nLeft ctrl + esc, then release keys and unhold \"ctrl\" modifier:\n```sh\nbtkb MOD_LEFTCTRL KEY_ESC ACT_RELEASE MOD_RESET\n```\n\u003e\u003e Note: this works the same as the `KEY_HOMESCREEN` event on Firestick (and maybe other Android TV devices)\n\n\n#### Alternative use\nWrite directly to the fifo, if you want:\n```sh\necho \"KEY_ENTER ACT_RELEASE\" \u003e\u003e /tmp/btkb.fifo\n```\n\u003e\u003e Note: This requires using the same user as configured in `config.ini`\n\n#### Credits\nNot sure who this is, but [very helpful!](http://yetanotherpointlesstechblog.blogspot.com/2016/04/emulating-bluetooth-keyboard-with.html)\n\n[AnesBenmerzoug/BluetoothHID](https://github.com/AnesBenmerzoug/Bluetooth_HID)","funding_links":[],"categories":[],"sub_categories":[],"project_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxakuru%2Fbtkb","html_url":"https://awesome.ecosyste.ms/projects/github.com%2Fmaxakuru%2Fbtkb","lists_url":"https://awesome.ecosyste.ms/api/v1/projects/github.com%2Fmaxakuru%2Fbtkb/lists"}