+static struct dcpu16_hw_ctl_cmd ctl_[] = {
+ { "buffer_size", "const size_t *", "size_t *", "get or set current buffer size" },
+ { "associate_rfbScreen", "rfbScreenInfoPtr", "NULL", "associates this keyboard instance with an rfb display" },
+ { NULL, NULL, NULL, NULL }
+};
+static
+int keyboard_data_ctl_(struct dcpu16_hw *hw, const char *cmd, void *data_in, void *data_out) {
+ if (strcmp(cmd, "buffer_size") == 0) {
+ struct keyboard_ *keyboard = (struct keyboard_ *)hw->data;
+ void *tmp_ptr;
+ const size_t *buf_sz_in = (const size_t *)data_in;
+ size_t *buf_sz_out = (size_t *)data_out;
+
+ if (buf_sz_out) {
+ *buf_sz_out = keyboard->buf_sz;
+ }
+
+ if (buf_sz_in) {
+#ifdef DEBUG
+ hw->vm->msg_cb_(DCPU16_MSG_DEBUG, "%s>> resizing buffer from %zu to %zu", __func__, keyboard->buf_sz, *buf_sz_in);
+#endif /* DEBUG */
+
+ tmp_ptr = realloc(keyboard->buf, *buf_sz_in);
+ if (tmp_ptr == NULL) {
+ hw->vm->msg_cb_(DCPU16_MSG_DEBUG, "%s():%s", "realloc", strerror(errno));
+ return -1;