Skip to content

Commit 34ae6b4

Browse files
committed
Fix typo
1 parent c948238 commit 34ae6b4

File tree

2 files changed

+4
-8
lines changed

2 files changed

+4
-8
lines changed

dualshock.go

Lines changed: 3 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -45,7 +45,7 @@ type State struct {
4545
Share, Options, PSHome bool
4646
Timestamp, BatteryLevel int
4747
LeftDPad DPad
48-
RigthDPad DPad
48+
RightDPad DPad
4949
Motion Motion
5050
Orientation Orientation
5151

@@ -101,7 +101,7 @@ func transform(b []byte) State {
101101
X: int(b[1]),
102102
Y: int(b[2]),
103103
},
104-
RigthDPad: DPad{
104+
RightDPad: DPad{
105105
X: int(b[3]),
106106
Y: int(b[4]),
107107
},
@@ -140,15 +140,14 @@ func New(reader io.Reader) *Controller {
140140
// read transforms data from the io.Reader and pushes it to the queue of
141141
// states
142142
func (c *Controller) read() {
143-
var b []byte
144143
for {
145144
select {
146145
case <-c.interrupt:
147146
close(c.errors)
148147
close(c.queue)
149148
return
150149
default:
151-
b = make([]byte, 64)
150+
b := make([]byte, 64)
152151
n, err := c.reader.Read(b)
153152

154153
if err != nil {

dualshock_test.go

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -18,12 +18,9 @@ func (f fakeDevice) Read(b []byte) (int, error) {
1818

1919
func TestDualshock(t *testing.T) {
2020
controller := New(fakeDevice{})
21-
2221
result := make(chan State, 1)
23-
defer close(result)
2422

25-
controller.Listen(func(state State) {
26-
controller.Close()
23+
go controller.Listen(func(state State) {
2724
result <- state
2825
})
2926

0 commit comments

Comments
 (0)