{"action":"created","issue":{"url":"https://api.github.com/repos/hybridgroup/gobot/issues/266","repository_url":"https://api.github.com/repos/hybridgroup/gobot","labels_url":"https://api.github.com/repos/hybridgroup/gobot/issues/266/labels{/name}","comments_url":"https://api.github.com/repos/hybridgroup/gobot/issues/266/comments","events_url":"https://api.github.com/repos/hybridgroup/gobot/issues/266/events","html_url":"https://github.com/hybridgroup/gobot/issues/266","id":135258037,"number":266,"title":"Analog joystick lag","user":{"login":"kittuov","id":7465236,"avatar_url":"https://avatars.githubusercontent.com/u/7465236?v=3","gravatar_id":"","url":"https://api.github.com/users/kittuov","html_url":"https://github.com/kittuov","followers_url":"https://api.github.com/users/kittuov/followers","following_url":"https://api.github.com/users/kittuov/following{/other_user}","gists_url":"https://api.github.com/users/kittuov/gists{/gist_id}","starred_url":"https://api.github.com/users/kittuov/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/kittuov/subscriptions","organizations_url":"https://api.github.com/users/kittuov/orgs","repos_url":"https://api.github.com/users/kittuov/repos","events_url":"https://api.github.com/users/kittuov/events{/privacy}","received_events_url":"https://api.github.com/users/kittuov/received_events","type":"User","site_admin":false},"labels":[],"state":"closed","locked":false,"assignee":null,"milestone":null,"comments":1,"created_at":"2016-02-21T20:55:45Z","updated_at":"2016-02-22T02:50:55Z","closed_at":"2016-02-22T02:50:55Z","body":"### How to reproduce the issue:\r\nrun example provide and move the analog stick of device very fast (Basically producing events faster than poll interval) the last state is reflected after a lag. the lag is even prominent if two sticks are used at the same time. \r\n### Possible fix:\r\nin ```go func (j *JoystickDriver) Start() (errs []error) ``` the goroutine can be modified as \r\n>Note:  *this leads to yet another bug*\r\n```go\r\ngo func() {\r\n\t\tfor {\r\n\t\t\tevent := j.poll()\r\n\t\t\tfor {\r\n\t\t\t\tif tem:=j.poll();tem==nil{\r\n\t\t\t\t\tbreak\r\n\t\t\t\t}else {\r\n\t\t\t\t\tevent = tem\r\n\t\t\t\t}\r\n\t\t\t}\r\n\t\t\tif event != nil {\r\n\t\t\t\tif err = j.handleEvent(event); err != nil {\r\n           ...\r\n\r\nThe code above is actually gets the latest event and lets the gobot process that.\r\n### Bug in this code:\r\n* If two axis are moved at the same time, only one of the event is processed. \r\n* some button events also may not be processed.\r\n\r\n#### TODO: In case of stacked events, loop through all new events and, \r\n1. get latest of all axis events and processes them. \r\n2. get all of button events and process them.\r\n3. *No idea what a hat is*"},"comment":{"url":"https://api.github.com/repos/hybridgroup/gobot/issues/comments/186976995","html_url":"https://github.com/hybridgroup/gobot/issues/266#issuecomment-186976995","issue_url":"https://api.github.com/repos/hybridgroup/gobot/issues/266","id":186976995,"user":{"login":"deadprogram","id":5520,"avatar_url":"https://avatars.githubusercontent.com/u/5520?v=3","gravatar_id":"","url":"https://api.github.com/users/deadprogram","html_url":"https://github.com/deadprogram","followers_url":"https://api.github.com/users/deadprogram/followers","following_url":"https://api.github.com/users/deadprogram/following{/other_user}","gists_url":"https://api.github.com/users/deadprogram/gists{/gist_id}","starred_url":"https://api.github.com/users/deadprogram/starred{/owner}{/repo}","subscriptions_url":"https://api.github.com/users/deadprogram/subscriptions","organizations_url":"https://api.github.com/users/deadprogram/orgs","repos_url":"https://api.github.com/users/deadprogram/repos","events_url":"https://api.github.com/users/deadprogram/events{/privacy}","received_events_url":"https://api.github.com/users/deadprogram/received_events","type":"User","site_admin":false},"created_at":"2016-02-22T02:50:55Z","updated_at":"2016-02-22T02:50:55Z","body":"This was fixed by @kittuov https://github.com/hybridgroup/gobot/commit/e84326b129610719bbad88ab3d596411b3839e7e"}}