# General-Query-Functions

The following are helper functions to query information from the state message, meaning that they will only return valid information following the invocation of \[hpc\_InitializeApp()]\(./State-Functions.md#hpc\_InitializeApp()), and only return new information after hpc\_RefreshState().

## hpc\_GetStateAsJSON

`size_t hpc_GetStateAsJSON(char *out_buf, size_t out_buf_sz)`

**Returns**

The current state message, serialized into a char buffer as JSON.

**Args**

char \*out\_buf, size\_t out\_buf\_sz

**Description**

Mostly useful for debugging - custom message queries can be constructed without an external JSON serializer, using the helper functions in libHoloPlayCore.h.

## hpc\_GetHoloPlayServiceVersion

`size_t hpc_GetHoloPlayServiceVersion(char *out_buf, size_t out_buf_sz)`

**Returns**

Current version of HoloPlay Service, as a string.

**Args**

char \*out\_buf, size\_t out\_buf\_sz

## hpc\_GetNumDevices

`int hpc_GetNumDevices(void)`

**Returns**

Number of Looking Glass devices connected with valid calibrations.

**Args**

None

## hpc\_GetDeviceHDMIName

`size_t hpc_GetDeviceHDMIName(int dev_index, char *out_buf, size_t out_buf_sz)`

**Returns**

Looking Glass device name retrieved from EDID.

**Args**

int dev\_index, char \*out\_buf, size\_t out\_buf\_sz

## hpc\_GetDeviceSerial

`size_t hpc_GetDeviceSerial(int dev_index, char *out_buf, size_t out_buf_sz)`

**Returns**

Serial number of device (same as the one printed on label).

**Args**

int dev\_index, char \*out\_buf, size\_t out\_buf\_sz

## hpc\_GetDeviceType

`size_t hpc_GetDeviceType(int dev_index, char *out_buf, size_t out_buf_sz)`

**Returns**

Device type as string. Currently one of the following:

* "standard": the legacy 8.9" display
* "large": the first generation 15.6" device
* "pro": the legacy 15.6" Pro Workstation device
* "8k": the first generation 8K device
* "portrait": the Looking Glass Portrait
* "4k\_gen2": the second generation 16"
* "8k\_gen2": the second generation 32"

**Args**

int dev\_index, char \*out\_buf, size\_t out\_buf\_sz

### \*Note on String Return Functions

Any function of the form "size\_t hpc\_DoThing(..., char\* out\_buf, size\_t out\_buf\_sz)" copies a string into a preallocated buffer of size out\_buf\_sz. The buffer is allocated and owned by the caller.

These functions return 0 if out\_buf\_sz was sufficient, or the actual size of string if out\_buf\_sz was too small.

This makes it much easier to pass strings into managed memory (i.e. for .NET bindings). Most of the strings returned by these functions are quite small.
