first commit

This commit is contained in:
2022-08-24 07:59:16 +02:00
commit adfe5792c4
259 changed files with 77719 additions and 0 deletions
+538
View File
@@ -0,0 +1,538 @@
/*
K3NG_PS2Keyboard.cpp - K3NG_PS2Keyboard library
Copyright (c) 2007 Free Software Foundation. All right reserved.
Written by Christian Weichel <info@32leaves.net>
- Modified 2011 Anthony Good anthony dot good at gmail dot com
- Amateur Radio Operator K3NG
- Modified for additional key codes to be returned and CTRL key combinations
** Mostly rewritten Paul Stoffregen <paul@pjrc.com> 2010, 2011
** Modified for use beginning with Arduino 13 by L. Abraham Smith, <n3bah@microcompdesign.com> *
** Modified for easy interrup pin assignement on method begin(datapin,irq_pin). Cuningan <cuninganreset@gmail.com> **
for more information you can read the original wiki in arduino.cc
at http://www.arduino.cc/playground/Main/PS2Keyboard
or http://www.pjrc.com/teensy/td_libs_PS2Keyboard.html
Version 2.1 (May 2011)
- timeout to recover from misaligned input
- compatibility with Arduino "new-extension" branch
- TODO: send function, proposed by Scott Penrose, scooterda at me dot com
Version 2.0 (June 2010)
- Buffering added, many scan codes can be captured without data loss
if your sketch is busy doing other work
- Shift keys supported, completely rewritten scan code to ascii
- Slow linear search replaced with fast indexed table lookups
- Support for Teensy, Arduino Mega, and Sanguino added
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
*/
// K3NG Version 2017.05.12.01
#if !defined(ARDUINO_SAM_DUE)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#endif
#if defined(ARDUINO) && ARDUINO >= 100
#include "Arduino.h" // for attachInterrupt, FALLING
#else
#include "WProgram.h"
#endif
#include "K3NG_PS2Keyboard.h"
#define BUFFER_SIZE 45
static volatile uint8_t buffer[BUFFER_SIZE];
static volatile uint8_t head, tail;
static uint8_t ps2Keyboard_DataPin;
static char ps2Keyboard_CharBuffer=0;
// The ISR for the external interrupt
void k3ng_ps2interrupt(void)
{
static uint8_t bitcount=0;
static uint8_t incoming=0;
static uint32_t prev_ms=0;
uint32_t now_ms;
uint8_t n, val;
val = digitalRead(ps2Keyboard_DataPin);
now_ms = millis();
if (now_ms - prev_ms > 250) {
bitcount = 0;
incoming = 0;
}
prev_ms = now_ms;
n = bitcount - 1;
if (n <= 7) {
incoming |= (val << n);
}
bitcount++;
if (bitcount == 11) {
uint8_t i = head + 1;
if (i >= BUFFER_SIZE) i = 0;
if (i != tail) {
buffer[i] = incoming;
head = i;
}
bitcount = 0;
incoming = 0;
}
}
static inline uint8_t get_scan_code(void)
{
uint8_t c, i;
i = tail;
if (i == head) return 0;
i++;
if (i >= BUFFER_SIZE) i = 0;
c = buffer[i];
tail = i;
return c;
}
// http://www.quadibloc.com/comp/scan.htm
// http://www.computer-engineering.org/ps2keyboard/scancodes2.html
#define BREAK 0x01
#define MODIFIER 0x02
#define SHIFT_L 0x04
#define SHIFT_R 0x08
#define CTRL 0x10
#define ALT 0x20
// These arrays provide a simple key map, to turn scan codes into ASCII
// output. If a non-US keyboard is used, these may need to be modified
// for the desired output.
//
#ifdef OPTION_PS2_KEYBOARD_US
const PROGMEM unsigned char scan2ascii_noshift[] = {
0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12,
0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, '`', 0,
0, PS2_LEFT_ALT /*Lalt*/, 0 /*Lshift*/, 0, 0 /*PS2_LEFT_CTRL*/ /*Lctrl*/, 'q', '1', 0,
0, 0, 'z', 's', 'a', 'w', '2', 0,
0, 'c', 'x', 'd', 'e', '4', '3', 0,
0, ' ', 'v', 'f', 't', 'r', '5', 0,
0, 'n', 'b', 'h', 'g', 'y', '6', 0,
0, 0, 'm', 'j', 'u', '7', '8', 0,
0, ',', 'k', 'i', 'o', '0', '9', 0,
0, '.', '/', 'l', ';', 'p', '-', 0,
0, 0, '\'', 0, '[', '=', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, ']', 0, '\\', 0, 0,
0, 0, 0, 0, 0, 0, PS2_BACKSPACE, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7 };
const PROGMEM unsigned char scan2ascii_shift[] = {
0, PS2_F9_SHIFT, 0, PS2_F5_SHIFT, PS2_F3_SHIFT, PS2_F1_SHIFT, PS2_F2_SHIFT, PS2_F12_SHIFT,
0, PS2_F10_SHIFT, PS2_F8_SHIFT, PS2_F6_SHIFT, PS2_F4_SHIFT, PS2_TAB_SHIFT, '~', 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'Q', '!', 0,
0, 0, 'Z', 'S', 'A', 'W', '@', 0,
0, 'C', 'X', 'D', 'E', '$', '#', 0,
0, ' ', 'V', 'F', 'T', 'R', '%', 0,
0, 'N', 'B', 'H', 'G', 'Y', '^', 0,
0, 0, 'M', 'J', 'U', '&', '*', 0,
0, '<', 'K', 'I', 'O', ')', '(', 0,
0, '>', '?', 'L', ':', 'P', '_', 0,
0, 0, '"', 0, '{', '+', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER_SHIFT /*Enter*/, '}', 0, '|', 0, 0,
0, 0, 0, 0, 0, 0, PS2_BACKSPACE_SHIFT, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_SHIFT, '+', '3', '-', '*', '9', PS2_SCROLL_SHIFT, 0,
0, 0, 0, PS2_F7_SHIFT };
const PROGMEM unsigned char scan2ascii_ctrl[] = {
0, PS2_F9_CTRL, 0, PS2_F5_CTRL, PS2_F3_CTRL, PS2_F1_CTRL, PS2_F2_CTRL, PS2_F12_CTRL,
0, PS2_F10_CTRL, PS2_F8_CTRL, PS2_F6_CTRL, PS2_F4_CTRL, PS2_TAB_SHIFT, '~', 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'Q', '!', 0,
0, 0, PS2_Z_CTRL, 'S', PS2_A_CTRL, PS2_W_CTRL, '@', 0,
0, PS2_C_CTRL /*'C'*/, 'X', PS2_D_CTRL, PS2_E_CTRL, '$', '#', 0,
0, ' ', 'V', 'F', PS2_T_CTRL, 'R', '%', 0,
0, PS2_N_CTRL, PS2_B_CTRL, PS2_H_CTRL, PS2_G_CTRL, 'Y', '^', 0,
0, 0, PS2_M_CTRL, 'J', PS2_U_CTRL, '&', '*', 0,
0, '<', 'K', PS2_I_CTRL, PS2_O_CTRL, ')', '(', 0,
0, '>', '?', 'L', ':', 'P', '_', 0,
0, 0, '"', 0, '{', '+', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER_SHIFT /*Enter*/, '}', 0, '|', 0, 0,
0, 0, 0, 0, 0, 0, PS2_BACKSPACE_SHIFT, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_SHIFT, '+', '3', '-', '*', '9', PS2_SCROLL_SHIFT, 0,
0, 0, 0, PS2_F7_SHIFT };
const PROGMEM unsigned char scan2ascii_alt[] = {
0, PS2_F9_ALT, 0, PS2_F5_ALT, PS2_F3_ALT, PS2_F1_ALT, PS2_F2_ALT, PS2_F12_ALT,
0, PS2_F10_ALT, PS2_F8_ALT, PS2_F6_ALT, PS2_F4_ALT, PS2_TAB_SHIFT, '~', 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'Q', '!', 0,
0, 0, PS2_Z_CTRL, 'S', PS2_A_CTRL, PS2_W_CTRL, '@', 0,
0, 'C', 'X', PS2_D_CTRL, PS2_E_CTRL, '$', '#', 0,
0, ' ', 'V', 'F', PS2_T_CTRL, 'R', '%', 0,
0, PS2_N_CTRL, PS2_B_CTRL, PS2_H_CTRL, PS2_G_CTRL, 'Y', '^', 0,
0, 0, PS2_M_CTRL, 'J', PS2_U_CTRL, '&', '*', 0,
0, '<', 'K', PS2_I_CTRL, PS2_O_CTRL, ')', '(', 0,
0, '>', '?', 'L', ':', 'P', '_', 0,
0, 0, '"', 0, '{', '+', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '}', 0, '|', 0, 0,
0, 0, 0, 0, 0, 0, PS2_BACKSPACE_SHIFT, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_ALT, '+', '3', '-', '*', '9', PS2_SCROLL_SHIFT, 0,
0, 0, 0, PS2_F7_ALT };
#endif //OPTION_PS2_KEYBOARD_US
//--------------------------------------------------
#ifdef OPTION_PS2_KEYBOARD_GERMAN
// without shift
const PROGMEM unsigned char scan2ascii_noshift[] =
{0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12,
0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, '^', 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'q', '1', 0,
0, 0, 'y', 's', 'a', 'w', '2', 0,
0, 'c', 'x', 'd', 'e', '4', '3', 0,
0, ' ', 'v', 'f', 't', 'r', '5', 0,
0, 'n', 'b', 'h', 'g', 'z', '6', 0,
0, 0, 'm', 'j', 'u', '7', '8', 0,
0, ',', 'k', 'i', 'o', '0', '9', 0,
0, '.', '-', 'l', PS2_o_DIAERESIS, 'p', PS2_SHARP_S, 0,
0, 0, PS2_a_DIAERESIS, 0, PS2_u_DIAERESIS, '\'', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '+', 0, '#', 0, 0,
0, '<', 0, 0, 0, 0, PS2_BACKSPACE, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7 };
// with shift
const PROGMEM unsigned char scan2ascii_shift[] =
{0, PS2_F9_SHIFT, 0, PS2_F5_SHIFT, PS2_F3_SHIFT, PS2_F1_SHIFT, PS2_F2_SHIFT, PS2_F12_SHIFT,
0, PS2_F10_SHIFT, PS2_F8_SHIFT, PS2_F6_SHIFT, PS2_F4_SHIFT, PS2_TAB_SHIFT, PS2_DEGREE_SIGN, 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'Q', '!', 0,
0, 0, 'Y', 'S', 'A', 'W', '"', 0,
0, 'C', 'X', 'D', 'E', '$', PS2_SECTION_SIGN, 0,
0, ' ', 'V', 'F', 'T', 'R', '%', 0,
0, 'N', 'B', 'H', 'G', 'Z', '&', 0,
0, 0, 'M', 'J', 'U', '/', '(', 0,
0, ';', 'K', 'I', 'O', '=', ')', 0,
0, ':', '_', 'L', PS2_O_DIAERESIS, 'P', '?', 0,
0, 0, PS2_A_DIAERESIS, 0, PS2_U_DIAERESIS, '`', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '*', 0, '\'', 0, 0,
0, '>', 0, 0, 0, 0, PS2_BACKSPACE, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_SHIFT, '+', '3', '-', '*', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7_SHIFT };
const PROGMEM unsigned char scan2ascii_ctrl[] = // this needs to be updated!!! (it is copy of US)
{0, PS2_F9_CTRL, 0, PS2_F5_CTRL, PS2_F3_CTRL, PS2_F1_CTRL, PS2_F2_CTRL, PS2_F12_CTRL,
0, PS2_F10_CTRL, PS2_F8_CTRL, PS2_F6_CTRL, PS2_F4_CTRL, PS2_TAB_SHIFT, '~', 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'Q', '!', 0,
0, 0, PS2_Z_CTRL, 'S', PS2_A_CTRL, PS2_W_CTRL, '@', 0,
0, PS2_C_CTRL /*'C'*/, 'X', PS2_D_CTRL, PS2_E_CTRL, '$', '#', 0,
0, ' ', 'V', 'F', PS2_T_CTRL, 'R', '%', 0,
0, PS2_N_CTRL, PS2_B_CTRL, PS2_H_CTRL, PS2_G_CTRL, 'Y', '^', 0,
0, 0, PS2_M_CTRL, 'J', PS2_U_CTRL, '&', '*', 0,
0, '<', 'K', PS2_I_CTRL, PS2_O_CTRL, ')', '(', 0,
0, '>', '?', 'L', ':', 'P', '_', 0,
0, 0, '"', 0, '{', '+', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER_SHIFT /*Enter*/, '}', 0, '|', 0, 0,
0, 0, 0, 0, 0, 0, PS2_BACKSPACE_SHIFT, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_CTRL, '+', '3', '-', '*', '9', PS2_SCROLL_SHIFT, 0,
0, 0, 0, PS2_F7_CTRL};
// with altgr
const PROGMEM unsigned char scan2ascii_alt[] =
{0, PS2_F9_ALT, 0, PS2_F5_ALT, PS2_F3_ALT, PS2_F1_ALT, PS2_F2_ALT, PS2_F12_ALT,
0, PS2_F10_ALT, PS2_F8_ALT, PS2_F6_ALT, PS2_F4_ALT, PS2_TAB, 0, 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, '@', 0, 0,
0, 0, 0, 0, 0, 0, PS2_SUPERSCRIPT_TWO, 0,
0, 0, 0, 0, PS2_CURRENCY_SIGN, 0, PS2_SUPERSCRIPT_THREE, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, 0, 0, 0, 0, 0, 0,
0, 0, PS2_MICRO_SIGN, 0, 0, '{', '[', 0,
0, 0, 0, 0, 0, '}', ']', 0,
0, 0, 0, 0, 0, 0, '\\', 0,
0, 0, 0, 0, 0, 0, 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '~', 0, '#', 0, 0,
0, '|', 0, 0, 0, 0, PS2_BACKSPACE, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_ALT, '+', '3', '-', '*', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7_ALT};
#endif //OPTION_PS2_KEYBOARD_GERMAN
//--------------------------------------------------
#ifdef OPTION_PS2_KEYBOARD_FRENCH
const PROGMEM unsigned char scan2ascii_noshift[] =
{0, PS2_F9, 0, PS2_F5, PS2_F3, PS2_F1, PS2_F2, PS2_F12,
0, PS2_F10, PS2_F8, PS2_F6, PS2_F4, PS2_TAB, PS2_SUPERSCRIPT_TWO, 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'a', '&', 0,
0, 0, 'w', 's', 'q', 'z', PS2_e_ACUTE, 0,
0, 'c', 'x', 'd', 'e', '\'', '"', 0,
0, ' ', 'v', 'f', 't', 'r', '(', 0,
0, 'n', 'b', 'h', 'g', 'y', '-', 0,
0, 0, ',', 'j', 'u', PS2_e_GRAVE, '_', 0,
0, ';', 'k', 'i', 'o', PS2_a_GRAVE, PS2_c_CEDILLA, 0,
0, ':', '!', 'l', 'm', 'p', ')', 0,
0, 0, PS2_u_GRAVE, 0, '^', '=', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '$', 0, '*', 0, 0,
0, '<', 0, 0, 0, 0, PS2_BACKSPACE, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11, '+', '3', '-', '*', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7 };
// with shift
const PROGMEM unsigned char scan2ascii_shift[] =
{0, PS2_F9_SHIFT, 0, PS2_F5_SHIFT, PS2_F3_SHIFT, PS2_F1_SHIFT, PS2_F2_SHIFT, PS2_F12_SHIFT,
0, PS2_F10_SHIFT, PS2_F8_SHIFT, PS2_F6_SHIFT, PS2_F4_SHIFT, PS2_TAB_SHIFT, 0, 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'A', '1', 0,
0, 0, 'W', 'S', 'Q', 'Z', '2', 0,
0, 'C', 'X', 'D', 'E', '4', '3', 0,
0, ' ', 'V', 'F', 'T', 'R', '5', 0,
0, 'N', 'B', 'H', 'G', 'Y', '6', 0,
0, 0, '?', 'J', 'U', '7', '8', 0,
0, '.', 'K', 'I', 'O', '0', '9', 0,
0, '/', PS2_SECTION_SIGN, 'L', 'M', 'P', PS2_DEGREE_SIGN, 0,
0, 0, '%', 0, PS2_DIAERESIS, '+', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, PS2_POUND_SIGN, 0, PS2_MICRO_SIGN, 0, 0,
0, '>', 0, 0, 0, 0, PS2_BACKSPACE, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_SHIFT, '+', '3', '-', '*', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7_SHIFT};
const PROGMEM unsigned char scan2ascii_ctrl[] = // this needs to be updated!!! (it is copy of US)
{0, PS2_F9_CTRL, 0, PS2_F5_CTRL, PS2_F3_CTRL, PS2_F1_CTRL, PS2_F2_CTRL, PS2_F12_CTRL,
0, PS2_F10_CTRL, PS2_F8_CTRL, PS2_F6_CTRL, PS2_F4_CTRL, PS2_TAB, '~', 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, 'Q', '!', 0,
0, 0, PS2_Z_CTRL, 'S', PS2_A_CTRL, PS2_W_CTRL, '@', 0,
0, PS2_C_CTRL /*'C'*/, 'X', PS2_D_CTRL, PS2_E_CTRL, '$', '#', 0,
0, ' ', 'V', 'F', PS2_T_CTRL, 'R', '%', 0,
0, PS2_N_CTRL, PS2_B_CTRL, PS2_H_CTRL, PS2_G_CTRL, 'Y', '^', 0,
0, 0, PS2_M_CTRL, 'J', PS2_U_CTRL, '&', '*', 0,
0, '<', 'K', PS2_I_CTRL, PS2_O_CTRL, ')', '(', 0,
0, '>', '?', 'L', ':', 'P', '_', 0,
0, 0, '"', 0, '{', '+', 0, 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER_SHIFT /*Enter*/, '}', 0, '|', 0, 0,
0, 0, 0, 0, 0, 0, PS2_BACKSPACE_SHIFT, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_CTRL, '+', '3', '-', '*', '9', PS2_SCROLL_SHIFT, 0,
0, 0, 0, PS2_F7_CTRL};
const PROGMEM unsigned char scan2ascii_alt[] =
// with altgr
{0, PS2_F9_ALT, 0, PS2_F5_ALT, PS2_F3_ALT, PS2_F1_ALT, PS2_F2_ALT, PS2_F12_ALT,
0, PS2_F10_ALT, PS2_F8_ALT, PS2_F6_ALT, PS2_F4_ALT, PS2_TAB, 0, 0,
0, 0 /*Lalt*/, 0 /*Lshift*/, 0, 0 /*Lctrl*/, '@', 0, 0,
0, 0, 0, 0, 0, 0, '~', 0,
0, 0, 0, 0, 0 /*PS2_EURO_SIGN*/, '{', '#', 0,
0, 0, 0, 0, 0, 0, '[', 0,
0, 0, 0, 0, 0, 0, '|', 0,
0, 0, 0, 0, 0, '`', '\\', 0,
0, 0, 0, 0, 0, '@', '^', 0,
0, 0, 0, 0, 0, 0, ']', 0,
0, 0, 0, 0, 0, 0, '}', 0,
0 /*CapsLock*/, 0 /*Rshift*/, PS2_ENTER /*Enter*/, '¤', 0, '#', 0, 0,
0, '|', 0, 0, 0, 0, PS2_BACKSPACE, 0,
0, '1', 0, '4', '7', 0, 0, 0,
'0', '.', '2', '5', '6', '8', PS2_ESC, 0 /*NumLock*/,
PS2_F11_ALT, '+', '3', '-', '*', '9', PS2_SCROLL, 0,
0, 0, 0, PS2_F7_ALT};
#endif //OPTION_PS2_KEYBOARD_FRENCH
//--------------------------------------------------
static char get_ascii_code(void)
{
static uint8_t state=0;
uint8_t s;
char c;
while (1) {
s = get_scan_code();
if (!s) return 0;
if (s == 0xF0) {
state |= BREAK;
} else if (s == 0xE0) {
state |= MODIFIER;
} else {
if (state & BREAK) {
if (s == 0x12) {
state &= ~SHIFT_L;
} else if (s == 0x59) {
state &= ~SHIFT_R;
//start K3NG modification
} else if (s == 0x14) {
state &= ~CTRL;
} else if (s == 0x11) {
state &= ~ALT;
}
// end K3NG modification
state &= ~(BREAK | MODIFIER);
continue;
}
if (s == 0x12) {
state |= SHIFT_L;
continue;
} else if (s == 0x59) {
state |= SHIFT_R;
continue;
} else if (s == 0x14) {
state |= CTRL;
continue;
} else if (s == 0x11) {
state |= ALT;
continue;
}
c = 0;
if (state & MODIFIER) {
switch (s) {
case 0x70: c = PS2_INSERT; break;
case 0x6C: c = PS2_HOME; break;
case 0x7D: c = PS2_PAGEUP; break;
case 0x71: c = PS2_DELETE; break;
case 0x69: c = PS2_END; break;
case 0x7A: c = PS2_PAGEDOWN; break;
case 0x75: c = PS2_UPARROW; break;
case 0x6B: c = PS2_LEFTARROW; break;
case 0x72: c = PS2_DOWNARROW; break;
case 0x74: c = PS2_RIGHTARROW; break;
case 0x4A: c = '/'; break;
case 0x5A: c = PS2_ENTER; break;
default: break;
}
} else if (state & (SHIFT_L | SHIFT_R)) {
if (s < sizeof(scan2ascii_shift))
c = pgm_read_byte(scan2ascii_shift + s);
//start K3NG modification
} else if ((state & CTRL)) {
if (s < sizeof(scan2ascii_ctrl))
c = pgm_read_byte(scan2ascii_ctrl + s);
} else if ((state & ALT)) {
if (s < sizeof(scan2ascii_alt))
c = pgm_read_byte(scan2ascii_alt + s);
//end K3NG modification
} else {
if (s < sizeof(scan2ascii_noshift))
c = pgm_read_byte(scan2ascii_noshift + s);
}
state &= ~(BREAK | MODIFIER);
if (c) return c;
}
}
}
bool K3NG_PS2Keyboard::available() {
if (ps2Keyboard_CharBuffer) return true;
ps2Keyboard_CharBuffer = get_ascii_code();
if (ps2Keyboard_CharBuffer) return true;
return false;
}
int K3NG_PS2Keyboard::read() {
char result;
result = ps2Keyboard_CharBuffer;
if (result) {
ps2Keyboard_CharBuffer = 0;
} else {
result = get_ascii_code();
}
if (!result) return -1;
return result;
}
K3NG_PS2Keyboard::K3NG_PS2Keyboard() {
// nothing to do here, begin() does it all
}
void K3NG_PS2Keyboard::begin(uint8_t dataPin, uint8_t irq_pin) {
uint8_t irq_num=0;
ps2Keyboard_DataPin = dataPin;
// initialize the pins
#ifdef INPUT_PULLUP
pinMode(irq_pin, INPUT_PULLUP);
pinMode(dataPin, INPUT_PULLUP);
#else
pinMode(irq_pin, INPUT);
digitalWrite(irq_pin, HIGH);
pinMode(dataPin, INPUT);
digitalWrite(dataPin, HIGH);
#endif
switch(irq_pin) {
#ifdef CORE_INT0_PIN
case CORE_INT0_PIN:
irq_num = 0;
break;
#endif
#ifdef CORE_INT1_PIN
case CORE_INT1_PIN:
irq_num = 1;
break;
#endif
#ifdef CORE_INT2_PIN
case CORE_INT2_PIN:
irq_num = 2;
break;
#endif
#ifdef CORE_INT3_PIN
case CORE_INT3_PIN:
irq_num = 3;
break;
#endif
#ifdef CORE_INT4_PIN
case CORE_INT4_PIN:
irq_num = 4;
break;
#endif
#ifdef CORE_INT5_PIN
case CORE_INT5_PIN:
irq_num = 5;
break;
#endif
#ifdef CORE_INT6_PIN
case CORE_INT6_PIN:
irq_num = 6;
break;
#endif
#ifdef CORE_INT7_PIN
case CORE_INT7_PIN:
irq_num = 7;
break;
#endif
default:
irq_num = 0;
break;
}
head = 0;
tail = 0;
attachInterrupt(irq_num, k3ng_ps2interrupt, FALLING);
}
+538
View File
@@ -0,0 +1,538 @@
/*
K3NG_PS2Keyboard.h - K3NG_PS2Keyboard library
Copyright (c) 2007 Free Software Foundation. All right reserved.
Originally written by Christian Weichel <info@32leaves.net>
- Forked from version 2.1 2015-01-28 by Anthony Good K3NG
- Modified by Anthony Good / anthony dot good at gmail dot com
- August 2011
- Amateur Radio Operator K3NG
- Modified for additional key codes to be returned and CTRL key combinations
- http://radioartisan.wordpress.com
** Mostly rewritten Paul Stoffregen <paul@pjrc.com>, June 2010
** Modified for use with Arduino 13 by L. Abraham Smith, <n3bah@microcompdesign.com> *
** Modified for easy interrup pin assignement on method begin(datapin,irq_pin). Cuningan <cuninganreset@gmail.com> **
This library is free software; you can redistribute it and/or
modify it under the terms of the GNU Lesser General Public
License as published by the Free Software Foundation; either
version 2.1 of the License, or (at your option) any later version.
This library 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
Lesser General Public License for more details.
You should have received a copy of the GNU Lesser General Public
License along with this library; if not, write to the Free Software
Foundation, Inc., 51 Franklin St, Fifth Floor, Boston, MA 02110-1301 USA
K3NG Updates
2015101401
Fixed issues with CTRL and ALT key combinations with German and French keyboards
*/
// K3NG Version 2017.05.12.01
#ifndef K3NG_PS2Keyboard_h
#define K3NG_PS2Keyboard_h
#define OPTION_PS2_KEYBOARD_US
// #define OPTION_PS2_KEYBOARD_GERMAN
// #define OPTION_PS2_KEYBOARD_FRENCH
#if !defined(ARDUINO_SAM_DUE)
#include <avr/io.h>
#include <avr/interrupt.h>
#include <avr/pgmspace.h>
#endif
// Every call to read() returns a single byte for each
// keystroke. These configure what byte will be returned
// for each "special" key. To ignore a key, use zero.
#define PS2_TAB 9
#define PS2_ENTER 13
#define PS2_BACKSPACE 127
#define PS2_ESC 27
#define PS2_INSERT 128
#define PS2_DELETE 127
#define PS2_HOME 129
#define PS2_END 156
#define PS2_PAGEUP 25
#define PS2_PAGEDOWN 26
#define PS2_UPARROW 11
#define PS2_LEFTARROW 8
#define PS2_DOWNARROW 10
#define PS2_RIGHTARROW 21
#define PS2_F1 130
#define PS2_F2 131
#define PS2_F3 132
#define PS2_F4 133
#define PS2_F5 134
#define PS2_F6 135
#define PS2_F7 136
#define PS2_F8 137
#define PS2_F9 138
#define PS2_F10 139
#define PS2_F11 140
#define PS2_F12 141
#define PS2_SCROLL 142
#define PS2_F1_SHIFT 143
#define PS2_F2_SHIFT 144
#define PS2_F3_SHIFT 145
#define PS2_F4_SHIFT 146
#define PS2_F5_SHIFT 147
#define PS2_F6_SHIFT 148
#define PS2_F7_SHIFT 149
#define PS2_F8_SHIFT 150
#define PS2_F9_SHIFT 151
#define PS2_F10_SHIFT 152
#define PS2_F11_SHIFT 153
#define PS2_F12_SHIFT 154
#define PS2_TAB_SHIFT 9
#define PS2_ENTER_SHIFT 13
#define PS2_BACKSPACE_SHIFT 157
#define PS2_LEFT_ALT 158
//#define PS2_LEFT_CTRL 159
#define PS2_SCROLL_SHIFT 160
#if defined(OPTION_PS2_KEYBOARD_US)
#define PS2_A_CTRL 162
#define PS2_B_CTRL 163
#define PS2_C_CTRL 164
#define PS2_D_CTRL 165
#define PS2_E_CTRL 166
#define PS2_F_CTRL 167
#define PS2_G_CTRL 168
#define PS2_H_CTRL 169
#define PS2_I_CTRL 170
#define PS2_J_CTRL 171
#define PS2_K_CTRL 172
#define PS2_L_CTRL 173
#define PS2_M_CTRL 174
#define PS2_N_CTRL 175
#define PS2_O_CTRL 176
#define PS2_P_CTRL 177
#define PS2_Q_CTRL 178
#define PS2_R_CTRL 179
#define PS2_S_CTRL 180
#define PS2_T_CTRL 181
#define PS2_U_CTRL 182
#define PS2_V_CTRL 183
#define PS2_W_CTRL 184
#define PS2_X_CTRL 185
#define PS2_Y_CTRL 186
#define PS2_Z_CTRL 187
#define PS2_F1_CTRL 188
#define PS2_F2_CTRL 189
#define PS2_F3_CTRL 190
#define PS2_F4_CTRL 191
#define PS2_F5_CTRL 192
#define PS2_F6_CTRL 193
#define PS2_F7_CTRL 194
#define PS2_F8_CTRL 195
#define PS2_F9_CTRL 196
#define PS2_F10_CTRL 197
#define PS2_F11_CTRL 198
#define PS2_F12_CTRL 199
#define PS2_F1_ALT 200
#define PS2_F2_ALT 201
#define PS2_F3_ALT 202
#define PS2_F4_ALT 203
#define PS2_F5_ALT 204
#define PS2_F6_ALT 205
#define PS2_F7_ALT 206
#define PS2_F8_ALT 207
#define PS2_F9_ALT 208
#define PS2_F10_ALT 209
#define PS2_F11_ALT 210
#define PS2_F12_ALT 211
#endif //OPTION_PS2_KEYBOARD_US
// ----------------- added K3NG
#if defined(OPTION_PS2_KEYBOARD_GERMAN)
#define PS2_A_CTRL 162
#define PS2_B_CTRL 163
#define PS2_C_CTRL 200 //164
#define PS2_D_CTRL 165
#define PS2_E_CTRL 166
#define PS2_F_CTRL 201 //167
#define PS2_G_CTRL 168
#define PS2_H_CTRL 169
#define PS2_I_CTRL 170
#define PS2_J_CTRL 171
#define PS2_K_CTRL 172
#define PS2_L_CTRL 173
#define PS2_M_CTRL 174
#define PS2_N_CTRL 175
#define PS2_O_CTRL 202 //176
#define PS2_P_CTRL 177
#define PS2_Q_CTRL 203 //178
#define PS2_R_CTRL 204 //179
#define PS2_S_CTRL 180
#define PS2_T_CTRL 205 //181
#define PS2_U_CTRL 182
#define PS2_V_CTRL 183
#define PS2_W_CTRL 184
#define PS2_X_CTRL 185
#define PS2_Y_CTRL 186
#define PS2_Z_CTRL 187
#define PS2_F1_CTRL 188
#define PS2_F2_CTRL 189
#define PS2_F3_CTRL 190
#define PS2_F4_CTRL 191
#define PS2_F5_CTRL 192
#define PS2_F6_CTRL 193
#define PS2_F7_CTRL 194
#define PS2_F8_CTRL 195
#define PS2_F9_CTRL 206 //196
#define PS2_F10_CTRL 197
#define PS2_F11_CTRL 198
#define PS2_F12_CTRL 199
#define PS2_F1_ALT 229
#define PS2_F2_ALT 230
#define PS2_F3_ALT 231
#define PS2_F4_ALT 232
#define PS2_F5_ALT 233
#define PS2_F6_ALT 234
#define PS2_F7_ALT 235
#define PS2_F8_ALT 236
#define PS2_F9_ALT 237
#define PS2_F10_ALT 238
#define PS2_F11_ALT 239
#define PS2_F12_ALT 240
//#define PS2_INVERTED_EXCLAMATION 161 // ¡
//#define PS2_CENT_SIGN 162 // ¢
//#define PS2_POUND_SIGN 163 // £
#define PS2_CURRENCY_SIGN 164 // ¤
//#define PS2_YEN_SIGN 165 // ¥
//#define PS2_BROKEN_BAR 166 // ¦
#define PS2_SECTION_SIGN 167 // §
//#define PS2_DIAERESIS 168 // ¨
//#define PS2_COPYRIGHT_SIGN 169 // ©
//#define PS2_FEMININE_ORDINAL 170 // ª
//#define PS2_LEFT_DOUBLE_ANGLE_QUOTE 171 // «
//#define PS2_NOT_SIGN 172 // ¬
//#define PS2_HYPHEN 173
//#define PS2_REGISTERED_SIGN 174 // ®
//#define PS2_MACRON 175 // ¯
#define PS2_DEGREE_SIGN 176 // °
//#define PS2_PLUS_MINUS_SIGN 177 // ±
#define PS2_SUPERSCRIPT_TWO 178 // ²
#define PS2_SUPERSCRIPT_THREE 179 // ³
//#define PS2_ACUTE_ACCENT 180 // ´
#define PS2_MICRO_SIGN 181 // µ
//#define PS2_PILCROW_SIGN 182 // ¶
//#define PS2_MIDDLE_DOT 183 // ·
//#define PS2_CEDILLA 184 // ¸
//#define PS2_SUPERSCRIPT_ONE 185 // ¹
//#define PS2_MASCULINE_ORDINAL 186 // º
//#define PS2_RIGHT_DOUBLE_ANGLE_QUOTE 187 // »
//#define PS2_FRACTION_ONE_QUARTER 188 // ¼
//#define PS2_FRACTION_ONE_HALF 189 // ½
//#define PS2_FRACTION_THREE_QUARTERS 190 // ¾
//#define PS2_INVERTED_QUESTION MARK 191 // ¿
//#define PS2_A_GRAVE 192 // À
//#define PS2_A_ACUTE 193 // Á
//#define PS2_A_CIRCUMFLEX 194 // Â
//#define PS2_A_TILDE 195 // Ã
#define PS2_A_DIAERESIS 196 // Ä
//#define PS2_A_RING_ABOVE 197 // Å
//#define PS2_AE 198 // Æ
//#define PS2_C_CEDILLA 199 // Ç
//#define PS2_E_GRAVE 200 // È
//#define PS2_E_ACUTE 201 // É
//#define PS2_E_CIRCUMFLEX 202 // Ê
//#define PS2_E_DIAERESIS 203 // Ë
//#define PS2_I_GRAVE 204 // Ì
//#define PS2_I_ACUTE 205 // Í
//#define PS2_I_CIRCUMFLEX 206 // Î
//#define PS2_I_DIAERESIS 207 // Ï
//#define PS2_ETH 208 // Ð
//#define PS2_N_TILDE 209 // Ñ
//#define PS2_O_GRAVE 210 // Ò
//#define PS2_O_ACUTE 211 // Ó
//#define PS2_O_CIRCUMFLEX 212 // Ô
//#define PS2_O_TILDE 213 // Õ
#define PS2_O_DIAERESIS 214 // Ö
//#define PS2_MULTIPLICATION 215 // ×
//#define PS2_O_STROKE 216 // Ø
//#define PS2_U_GRAVE 217 // Ù
//#define PS2_U_ACUTE 218 // Ú
//#define PS2_U_CIRCUMFLEX 219 // Û
#define PS2_U_DIAERESIS 220 // Ü
//#define PS2_Y_ACUTE 221 // Ý
//#define PS2_THORN 222 // Þ
#define PS2_SHARP_S 223 // ß
//#define PS2_a_GRAVE 224 // à
//#define PS2_a_ACUTE 225 // á
//#define PS2_a_CIRCUMFLEX 226 // â
//#define PS2_a_TILDE 227 // ã
#define PS2_a_DIAERESIS 228 // ä
//#define PS2_a_RING_ABOVE 229 // å
//#define PS2_ae 230 // æ
//#define PS2_c_CEDILLA 231 // ç
//#define PS2_e_GRAVE 232 // è
//#define PS2_e_ACUTE 233 // é
//#define PS2_e_CIRCUMFLEX 234 // ê
//#define PS2_e_DIAERESIS 235 // ë
//#define PS2_i_GRAVE 236 // ì
//#define PS2_i_ACUTE 237 // í
//#define PS2_i_CIRCUMFLEX 238 // î
//#define PS2_i_DIAERESIS 239 // ï
//#define PS2_eth 240 // ð
//#define PS2_n_TILDE 241 // ñ
//#define PS2_o_GRAVE 242 // ò
//#define PS2_o_ACUTE 243 // ó
//#define PS2_o_CIRCUMFLEX 244 // ô
//#define PS2_o_TILDE 245 // õ
#define PS2_o_DIAERESIS 246 // ö
//#define PS2_DIVISION 247 // ÷
//#define PS2_o_STROKE 248 // ø
//#define PS2_u_GRAVE 249 // ù
//#define PS2_u_ACUTE 250 // ú
//#define PS2_u_CIRCUMFLEX 251 // û
#define PS2_u_DIAERESIS 252 // ü
//#define PS2_y_ACUTE 253 // ý
//#define PS2_thorn 254 // þ
//#define PS2_y_DIAERESIS 255 // ÿ
#endif //defined(OPTION_PS2_KEYBOARD_GERMAN)
#if defined(OPTION_PS2_KEYBOARD_FRENCH)
#define PS2_A_CTRL 162
#define PS2_B_CTRL 200 //163
#define PS2_C_CTRL 164
#define PS2_D_CTRL 165
#define PS2_E_CTRL 166
#define PS2_F_CTRL 201 //167
#define PS2_G_CTRL 202 //168
#define PS2_H_CTRL 169
#define PS2_I_CTRL 170
#define PS2_J_CTRL 171
#define PS2_K_CTRL 172
#define PS2_L_CTRL 173
#define PS2_M_CTRL 174
#define PS2_N_CTRL 175
#define PS2_O_CTRL 203 //176
#define PS2_P_CTRL 177
#define PS2_Q_CTRL 204 //178
#define PS2_R_CTRL 179
#define PS2_S_CTRL 180
#define PS2_T_CTRL 205 //181
#define PS2_U_CTRL 182
#define PS2_V_CTRL 183
#define PS2_W_CTRL 184
#define PS2_X_CTRL 185
#define PS2_Y_CTRL 186
#define PS2_Z_CTRL 187
#define PS2_F1_CTRL 188
#define PS2_F2_CTRL 189
#define PS2_F3_CTRL 190
#define PS2_F4_CTRL 191
#define PS2_F5_CTRL 192
#define PS2_F6_CTRL 193
#define PS2_F7_CTRL 194
#define PS2_F8_CTRL 195
#define PS2_F9_CTRL 196
#define PS2_F10_CTRL 197
#define PS2_F11_CTRL 198
#define PS2_F12_CTRL 199
#define PS2_F1_ALT 233
#define PS2_F2_ALT 234
#define PS2_F3_ALT 235
#define PS2_F4_ALT 236
#define PS2_F5_ALT 237
#define PS2_F6_ALT 238
#define PS2_F7_ALT 239
#define PS2_F8_ALT 240
#define PS2_F9_ALT 241
#define PS2_F10_ALT 242
#define PS2_F11_ALT 243
#define PS2_F12_ALT 244
//#define PS2_INVERTED_EXCLAMATION 161 // ¡
//#define PS2_CENT_SIGN 162 // ¢
#define PS2_POUND_SIGN 163 // £
//#define PS2_CURRENCY_SIGN 164 // ¤
//#define PS2_YEN_SIGN 165 // ¥
//#define PS2_BROKEN_BAR 166 // ¦
#define PS2_SECTION_SIGN 167 // §
#define PS2_DIAERESIS 168 // ¨
//#define PS2_COPYRIGHT_SIGN 169 // ©
//#define PS2_FEMININE_ORDINAL 170 // ª
//#define PS2_LEFT_DOUBLE_ANGLE_QUOTE 171 // «
//#define PS2_NOT_SIGN 172 // ¬
//#define PS2_HYPHEN 173
//#define PS2_REGISTERED_SIGN 174 // ®
//#define PS2_MACRON 175 // ¯
#define PS2_DEGREE_SIGN 176 // °
//#define PS2_PLUS_MINUS_SIGN 177 // ±
#define PS2_SUPERSCRIPT_TWO 178 // ²
//#define PS2_SUPERSCRIPT_THREE 179 // ³
//#define PS2_ACUTE_ACCENT 180 // ´
#define PS2_MICRO_SIGN 181 // µ
//#define PS2_PILCROW_SIGN 182 // ¶
//#define PS2_MIDDLE_DOT 183 // ·
//#define PS2_CEDILLA 184 // ¸
//#define PS2_SUPERSCRIPT_ONE 185 // ¹
//#define PS2_MASCULINE_ORDINAL 186 // º
//#define PS2_RIGHT_DOUBLE_ANGLE_QUOTE 187 // »
//#define PS2_FRACTION_ONE_QUARTER 188 // ¼
//#define PS2_FRACTION_ONE_HALF 189 // ½
//#define PS2_FRACTION_THREE_QUARTERS 190 // ¾
//#define PS2_INVERTED_QUESTION MARK 191 // ¿
//#define PS2_A_GRAVE 192 // À
//#define PS2_A_ACUTE 193 // Á
//#define PS2_A_CIRCUMFLEX 194 // Â
//#define PS2_A_TILDE 195 // Ã
//#define PS2_A_DIAERESIS 196 // Ä
//#define PS2_A_RING_ABOVE 197 // Å
//#define PS2_AE 198 // Æ
//#define PS2_C_CEDILLA 199 // Ç
//#define PS2_E_GRAVE 200 // È
//#define PS2_E_ACUTE 201 // É
//#define PS2_E_CIRCUMFLEX 202 // Ê
//#define PS2_E_DIAERESIS 203 // Ë
//#define PS2_I_GRAVE 204 // Ì
//#define PS2_I_ACUTE 205 // Í
//#define PS2_I_CIRCUMFLEX 206 // Î
//#define PS2_I_DIAERESIS 207 // Ï
//#define PS2_ETH 208 // Ð
//#define PS2_N_TILDE 209 // Ñ
//#define PS2_O_GRAVE 210 // Ò
//#define PS2_O_ACUTE 211 // Ó
//#define PS2_O_CIRCUMFLEX 212 // Ô
//#define PS2_O_TILDE 213 // Õ
//#define PS2_O_DIAERESIS 214 // Ö
//#define PS2_MULTIPLICATION 215 // ×
//#define PS2_O_STROKE 216 // Ø
//#define PS2_U_GRAVE 217 // Ù
//#define PS2_U_ACUTE 218 // Ú
//#define PS2_U_CIRCUMFLEX 219 // Û
//#define PS2_U_DIAERESIS 220 // Ü
//#define PS2_Y_ACUTE 221 // Ý
//#define PS2_THORN 222 // Þ
//#define PS2_SHARP_S 223 // ß
#define PS2_a_GRAVE 224 // à
//#define PS2_a_ACUTE 225 // á
//#define PS2_a_CIRCUMFLEX 226 // â
//#define PS2_a_TILDE 227 // ã
//#define PS2_a_DIAERESIS 228 // ä
//#define PS2_a_RING_ABOVE 229 // å
//#define PS2_ae 230 // æ
#define PS2_c_CEDILLA 231 // ç
#define PS2_e_GRAVE 232 // è
#define PS2_e_ACUTE 233 // é
//#define PS2_e_CIRCUMFLEX 234 // ê
//#define PS2_e_DIAERESIS 235 // ë
//#define PS2_i_GRAVE 236 // ì
//#define PS2_i_ACUTE 237 // í
//#define PS2_i_CIRCUMFLEX 238 // î
//#define PS2_i_DIAERESIS 239 // ï
//#define PS2_eth 240 // ð
//#define PS2_n_TILDE 241 // ñ
//#define PS2_o_GRAVE 242 // ò
//#define PS2_o_ACUTE 243 // ó
//#define PS2_o_CIRCUMFLEX 244 // ô
//#define PS2_o_TILDE 245 // õ
//#define PS2_o_DIAERESIS 246 // ö
//#define PS2_DIVISION 247 // ÷
//#define PS2_o_STROKE 248 // ø
#define PS2_u_GRAVE 249 // ù
//#define PS2_u_ACUTE 250 // ú
//#define PS2_u_CIRCUMFLEX 251 // û
//#define PS2_u_DIAERESIS 252 // ü
//#define PS2_y_ACUTE 253 // ý
//#define PS2_thorn 254 // þ
//#define PS2_y_DIAERESIS 255 // ÿ
#endif //defined(OPTION_PS2_KEYBOARD_FRENCH)
// -------------
/* Previous versions of this library returned a mix of ascii characters
* and raw scan codes (if no ASCII character could be found). There was
* no way to determine if a byte was ascii or a raw scan code. With
* version 2.0, only ASCII is returned, plus the special bytes above.
* These raw scan codes are never returned by read() anymore.
*
* PS2 keyboard "make" codes to check for certain keys.
*/
//#define PS2_KC_BREAK 0xf0
//#define PS2_KC_ENTER 0x0d
//#define PS2_KC_ESC 0x76
//#define PS2_KC_KPLUS 0x79
//#define PS2_KC_KMINUS 0x7b
//#define PS2_KC_KMULTI 0x7c
//#define PS2_KC_NUM 0x77
//#define PS2_KC_BKSP 0x66
/**
* Purpose: Provides an easy access to PS2 keyboards
* Author: Christian Weichel
*/
class K3NG_PS2Keyboard {
public:
/**
* This constructor does basically nothing. Please call the begin(int,int)
* method before using any other method of this class.
*/
K3NG_PS2Keyboard();
/**
* Starts the keyboard "service" by registering the external interrupt.
* setting the pin modes correctly and driving those needed to high.
* The propably best place to call this method is in the setup routine.
*/
static void begin(uint8_t dataPin, uint8_t irq_pin);
/**
* Returns true if there is a char to be read, false if not.
*/
static bool available();
/**
* Returns the char last read from the keyboard.
* If there is no char availble, -1 is returned.
*/
static int read();
};
// interrupt pins for known boards
#ifndef CORE_INT0_PIN // if not already defined by core (eg, Teensy)
#if defined(__AVR_ATmega1280__) || defined(__AVR_ATmega2560__) // Arduino Mega
#define CORE_INT0_PIN 2
#define CORE_INT1_PIN 3
#define CORE_INT2_PIN 21
#define CORE_INT3_PIN 20
#define CORE_INT4_PIN 19
#define CORE_INT5_PIN 18
#elif defined(__AVR_ATmega644P__) || defined(__AVR_ATmega644__) // Sanguino
#define CORE_INT0_PIN 10
#define CORE_INT1_PIN 11
#define CORE_INT2_PIN 2
#else // Arduino Duemilanove, Diecimila, LilyPad, Mini, Fio, etc...
#define CORE_INT0_PIN 2
#define CORE_INT1_PIN 3
#endif
#endif
#endif
+10
View File
@@ -0,0 +1,10 @@
name=K3NG_PS2Keyboard
version=2016111701
author=Anthony Good, K3NG <anthony.good@gmail.com>
maintainer=Anthony Good, K3NG <anthony.good@gmail.com>
sentence=For use with the K3NG CW Keyer for PS2 keyboard support
paragraph=For use with the K3NG CW Keyer for PS2 keyboard support
category=Uncategorized
url=https://github.com/k3ng/k3ng_cw_keyer
architectures=avr
includes=K3NG_PS2Keyboard.h