Exemplo n.º 1
0
static void keyboard_handle_enter(void *data, struct wl_keyboard *keyboard, uint32_t serial,
		struct wl_surface *surface, struct wl_array *keys)
{
	uint32_t *key, *pressedKey;
	UwacSeat *input = (UwacSeat *)data;
	int i, found;
	UwacKeyboardEnterLeaveEvent *event;

	event = (UwacKeyboardEnterLeaveEvent *)UwacDisplayNewEvent(input->display, UWAC_EVENT_KEYBOARD_ENTER);
	if (!event)
		return;

	event->window = input->keyboard_focus = (UwacWindow *)wl_surface_get_user_data(surface);

	/* look for keys that have been released */
	found = false;
	for (pressedKey = input->pressed_keys.data, i = 0; i < input->pressed_keys.size; i += sizeof(uint32_t)) {
		wl_array_for_each(key, keys) {
			if (*key == *pressedKey) {
				found = true;
				break;
			}
		}

		if (!found) {
			keyboard_handle_key(data, keyboard, serial, 0, *pressedKey, WL_KEYBOARD_KEY_STATE_RELEASED);
		} else {
			pressedKey++;
		}
	}

	/* handle keys that are now pressed */
	wl_array_for_each(key, keys) {
		keyboard_handle_key(data, keyboard, serial, 0, *key, WL_KEYBOARD_KEY_STATE_PRESSED);
	}
Exemplo n.º 2
0
static void keyboard_refresh(void){

  static char check[4] = {1,1,1,1};

#ifdef USE_SW1_WITH_POLLING
  if(gpio_get_pin(KEY_PIN(0),0)){
   if (check[0]){
      keyboard_handle_key(0);
      check[0] = 0;
    }
  }
  else{
    check[0] = 1;
  }
#endif

#ifdef USE_SW2_WITH_POLLING
  if(gpio_get_pin(KEY_PIN(1),0)){
   if (check[1]){
      keyboard_handle_key(1);
      check[1] = 0;
    }
  }
  else{
    check[1] = 1;
  }
#endif

#ifdef USE_SW3_WITH_POLLING
  if(gpio_get_pin(KEY_PIN(2),0)){
   if (check[2]){
      keyboard_handle_key(2);
      check[2] = 0;
    }
  }
  else{
    check[2] = 1;
  }
#endif

#ifdef USE_SW4_WITH_POLLING

  if(gpio_get_pin(KEY_PIN(3),0)){
   if (check[3]){
      keyboard_handle_key(3);
      check[3] = 0;
    }
  }
  else{
    check[3] = 1;
  }

#endif


}
Exemplo n.º 3
0
static void
button_handler(struct widget *widget,
	       struct input *input, uint32_t time,
	       uint32_t button,
	       enum wl_pointer_button_state state, void *data)
{
	struct keyboard *keyboard = data;
	struct rectangle allocation;
	int32_t x, y;
	int row, col;
	unsigned int i;

	if (state != WL_POINTER_BUTTON_STATE_PRESSED || button != BTN_LEFT) {
		return;
	}

	input_get_position(input, &x, &y);

	widget_get_allocation(keyboard->widget, &allocation);
	x -= allocation.x;
	y -= allocation.y;

	row = y / key_height;
	col = x / key_width + row * columns;
	for (i = 0; i < sizeof(keys) / sizeof(*keys); ++i) {
		col -= keys[i].width;
		if (col < 0) {
			keyboard_handle_key(keyboard, &keys[i]);
			break;
		}
	}

	widget_schedule_redraw(widget);
}
Exemplo n.º 4
0
static void
button_handler(struct widget *widget,
	       struct input *input, uint32_t time,
	       uint32_t button,
	       enum wl_pointer_button_state state, void *data)
{
	struct keyboard *keyboard = data;
	struct rectangle allocation;
	int32_t x, y;
	int row, col;
	unsigned int i;
	const struct layout *layout;

	layout = get_current_layout(keyboard->keyboard);

	if (button != BTN_LEFT) {
		return;
	}

	input_get_position(input, &x, &y);

	widget_get_allocation(keyboard->widget, &allocation);
	x -= allocation.x;
	y -= allocation.y;

	row = y / key_height;
	col = x / key_width + row * layout->columns;
	for (i = 0; i < layout->count; ++i) {
		col -= layout->keys[i].width;
		if (col < 0) {
			keyboard_handle_key(keyboard, time, &layout->keys[i], input, state);
			break;
		}
	}

	widget_schedule_redraw(widget);
}