/**
* @fileoverview This file implements the C1Pjs Keyboard component.
* @author Jeff Parsons
* @copyright © Jeff Parsons 2012-2017
*
* This file is part of PCjs, a computer emulation software project at .
*
* PCjs is free software: you can redistribute it and/or modify it under the terms of the
* GNU General Public License as published by the Free Software Foundation, either version 3
* of the License, or (at your option) any later version.
*
* PCjs is distributed in the hope that it will be useful, but WITHOUT ANY WARRANTY; without
* even the implied warranty of MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
* GNU General Public License for more details.
*
* You should have received a copy of the GNU General Public License along with PCjs. If not,
* see .
*
* You are required to include the above copyright notice in every modified copy of this work
* and to display that copyright notice when the software starts running; see COPYRIGHT in
* .
*
* Some PCjs files also attempt to load external resource files, such as character-image files,
* ROM files, and disk image files. Those external resource files are not considered part of PCjs
* for purposes of the GNU General Public License, and the author does not claim any copyright
* as to their contents.
*/
"use strict";
if (NODE) {
var Str = require("../../shared/lib/strlib");
var Web = require("../../shared/lib/weblib");
var Component = require("../../shared/lib/component");
}
/**
* TODO: The Closure Compiler treats ES6 classes as 'struct' rather than 'dict' by default,
* which would force us to declare all class properties in the constructor, as well as prevent
* us from defining any named properties. So, for now, we mark all our classes as 'unrestricted'.
*
* @unrestricted
*/
class C1PKeyboard extends Component {
/**
* C1PKeyboard(parmsKbd)
*
* The Keyboard component can be configured with the following (parmsKbd) properties:
*
* model: model number (one of: 542 or 600; 600 is the default)
*
* Its main purpose is to receive binding requests for various keyboard events,
* and to use those events to simulate the C1P's keyboard hardware; specifically,
* an OSI model 600 board (NOT the model 542).
*
* Keys on the C1P keyboard that differ from modern keyboards, along with their
* closest modern counterpart:
*
* C1P PC
* --- --
* 2" 2@
* 6& 6^
* 7' 7&
* 8( 8*
* 9) 9(
* 0 0)
* :* -_
* -= =+
* ;+ ;:
* LINEFEED CTRL-J
* RETURN ENTER (or CTRL-M)
* SHIFT-O DELETE (or CTRL-H)
* SHIFT-N ^
* SHIFT-P @ (used by the BASIC-IN-ROM to abandon the current line)
* SHIFT-L \
* SHIFT-K [
* SHIFT-M ]
* CTRL-C Same (used by the BASIC-IN-ROM to interrupt RUN and LIST, unless disabled with POKE 530,1)
* CTRL-O Same (used by the BASIC-IN-ROM to suppress output until another CTRL-O is typed)
* RUB-OUT (no mapping chosen for this key yet)
* REPEAT (no mapping chosen for this key yet)
*
* Problems with iOS Devices
* -------------------------
* The keyboard pops up with the SHIFT key depressed, which is not the initial keyboard state that the C1P expects.
* I tried to fix that by adding an 'autocapitalize="off"' attribute alongside the 'contenteditable="true"' attribute
* on the