[摘要]defined(__AVR_ATmega644__) // Sanguino #defineCORE_INT0_PIN 10 #defineCORE_INT1_PIN 11 #defineCORE_...
defined(__AVR_ATmega644__) // Sanguino #defineCORE_INT0_PIN 10 #defineCORE_INT1_PIN 11 #defineCORE_INT2_PIN 2 #elifdefined(__AVR_ATmega32U4__) // Leonardo #define CORE_INT0_PIN 3 #define CORE_INT1_PIN 2 #define CORE_INT2_PIN 0 #define CORE_INT3_PIN 1 #else //ArduinoDuemilanove, Diecimila, LilyPad, Mini, Fio, etc… #defineCORE_INT0_PIN 2 #defineCORE_INT1_PIN 3 #endif #endif #endif /* * PS2Keyboard.cpp * Arduino PS2键盘支持库 * 修改自http://www.pjrc.com/teensy/arduino_libraries/PS2Keyboard.zip * 修改者:b41k3r * 基于GPLv2开源 */ #include"PS2Keyboard.h" #define BUFFER_SIZE 45 static volatile uint8_tbuffer[BUFFER_SIZE]; static volatile uint8_thead, tail; static uint8_t DataPin; static uint8_tCharBuffer=0; static uint8_tUTF8next=0; static const PS2Keymap_t*keymap=NULL; intCombinationKey=0; //增加了一个参数,用来判定按下的是否是功能键和组合键 voidps2interrupt(void) //读取键盘输入的函数,基本原理同前面的demo程序 { staticuint8_t bitcount=0; staticuint8_t incoming=0; staticuint32_t prev_ms=0; uint32_tnow_ms; uint8_t n,val; val =digitalRead(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
关键词:间谍游戏:用Arduino制作硬件键盘记录器