Skip to content

Commit

Permalink
Fix typo
Browse files Browse the repository at this point in the history
  • Loading branch information
quartercastle committed Jun 18, 2019
1 parent c948238 commit 34ae6b4
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 8 deletions.
7 changes: 3 additions & 4 deletions dualshock.go
Original file line number Diff line number Diff line change
Expand Up @@ -45,7 +45,7 @@ type State struct {
Share, Options, PSHome bool
Timestamp, BatteryLevel int
LeftDPad DPad
RigthDPad DPad
RightDPad DPad
Motion Motion
Orientation Orientation

Expand Down Expand Up @@ -101,7 +101,7 @@ func transform(b []byte) State {
X: int(b[1]),
Y: int(b[2]),
},
RigthDPad: DPad{
RightDPad: DPad{
X: int(b[3]),
Y: int(b[4]),
},
Expand Down Expand Up @@ -140,15 +140,14 @@ func New(reader io.Reader) *Controller {
// read transforms data from the io.Reader and pushes it to the queue of
// states
func (c *Controller) read() {
var b []byte
for {
select {
case <-c.interrupt:
close(c.errors)
close(c.queue)
return
default:
b = make([]byte, 64)
b := make([]byte, 64)
n, err := c.reader.Read(b)

if err != nil {
Expand Down
5 changes: 1 addition & 4 deletions dualshock_test.go
Original file line number Diff line number Diff line change
Expand Up @@ -18,12 +18,9 @@ func (f fakeDevice) Read(b []byte) (int, error) {

func TestDualshock(t *testing.T) {
controller := New(fakeDevice{})

result := make(chan State, 1)
defer close(result)

controller.Listen(func(state State) {
controller.Close()
go controller.Listen(func(state State) {
result <- state
})

Expand Down

0 comments on commit 34ae6b4

Please sign in to comment.