Move USB Host Shield and Arduino core to lib/
(#13973)
This commit is contained in:
@ -0,0 +1,110 @@
|
||||
/*
|
||||
Example sketch for the original Xbox library - developed by Kristian Lauszus
|
||||
For more information visit my blog: http://blog.tkjelectronics.dk/ or
|
||||
send me an e-mail: kristianl@tkjelectronics.com
|
||||
*/
|
||||
|
||||
#include <XBOXOLD.h>
|
||||
#include <usbhub.h>
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
USBHub Hub1(&Usb); // The controller has a built in hub, so this instance is needed
|
||||
XBOXOLD Xbox(&Usb);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
#if !defined(__MIPSEL__)
|
||||
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); // halt
|
||||
}
|
||||
Serial.print(F("\r\nXBOX Library Started"));
|
||||
}
|
||||
void loop() {
|
||||
Usb.Task();
|
||||
if (Xbox.XboxConnected) {
|
||||
if (Xbox.getButtonPress(BLACK) || Xbox.getButtonPress(WHITE)) {
|
||||
Serial.print("BLACK: ");
|
||||
Serial.print(Xbox.getButtonPress(BLACK));
|
||||
Serial.print("\tWHITE: ");
|
||||
Serial.println(Xbox.getButtonPress(WHITE));
|
||||
Xbox.setRumbleOn(Xbox.getButtonPress(BLACK), Xbox.getButtonPress(WHITE));
|
||||
} else
|
||||
Xbox.setRumbleOn(0, 0);
|
||||
|
||||
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
|
||||
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) {
|
||||
Serial.print(F("LeftHatX: "));
|
||||
Serial.print(Xbox.getAnalogHat(LeftHatX));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) {
|
||||
Serial.print(F("LeftHatY: "));
|
||||
Serial.print(Xbox.getAnalogHat(LeftHatY));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) {
|
||||
Serial.print(F("RightHatX: "));
|
||||
Serial.print(Xbox.getAnalogHat(RightHatX));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
|
||||
Serial.print(F("RightHatY: "));
|
||||
Serial.print(Xbox.getAnalogHat(RightHatY));
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
if (Xbox.getButtonClick(UP))
|
||||
Serial.println(F("Up"));
|
||||
if (Xbox.getButtonClick(DOWN))
|
||||
Serial.println(F("Down"));
|
||||
if (Xbox.getButtonClick(LEFT))
|
||||
Serial.println(F("Left"));
|
||||
if (Xbox.getButtonClick(RIGHT))
|
||||
Serial.println(F("Right"));
|
||||
|
||||
if (Xbox.getButtonClick(START))
|
||||
Serial.println(F("Start"));
|
||||
if (Xbox.getButtonClick(BACK))
|
||||
Serial.println(F("Back"));
|
||||
if (Xbox.getButtonClick(L3))
|
||||
Serial.println(F("L3"));
|
||||
if (Xbox.getButtonClick(R3))
|
||||
Serial.println(F("R3"));
|
||||
|
||||
if (Xbox.getButtonPress(A)) {
|
||||
Serial.print(F("A: "));
|
||||
Serial.println(Xbox.getButtonPress(A));
|
||||
}
|
||||
if (Xbox.getButtonPress(B)) {
|
||||
Serial.print(F("B: "));
|
||||
Serial.println(Xbox.getButtonPress(B));
|
||||
}
|
||||
if (Xbox.getButtonPress(X)) {
|
||||
Serial.print(F("X: "));
|
||||
Serial.println(Xbox.getButtonPress(X));
|
||||
}
|
||||
if (Xbox.getButtonPress(Y)) {
|
||||
Serial.print(F("Y: "));
|
||||
Serial.println(Xbox.getButtonPress(Y));
|
||||
}
|
||||
if (Xbox.getButtonPress(L1)) {
|
||||
Serial.print(F("L1: "));
|
||||
Serial.println(Xbox.getButtonPress(L1));
|
||||
}
|
||||
if (Xbox.getButtonPress(R1)) {
|
||||
Serial.print(F("R1: "));
|
||||
Serial.println(Xbox.getButtonPress(R1));
|
||||
}
|
||||
}
|
||||
delay(1);
|
||||
}
|
@ -0,0 +1,106 @@
|
||||
/*
|
||||
Example sketch for the Xbox ONE USB library - by guruthree, based on work by
|
||||
Kristian Lauszus.
|
||||
*/
|
||||
|
||||
#include <XBOXONE.h>
|
||||
// Satisfy IDE, which only needs to see the include statment in the ino.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
XBOXONE Xbox(&Usb);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
}
|
||||
Serial.print(F("\r\nXBOX USB Library Started"));
|
||||
}
|
||||
void loop() {
|
||||
Usb.Task();
|
||||
if (Xbox.XboxOneConnected) {
|
||||
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
|
||||
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) {
|
||||
Serial.print(F("LeftHatX: "));
|
||||
Serial.print(Xbox.getAnalogHat(LeftHatX));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) {
|
||||
Serial.print(F("LeftHatY: "));
|
||||
Serial.print(Xbox.getAnalogHat(LeftHatY));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) {
|
||||
Serial.print(F("RightHatX: "));
|
||||
Serial.print(Xbox.getAnalogHat(RightHatX));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
|
||||
Serial.print(F("RightHatY: "));
|
||||
Serial.print(Xbox.getAnalogHat(RightHatY));
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
if (Xbox.getButtonPress(L2) > 0 || Xbox.getButtonPress(R2) > 0) {
|
||||
if (Xbox.getButtonPress(L2) > 0) {
|
||||
Serial.print(F("L2: "));
|
||||
Serial.print(Xbox.getButtonPress(L2));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getButtonPress(R2) > 0) {
|
||||
Serial.print(F("R2: "));
|
||||
Serial.print(Xbox.getButtonPress(R2));
|
||||
Serial.print("\t");
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
if (Xbox.getButtonClick(UP))
|
||||
Serial.println(F("Up"));
|
||||
if (Xbox.getButtonClick(DOWN))
|
||||
Serial.println(F("Down"));
|
||||
if (Xbox.getButtonClick(LEFT))
|
||||
Serial.println(F("Left"));
|
||||
if (Xbox.getButtonClick(RIGHT))
|
||||
Serial.println(F("Right"));
|
||||
|
||||
if (Xbox.getButtonClick(START))
|
||||
Serial.println(F("Start"));
|
||||
if (Xbox.getButtonClick(BACK))
|
||||
Serial.println(F("Back"));
|
||||
if (Xbox.getButtonClick(XBOX))
|
||||
Serial.println(F("Xbox"));
|
||||
if (Xbox.getButtonClick(SYNC))
|
||||
Serial.println(F("Sync"));
|
||||
|
||||
if (Xbox.getButtonClick(L1))
|
||||
Serial.println(F("L1"));
|
||||
if (Xbox.getButtonClick(R1))
|
||||
Serial.println(F("R1"));
|
||||
if (Xbox.getButtonClick(L2))
|
||||
Serial.println(F("L2"));
|
||||
if (Xbox.getButtonClick(R2))
|
||||
Serial.println(F("R2"));
|
||||
if (Xbox.getButtonClick(L3))
|
||||
Serial.println(F("L3"));
|
||||
if (Xbox.getButtonClick(R3))
|
||||
Serial.println(F("R3"));
|
||||
|
||||
|
||||
if (Xbox.getButtonClick(A))
|
||||
Serial.println(F("A"));
|
||||
if (Xbox.getButtonClick(B))
|
||||
Serial.println(F("B"));
|
||||
if (Xbox.getButtonClick(X))
|
||||
Serial.println(F("X"));
|
||||
if (Xbox.getButtonClick(Y))
|
||||
Serial.println(F("Y"));
|
||||
}
|
||||
delay(1);
|
||||
}
|
@ -0,0 +1,122 @@
|
||||
/*
|
||||
Example sketch for the Xbox Wireless Reciver library - developed by Kristian Lauszus
|
||||
It supports up to four controllers wirelessly
|
||||
For more information see the blog post: http://blog.tkjelectronics.dk/2012/12/xbox-360-receiver-added-to-the-usb-host-library/ or
|
||||
send me an e-mail: kristianl@tkjelectronics.com
|
||||
*/
|
||||
|
||||
#include <XBOXRECV.h>
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
XBOXRECV Xbox(&Usb);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
#if !defined(__MIPSEL__)
|
||||
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
}
|
||||
Serial.print(F("\r\nXbox Wireless Receiver Library Started"));
|
||||
}
|
||||
void loop() {
|
||||
Usb.Task();
|
||||
if (Xbox.XboxReceiverConnected) {
|
||||
for (uint8_t i = 0; i < 4; i++) {
|
||||
if (Xbox.Xbox360Connected[i]) {
|
||||
if (Xbox.getButtonPress(L2, i) || Xbox.getButtonPress(R2, i)) {
|
||||
Serial.print("L2: ");
|
||||
Serial.print(Xbox.getButtonPress(L2, i));
|
||||
Serial.print("\tR2: ");
|
||||
Serial.println(Xbox.getButtonPress(R2, i));
|
||||
Xbox.setRumbleOn(Xbox.getButtonPress(L2, i), Xbox.getButtonPress(R2, i), i);
|
||||
}
|
||||
|
||||
if (Xbox.getAnalogHat(LeftHatX, i) > 7500 || Xbox.getAnalogHat(LeftHatX, i) < -7500 || Xbox.getAnalogHat(LeftHatY, i) > 7500 || Xbox.getAnalogHat(LeftHatY, i) < -7500 || Xbox.getAnalogHat(RightHatX, i) > 7500 || Xbox.getAnalogHat(RightHatX, i) < -7500 || Xbox.getAnalogHat(RightHatY, i) > 7500 || Xbox.getAnalogHat(RightHatY, i) < -7500) {
|
||||
if (Xbox.getAnalogHat(LeftHatX, i) > 7500 || Xbox.getAnalogHat(LeftHatX, i) < -7500) {
|
||||
Serial.print(F("LeftHatX: "));
|
||||
Serial.print(Xbox.getAnalogHat(LeftHatX, i));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(LeftHatY, i) > 7500 || Xbox.getAnalogHat(LeftHatY, i) < -7500) {
|
||||
Serial.print(F("LeftHatY: "));
|
||||
Serial.print(Xbox.getAnalogHat(LeftHatY, i));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(RightHatX, i) > 7500 || Xbox.getAnalogHat(RightHatX, i) < -7500) {
|
||||
Serial.print(F("RightHatX: "));
|
||||
Serial.print(Xbox.getAnalogHat(RightHatX, i));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(RightHatY, i) > 7500 || Xbox.getAnalogHat(RightHatY, i) < -7500) {
|
||||
Serial.print(F("RightHatY: "));
|
||||
Serial.print(Xbox.getAnalogHat(RightHatY, i));
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
if (Xbox.getButtonClick(UP, i)) {
|
||||
Xbox.setLedOn(LED1, i);
|
||||
Serial.println(F("Up"));
|
||||
}
|
||||
if (Xbox.getButtonClick(DOWN, i)) {
|
||||
Xbox.setLedOn(LED4, i);
|
||||
Serial.println(F("Down"));
|
||||
}
|
||||
if (Xbox.getButtonClick(LEFT, i)) {
|
||||
Xbox.setLedOn(LED3, i);
|
||||
Serial.println(F("Left"));
|
||||
}
|
||||
if (Xbox.getButtonClick(RIGHT, i)) {
|
||||
Xbox.setLedOn(LED2, i);
|
||||
Serial.println(F("Right"));
|
||||
}
|
||||
|
||||
if (Xbox.getButtonClick(START, i)) {
|
||||
Xbox.setLedMode(ALTERNATING, i);
|
||||
Serial.println(F("Start"));
|
||||
}
|
||||
if (Xbox.getButtonClick(BACK, i)) {
|
||||
Xbox.setLedBlink(ALL, i);
|
||||
Serial.println(F("Back"));
|
||||
}
|
||||
if (Xbox.getButtonClick(L3, i))
|
||||
Serial.println(F("L3"));
|
||||
if (Xbox.getButtonClick(R3, i))
|
||||
Serial.println(F("R3"));
|
||||
|
||||
if (Xbox.getButtonClick(L1, i))
|
||||
Serial.println(F("L1"));
|
||||
if (Xbox.getButtonClick(R1, i))
|
||||
Serial.println(F("R1"));
|
||||
if (Xbox.getButtonClick(XBOX, i)) {
|
||||
Xbox.setLedMode(ROTATING, i);
|
||||
Serial.print(F("Xbox (Battery: "));
|
||||
Serial.print(Xbox.getBatteryLevel(i)); // The battery level in the range 0-3
|
||||
Serial.println(F(")"));
|
||||
}
|
||||
if (Xbox.getButtonClick(SYNC, i)) {
|
||||
Serial.println(F("Sync"));
|
||||
Xbox.disconnect(i);
|
||||
}
|
||||
|
||||
if (Xbox.getButtonClick(A, i))
|
||||
Serial.println(F("A"));
|
||||
if (Xbox.getButtonClick(B, i))
|
||||
Serial.println(F("B"));
|
||||
if (Xbox.getButtonClick(X, i))
|
||||
Serial.println(F("X"));
|
||||
if (Xbox.getButtonClick(Y, i))
|
||||
Serial.println(F("Y"));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
@ -0,0 +1,113 @@
|
||||
/*
|
||||
Example sketch for the Xbox 360 USB library - developed by Kristian Lauszus
|
||||
For more information visit my blog: http://blog.tkjelectronics.dk/ or
|
||||
send me an e-mail: kristianl@tkjelectronics.com
|
||||
*/
|
||||
|
||||
#include <XBOXUSB.h>
|
||||
|
||||
// Satisfy the IDE, which needs to see the include statment in the ino too.
|
||||
#ifdef dobogusinclude
|
||||
#include <spi4teensy3.h>
|
||||
#include <SPI.h>
|
||||
#endif
|
||||
|
||||
USB Usb;
|
||||
XBOXUSB Xbox(&Usb);
|
||||
|
||||
void setup() {
|
||||
Serial.begin(115200);
|
||||
#if !defined(__MIPSEL__)
|
||||
while (!Serial); // Wait for serial port to connect - used on Leonardo, Teensy and other boards with built-in USB CDC serial connection
|
||||
#endif
|
||||
if (Usb.Init() == -1) {
|
||||
Serial.print(F("\r\nOSC did not start"));
|
||||
while (1); //halt
|
||||
}
|
||||
Serial.print(F("\r\nXBOX USB Library Started"));
|
||||
}
|
||||
void loop() {
|
||||
Usb.Task();
|
||||
if (Xbox.Xbox360Connected) {
|
||||
if (Xbox.getButtonPress(L2) || Xbox.getButtonPress(R2)) {
|
||||
Serial.print("L2: ");
|
||||
Serial.print(Xbox.getButtonPress(L2));
|
||||
Serial.print("\tR2: ");
|
||||
Serial.println(Xbox.getButtonPress(R2));
|
||||
Xbox.setRumbleOn(Xbox.getButtonPress(L2), Xbox.getButtonPress(R2));
|
||||
} else
|
||||
Xbox.setRumbleOn(0, 0);
|
||||
|
||||
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500 || Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500 || Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500 || Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
|
||||
if (Xbox.getAnalogHat(LeftHatX) > 7500 || Xbox.getAnalogHat(LeftHatX) < -7500) {
|
||||
Serial.print(F("LeftHatX: "));
|
||||
Serial.print(Xbox.getAnalogHat(LeftHatX));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(LeftHatY) > 7500 || Xbox.getAnalogHat(LeftHatY) < -7500) {
|
||||
Serial.print(F("LeftHatY: "));
|
||||
Serial.print(Xbox.getAnalogHat(LeftHatY));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(RightHatX) > 7500 || Xbox.getAnalogHat(RightHatX) < -7500) {
|
||||
Serial.print(F("RightHatX: "));
|
||||
Serial.print(Xbox.getAnalogHat(RightHatX));
|
||||
Serial.print("\t");
|
||||
}
|
||||
if (Xbox.getAnalogHat(RightHatY) > 7500 || Xbox.getAnalogHat(RightHatY) < -7500) {
|
||||
Serial.print(F("RightHatY: "));
|
||||
Serial.print(Xbox.getAnalogHat(RightHatY));
|
||||
}
|
||||
Serial.println();
|
||||
}
|
||||
|
||||
if (Xbox.getButtonClick(UP)) {
|
||||
Xbox.setLedOn(LED1);
|
||||
Serial.println(F("Up"));
|
||||
}
|
||||
if (Xbox.getButtonClick(DOWN)) {
|
||||
Xbox.setLedOn(LED4);
|
||||
Serial.println(F("Down"));
|
||||
}
|
||||
if (Xbox.getButtonClick(LEFT)) {
|
||||
Xbox.setLedOn(LED3);
|
||||
Serial.println(F("Left"));
|
||||
}
|
||||
if (Xbox.getButtonClick(RIGHT)) {
|
||||
Xbox.setLedOn(LED2);
|
||||
Serial.println(F("Right"));
|
||||
}
|
||||
|
||||
if (Xbox.getButtonClick(START)) {
|
||||
Xbox.setLedMode(ALTERNATING);
|
||||
Serial.println(F("Start"));
|
||||
}
|
||||
if (Xbox.getButtonClick(BACK)) {
|
||||
Xbox.setLedBlink(ALL);
|
||||
Serial.println(F("Back"));
|
||||
}
|
||||
if (Xbox.getButtonClick(L3))
|
||||
Serial.println(F("L3"));
|
||||
if (Xbox.getButtonClick(R3))
|
||||
Serial.println(F("R3"));
|
||||
|
||||
if (Xbox.getButtonClick(L1))
|
||||
Serial.println(F("L1"));
|
||||
if (Xbox.getButtonClick(R1))
|
||||
Serial.println(F("R1"));
|
||||
if (Xbox.getButtonClick(XBOX)) {
|
||||
Xbox.setLedMode(ROTATING);
|
||||
Serial.println(F("Xbox"));
|
||||
}
|
||||
|
||||
if (Xbox.getButtonClick(A))
|
||||
Serial.println(F("A"));
|
||||
if (Xbox.getButtonClick(B))
|
||||
Serial.println(F("B"));
|
||||
if (Xbox.getButtonClick(X))
|
||||
Serial.println(F("X"));
|
||||
if (Xbox.getButtonClick(Y))
|
||||
Serial.println(F("Y"));
|
||||
}
|
||||
delay(1);
|
||||
}
|
Reference in New Issue
Block a user