android_keyboard_map_java.tmpl 3.39 KB
Newer Older
1 2 3 4 5 6 7 8 9 10 11 12 13
package io.flutter.embedding.android;

// Copyright 2013 The Flutter Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// DO NOT EDIT -- DO NOT EDIT -- DO NOT EDIT
// This file is generated by flutter/flutter@dev/tools/gen_keycodes/bin/gen_keycodes.dart and
// should not be edited directly.
//
// Edit the template dev/tools/gen_keycodes/data/android_keyboard_map_java.tmpl instead.
// See dev/tools/gen_keycodes/README.md for more information.

14
import android.view.KeyEvent;
15 16
import java.util.HashMap;

17
/** Static information used by {@link KeyEmbedderResponder}. */
18
public class KeyboardMap {
19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71
  /** A physicalKey-logicalKey pair used to define mappings. */
  public static class KeyPair {
    public KeyPair(long physicalKey, long logicalKey) {
      this.physicalKey = physicalKey;
      this.logicalKey = logicalKey;
    }

    public long physicalKey;
    public long logicalKey;
  }

  /**
   * An immutable configuration item that defines how to synchronize pressing modifiers (such as
   * Shift or Ctrl), so that the {@link KeyEmbedderResponder} must synthesize events until the
   * combined pressing state of {@link keys} matches the true meta state masked by {@link mask}.
   */
  public static class PressingGoal {
    public PressingGoal(int mask, KeyPair[] keys) {
      this.mask = mask;
      this.keys = keys;
    }

    public final int mask;
    public final KeyPair[] keys;
  }

  /**
   * A configuration item that defines how to synchronize toggling modifiers (such as CapsLock), so
   * that the {@link KeyEmbedderResponder} must synthesize events until the enabling state of the
   * key matches the true meta state masked by {@link #mask}.
   *
   * <p>The objects of this class are mutable. The {@link #enabled} field will be used to store the
   * current enabling state.
   */
  public static class TogglingGoal {
    public TogglingGoal(int mask, long physicalKey, long logicalKey) {
      this.mask = mask;
      this.physicalKey = physicalKey;
      this.logicalKey = logicalKey;
    }

    public final int mask;
    public final long physicalKey;
    public final long logicalKey;
    /**
     * Used by {@link KeyEmbedderResponder} to store the current enabling state of this modifier.
     *
     * <p>Initialized as false.
     */
    public boolean enabled = false;
  }

  /** Maps from Android scan codes {@link KeyEvent#getScanCode()} to Flutter physical keys. */
72 73 74 75 76 77 78 79 80
  public static final HashMap<Long, Long> scanCodeToPhysical =
      new HashMap<Long, Long>() {
        private static final long serialVersionUID = 1L;

        {
@@@ANDROID_SCAN_CODE_MAP@@@
        }
      };

81
  /** Maps from Android key codes {@link KeyEvent#getKeyCode()} to Flutter logical keys. */
82 83 84 85 86 87 88 89
  public static final HashMap<Long, Long> keyCodeToLogical =
      new HashMap<Long, Long>() {
        private static final long serialVersionUID = 1L;

        {
@@@ANDROID_KEY_CODE_MAP@@@
        }
      };
90 91 92 93 94 95 96 97 98 99 100 101 102 103 104 105 106 107 108

  public static final PressingGoal[] pressingGoals =
      new PressingGoal[] {
@@@PRESSING_GOALS@@@
      };

  /**
   * A list of toggling modifiers that must be synchronized on each key event.
   *
   * <p>The list is not a static variable but constructed by a function, because {@link
   * TogglingGoal} is mutable.
   */
  public static TogglingGoal[] getTogglingGoals() {
    return new TogglingGoal[] {
@@@TOGGLING_GOALS@@@
    };
  }

@@@MASK_CONSTANTS@@@
109
}