示例#1
0
// disable a layer
void layer_disable(layer l) {
  // base layer stays always on
  if (l >= KB_LAYERS || l == 0) { return; }

  if (layers_active[l] > 0) {
    layers_active[l] -= 1;
  }

  if (l == layers_top) {
    layers_top = highest_active_layer();
  }

  // re-press affected keys
  for (u8 row=0; row<KB_ROWS; row++) {
    for (u8 col=0; col<KB_COLUMNS; col++) {
      if (layers_pressed[row][col] == l) {
        keyfunc func = (kb_keyfunc(l, row, col));
        // FIXME don't re-send normal keys until we have key repeats
        if (is_layer_keyfunc(func)) {
          // FIXME this kinda shouldn't be here and it privileges layer 0 even more
          layers_pressed[row][col] = 0;
          exec_key(l, row, col, false);

          layers_pressed[row][col] = layers_top;
          exec_key(layers_top, row, col, true);
        }
      }
    }
  }
}
示例#2
0
文件: loop.c 项目: tmerlier/2048
int				main_loop(t_env *env)
{
	int				key;
	int				ret_exec;

	set_winsize(env);
	if (env->load == 1)
		load_game(env);
	dup_plate(env->last_plate, env->plate, env->size);
	print_plate(env);
	while (refresh() == OK && (key = getch()) && clear() == OK)
	{
		if (key == KEY_RESIZE && (ret_exec = 0) == 0)
			set_winsize(env);
		if (test_window(env))
			mvprintw(1, 1, "Affichage impossible");
		else
		{
			dup_plate(env->last_plate, env->plate, env->size);
			if (key != KEY_RESIZE)
				ret_exec = exec_key(env, key);
			if (ret_exec != 0)
				return (ret_exec);
		}
		print_plate(env);
	}
	return (0);
}
示例#3
0
void main_key_down_new(u8 row, u8 col) {
  layer layer = layers_top;
  layers_pressed[row][col] = layer;

  time_pressed[row][col] = now();
  /* debug_printf("down: %lu\n", time_pressed[row][col]); */

  exec_key(layer, row, col, true);
}
示例#4
0
void main_key_up(u8 row, u8 col) {
  layer layer = layers_pressed[row][col];
  layers_pressed[row][col] = 0;

  // stop key repeat
  if (repeating[row][col]) {
    repeating[row][col] = false;
    /* debug_printf("stop: %lu\n", now() - time_pressed[row][col]); */
  }

  exec_key(layer, row, col, false);
}