Home | History | Annotate | Download | only in api
      1 // Copyright 2013 The Chromium Authors. All rights reserved.
      2 // Use of this source code is governed by a BSD-style license that can be
      3 // found in the LICENSE file.
      4 
      5 // Braille display access private API.
      6 namespace brailleDisplayPrivate {
      7   // Braille display keyboard command.
      8   enum KeyCommand {
      9     line_up,
     10     line_down,
     11     pan_left,
     12     pan_right,
     13     top,
     14     bottom,
     15     routing,
     16     secondary_routing,
     17     dots,
     18     standard_key
     19   };
     20 
     21   // A keyboard event.  This is not a standard keyboard event because
     22   // braille display keyboards look significantly different from standard
     23   // keyboards.
     24   dictionary KeyEvent {
     25     KeyCommand command;
     26     // 0-based display position for commands that involve a routing key.
     27     long? displayPosition;
     28     // Braille dot keys that were pressed, stored in the low-order bits.
     29     // Dot 1 is stored in bit 0, dot2 in bit 1, etc.
     30     long? brailleDots;
     31     // DOM keyboard event code.  This is present when command is standard_key
     32     // and the braille display event represents a non-alphanumeric key such
     33     // as an arrow key or function key.
     34     // The value is as defined by the |code| property in
     35     // http://www.w3.org/TR/uievents/#keyboard-event-interface
     36     DOMString? standardKeyCode;
     37     // DOM keyboard event character value.  This is present if the
     38     // braille key event corresponds to a character.
     39     DOMString? standardKeyChar;
     40     // Whether the space key was pressed.
     41     boolean? spaceKey;
     42     // Whether the alt key was pressed.
     43     boolean? altKey;
     44     // Whether the shift key was pressed.
     45     boolean? shiftKey;
     46     // Whether the ctrl key was pressed.
     47     boolean? ctrlKey;
     48   };
     49 
     50   // The current braille display state.
     51   dictionary DisplayState {
     52     // Whether a braille display is currently available.
     53     boolean available;
     54     // Number of braille cells on the currently connected display.
     55     long? textCellCount;
     56   };
     57 
     58   callback DisplayStateCallback = void(DisplayState result);
     59 
     60   interface Functions {
     61     // Gets the current display state.
     62     static void getDisplayState(DisplayStateCallback callback);
     63     // Write the given dot patterns to the display.  The buffer contains one
     64     // byte for each braille cell on the display, starting from the leftmost
     65     // cell. Each byte contains a bit pattern indicating which dots should be
     66     // raised in the corresponding cell with the low-order bit representing
     67     // dot 1 and so on until bit 7 which corresponds to dot 8.  If the number
     68     // of bytes in the buffer is not equal to the display size, the buffer
     69     // will either be clipped or padded with blank cells on the right.
     70     static void writeDots(ArrayBuffer cells);
     71   };
     72 
     73   interface Events {
     74     // Fired when a braille display is connected or disconnected.
     75     static void onDisplayStateChanged(DisplayState state);
     76     // Fired when an input event is received from the display.
     77     static void onKeyEvent(KeyEvent event);
     78   };
     79 };
     80