# HoloPlay Service Related

## Device Status

If HoloPlay Service receives an `info` command, it will respond with information about HoloPlay Service and any connected devices.

### Example Response

```javascript
{
  "error": 0,
  "version": "1.0.0",
  "devices": [
    {
      "hwid": "LKG030nffpp24",
      "state": "hidden",
      "windowCoords": [1920, 0],
      "hardwareVersion": "standard",
      "buttons": {
        [0, 0, 0, 0]
      }
      "calibration": {
        "pitch": 50.060001373291016,
        "slope": -7.7369561195373535,
        "center": 0.26147353649139404,
    ...
      }
    {
  ]
}
```

### Field Descriptions

`version`

The version of HoloPlay Service installed on the machine.

`devices`

An array of all devices currently connected.

`devices[idx].state`

The state of the specified device. Can be one of the following states:

* `hidden` — the window is not visible.
* `ok` — the window exists and is ready to receive content.
* `nocalibration` — there's an error reading calibration, please ensure your cables are connected.

`devices[idx].windowCoords`

Display position of the device as window coordinates. The position is relative to the top left-hand corner of the main monitor.

`devices[idx].hardwareVersion`

Can be `standard`, `large`, `pro`, or `8k`. Standard refers to the [8.9" Looking Glass](https://lookingglassfactory.com/product/8-9), large to the [15.6" unit](https://lookingglassfactory.com/product/15-6), pro to the [15.6" Pro](https://lookingglassfactory.com/product/15-6), and 8K to the [Looking Glass 8K](https://lookingglassfactory.com/product/8k).

`devices[idx].buttons`

Whether or not each of the buttons is currently pressed for the specified device.

`devices[idx].calibration`

Calibration data for the specified device.

## Quilt Settings

A description of quilt view count and tiling. All parameters are optional.

* `vx` (int) - number of columns.
  * default value: 1.
* `vy` (int) - number of rows.
  * default value: 1.
* `vtotal` (int) - total number of views in quilt.
  * default value: `vx` \* `vy`.
  * only necessary for quilts that have "missing" views in some positions.
* `aspect` (float) - original aspect ratio of the quilt.
  * default value: if unspecified, will match aspect ratio of target display (16/10 for the 8.9" Looking Glass, 16/9 for the 15.6" Looking Glass, etc).
* `overscan` (bool/int) - scaling setting when on a device with a different aspect ratio than the quilt. It only makes a difference when the quilt aspect is specified and its different than the aspect ratio of the Looking Glass.
  * default value: 0.
  * `overscan=1` scales the image until it fills all possible space on the display, cutting out extra part of image.
  * `overscan=0` scales the image until its largest side fits the display, leaving black edges on the other sides.
  * `overscan` has no effect if `aspect` is either unspecified or equal to the resolution of the target display.
* `invert` (bool/int) - inverted view cone setting.
  * default value: 0.
  * `invert=1` causes the views to be read in the opposite order as they are encoded in the texture, from the top right to the bottom left.

## Error Codes

Every command issued to the driver has a corresponding response issued in CBOR format. At minimum, the response contains an error code, which may be one of the following:

| Error | Description                                                                                                                       |
| ----- | --------------------------------------------------------------------------------------------------------------------------------- |
| 0     | No error, everything ok.                                                                                                          |
| 1     | CBOR parser failure.                                                                                                              |
| 2     | Driver could not understand the command.                                                                                          |
| 3     | Driver expected an image file in binary data, but could not read one.                                                             |
| 4     | Client attempted to draw to a Looking Glass that is not connected or has no calibration.                                          |
| 5     | Client attempted to load a nonexistent key from the cache.                                                                        |
| 6     | Client attempted to register an app ID after sending one or more messages.                                                        |
| 7     | Client attempted to do something that is not allowed (i.e., tried to take over a display currently occupied by a greedy process). |
