@@ -2,7 +2,7 @@ const { Board, ESC, Fn } = require("../lib/johnny-five.js");
2
2
const dualShock = require ( "dualshock-controller" ) ;
3
3
4
4
const board = new Board ( ) ;
5
- const controller = dualShock ( {
5
+ const gamepad = dualShock ( {
6
6
config : "dualShock3" ,
7
7
analogStickSmoothing : false
8
8
} ) ;
@@ -12,11 +12,11 @@ board.on("ready", () => {
12
12
let speed = 0 ;
13
13
let last = null ;
14
14
15
- controller . on ( "connected" , ( ) => {
16
- controller . isConnected = true ;
15
+ gamepad . on ( "connected" , ( ) => {
16
+ gamepad . isConnected = true ;
17
17
} ) ;
18
18
19
- controller . on ( "dpadUp:press" , ( ) => {
19
+ gamepad . on ( "dpadUp:press" , ( ) => {
20
20
if ( last !== "up" ) {
21
21
speed = 0 ;
22
22
} else {
@@ -26,7 +26,7 @@ board.on("ready", () => {
26
26
last = "up" ;
27
27
} ) ;
28
28
29
- controller . on ( "dpadDown:press" , ( ) => {
29
+ gamepad . on ( "dpadDown:press" , ( ) => {
30
30
if ( last !== "down" ) {
31
31
speed = 0 ;
32
32
} else {
@@ -36,13 +36,13 @@ board.on("ready", () => {
36
36
last = "down" ;
37
37
} ) ;
38
38
39
- controller . on ( "circle:press" , ( ) => {
39
+ gamepad . on ( "circle:press" , ( ) => {
40
40
last = null ;
41
41
speed = 0 ;
42
42
esc . brake ( ) ;
43
43
} ) ;
44
44
45
- controller . on ( "right:move" , position => {
45
+ gamepad . on ( "right:move" , position => {
46
46
const y = Fn . scale ( position . y , 255 , 0 , 0 , 180 ) | 0 ;
47
47
48
48
if ( y > 100 ) {
0 commit comments