summaryrefslogtreecommitdiffstats
path: root/chrome/common/extensions/api/braille_display_private.idl
blob: 98921856ffef1a5575894a207a237a615c73cecd (plain)
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
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
72
73
74
75
76
77
78
79
// Copyright 2013 The Chromium Authors. All rights reserved.
// Use of this source code is governed by a BSD-style license that can be
// found in the LICENSE file.

// Braille display access private API.
[use_movable_types=true]namespace brailleDisplayPrivate {
  // Braille display keyboard command.
  enum KeyCommand {
    line_up,
    line_down,
    pan_left,
    pan_right,
    top,
    bottom,
    routing,
    secondary_routing,
    dots,
    standard_key
  };

  // A keyboard event.  This is not a standard keyboard event because
  // braille display keyboards look significantly different from standard
  // keyboards.
  dictionary KeyEvent {
    KeyCommand command;
    // 0-based display position for commands that involve a routing key.
    long? displayPosition;
    // Braille dot keys that were pressed, stored in the low-order bits.
    // Dot 1 is stored in bit 0, dot2 in bit 1, etc.
    long? brailleDots;
    // DOM keyboard event code.  This is present when command is standard_key
    // and the braille display event represents a non-alphanumeric key such
    // as an arrow key or function key.
    // The value is as defined by the |code| property in
    // http://www.w3.org/TR/uievents/#keyboard-event-interface
    DOMString? standardKeyCode;
    // DOM keyboard event character value.  This is present if the
    // braille key event corresponds to a character.
    DOMString? standardKeyChar;
    // Whether the space key was pressed.
    boolean? spaceKey;
    // Whether the alt key was pressed.
    boolean? altKey;
    // Whether the shift key was pressed.
    boolean? shiftKey;
    // Whether the ctrl key was pressed.
    boolean? ctrlKey;
  };

  // The current braille display state.
  dictionary DisplayState {
    // Whether a braille display is currently available.
    boolean available;
    // Number of braille cells on the currently connected display.
    long? textCellCount;
  };

  callback DisplayStateCallback = void(DisplayState result);

  interface Functions {
    // Gets the current display state.
    static void getDisplayState(DisplayStateCallback callback);
    // Write the given dot patterns to the display.  The buffer contains one
    // byte for each braille cell on the display, starting from the leftmost
    // cell. Each byte contains a bit pattern indicating which dots should be
    // raised in the corresponding cell with the low-order bit representing
    // dot 1 and so on until bit 7 which corresponds to dot 8.  If the number
    // of bytes in the buffer is not equal to the display size, the buffer
    // will either be clipped or padded with blank cells on the right.
    static void writeDots(ArrayBuffer cells);
  };

  interface Events {
    // Fired when a braille display is connected or disconnected.
    static void onDisplayStateChanged(DisplayState state);
    // Fired when an input event is received from the display.
    static void onKeyEvent(KeyEvent event);
  };
};