ノートPCのキーボードを他のデバイスで使う
原題: Your Laptop Keyboard, On Another Device
日本語訳
# タイトル
ノートPCのキーボードを別のデバイスで使う方法
# 本文
Raspberry Piなどのマシンの初回セットアップ時に、キーボードの問題に直面したことがある人は多いでしょう。予備のキーボードが見当たらないか、あるいは散らかったデスクにフルサイズのキーボードを置くスペースがないといった状況です。[Henk]氏は、今あるノートPCのキーボードを使うという便利な解決策を提案しています。
彼のやり方は、KVMの「K(キーボード)」の部分だけを取り出したもので、独創的かつシンプルです。ノートPC側は、受信側を持たないシリアル端末として機能します。ここで使われるシリアルポートは、USB-シリアル変換を実装したRP2040ボードです。このシリアル接続はもう一つのRP2040へと繋がり、そこがこの仕組みの肝となる部分を担います。それは「シリアル-USB HIDキーボード」です。これにより、ノートPCでの打鍵がシリアル接続を通じて送られ、Raspberry Piやその他のコンピュータ上では、あたかもローカルで入力されたかのようにUSBキーボードとして認識されます。少し面倒な初回セットアップさえ済ませてしまえば、あとは通常通りSSHやその他のリモートアクセスプロトコル経由で操作できます。コードも公開されているため、RP2040ボードを2つ持っていれば誰でも実現可能です。
本来なら完全にヘッドレスで運用するはずのマシンをセットアップするために、キーボードが必要になって困った経験は誰しも一度はあるはずです。だからこそ、私たちはこのハックを気に入っています。「予備のキーボードがどうしても必要になった」という、めったにないが突発的な事態に備えて、頭の片隅に置いておくと役立つアイデアです。
原文(英語)を表示
It’s likely many of us have been in the position of first set-up on a machine such as a Raspberry Pi, and had keyboard problems. Either no spare keyboard is to be found, or a cluttered desk has to find extra space for a full-size keyboard. [Henk] has a handy solution, use the existing keyboard on your laptop.
His approach is both ingenious and simple, as it’s only the K part of a KVM. On the laptop end, it’s a serial terminal, without the receiving side. The serial port in question is an RP2040 board which implements a USB-to-serial port. This serial connection goes to another RP2040, which does the ingenious bit. It’s a serial-to-USB HID keyboard. All of this means that keystrokes on the laptop are sent down the serial connection, and appear on the Pi or whatever computer as a USB keyboard as though typed locally. The mildly annoying first set-up can be done, and then it can be run via SSH or whatever other remote access protocol as normal. The code is provided, so anyone with a couple of RP2040 boards can do it.
We like this hack, because we’ve had the annoyance of needing a keyboard to set up what would otherwise be a completely headless machine too many times. It’s one to store away at the back of your mind, for those rare improvisational need-an-extra-keyboard moments.