18c2ecf20Sopenharmony_ci====================================
28c2ecf20Sopenharmony_ciIntelligent Keyboard (ikbd) Protocol
38c2ecf20Sopenharmony_ci====================================
48c2ecf20Sopenharmony_ci
58c2ecf20Sopenharmony_ci
68c2ecf20Sopenharmony_ciIntroduction
78c2ecf20Sopenharmony_ci============
88c2ecf20Sopenharmony_ci
98c2ecf20Sopenharmony_ciThe Atari Corp. Intelligent Keyboard (ikbd) is a general purpose keyboard
108c2ecf20Sopenharmony_cicontroller that is flexible enough that it can be used in a variety of
118c2ecf20Sopenharmony_ciproducts without modification. The keyboard, with its microcontroller,
128c2ecf20Sopenharmony_ciprovides a convenient connection point for a mouse and switch-type joysticks.
138c2ecf20Sopenharmony_ciThe ikbd processor also maintains a time-of-day clock with one second
148c2ecf20Sopenharmony_ciresolution.
158c2ecf20Sopenharmony_ciThe ikbd has been designed to be general enough that it can be used with a
168c2ecf20Sopenharmony_civariety of new computer products. Product variations in a number of
178c2ecf20Sopenharmony_cikeyswitches, mouse resolution, etc. can be accommodated.
188c2ecf20Sopenharmony_ciThe ikbd communicates with the main processor over a high speed bi-directional
198c2ecf20Sopenharmony_ciserial interface. It can function in a variety of modes to facilitate
208c2ecf20Sopenharmony_cidifferent applications of the keyboard,  joysticks, or mouse. Limited use of
218c2ecf20Sopenharmony_cithe controller is possible in applications in which only a unidirectional
228c2ecf20Sopenharmony_cicommunications medium is available by carefully designing the default modes.
238c2ecf20Sopenharmony_ci
248c2ecf20Sopenharmony_ciKeyboard
258c2ecf20Sopenharmony_ci========
268c2ecf20Sopenharmony_ci
278c2ecf20Sopenharmony_ciThe keyboard always returns key make/break scan codes. The ikbd generates
288c2ecf20Sopenharmony_cikeyboard scan codes for each key press and release. The key scan make (key
298c2ecf20Sopenharmony_ciclosure) codes start at 1, and are defined in Appendix A. For example, the
308c2ecf20Sopenharmony_ciISO key position in the scan code table should exist even if no keyswitch
318c2ecf20Sopenharmony_ciexists in that position on a particular keyboard. The break code for each key
328c2ecf20Sopenharmony_ciis obtained by ORing 0x80 with the make code.
338c2ecf20Sopenharmony_ci
348c2ecf20Sopenharmony_ciThe special codes 0xF6 through 0xFF are reserved for use as follows:
358c2ecf20Sopenharmony_ci
368c2ecf20Sopenharmony_ci=================== ====================================================
378c2ecf20Sopenharmony_ci    Code            Command
388c2ecf20Sopenharmony_ci=================== ====================================================
398c2ecf20Sopenharmony_ci    0xF6            status report
408c2ecf20Sopenharmony_ci    0xF7            absolute mouse position record
418c2ecf20Sopenharmony_ci    0xF8-0xFB       relative mouse position records (lsbs determined by
428c2ecf20Sopenharmony_ci                    mouse button states)
438c2ecf20Sopenharmony_ci    0xFC            time-of-day
448c2ecf20Sopenharmony_ci    0xFD            joystick report (both sticks)
458c2ecf20Sopenharmony_ci    0xFE            joystick 0 event
468c2ecf20Sopenharmony_ci    0xFF            joystick 1 event
478c2ecf20Sopenharmony_ci=================== ====================================================
488c2ecf20Sopenharmony_ci
498c2ecf20Sopenharmony_ciThe two shift keys return different scan codes in this mode. The ENTER key
508c2ecf20Sopenharmony_ciand the RETurn key are also distinct.
518c2ecf20Sopenharmony_ci
528c2ecf20Sopenharmony_ciMouse
538c2ecf20Sopenharmony_ci=====
548c2ecf20Sopenharmony_ci
558c2ecf20Sopenharmony_ciThe mouse port should be capable of supporting a mouse with resolution of
568c2ecf20Sopenharmony_ciapproximately 200 counts (phase changes or 'clicks') per inch of travel. The
578c2ecf20Sopenharmony_cimouse should be scanned at a rate that will permit accurate tracking at
588c2ecf20Sopenharmony_civelocities up to 10 inches per second.
598c2ecf20Sopenharmony_ciThe ikbd can report mouse motion in three distinctly different ways. It can
608c2ecf20Sopenharmony_cireport relative motion, absolute motion in a coordinate system maintained
618c2ecf20Sopenharmony_ciwithin the ikbd, or by converting mouse motion into keyboard cursor control
628c2ecf20Sopenharmony_cikey equivalents.
638c2ecf20Sopenharmony_ciThe mouse buttons can be treated as part of the mouse or as additional
648c2ecf20Sopenharmony_cikeyboard keys.
658c2ecf20Sopenharmony_ci
668c2ecf20Sopenharmony_ciRelative Position Reporting
678c2ecf20Sopenharmony_ci---------------------------
688c2ecf20Sopenharmony_ci
698c2ecf20Sopenharmony_ciIn relative position mode, the ikbd will return relative mouse position
708c2ecf20Sopenharmony_cirecords whenever a mouse event occurs. A mouse event consists of a mouse
718c2ecf20Sopenharmony_cibutton being pressed or released, or motion in either axis exceeding a
728c2ecf20Sopenharmony_cisettable threshold of motion. Regardless of the threshold, all bits of
738c2ecf20Sopenharmony_ciresolution are returned to the host computer.
748c2ecf20Sopenharmony_ciNote that the ikbd may return mouse relative position reports with
758c2ecf20Sopenharmony_cisignificantly more than the threshold delta x or y. This may happen since no
768c2ecf20Sopenharmony_cirelative mouse motion events will be generated: (a) while the keyboard has
778c2ecf20Sopenharmony_cibeen 'paused' ( the event will be stored until keyboard communications is
788c2ecf20Sopenharmony_ciresumed) (b) while any event is being transmitted.
798c2ecf20Sopenharmony_ci
808c2ecf20Sopenharmony_ciThe relative mouse position record is a three byte record of the form
818c2ecf20Sopenharmony_ci(regardless of keyboard mode)::
828c2ecf20Sopenharmony_ci
838c2ecf20Sopenharmony_ci    %111110xy           ; mouse position record flag
848c2ecf20Sopenharmony_ci                        ; where y is the right button state
858c2ecf20Sopenharmony_ci                        ; and x is the left button state
868c2ecf20Sopenharmony_ci    X                   ; delta x as twos complement integer
878c2ecf20Sopenharmony_ci    Y                   ; delta y as twos complement integer
888c2ecf20Sopenharmony_ci
898c2ecf20Sopenharmony_ciNote that the value of the button state bits should be valid even if the
908c2ecf20Sopenharmony_ciMOUSE BUTTON ACTION has set the buttons to act like part of the keyboard.
918c2ecf20Sopenharmony_ciIf the accumulated motion before the report packet is generated exceeds the
928c2ecf20Sopenharmony_ci+127...-128 range, the motion is broken into multiple packets.
938c2ecf20Sopenharmony_ciNote that the sign of the delta y reported is a function of the Y origin
948c2ecf20Sopenharmony_ciselected.
958c2ecf20Sopenharmony_ci
968c2ecf20Sopenharmony_ciAbsolute Position reporting
978c2ecf20Sopenharmony_ci---------------------------
988c2ecf20Sopenharmony_ci
998c2ecf20Sopenharmony_ciThe ikbd can also maintain absolute mouse position. Commands exist for
1008c2ecf20Sopenharmony_ciresetting the mouse position, setting X/Y scaling, and interrogating the
1018c2ecf20Sopenharmony_cicurrent mouse position.
1028c2ecf20Sopenharmony_ci
1038c2ecf20Sopenharmony_ciMouse Cursor Key Mode
1048c2ecf20Sopenharmony_ci---------------------
1058c2ecf20Sopenharmony_ci
1068c2ecf20Sopenharmony_ciThe ikbd can translate mouse motion into the equivalent cursor keystrokes.
1078c2ecf20Sopenharmony_ciThe number of mouse clicks per keystroke is independently programmable in
1088c2ecf20Sopenharmony_cieach axis. The ikbd internally maintains mouse motion information to the
1098c2ecf20Sopenharmony_cihighest resolution available, and merely generates a pair of cursor key events
1108c2ecf20Sopenharmony_cifor each multiple of the scale factor.
1118c2ecf20Sopenharmony_ciMouse motion produces the cursor key make code immediately followed by the
1128c2ecf20Sopenharmony_cibreak code for the appropriate cursor key. The mouse buttons produce scan
1138c2ecf20Sopenharmony_cicodes above those normally assigned for the largest envisioned keyboard (i.e.
1148c2ecf20Sopenharmony_ciLEFT=0x74 & RIGHT=0x75).
1158c2ecf20Sopenharmony_ci
1168c2ecf20Sopenharmony_ciJoystick
1178c2ecf20Sopenharmony_ci========
1188c2ecf20Sopenharmony_ci
1198c2ecf20Sopenharmony_ciJoystick Event Reporting
1208c2ecf20Sopenharmony_ci------------------------
1218c2ecf20Sopenharmony_ci
1228c2ecf20Sopenharmony_ciIn this mode, the ikbd generates a record whenever the joystick position is
1238c2ecf20Sopenharmony_cichanged (i.e. for each opening or closing of a joystick switch or trigger).
1248c2ecf20Sopenharmony_ci
1258c2ecf20Sopenharmony_ciThe joystick event record is two bytes of the form::
1268c2ecf20Sopenharmony_ci
1278c2ecf20Sopenharmony_ci    %1111111x           ; Joystick event marker
1288c2ecf20Sopenharmony_ci                        ; where x is Joystick 0 or 1
1298c2ecf20Sopenharmony_ci    %x000yyyy           ; where yyyy is the stick position
1308c2ecf20Sopenharmony_ci                        ; and x is the trigger
1318c2ecf20Sopenharmony_ci
1328c2ecf20Sopenharmony_ciJoystick Interrogation
1338c2ecf20Sopenharmony_ci----------------------
1348c2ecf20Sopenharmony_ci
1358c2ecf20Sopenharmony_ciThe current state of the joystick ports may be interrogated at any time in
1368c2ecf20Sopenharmony_cithis mode by sending an 'Interrogate Joystick' command to the ikbd.
1378c2ecf20Sopenharmony_ci
1388c2ecf20Sopenharmony_ciThe ikbd response to joystick interrogation is a three byte report of the form::
1398c2ecf20Sopenharmony_ci
1408c2ecf20Sopenharmony_ci    0xFD                ; joystick report header
1418c2ecf20Sopenharmony_ci    %x000yyyy           ; Joystick 0
1428c2ecf20Sopenharmony_ci    %x000yyyy           ; Joystick 1
1438c2ecf20Sopenharmony_ci                        ; where x is the trigger
1448c2ecf20Sopenharmony_ci                        ; and yyy is the stick position
1458c2ecf20Sopenharmony_ci
1468c2ecf20Sopenharmony_ciJoystick Monitoring
1478c2ecf20Sopenharmony_ci-------------------
1488c2ecf20Sopenharmony_ci
1498c2ecf20Sopenharmony_ciA mode is available that devotes nearly all of the keyboard communications
1508c2ecf20Sopenharmony_citime to reporting the state of the joystick ports at a user specifiable rate.
1518c2ecf20Sopenharmony_ciIt remains in this mode until reset or commanded into another mode. The PAUSE
1528c2ecf20Sopenharmony_cicommand in this mode not only stop the output but also temporarily stops
1538c2ecf20Sopenharmony_ciscanning the joysticks (samples are not queued).
1548c2ecf20Sopenharmony_ci
1558c2ecf20Sopenharmony_ciFire Button Monitoring
1568c2ecf20Sopenharmony_ci----------------------
1578c2ecf20Sopenharmony_ci
1588c2ecf20Sopenharmony_ciA mode is provided to permit monitoring a single input bit at a high rate. In
1598c2ecf20Sopenharmony_cithis mode the ikbd monitors the state of the Joystick 1 fire button at the
1608c2ecf20Sopenharmony_cimaximum rate permitted by the serial communication channel. The data is packed
1618c2ecf20Sopenharmony_ci8 bits per byte for transmission to the host. The ikbd remains in this mode
1628c2ecf20Sopenharmony_ciuntil reset or commanded into another mode. The PAUSE command in this mode not
1638c2ecf20Sopenharmony_cionly stops the output but also temporarily stops scanning the button (samples
1648c2ecf20Sopenharmony_ciare not queued).
1658c2ecf20Sopenharmony_ci
1668c2ecf20Sopenharmony_ciJoystick Key Code Mode
1678c2ecf20Sopenharmony_ci----------------------
1688c2ecf20Sopenharmony_ci
1698c2ecf20Sopenharmony_ciThe ikbd may be commanded to translate the use of either joystick into the
1708c2ecf20Sopenharmony_ciequivalent cursor control keystroke(s). The ikbd provides a single breakpoint
1718c2ecf20Sopenharmony_civelocity joystick cursor.
1728c2ecf20Sopenharmony_ciJoystick events produce the make code, immediately followed by the break code
1738c2ecf20Sopenharmony_cifor the appropriate cursor motion keys. The trigger or fire buttons of the
1748c2ecf20Sopenharmony_cijoysticks produce pseudo key scan codes above those used by the largest key
1758c2ecf20Sopenharmony_cimatrix envisioned (i.e. JOYSTICK0=0x74, JOYSTICK1=0x75).
1768c2ecf20Sopenharmony_ci
1778c2ecf20Sopenharmony_ciTime-of-Day Clock
1788c2ecf20Sopenharmony_ci=================
1798c2ecf20Sopenharmony_ci
1808c2ecf20Sopenharmony_ciThe ikbd also maintains a time-of-day clock for the system. Commands are
1818c2ecf20Sopenharmony_ciavailable to set and interrogate the timer-of-day clock. Time-keeping is
1828c2ecf20Sopenharmony_cimaintained down to a resolution of one second.
1838c2ecf20Sopenharmony_ci
1848c2ecf20Sopenharmony_ciStatus Inquiries
1858c2ecf20Sopenharmony_ci================
1868c2ecf20Sopenharmony_ci
1878c2ecf20Sopenharmony_ciThe current state of ikbd modes and parameters may be found by sending status
1888c2ecf20Sopenharmony_ciinquiry commands that correspond to the ikbd set commands.
1898c2ecf20Sopenharmony_ci
1908c2ecf20Sopenharmony_ciPower-Up Mode
1918c2ecf20Sopenharmony_ci=============
1928c2ecf20Sopenharmony_ci
1938c2ecf20Sopenharmony_ciThe keyboard controller will perform a simple self-test on power-up to detect
1948c2ecf20Sopenharmony_cimajor controller faults (ROM checksum and RAM test) and such things as stuck
1958c2ecf20Sopenharmony_cikeys. Any keys down at power-up are presumed to be stuck, and their BREAK
1968c2ecf20Sopenharmony_ci(sic) code is returned (which without the preceding MAKE code is a flag for a
1978c2ecf20Sopenharmony_cikeyboard error). If the controller self-test completes without error, the code
1988c2ecf20Sopenharmony_ci0xF0 is returned. (This code will be used to indicate the version/release of
1998c2ecf20Sopenharmony_cithe ikbd controller. The first release of the ikbd is version 0xF0, should
2008c2ecf20Sopenharmony_cithere be a second release it will be 0xF1, and so on.)
2018c2ecf20Sopenharmony_ciThe ikbd defaults to a mouse position reporting with threshold of 1 unit in
2028c2ecf20Sopenharmony_cieither axis and the Y=0 origin at the top of the screen, and joystick event
2038c2ecf20Sopenharmony_cireporting mode for joystick 1, with both buttons being logically assigned to
2048c2ecf20Sopenharmony_cithe mouse. After any joystick command, the ikbd assumes that joysticks are
2058c2ecf20Sopenharmony_ciconnected to both Joystick0 and Joystick1. Any mouse command (except MOUSE
2068c2ecf20Sopenharmony_ciDISABLE) then causes port 0 to again be scanned as if it were a mouse, and
2078c2ecf20Sopenharmony_ciboth buttons are logically connected to it. If a mouse disable command is
2088c2ecf20Sopenharmony_cireceived while port 0 is presumed to be a mouse, the button is logically
2098c2ecf20Sopenharmony_ciassigned to Joystick1 (until the mouse is reenabled by another mouse command).
2108c2ecf20Sopenharmony_ci
2118c2ecf20Sopenharmony_ciikbd Command Set
2128c2ecf20Sopenharmony_ci================
2138c2ecf20Sopenharmony_ci
2148c2ecf20Sopenharmony_ciThis section contains a list of commands that can be sent to the ikbd. Command
2158c2ecf20Sopenharmony_cicodes (such as 0x00) which are not specified should perform no operation
2168c2ecf20Sopenharmony_ci(NOPs).
2178c2ecf20Sopenharmony_ci
2188c2ecf20Sopenharmony_ciRESET
2198c2ecf20Sopenharmony_ci-----
2208c2ecf20Sopenharmony_ci
2218c2ecf20Sopenharmony_ci::
2228c2ecf20Sopenharmony_ci
2238c2ecf20Sopenharmony_ci    0x80
2248c2ecf20Sopenharmony_ci    0x01
2258c2ecf20Sopenharmony_ci
2268c2ecf20Sopenharmony_ciN.B. The RESET command is the only two byte command understood by the ikbd.
2278c2ecf20Sopenharmony_ciAny byte following an 0x80 command byte other than 0x01 is ignored (and causes
2288c2ecf20Sopenharmony_cithe 0x80 to be ignored).
2298c2ecf20Sopenharmony_ciA reset may also be caused by sending a break lasting at least 200mS to the
2308c2ecf20Sopenharmony_ciikbd.
2318c2ecf20Sopenharmony_ciExecuting the RESET command returns the keyboard to its default (power-up)
2328c2ecf20Sopenharmony_cimode and parameter settings. It does not affect the time-of-day clock.
2338c2ecf20Sopenharmony_ciThe RESET command or function causes the ikbd to perform a simple self-test.
2348c2ecf20Sopenharmony_ciIf the test is successful, the ikbd will send the code of 0xF0 within 300mS
2358c2ecf20Sopenharmony_ciof receipt of the RESET command (or the end of the break, or power-up). The
2368c2ecf20Sopenharmony_ciikbd will then scan the key matrix for any stuck (closed) keys. Any keys found
2378c2ecf20Sopenharmony_ciclosed will cause the break scan code to be generated (the break code arriving
2388c2ecf20Sopenharmony_ciwithout being preceded by the make code is a flag for a key matrix error).
2398c2ecf20Sopenharmony_ci
2408c2ecf20Sopenharmony_ciSET MOUSE BUTTON ACTION
2418c2ecf20Sopenharmony_ci-----------------------
2428c2ecf20Sopenharmony_ci
2438c2ecf20Sopenharmony_ci::
2448c2ecf20Sopenharmony_ci
2458c2ecf20Sopenharmony_ci    0x07
2468c2ecf20Sopenharmony_ci    %00000mss           ; mouse button action
2478c2ecf20Sopenharmony_ci                        ;       (m is presumed = 1 when in MOUSE KEYCODE mode)
2488c2ecf20Sopenharmony_ci                        ; mss=0xy, mouse button press or release causes mouse
2498c2ecf20Sopenharmony_ci                        ;  position report
2508c2ecf20Sopenharmony_ci                        ;  where y=1, mouse key press causes absolute report
2518c2ecf20Sopenharmony_ci                        ;  and x=1, mouse key release causes absolute report
2528c2ecf20Sopenharmony_ci                        ; mss=100, mouse buttons act like keys
2538c2ecf20Sopenharmony_ci
2548c2ecf20Sopenharmony_ciThis command sets how the ikbd should treat the buttons on the mouse. The
2558c2ecf20Sopenharmony_cidefault mouse button action mode is %00000000, the buttons are treated as part
2568c2ecf20Sopenharmony_ciof the mouse logically.
2578c2ecf20Sopenharmony_ciWhen buttons act like keys, LEFT=0x74 & RIGHT=0x75.
2588c2ecf20Sopenharmony_ci
2598c2ecf20Sopenharmony_ciSET RELATIVE MOUSE POSITION REPORTING
2608c2ecf20Sopenharmony_ci-------------------------------------
2618c2ecf20Sopenharmony_ci
2628c2ecf20Sopenharmony_ci::
2638c2ecf20Sopenharmony_ci
2648c2ecf20Sopenharmony_ci    0x08
2658c2ecf20Sopenharmony_ci
2668c2ecf20Sopenharmony_ciSet relative mouse position reporting. (DEFAULT) Mouse position packets are
2678c2ecf20Sopenharmony_cigenerated asynchronously by the ikbd whenever motion exceeds the setable
2688c2ecf20Sopenharmony_cithreshold in either axis (see SET MOUSE THRESHOLD). Depending upon the mouse
2698c2ecf20Sopenharmony_cikey mode, mouse position reports may also be generated when either mouse
2708c2ecf20Sopenharmony_cibutton is pressed or released. Otherwise the mouse buttons behave as if they
2718c2ecf20Sopenharmony_ciwere keyboard keys.
2728c2ecf20Sopenharmony_ci
2738c2ecf20Sopenharmony_ciSET ABSOLUTE MOUSE POSITIONING
2748c2ecf20Sopenharmony_ci------------------------------
2758c2ecf20Sopenharmony_ci
2768c2ecf20Sopenharmony_ci::
2778c2ecf20Sopenharmony_ci
2788c2ecf20Sopenharmony_ci    0x09
2798c2ecf20Sopenharmony_ci    XMSB                ; X maximum (in scaled mouse clicks)
2808c2ecf20Sopenharmony_ci    XLSB
2818c2ecf20Sopenharmony_ci    YMSB                ; Y maximum (in scaled mouse clicks)
2828c2ecf20Sopenharmony_ci    YLSB
2838c2ecf20Sopenharmony_ci
2848c2ecf20Sopenharmony_ciSet absolute mouse position maintenance. Resets the ikbd maintained X and Y
2858c2ecf20Sopenharmony_cicoordinates.
2868c2ecf20Sopenharmony_ciIn this mode, the value of the internally maintained coordinates does NOT wrap
2878c2ecf20Sopenharmony_cibetween 0 and large positive numbers. Excess motion below 0 is ignored. The
2888c2ecf20Sopenharmony_cicommand sets the maximum positive value that can be attained in the scaled
2898c2ecf20Sopenharmony_cicoordinate system. Motion beyond that value is also ignored.
2908c2ecf20Sopenharmony_ci
2918c2ecf20Sopenharmony_ciSET MOUSE KEYCODE MOSE
2928c2ecf20Sopenharmony_ci----------------------
2938c2ecf20Sopenharmony_ci
2948c2ecf20Sopenharmony_ci::
2958c2ecf20Sopenharmony_ci
2968c2ecf20Sopenharmony_ci    0x0A
2978c2ecf20Sopenharmony_ci    deltax              ; distance in X clicks to return (LEFT) or (RIGHT)
2988c2ecf20Sopenharmony_ci    deltay              ; distance in Y clicks to return (UP) or (DOWN)
2998c2ecf20Sopenharmony_ci
3008c2ecf20Sopenharmony_ciSet mouse monitoring routines to return cursor motion keycodes instead of
3018c2ecf20Sopenharmony_cieither RELATIVE or ABSOLUTE motion records. The ikbd returns the appropriate
3028c2ecf20Sopenharmony_cicursor keycode after mouse travel exceeding the user specified deltas in
3038c2ecf20Sopenharmony_cieither axis. When the keyboard is in key scan code mode, mouse motion will
3048c2ecf20Sopenharmony_cicause the make code immediately followed by the break code. Note that this
3058c2ecf20Sopenharmony_cicommand is not affected by the mouse motion origin.
3068c2ecf20Sopenharmony_ci
3078c2ecf20Sopenharmony_ciSET MOUSE THRESHOLD
3088c2ecf20Sopenharmony_ci-------------------
3098c2ecf20Sopenharmony_ci
3108c2ecf20Sopenharmony_ci::
3118c2ecf20Sopenharmony_ci
3128c2ecf20Sopenharmony_ci    0x0B
3138c2ecf20Sopenharmony_ci    X                   ; x threshold in mouse ticks (positive integers)
3148c2ecf20Sopenharmony_ci    Y                   ; y threshold in mouse ticks (positive integers)
3158c2ecf20Sopenharmony_ci
3168c2ecf20Sopenharmony_ciThis command sets the threshold before a mouse event is generated. Note that
3178c2ecf20Sopenharmony_ciit does NOT affect the resolution of the data returned to the host. This
3188c2ecf20Sopenharmony_cicommand is valid only in RELATIVE MOUSE POSITIONING mode. The thresholds
3198c2ecf20Sopenharmony_cidefault to 1 at RESET (or power-up).
3208c2ecf20Sopenharmony_ci
3218c2ecf20Sopenharmony_ciSET MOUSE SCALE
3228c2ecf20Sopenharmony_ci---------------
3238c2ecf20Sopenharmony_ci
3248c2ecf20Sopenharmony_ci::
3258c2ecf20Sopenharmony_ci
3268c2ecf20Sopenharmony_ci    0x0C
3278c2ecf20Sopenharmony_ci    X                   ; horizontal mouse ticks per internal X
3288c2ecf20Sopenharmony_ci    Y                   ; vertical mouse ticks per internal Y
3298c2ecf20Sopenharmony_ci
3308c2ecf20Sopenharmony_ciThis command sets the scale factor for the ABSOLUTE MOUSE POSITIONING mode.
3318c2ecf20Sopenharmony_ciIn this mode, the specified number of mouse phase changes ('clicks') must
3328c2ecf20Sopenharmony_cioccur before the internally maintained coordinate is changed by one
3338c2ecf20Sopenharmony_ci(independently scaled for each axis). Remember that the mouse position
3348c2ecf20Sopenharmony_ciinformation is available only by interrogating the ikbd in the ABSOLUTE MOUSE
3358c2ecf20Sopenharmony_ciPOSITIONING mode unless the ikbd has been commanded to report on button press
3368c2ecf20Sopenharmony_cior release (see SET MOSE BUTTON ACTION).
3378c2ecf20Sopenharmony_ci
3388c2ecf20Sopenharmony_ciINTERROGATE MOUSE POSITION
3398c2ecf20Sopenharmony_ci--------------------------
3408c2ecf20Sopenharmony_ci
3418c2ecf20Sopenharmony_ci::
3428c2ecf20Sopenharmony_ci
3438c2ecf20Sopenharmony_ci    0x0D
3448c2ecf20Sopenharmony_ci    Returns:
3458c2ecf20Sopenharmony_ci            0xF7       ; absolute mouse position header
3468c2ecf20Sopenharmony_ci    BUTTONS
3478c2ecf20Sopenharmony_ci            0000dcba   ; where a is right button down since last interrogation
3488c2ecf20Sopenharmony_ci                       ; b is right button up since last
3498c2ecf20Sopenharmony_ci                       ; c is left button down since last
3508c2ecf20Sopenharmony_ci                       ; d is left button up since last
3518c2ecf20Sopenharmony_ci            XMSB       ; X coordinate
3528c2ecf20Sopenharmony_ci            XLSB
3538c2ecf20Sopenharmony_ci            YMSB       ; Y coordinate
3548c2ecf20Sopenharmony_ci            YLSB
3558c2ecf20Sopenharmony_ci
3568c2ecf20Sopenharmony_ciThe INTERROGATE MOUSE POSITION command is valid when in the ABSOLUTE MOUSE
3578c2ecf20Sopenharmony_ciPOSITIONING mode, regardless of the setting of the MOUSE BUTTON ACTION.
3588c2ecf20Sopenharmony_ci
3598c2ecf20Sopenharmony_ciLOAD MOUSE POSITION
3608c2ecf20Sopenharmony_ci-------------------
3618c2ecf20Sopenharmony_ci
3628c2ecf20Sopenharmony_ci::
3638c2ecf20Sopenharmony_ci
3648c2ecf20Sopenharmony_ci    0x0E
3658c2ecf20Sopenharmony_ci    0x00                ; filler
3668c2ecf20Sopenharmony_ci    XMSB                ; X coordinate
3678c2ecf20Sopenharmony_ci    XLSB                ; (in scaled coordinate system)
3688c2ecf20Sopenharmony_ci    YMSB                ; Y coordinate
3698c2ecf20Sopenharmony_ci    YLSB
3708c2ecf20Sopenharmony_ci
3718c2ecf20Sopenharmony_ciThis command allows the user to preset the internally maintained absolute
3728c2ecf20Sopenharmony_cimouse position.
3738c2ecf20Sopenharmony_ci
3748c2ecf20Sopenharmony_ciSET Y=0 AT BOTTOM
3758c2ecf20Sopenharmony_ci-----------------
3768c2ecf20Sopenharmony_ci
3778c2ecf20Sopenharmony_ci::
3788c2ecf20Sopenharmony_ci
3798c2ecf20Sopenharmony_ci    0x0F
3808c2ecf20Sopenharmony_ci
3818c2ecf20Sopenharmony_ciThis command makes the origin of the Y axis to be at the bottom of the
3828c2ecf20Sopenharmony_cilogical coordinate system internal to the ikbd for all relative or absolute
3838c2ecf20Sopenharmony_cimouse motion. This causes mouse motion toward the user to be negative in sign
3848c2ecf20Sopenharmony_ciand away from the user to be positive.
3858c2ecf20Sopenharmony_ci
3868c2ecf20Sopenharmony_ciSET Y=0 AT TOP
3878c2ecf20Sopenharmony_ci--------------
3888c2ecf20Sopenharmony_ci
3898c2ecf20Sopenharmony_ci::
3908c2ecf20Sopenharmony_ci
3918c2ecf20Sopenharmony_ci    0x10
3928c2ecf20Sopenharmony_ci
3938c2ecf20Sopenharmony_ciMakes the origin of the Y axis to be at the top of the logical coordinate
3948c2ecf20Sopenharmony_cisystem within the ikbd for all relative or absolute mouse motion. (DEFAULT)
3958c2ecf20Sopenharmony_ciThis causes mouse motion toward the user to be positive in sign and away from
3968c2ecf20Sopenharmony_cithe user to be negative.
3978c2ecf20Sopenharmony_ci
3988c2ecf20Sopenharmony_ciRESUME
3998c2ecf20Sopenharmony_ci------
4008c2ecf20Sopenharmony_ci
4018c2ecf20Sopenharmony_ci::
4028c2ecf20Sopenharmony_ci
4038c2ecf20Sopenharmony_ci    0x11
4048c2ecf20Sopenharmony_ci
4058c2ecf20Sopenharmony_ciResume sending data to the host. Since any command received by the ikbd after
4068c2ecf20Sopenharmony_ciits output has been paused also causes an implicit RESUME this command can be
4078c2ecf20Sopenharmony_cithought of as a NO OPERATION command. If this command is received by the ikbd
4088c2ecf20Sopenharmony_ciand it is not PAUSED, it is simply ignored.
4098c2ecf20Sopenharmony_ci
4108c2ecf20Sopenharmony_ciDISABLE MOUSE
4118c2ecf20Sopenharmony_ci-------------
4128c2ecf20Sopenharmony_ci
4138c2ecf20Sopenharmony_ci::
4148c2ecf20Sopenharmony_ci
4158c2ecf20Sopenharmony_ci    0x12
4168c2ecf20Sopenharmony_ci
4178c2ecf20Sopenharmony_ciAll mouse event reporting is disabled (and scanning may be internally
4188c2ecf20Sopenharmony_cidisabled). Any valid mouse mode command resumes mouse motion monitoring. (The
4198c2ecf20Sopenharmony_civalid mouse mode commands are SET RELATIVE MOUSE POSITION REPORTING, SET
4208c2ecf20Sopenharmony_ciABSOLUTE MOUSE POSITIONING, and SET MOUSE KEYCODE MODE. )
4218c2ecf20Sopenharmony_ciN.B. If the mouse buttons have been commanded to act like keyboard keys, this
4228c2ecf20Sopenharmony_cicommand DOES affect their actions.
4238c2ecf20Sopenharmony_ci
4248c2ecf20Sopenharmony_ciPAUSE OUTPUT
4258c2ecf20Sopenharmony_ci------------
4268c2ecf20Sopenharmony_ci
4278c2ecf20Sopenharmony_ci::
4288c2ecf20Sopenharmony_ci
4298c2ecf20Sopenharmony_ci    0x13
4308c2ecf20Sopenharmony_ci
4318c2ecf20Sopenharmony_ciStop sending data to the host until another valid command is received. Key
4328c2ecf20Sopenharmony_cimatrix activity is still monitored and scan codes or ASCII characters enqueued
4338c2ecf20Sopenharmony_ci(up to the maximum supported by the microcontroller) to be sent when the host
4348c2ecf20Sopenharmony_ciallows the output to be resumed. If in the JOYSTICK EVENT REPORTING mode,
4358c2ecf20Sopenharmony_cijoystick events are also queued.
4368c2ecf20Sopenharmony_ciMouse motion should be accumulated while the output is paused. If the ikbd is
4378c2ecf20Sopenharmony_ciin RELATIVE MOUSE POSITIONING REPORTING mode, motion is accumulated beyond the
4388c2ecf20Sopenharmony_cinormal threshold limits to produce the minimum number of packets necessary for
4398c2ecf20Sopenharmony_citransmission when output is resumed. Pressing or releasing either mouse button
4408c2ecf20Sopenharmony_cicauses any accumulated motion to be immediately queued as packets, if the
4418c2ecf20Sopenharmony_cimouse is in RELATIVE MOUSE POSITION REPORTING mode.
4428c2ecf20Sopenharmony_ciBecause of the limitations of the microcontroller memory this command should
4438c2ecf20Sopenharmony_cibe used sparingly, and the output should not be shut of for more than <tbd>
4448c2ecf20Sopenharmony_cimilliseconds at a time.
4458c2ecf20Sopenharmony_ciThe output is stopped only at the end of the current 'even'. If the PAUSE
4468c2ecf20Sopenharmony_ciOUTPUT command is received in the middle of a multiple byte report, the packet
4478c2ecf20Sopenharmony_ciwill still be transmitted to conclusion and then the PAUSE will take effect.
4488c2ecf20Sopenharmony_ciWhen the ikbd is in either the JOYSTICK MONITORING mode or the FIRE BUTTON
4498c2ecf20Sopenharmony_ciMONITORING mode, the PAUSE OUTPUT command also temporarily stops the
4508c2ecf20Sopenharmony_cimonitoring process (i.e. the samples are not enqueued for transmission).
4518c2ecf20Sopenharmony_ci
4528c2ecf20Sopenharmony_ciSET JOYSTICK EVENT REPORTING
4538c2ecf20Sopenharmony_ci----------------------------
4548c2ecf20Sopenharmony_ci
4558c2ecf20Sopenharmony_ci::
4568c2ecf20Sopenharmony_ci
4578c2ecf20Sopenharmony_ci    0x14
4588c2ecf20Sopenharmony_ci
4598c2ecf20Sopenharmony_ciEnter JOYSTICK EVENT REPORTING mode (DEFAULT). Each opening or closure of a
4608c2ecf20Sopenharmony_cijoystick switch or trigger causes a joystick event record to be generated.
4618c2ecf20Sopenharmony_ci
4628c2ecf20Sopenharmony_ciSET JOYSTICK INTERROGATION MODE
4638c2ecf20Sopenharmony_ci-------------------------------
4648c2ecf20Sopenharmony_ci
4658c2ecf20Sopenharmony_ci::
4668c2ecf20Sopenharmony_ci
4678c2ecf20Sopenharmony_ci    0x15
4688c2ecf20Sopenharmony_ci
4698c2ecf20Sopenharmony_ciDisables JOYSTICK EVENT REPORTING. Host must send individual JOYSTICK
4708c2ecf20Sopenharmony_ciINTERROGATE commands to sense joystick state.
4718c2ecf20Sopenharmony_ci
4728c2ecf20Sopenharmony_ciJOYSTICK INTERROGATE
4738c2ecf20Sopenharmony_ci--------------------
4748c2ecf20Sopenharmony_ci
4758c2ecf20Sopenharmony_ci::
4768c2ecf20Sopenharmony_ci
4778c2ecf20Sopenharmony_ci    0x16
4788c2ecf20Sopenharmony_ci
4798c2ecf20Sopenharmony_ciReturn a record indicating the current state of the joysticks. This command
4808c2ecf20Sopenharmony_ciis valid in either the JOYSTICK EVENT REPORTING mode or the JOYSTICK
4818c2ecf20Sopenharmony_ciINTERROGATION MODE.
4828c2ecf20Sopenharmony_ci
4838c2ecf20Sopenharmony_ciSET JOYSTICK MONITORING
4848c2ecf20Sopenharmony_ci-----------------------
4858c2ecf20Sopenharmony_ci
4868c2ecf20Sopenharmony_ci::
4878c2ecf20Sopenharmony_ci
4888c2ecf20Sopenharmony_ci    0x17
4898c2ecf20Sopenharmony_ci    rate                ; time between samples in hundredths of a second
4908c2ecf20Sopenharmony_ci    Returns: (in packets of two as long as in mode)
4918c2ecf20Sopenharmony_ci            %000000xy   ; where y is JOYSTICK1 Fire button
4928c2ecf20Sopenharmony_ci                        ; and x is JOYSTICK0 Fire button
4938c2ecf20Sopenharmony_ci            %nnnnmmmm   ; where m is JOYSTICK1 state
4948c2ecf20Sopenharmony_ci                        ; and n is JOYSTICK0 state
4958c2ecf20Sopenharmony_ci
4968c2ecf20Sopenharmony_ciSets the ikbd to do nothing but monitor the serial command line, maintain the
4978c2ecf20Sopenharmony_citime-of-day clock, and monitor the joystick. The rate sets the interval
4988c2ecf20Sopenharmony_cibetween joystick samples.
4998c2ecf20Sopenharmony_ciN.B. The user should not set the rate higher than the serial communications
5008c2ecf20Sopenharmony_cichannel will allow the 2 bytes packets to be transmitted.
5018c2ecf20Sopenharmony_ci
5028c2ecf20Sopenharmony_ciSET FIRE BUTTON MONITORING
5038c2ecf20Sopenharmony_ci--------------------------
5048c2ecf20Sopenharmony_ci
5058c2ecf20Sopenharmony_ci::
5068c2ecf20Sopenharmony_ci
5078c2ecf20Sopenharmony_ci    0x18
5088c2ecf20Sopenharmony_ci    Returns: (as long as in mode)
5098c2ecf20Sopenharmony_ci            %bbbbbbbb   ; state of the JOYSTICK1 fire button packed
5108c2ecf20Sopenharmony_ci                        ; 8 bits per byte, the first sample if the MSB
5118c2ecf20Sopenharmony_ci
5128c2ecf20Sopenharmony_ciSet the ikbd to do nothing but monitor the serial command line, maintain the
5138c2ecf20Sopenharmony_citime-of-day clock, and monitor the fire button on Joystick 1. The fire button
5148c2ecf20Sopenharmony_ciis scanned at a rate that causes 8 samples to be made in the time it takes for
5158c2ecf20Sopenharmony_cithe previous byte to be sent to the host (i.e. scan rate = 8/10 * baud rate).
5168c2ecf20Sopenharmony_ciThe sample interval should be as constant as possible.
5178c2ecf20Sopenharmony_ci
5188c2ecf20Sopenharmony_ciSET JOYSTICK KEYCODE MODE
5198c2ecf20Sopenharmony_ci-------------------------
5208c2ecf20Sopenharmony_ci
5218c2ecf20Sopenharmony_ci::
5228c2ecf20Sopenharmony_ci
5238c2ecf20Sopenharmony_ci    0x19
5248c2ecf20Sopenharmony_ci    RX                  ; length of time (in tenths of seconds) until
5258c2ecf20Sopenharmony_ci                        ; horizontal velocity breakpoint is reached
5268c2ecf20Sopenharmony_ci    RY                  ; length of time (in tenths of seconds) until
5278c2ecf20Sopenharmony_ci                        ; vertical velocity breakpoint is reached
5288c2ecf20Sopenharmony_ci    TX                  ; length (in tenths of seconds) of joystick closure
5298c2ecf20Sopenharmony_ci                        ; until horizontal cursor key is generated before RX
5308c2ecf20Sopenharmony_ci                        ; has elapsed
5318c2ecf20Sopenharmony_ci    TY                  ; length (in tenths of seconds) of joystick closure
5328c2ecf20Sopenharmony_ci                        ; until vertical cursor key is generated before RY
5338c2ecf20Sopenharmony_ci                        ; has elapsed
5348c2ecf20Sopenharmony_ci    VX                  ; length (in tenths of seconds) of joystick closure
5358c2ecf20Sopenharmony_ci                        ; until horizontal cursor keystrokes are generated
5368c2ecf20Sopenharmony_ci                        ; after RX has elapsed
5378c2ecf20Sopenharmony_ci    VY                  ; length (in tenths of seconds) of joystick closure
5388c2ecf20Sopenharmony_ci                        ; until vertical cursor keystrokes are generated
5398c2ecf20Sopenharmony_ci                        ; after RY has elapsed
5408c2ecf20Sopenharmony_ci
5418c2ecf20Sopenharmony_ciIn this mode, joystick 0 is scanned in a way that simulates cursor keystrokes.
5428c2ecf20Sopenharmony_ciOn initial closure, a keystroke pair (make/break) is generated. Then up to Rn
5438c2ecf20Sopenharmony_citenths of seconds later, keystroke pairs are generated every Tn tenths of
5448c2ecf20Sopenharmony_ciseconds. After the Rn breakpoint is reached, keystroke pairs are generated
5458c2ecf20Sopenharmony_cievery Vn tenths of seconds. This provides a velocity (auto-repeat) breakpoint
5468c2ecf20Sopenharmony_cifeature.
5478c2ecf20Sopenharmony_ciNote that by setting RX and/or Ry to zero, the velocity feature can be
5488c2ecf20Sopenharmony_cidisabled. The values of TX and TY then become meaningless, and the generation
5498c2ecf20Sopenharmony_ciof cursor 'keystrokes' is set by VX and VY.
5508c2ecf20Sopenharmony_ci
5518c2ecf20Sopenharmony_ciDISABLE JOYSTICKS
5528c2ecf20Sopenharmony_ci-----------------
5538c2ecf20Sopenharmony_ci
5548c2ecf20Sopenharmony_ci::
5558c2ecf20Sopenharmony_ci
5568c2ecf20Sopenharmony_ci    0x1A
5578c2ecf20Sopenharmony_ci
5588c2ecf20Sopenharmony_ciDisable the generation of any joystick events (and scanning may be internally
5598c2ecf20Sopenharmony_cidisabled). Any valid joystick mode command resumes joystick monitoring. (The
5608c2ecf20Sopenharmony_cijoystick mode commands are SET JOYSTICK EVENT REPORTING, SET JOYSTICK
5618c2ecf20Sopenharmony_ciINTERROGATION MODE, SET JOYSTICK MONITORING, SET FIRE BUTTON MONITORING, and
5628c2ecf20Sopenharmony_ciSET JOYSTICK KEYCODE MODE.)
5638c2ecf20Sopenharmony_ci
5648c2ecf20Sopenharmony_ciTIME-OF-DAY CLOCK SET
5658c2ecf20Sopenharmony_ci---------------------
5668c2ecf20Sopenharmony_ci
5678c2ecf20Sopenharmony_ci::
5688c2ecf20Sopenharmony_ci
5698c2ecf20Sopenharmony_ci    0x1B
5708c2ecf20Sopenharmony_ci    YY                  ; year (2 least significant digits)
5718c2ecf20Sopenharmony_ci    MM                  ; month
5728c2ecf20Sopenharmony_ci    DD                  ; day
5738c2ecf20Sopenharmony_ci    hh                  ; hour
5748c2ecf20Sopenharmony_ci    mm                  ; minute
5758c2ecf20Sopenharmony_ci    ss                  ; second
5768c2ecf20Sopenharmony_ci
5778c2ecf20Sopenharmony_ciAll time-of-day data should be sent to the ikbd in packed BCD format.
5788c2ecf20Sopenharmony_ciAny digit that is not a valid BCD digit should be treated as a 'don't care'
5798c2ecf20Sopenharmony_ciand not alter that particular field of the date or time. This permits setting
5808c2ecf20Sopenharmony_cionly some subfields of the time-of-day clock.
5818c2ecf20Sopenharmony_ci
5828c2ecf20Sopenharmony_ciINTERROGATE TIME-OF-DAT CLOCK
5838c2ecf20Sopenharmony_ci-----------------------------
5848c2ecf20Sopenharmony_ci
5858c2ecf20Sopenharmony_ci::
5868c2ecf20Sopenharmony_ci
5878c2ecf20Sopenharmony_ci    0x1C
5888c2ecf20Sopenharmony_ci    Returns:
5898c2ecf20Sopenharmony_ci            0xFC        ; time-of-day event header
5908c2ecf20Sopenharmony_ci            YY          ; year (2 least significant digits)
5918c2ecf20Sopenharmony_ci            MM          ; month
5928c2ecf20Sopenharmony_ci            DD          ; day
5938c2ecf20Sopenharmony_ci            hh          ; hour
5948c2ecf20Sopenharmony_ci            mm          ; minute
5958c2ecf20Sopenharmony_ci            ss          ; second
5968c2ecf20Sopenharmony_ci
5978c2ecf20Sopenharmony_ci    All time-of-day is sent in packed BCD format.
5988c2ecf20Sopenharmony_ci
5998c2ecf20Sopenharmony_ciMEMORY LOAD
6008c2ecf20Sopenharmony_ci-----------
6018c2ecf20Sopenharmony_ci
6028c2ecf20Sopenharmony_ci::
6038c2ecf20Sopenharmony_ci
6048c2ecf20Sopenharmony_ci    0x20
6058c2ecf20Sopenharmony_ci    ADRMSB              ; address in controller
6068c2ecf20Sopenharmony_ci    ADRLSB              ; memory to be loaded
6078c2ecf20Sopenharmony_ci    NUM                 ; number of bytes (0-128)
6088c2ecf20Sopenharmony_ci    { data }
6098c2ecf20Sopenharmony_ci
6108c2ecf20Sopenharmony_ciThis command permits the host to load arbitrary values into the ikbd
6118c2ecf20Sopenharmony_cicontroller memory. The time between data bytes must be less than 20ms.
6128c2ecf20Sopenharmony_ci
6138c2ecf20Sopenharmony_ciMEMORY READ
6148c2ecf20Sopenharmony_ci-----------
6158c2ecf20Sopenharmony_ci
6168c2ecf20Sopenharmony_ci::
6178c2ecf20Sopenharmony_ci
6188c2ecf20Sopenharmony_ci    0x21
6198c2ecf20Sopenharmony_ci    ADRMSB              ; address in controller
6208c2ecf20Sopenharmony_ci    ADRLSB              ; memory to be read
6218c2ecf20Sopenharmony_ci    Returns:
6228c2ecf20Sopenharmony_ci            0xF6        ; status header
6238c2ecf20Sopenharmony_ci            0x20        ; memory access
6248c2ecf20Sopenharmony_ci            { data }    ; 6 data bytes starting at ADR
6258c2ecf20Sopenharmony_ci
6268c2ecf20Sopenharmony_ciThis command permits the host to read from the ikbd controller memory.
6278c2ecf20Sopenharmony_ci
6288c2ecf20Sopenharmony_ciCONTROLLER EXECUTE
6298c2ecf20Sopenharmony_ci------------------
6308c2ecf20Sopenharmony_ci
6318c2ecf20Sopenharmony_ci::
6328c2ecf20Sopenharmony_ci
6338c2ecf20Sopenharmony_ci    0x22
6348c2ecf20Sopenharmony_ci    ADRMSB              ; address of subroutine in
6358c2ecf20Sopenharmony_ci    ADRLSB              ; controller memory to be called
6368c2ecf20Sopenharmony_ci
6378c2ecf20Sopenharmony_ciThis command allows the host to command the execution of a subroutine in the
6388c2ecf20Sopenharmony_ciikbd controller memory.
6398c2ecf20Sopenharmony_ci
6408c2ecf20Sopenharmony_ciSTATUS INQUIRIES
6418c2ecf20Sopenharmony_ci----------------
6428c2ecf20Sopenharmony_ci
6438c2ecf20Sopenharmony_ci::
6448c2ecf20Sopenharmony_ci
6458c2ecf20Sopenharmony_ci    Status commands are formed by inclusively ORing 0x80 with the
6468c2ecf20Sopenharmony_ci    relevant SET command.
6478c2ecf20Sopenharmony_ci
6488c2ecf20Sopenharmony_ci    Example:
6498c2ecf20Sopenharmony_ci    0x88 (or 0x89 or 0x8A)  ; request mouse mode
6508c2ecf20Sopenharmony_ci    Returns:
6518c2ecf20Sopenharmony_ci            0xF6        ; status response header
6528c2ecf20Sopenharmony_ci            mode        ; 0x08 is RELATIVE
6538c2ecf20Sopenharmony_ci                        ; 0x09 is ABSOLUTE
6548c2ecf20Sopenharmony_ci                        ; 0x0A is KEYCODE
6558c2ecf20Sopenharmony_ci            param1      ; 0 is RELATIVE
6568c2ecf20Sopenharmony_ci                        ; XMSB maximum if ABSOLUTE
6578c2ecf20Sopenharmony_ci                        ; DELTA X is KEYCODE
6588c2ecf20Sopenharmony_ci            param2      ; 0 is RELATIVE
6598c2ecf20Sopenharmony_ci                        ; YMSB maximum if ABSOLUTE
6608c2ecf20Sopenharmony_ci                        ; DELTA Y is KEYCODE
6618c2ecf20Sopenharmony_ci            param3      ; 0 if RELATIVE
6628c2ecf20Sopenharmony_ci                        ; or KEYCODE
6638c2ecf20Sopenharmony_ci                        ; YMSB is ABSOLUTE
6648c2ecf20Sopenharmony_ci            param4      ; 0 if RELATIVE
6658c2ecf20Sopenharmony_ci                        ; or KEYCODE
6668c2ecf20Sopenharmony_ci                        ; YLSB is ABSOLUTE
6678c2ecf20Sopenharmony_ci            0           ; pad
6688c2ecf20Sopenharmony_ci            0
6698c2ecf20Sopenharmony_ci
6708c2ecf20Sopenharmony_ciThe STATUS INQUIRY commands request the ikbd to return either the current mode
6718c2ecf20Sopenharmony_cior the parameters associated with a given command. All status reports are
6728c2ecf20Sopenharmony_cipadded to form 8 byte long return packets. The responses to the status
6738c2ecf20Sopenharmony_cirequests are designed so that the host may store them away (after stripping
6748c2ecf20Sopenharmony_cioff the status report header byte) and later send them back as commands to
6758c2ecf20Sopenharmony_ciikbd to restore its state. The 0 pad bytes will be treated as NOPs by the
6768c2ecf20Sopenharmony_ciikbd.
6778c2ecf20Sopenharmony_ci
6788c2ecf20Sopenharmony_ci    Valid STATUS INQUIRY commands are::
6798c2ecf20Sopenharmony_ci
6808c2ecf20Sopenharmony_ci            0x87    mouse button action
6818c2ecf20Sopenharmony_ci            0x88    mouse mode
6828c2ecf20Sopenharmony_ci            0x89
6838c2ecf20Sopenharmony_ci            0x8A
6848c2ecf20Sopenharmony_ci            0x8B    mnouse threshold
6858c2ecf20Sopenharmony_ci            0x8C    mouse scale
6868c2ecf20Sopenharmony_ci            0x8F    mouse vertical coordinates
6878c2ecf20Sopenharmony_ci            0x90    ( returns       0x0F Y=0 at bottom
6888c2ecf20Sopenharmony_ci                            0x10 Y=0 at top )
6898c2ecf20Sopenharmony_ci            0x92    mouse enable/disable
6908c2ecf20Sopenharmony_ci                    ( returns       0x00 enabled)
6918c2ecf20Sopenharmony_ci                            0x12 disabled )
6928c2ecf20Sopenharmony_ci            0x94    joystick mode
6938c2ecf20Sopenharmony_ci            0x95
6948c2ecf20Sopenharmony_ci            0x96
6958c2ecf20Sopenharmony_ci            0x9A    joystick enable/disable
6968c2ecf20Sopenharmony_ci                    ( returns       0x00 enabled
6978c2ecf20Sopenharmony_ci                            0x1A disabled )
6988c2ecf20Sopenharmony_ci
6998c2ecf20Sopenharmony_ciIt is the (host) programmer's responsibility to have only one unanswered
7008c2ecf20Sopenharmony_ciinquiry in process at a time.
7018c2ecf20Sopenharmony_ciSTATUS INQUIRY commands are not valid if the ikbd is in JOYSTICK MONITORING
7028c2ecf20Sopenharmony_cimode or FIRE BUTTON MONITORING mode.
7038c2ecf20Sopenharmony_ci
7048c2ecf20Sopenharmony_ci
7058c2ecf20Sopenharmony_ciSCAN CODES
7068c2ecf20Sopenharmony_ci==========
7078c2ecf20Sopenharmony_ci
7088c2ecf20Sopenharmony_ciThe key scan codes returned by the ikbd are chosen to simplify the
7098c2ecf20Sopenharmony_ciimplementation of GSX.
7108c2ecf20Sopenharmony_ci
7118c2ecf20Sopenharmony_ciGSX Standard Keyboard Mapping
7128c2ecf20Sopenharmony_ci
7138c2ecf20Sopenharmony_ci======= ============
7148c2ecf20Sopenharmony_ciHex	Keytop
7158c2ecf20Sopenharmony_ci======= ============
7168c2ecf20Sopenharmony_ci01	Esc
7178c2ecf20Sopenharmony_ci02	1
7188c2ecf20Sopenharmony_ci03	2
7198c2ecf20Sopenharmony_ci04	3
7208c2ecf20Sopenharmony_ci05	4
7218c2ecf20Sopenharmony_ci06	5
7228c2ecf20Sopenharmony_ci07	6
7238c2ecf20Sopenharmony_ci08	7
7248c2ecf20Sopenharmony_ci09	8
7258c2ecf20Sopenharmony_ci0A	9
7268c2ecf20Sopenharmony_ci0B	0
7278c2ecf20Sopenharmony_ci0C	\-
7288c2ecf20Sopenharmony_ci0D	\=
7298c2ecf20Sopenharmony_ci0E	BS
7308c2ecf20Sopenharmony_ci0F	TAB
7318c2ecf20Sopenharmony_ci10	Q
7328c2ecf20Sopenharmony_ci11	W
7338c2ecf20Sopenharmony_ci12	E
7348c2ecf20Sopenharmony_ci13	R
7358c2ecf20Sopenharmony_ci14	T
7368c2ecf20Sopenharmony_ci15	Y
7378c2ecf20Sopenharmony_ci16	U
7388c2ecf20Sopenharmony_ci17	I
7398c2ecf20Sopenharmony_ci18	O
7408c2ecf20Sopenharmony_ci19	P
7418c2ecf20Sopenharmony_ci1A	[
7428c2ecf20Sopenharmony_ci1B	]
7438c2ecf20Sopenharmony_ci1C	RET
7448c2ecf20Sopenharmony_ci1D	CTRL
7458c2ecf20Sopenharmony_ci1E	A
7468c2ecf20Sopenharmony_ci1F	S
7478c2ecf20Sopenharmony_ci20	D
7488c2ecf20Sopenharmony_ci21	F
7498c2ecf20Sopenharmony_ci22	G
7508c2ecf20Sopenharmony_ci23	H
7518c2ecf20Sopenharmony_ci24	J
7528c2ecf20Sopenharmony_ci25	K
7538c2ecf20Sopenharmony_ci26	L
7548c2ecf20Sopenharmony_ci27	;
7558c2ecf20Sopenharmony_ci28	'
7568c2ecf20Sopenharmony_ci29	\`
7578c2ecf20Sopenharmony_ci2A	(LEFT) SHIFT
7588c2ecf20Sopenharmony_ci2B	\\
7598c2ecf20Sopenharmony_ci2C	Z
7608c2ecf20Sopenharmony_ci2D	X
7618c2ecf20Sopenharmony_ci2E	C
7628c2ecf20Sopenharmony_ci2F	V
7638c2ecf20Sopenharmony_ci30	B
7648c2ecf20Sopenharmony_ci31	N
7658c2ecf20Sopenharmony_ci32	M
7668c2ecf20Sopenharmony_ci33	,
7678c2ecf20Sopenharmony_ci34	.
7688c2ecf20Sopenharmony_ci35	/
7698c2ecf20Sopenharmony_ci36	(RIGHT) SHIFT
7708c2ecf20Sopenharmony_ci37	{ NOT USED }
7718c2ecf20Sopenharmony_ci38	ALT
7728c2ecf20Sopenharmony_ci39	SPACE BAR
7738c2ecf20Sopenharmony_ci3A	CAPS LOCK
7748c2ecf20Sopenharmony_ci3B	F1
7758c2ecf20Sopenharmony_ci3C	F2
7768c2ecf20Sopenharmony_ci3D	F3
7778c2ecf20Sopenharmony_ci3E	F4
7788c2ecf20Sopenharmony_ci3F	F5
7798c2ecf20Sopenharmony_ci40	F6
7808c2ecf20Sopenharmony_ci41	F7
7818c2ecf20Sopenharmony_ci42	F8
7828c2ecf20Sopenharmony_ci43	F9
7838c2ecf20Sopenharmony_ci44	F10
7848c2ecf20Sopenharmony_ci45	{ NOT USED }
7858c2ecf20Sopenharmony_ci46	{ NOT USED }
7868c2ecf20Sopenharmony_ci47	HOME
7878c2ecf20Sopenharmony_ci48	UP ARROW
7888c2ecf20Sopenharmony_ci49	{ NOT USED }
7898c2ecf20Sopenharmony_ci4A	KEYPAD -
7908c2ecf20Sopenharmony_ci4B	LEFT ARROW
7918c2ecf20Sopenharmony_ci4C	{ NOT USED }
7928c2ecf20Sopenharmony_ci4D	RIGHT ARROW
7938c2ecf20Sopenharmony_ci4E	KEYPAD +
7948c2ecf20Sopenharmony_ci4F	{ NOT USED }
7958c2ecf20Sopenharmony_ci50	DOWN ARROW
7968c2ecf20Sopenharmony_ci51	{ NOT USED }
7978c2ecf20Sopenharmony_ci52	INSERT
7988c2ecf20Sopenharmony_ci53	DEL
7998c2ecf20Sopenharmony_ci54	{ NOT USED }
8008c2ecf20Sopenharmony_ci5F	{ NOT USED }
8018c2ecf20Sopenharmony_ci60	ISO KEY
8028c2ecf20Sopenharmony_ci61	UNDO
8038c2ecf20Sopenharmony_ci62	HELP
8048c2ecf20Sopenharmony_ci63	KEYPAD (
8058c2ecf20Sopenharmony_ci64	KEYPAD /
8068c2ecf20Sopenharmony_ci65	KEYPAD *
8078c2ecf20Sopenharmony_ci66	KEYPAD *
8088c2ecf20Sopenharmony_ci67	KEYPAD 7
8098c2ecf20Sopenharmony_ci68	KEYPAD 8
8108c2ecf20Sopenharmony_ci69	KEYPAD 9
8118c2ecf20Sopenharmony_ci6A	KEYPAD 4
8128c2ecf20Sopenharmony_ci6B	KEYPAD 5
8138c2ecf20Sopenharmony_ci6C	KEYPAD 6
8148c2ecf20Sopenharmony_ci6D	KEYPAD 1
8158c2ecf20Sopenharmony_ci6E	KEYPAD 2
8168c2ecf20Sopenharmony_ci6F	KEYPAD 3
8178c2ecf20Sopenharmony_ci70	KEYPAD 0
8188c2ecf20Sopenharmony_ci71	KEYPAD .
8198c2ecf20Sopenharmony_ci72	KEYPAD ENTER
8208c2ecf20Sopenharmony_ci======= ============
821