资源简介
下载解压放在arduino安装目录下的library
代码片段和文件信息
#include “PS2X_lib.h“
#include
#include
#include
#include
#if ARDUINO > 22
#include “Arduino.h“
#else
#include “WProgram.h“
#include “pins_arduino.h“
#endif
static byte enter_config[]={0x010x430x000x010x00};
static byte set_mode[]={0x010x440x000x010x030x000x000x000x00};
static byte set_bytes_large[]={0x010x4F0x000xFF0xFF0x030x000x000x00};
static byte exit_config[]={0x010x430x000x000x5A0x5A0x5A0x5A0x5A};
static byte enable_rumble[]={0x010x4D0x000x000x01};
static byte type_read[]={0x010x450x000x5A0x5A0x5A0x5A0x5A0x5A};
/****************************************************************************************/
boolean PS2X::NewButtonState() {
return ((last_buttons ^ buttons) > 0);
}
/****************************************************************************************/
boolean PS2X::NewButtonState(unsigned int button) {
return (((last_buttons ^ buttons) & button) > 0);
}
/****************************************************************************************/
boolean PS2X::ButtonPressed(unsigned int button) {
return(NewButtonState(button) & Button(button));
}
/****************************************************************************************/
boolean PS2X::ButtonReleased(unsigned int button) {
return((NewButtonState(button)) & ((~last_buttons & button) > 0));
}
/****************************************************************************************/
boolean PS2X::Button(uint16_t button) {
return ((~buttons & button) > 0);
}
/****************************************************************************************/
unsigned int PS2X::ButtonDataByte() {
return (~buttons);
}
/****************************************************************************************/
byte PS2X::Analog(byte button) {
return PS2data[button];
}
/****************************************************************************************/
unsigned char PS2X::_gamepad_shiftinout (char byte) {
unsigned char tmp = 0;
for(unsigned char i=0;i<8;i++) {
if(CHK(bytei)) CMD_SET();
else CMD_CLR();
CLK_CLR();
delayMicroseconds(CTRL_CLK);
//if(DAT_CHK()) SET(tmpi);
if(DAT_CHK()) bitSet(tmpi);
CLK_SET();
#if CTRL_CLK_HIGH
delayMicroseconds(CTRL_CLK_HIGH);
#endif
}
CMD_SET();
delayMicroseconds(CTRL_BYTE_DELAY);
return tmp;
}
/****************************************************************************************/
void PS2X::read_gamepad() {
read_gamepad(false 0x00);
}
/****************************************************************************************/
boolean PS2X::read_gamepad(boolean motor1 byte motor2) {
double temp = millis() - last_read;
if (temp > 1500) //waited to long
reconfig_gamepad();
if(temp < read_delay) //waited too short
delay(read_delay - temp);
if(motor2 != 0x00)
motor2 = map(motor202550x400xFF); //noting below 40 will make it spin
属性 大小 日期 时间 名称
----------- --------- ---------- ----- ----
....... 4108 2013-07-08 01:18 PS2X_lib\examples\PS2XMouse\PS2XMouse.ino
文件 7257 2019-10-16 20:03 PS2X_lib\examples\PS2X_Example\PS2X_Example.ino
文件 18684 2019-10-16 21:39 PS2X_lib\examples\PS2X_Example\PS2X_Example.ino.standard.hex
文件 19688 2019-10-16 21:39 PS2X_lib\examples\PS2X_Example\PS2X_Example.ino.with_bootloader.standard.hex
....... 1604 2013-07-08 01:18 PS2X_lib\keywords.txt
....... 13161 2013-07-08 01:18 PS2X_lib\PS2X_lib.cpp
....... 7480 2013-07-08 01:18 PS2X_lib\PS2X_lib.h
目录 0 2013-07-08 01:18 PS2X_lib\examples\PS2XMouse
目录 0 2019-10-16 21:39 PS2X_lib\examples\PS2X_Example
目录 0 2013-07-08 01:18 PS2X_lib\examples
目录 0 2013-07-08 01:18 PS2X_lib
----------- --------- ---------- ----- ----
71982 11
评论
共有 条评论