ElectricRCAircraftGuy / eRCaGuy_ComputaPranksta_Support

Public support for my "Computa Pranksta" mouse jiggler device I sell on Amazon and elsewhere.
Other
4 stars 2 forks source link

How does the Computa Pranksta work? I mean, doesn't it have to install software on your computer? #1

Open ElectricRCAircraftGuy opened 4 years ago

ElectricRCAircraftGuy commented 4 years ago

Answer:

In short:

It's a keyboard. It's a mouse. You plug it in to use it. You unplug it to stop using it. Aside from a driver your computer may automatically install, and which I can't really control, it doesn't install anything on your computer. To completely disable it, you unplug it. That's it!

Details:

Note that if you are having computer problems while the device is unplugged, the problems are not caused by the device. It only interacts with your computer while it is plugged in. If you unplug it, it can't do anything to your computer. To help you understand how the device works, I'll go into some of the details of it.

Most people assume that a keyboard is just a dumb device and that when you press a key an electrical circuit is completed and that is it. Though an electrical circuit is completed when you press a key, it is far more complicated than that. Each keyboard and mouse has its own microprocessor. This is frequently in the form of a microcontroller (read about them here).

A mouse or keyboard runs its own code, has its own processor, and has its own memory. It looks for key presses itself, then when it sees them, it packages them up into special data packets based on the USB HID (Human Interface Device) standard (the official standard is described in this 97 pg document here), then it sends out these data packets over USB to the computer. When you plug in a USB keyboard or mouse to a computer, the computer "enumerates" it. This means it asks it for its USB ID and then assigns it a number to keep track of it in the computer. Based on its USB ID and how the USB device you plugged in describes itself, the computer may automatically install a known or generic driver to talk to the device. "Generic" keyboards and mice are plug-and-play. I'm relying on some USB HID libraries on the device which handle this part for me from the device side. The computer side is handled by the computer automatically.

Once the computer registers it as a keyboard or mouse (or, in the case of my device, both), it waits for data packets from the keyboard or mouse's processor. As data packets come in, the computer responds by either moving the cursor or entering the key-press described in the data packet. With 3 small exceptions, generic keyboards and mice generally don't get any data back from the computer. The exceptions are the 3 LED states for Scroll Lock, Num Lock, and Caps Lock. Since an external keyboard usually has LEDs for these 3 states, they must be synchronized between the computer and external keyboard. If you press the Caps Lock button on the external keyboard, for instance, it tells the computer about it, so the computer can know the state, and the external keyboard was pressed so of course it knows about it too. However, if you press the Caps Lock button on the laptop's own built-in keyboard, how can it tell the external keyboard about it so the external keyboard can also light up its Caps Lock LED? The answer is that the USB HID interface protocol for generic keyboards allows 3 bits of information contained in a single byte to be periodically sent from the computer back to the external keyboard. These contain the 3 LED states. This way, if you press Caps Lock, Num Lock, or Scroll Lock on your laptop's built-in keyboard, any external keyboard will also find out about it so it can light up its corresponding LED as well.

In the case of my device, it can see these 3 LED states from the computer as well. So, when you press Scroll Lock 5 times, I have manually programmed the Computa Pranksta myself to look for those 5 toggles of the Scroll Lock LED state being sent from the computer. Once that happens, it types out a set of pre-coded sentences which are stored externally from your computer, on my device.

This is the interaction with the device and how it works. Nothing is installed on your computer whatsoever, except a driver if your computer deems it necessary when it sees the USB HID descriptor my device sends out. But, for security reasons of course, computer and operating system manufacturers only install known drivers from known sources. In other words, my device does not tell you how to install the driver, and it does not contain the driver itself. It just says, "here I am", and your computer decides which and when and how to install its own driver.

The fact that my device is typing a set of precoded characters when it interacts with you, and looking for Caps Lock and Scroll Lock presses from you, is why any text editor on your computer works too! You just need to see what my device is typing is all, so any text editor works.

All of this is implemented on my device on an ATTiny85 microcontroller. You can see its specs here: https://www.microchip.com/wwwproducts/en/ATtiny85. This microcontroller has a processor running at ~16 MHz (250x slower than a computer). It has a tiny program space (like a tiny little Flash drive) of 8 KiB (125 Million times smaller than most hard drives today), and 512 bytes of RAM (~31 Million times smaller than most computers). Even though that's hardly anything, it's enough to store thousands of lines of code, which is enough to bit-bang out the USB protocol using micronucleous and the V-USB library, handle the USB HID descriptor language, and store a few dozen pre-programmed commands I have stored into it.

When you plug it into a computer, the computer thinks it is a keyboard and mouse combo. It installs nothing whatsoever on your computer, and all it can get from your computer is 3 LED states (Num Lock, Scroll Lock and Caps Lock).

To disable it, you unplug it. This is how the device works.