Esempio n. 1
0
File: keys.c Progetto: bbolli/tig
enum status_code
add_keybinding(struct keymap *table, enum request request, struct key_input *input)
{
	char buf[SIZEOF_STR];
	bool conflict = FALSE;
	size_t i;

	for (i = 0; i < table->size; i++) {
		if (keybinding_equals(&table->data[i].input, input, &conflict)) {
			enum request old_request = table->data[i].request;
			const char *old_name;

			table->data[i].request = request;
			if (!conflict)
				return SUCCESS;

			old_name = get_request_name(old_request);
			string_ncopy(buf, old_name, strlen(old_name));
			return error("Key binding for %s and %s conflict; "
				     "keys using Ctrl are case insensitive",
				     buf, get_request_name(request));
		}
	}

	table->data = realloc(table->data, (table->size + 1) * sizeof(*table->data));
	if (!table->data)
		die("Failed to allocate keybinding");
	table->data[table->size].input = *input;
	table->data[table->size++].request = request;
	return SUCCESS;
}
void print_request(const InputRqParsingOutput& data)
{

  MySerial.println(get_request_name(data.request_type));

  if (data.id_attr_found)
  {
    MySerial.print("Sector: ");
    MySerial.println(data.id_attr_buf);
  }

}
Esempio n. 3
0
File: keys.c Progetto: acklinr/tig
enum status_code
add_keybinding(struct keymap *table, enum request request,
	       const struct key key[], size_t keys)
{
	struct keybinding *keybinding;
	char buf[SIZEOF_STR];
	bool conflict = false;
	size_t i;

	for (i = 0; i < table->size; i++) {
		if (keybinding_equals(table->data[i], key, keys, &conflict)) {
			enum request old_request = table->data[i]->request;
			const char *old_name;

			table->data[i]->request = request;
			if (!conflict)
				return SUCCESS;

			old_name = get_request_name(old_request);
			string_ncopy(buf, old_name, strlen(old_name));
			return error("Key binding for %s and %s conflict; "
				     "keys using Ctrl are case insensitive",
				     buf, get_request_name(request));
		}
	}

	table->data = realloc(table->data, (table->size + 1) * sizeof(*table->data));
	keybinding = calloc(1, sizeof(*keybinding) + (sizeof(*key) * (keys - 1)));
	if (!table->data || !keybinding)
		die("Failed to allocate keybinding");

	memcpy(keybinding->key, key, sizeof(*key) * keys);
	keybinding->keys = keys;
	keybinding->request = request;
	table->data[table->size++] = keybinding;
	return SUCCESS;
}
void print_request(const InputRqParsingOutput& data)
{

  Serial.println(get_request_name(data.request_type));

  if (data.id_attr_found)
  {
    Serial.print("Lockbox: ");
    Serial.println(data.id_attr_buf);
  }
  if (data.percent_attr_found)
  {
    Serial.print("Percent: ");
    Serial.println(data.percent_attr_buf);
  }
}