Communication

int libmk_send_packet(LibMK_Handle *handle, unsigned char *packet)

Send a single packet and verify the response.

Sends a single packet of data to the keyboard of size LIBMK_PACKET_SIZE (will segfault if not properly sized!) and verifies the response of the keyboard by checking the header of the response packet. Frees the memory of the provided packet pointer.

Return

LibMK_Result result code

Parameters
  • handle: LibMK_Handle for the device to send the packet to

  • packet: Array of bytes (unsigned char) to send of size LIBMK_PACKET_SIZE

int libmk_exch_packet(LibMK_Handle *handle, unsigned char *packet)

Exchange a single packet with the keyboard.

Send a single packet to the keyboard and then store the response in the packet array. Does not free the packet memory or verify the response as an error response.

Return

LibMK_Result result code, response in packet

Parameters
  • handle: LibMK_Handle for the device to exchange data with

  • packet: Array of bytes (unsigned char) to send of size LIBMK_PACKET_SIZE and to put response in

unsigned char *libmk_build_packet(unsigned char predef, ...)

Build a new packet of data that can be sent to keyboard.

Return

Pointer to the allocated packet with the set bytes. NULL if no memory could be allocated.

Parameters
  • predef: Amount of bytes given in the variable arguments

  • ...: Bytes to from index zero of the packet. The amount of bytes given must be equal to the amount specified by predef, otherwise this function will segfault.