Remove joystick-specific examples

They now live in hybridgroup/cylon-joystick
This commit is contained in:
Andrew Stewart 2014-03-05 21:28:30 -08:00
parent 5527a79858
commit 267c9fc7f6
6 changed files with 0 additions and 240 deletions

View File

@ -1,21 +0,0 @@
Cylon = require '../..'
Cylon.robot
connection: { name: 'joystick', adaptor: 'joystick', controller: 'dualshock3' }
device: { name: 'controller', driver: 'dualshock3' }
work: (my) ->
["square", "circle", "x", "triangle"].forEach (button) ->
my.controller.on "#{button}:press", ->
console.log "Button #{button} pressed."
my.controller.on "#{button}:release", ->
console.log "Button #{button} released."
my.controller.on "left:move", (pos) ->
console.log "Left Stick:", pos
my.controller.on "right:move", (pos) ->
console.log "Right Stick:", pos
Cylon.start()

View File

@ -1,28 +0,0 @@
var Cylon = require('../..');
Cylon.robot({
connection: { name: 'joystick', adaptor: 'joystick', controller: 'dualshock3' },
device: { name: 'controller', driver: 'dualshock3' },
work: function(my) {
["square", "circle", "x", "triangle"].forEach(function(button) {
my.controller.on(button + ":press", function() {
console.log("Button " + button + " pressed.");
});
my.controller.on(button + ":release", function() {
console.log("Button " + button + " released.");
});
});
my.controller.on("left:move", function(pos) {
console.log("Left Stick:", pos);
});
my.controller.on("right:move", function(pos) {
console.log("Right Stick:", pos);
});
}
});
Cylon.start();

View File

@ -1,57 +0,0 @@
# Joystick - DualShock 3 Controller
For this Cylon example, we'll demonstrate how to get input from a DualShock
3 controller.
You can connect to the controller over Bluetooth, or plug it in via USB and
press the 'PS' button to connect it to your system.
Before we get started, make sure you've got `cylon-joystick` installed via NPM
so we can connect to the controller.
First, let's load up Cylon:
Cylon = require '../..'
With that done, we can start defining our new robot.
Cylon.robot
We'll be setting up a connection to our DualShock controller, and also setting
the controller up as a device the robot can talk to:
connection:
name: 'joystick'
adaptor: 'joystick'
controller: 'dualshock3'
device:
name: 'controller'
driver: 'dualshock3'
With our connection to the controller established, we'll tell it what to do:
work: (my) ->
Let's ask our robot to tell us when the face buttons on the controller (Square,
Circle, X, Triangle) are pressed and released:
["square", "circle", "x", "triangle"].forEach (button) ->
my.controller.on "#{button}:press", ->
console.log "Button #{button} pressed."
my.controller.on "#{button}:release", ->
console.log "Button #{button} released."
Next up, when someone moves the left and right analog sticks, lets' print their
current positions.
my.controller.on "left:move", (pos) ->
console.log "Left Stick:", pos
my.controller.on "right:move", (pos) ->
console.log "Right Stick:", pos
And with our work defined, we can tell Cylon to start up our Robot:
Cylon.start()

View File

@ -1,29 +0,0 @@
Cylon = require '../..'
Cylon.robot
connection: { name: 'joystick', adaptor: 'joystick', controller: 'xbox360' }
device: { name: 'controller', driver: 'xbox360' }
work: (my) ->
["a", "b", "x", "y"].forEach (button) ->
my.controller.on "#{button}:press", ->
console.log "Button #{button} pressed."
my.controller.on "#{button}:release", ->
console.log "Button #{button} released."
lastPosition =
left: { x: 0, y: 0 }
right: { x: 0, y: 0 }
my.controller.on "left:move", (pos) ->
last = lastPosition.left
unless pos.x is last.x and pos.y is last.y
console.log "Left Stick:", pos
my.controller.on "right:move", (pos) ->
last = lastPosition.right
unless pos.x is last.x and pos.y is last.y
console.log "Right Stick:", pos
Cylon.start()

View File

@ -1,39 +0,0 @@
var Cylon = require('../..');
Cylon.robot({
connection: { name: 'joystick', adaptor: 'joystick', controller: 'xbox360' },
device: { name: 'controller', driver: 'xbox360' },
work: function(my) {
["a", "b", "x", "y"].forEach(function(button) {
my.controller.on(button + ":press", function() {
console.log("Button " + button + " pressed.");
});
my.controller.on(button + ":release", function() {
console.log("Button " + button + " released.");
});
});
var lastPosition = {
left: { x: 0, y: 0 },
right: { x: 0, y: 0 }
};
my.controller.on("left:move", function(pos) {
var last = lastPosition.left;
if (!(pos.x === last.x && pos.y === last.y)) {
console.log("Left Stick:", pos);
}
});
my.controller.on("right:move", function(pos) {
var last = lastPosition.right;
if (!(pos.x === last.x && pos.y === last.y)) {
console.log("Right Stick:", pos);
}
});
}
});
Cylon.start();

View File

@ -1,66 +0,0 @@
# Joystick - Xbox 360 Controller
For this Cylon example, we'll demonstrate how to get input from a wired Xbox 360
controller.
Before we get started, make sure you've got `cylon-joystick` installed via NPM
so we can connect to the controller.
First, let's load up Cylon:
Cylon = require '../..'
With that done, we can start defining our new robot.
Cylon.robot
We'll be setting up a connection to our 360 controller, and also setting the
controller up as a device the robot can talk to:
connection:
name: 'joystick'
adaptor: 'joystick'
controller: 'xbox360'
device:
name: 'controller'
driver: 'xbox360'
With our connection to the controller established, we'll tell it what to do:
work: (my) ->
Let's ask our robot to tell us when the face buttons on the controller (A, B, X,
Y) are pressed and released:
["a", "b", "x", "y"].forEach (button) ->
my.controller.on "#{button}:press", ->
console.log "Button #{button} pressed."
my.controller.on "#{button}:release", ->
console.log "Button #{button} released."
Next up, when someone moves the left and right analog sticks, lets' print their
current positions.
Since the Xbox 360 controller's adaptor emits the `left:move`
and `right:move` events even when the sticks aren't moved, we'll prevent it from
emitting duplicate events, too:
lastPosition =
left: { x: 0, y: 0 }
right: { x: 0, y: 0 }
my.controller.on "left:move", (pos) ->
last = lastPosition.left
unless pos.x is last.x and pos.y is last.y
console.log "Left Stick:", pos
my.controller.on "right:move", (pos) ->
last = lastPosition.right
unless pos.x is last.x and pos.y is last.y
console.log "Right Stick:", pos
And with our work defined, we can tell Cylon to start up our Robot:
Cylon.start()