MagiScript provides the ability to turn a compatible device, such as the Atom, into a Bluetooth keyboard. This enables the device to send keystrokes to a phone or computer that has been paired with it.
To use the keyboard and media support in MagiScript, you need to pair your device with the target phone or computer. Once the pairing process is complete, you can use the available functions to send keystrokes or media commands to the target device.
When Atom is paired with a host device, that will automatically connect to Atom when you are turning it on. You can still connect to Atom via Bluetooth from the same host device to develop mini-apps or use Atom. You can even pair another device, but this can start being unreliable. If you experience that you cannot connect to Atom again, or your device cannot pair with it, go to your Bluetooth settings to unpair Atom, and connect to it again.
The keyboard.type() function allows you to type a string of characters on the target device. The function takes a string as its argument, and it types each character of the string sequentially. For example, if you want to type the string "Hello, world!", you can use the following code:
keyboard.type('Hello, world!');
You can use multiple values, and even numbers. Atom will add a space between them:
keyboard.type('Hello', 'World');
keyboard.type('Temperature:', 42);
The keyboard.tap() function allows you to tap a specific key on the target device. The function takes a keyCode as its argument, which represents the key that you want to tap. The available keyCodes are listed below:
For example, if you want to tap the "Enter" key, you can use the following code:
keyboard.tap(KBD_RETURN);
Also, multiple keys can be listed:
keyboard.tap(KBD_UP, KBD_END);
The media.tap() function allows you to send media commands to the target device. The function takes a mediaKeyCode as its argument, which represents the media command that you want to send. The available mediaKeyCodes are listed below:
For example, if you want to play or pause media playback on the target device, you can use the following code:
media.tap(MEDIA_PLAY_PAUSE);
It's important to note that not all devices support all of the available keyCodes and mediaKeyCodes. Some devices may have additional keyCodes or mediaKeyCodes that are not listed here.
MagiScript provides a simple and convenient way to turn a compatible device into a Bluetooth keyboard and send keystrokes or media commands to a target device. With the available functions, developers can create various applications that require keyboard or media input.