Sometimes a Mouse Is Actually a Keyboard

Hotel-room hacking has been a staple of many a BCCD developer. Last night in Salt Lake City for the SC12 conference was no exception, with an interesting case in which we found ourselves without a hard-lined keyboard to plug into our LittleFe testing unit. Among the things we did have on-hand were a USB mouse and a Bluetooth keyboard, the former of which we were able to use exclusively to eventually pair the latter with our LittleFe, a task that would normally require the use of a keyboard.

Since BCCD is built on top of Linux, we first leveraged the fact that highlighting text with the mouse copies text to a buffer behind the scenes, implicitly performing the equivalent of Control-C on a Windows machine or Command-C on a Mac. Since our mouse had 3 buttons, we were also able to also leverage the fact that the middle mouse button can be clicked to paste the buffer, the equivalent of Control-V under Windows or Command-V under Mac. Through a creative and hacky use of highlighting and pasting, we were able to "type" in the BCCD's command-line terminals using only the mouse.

The default BCCD prompt text is "node000@bccd.net", so the text we had initially available to us were the letters 'n', 'o', 'd', 'e', '0', '@', 'b', 'c', 'd', '.', and 't', but these were not enough letters to enter any particularly-useful commands. Right-clicking on the BCCD desktop provides a Fluxbox menu, however, and we were able to open the Vi editor and patch together the standard "ls" command from random 'l' and 's' characters scattered throughout Vi's welcome screen. The pivotal moment for us came when we highlighted a blank line and pasted it as a newline character at the end of the "ls" command. When the familiar files and folders in the BCCD's home directory appeared, we knew we were probably on to something.

To get more useful commands, we decided to copy and paste the word "help", which provided us a list of frequently-used Bash commands. We found this useful in particular for highlighting and pasting the "ifconfig" command, which features prominently in the LittleFe's wifi setup, described in detail at http://littlefe.net/wiki/index.php/Configure-wifi-v4. Our reason for setting up the wifi was to install a particular software package called "matchbox-keyboard", which allows the user to click letters on a software QWERTY keyboard. matchbox-keyboard dramatically increased how quickly we could "type" using the mouse.

The final step for us was pairing the LittleFe with the Bluetooth keyboard, for which we used the commands "hcitool scan" to detect the device and "sudo hidd --connect " to pair it with the LittleFe. We quickly found that, as expected, a hardware keyboard was more robust and productive than working purely from the USB mouse or even matchbox-keyboard. However, it was nice to find that even without a hard-line keyboard we could use a mouse to eventually obtain keyboard functionality on BCCD. matchbox-keyboard is now included as a standard package in the BCCD.

Happy hacking!