From patchwork Fri Aug 5 14:09:18 2011 Content-Type: text/plain; charset="utf-8" MIME-Version: 1.0 Content-Transfer-Encoding: 7bit X-Patchwork-Submitter: Antonio Ospite X-Patchwork-Id: 1038712 Received: from vger.kernel.org (vger.kernel.org [209.132.180.67]) by demeter2.kernel.org (8.14.4/8.14.4) with ESMTP id p75EFJH2007035 for ; Fri, 5 Aug 2011 14:15:19 GMT Received: (majordomo@vger.kernel.org) by vger.kernel.org via listexpand id S1756689Ab1HEOPR (ORCPT ); Fri, 5 Aug 2011 10:15:17 -0400 Received: from smtp207.alice.it ([82.57.200.103]:48962 "EHLO smtp207.alice.it" rhost-flags-OK-OK-OK-OK) by vger.kernel.org with ESMTP id S1753687Ab1HEOPR (ORCPT ); Fri, 5 Aug 2011 10:15:17 -0400 X-Greylist: IP, sender and recipient auto-whitelisted, not delayed by milter-greylist-4.2.6 (demeter2.kernel.org [140.211.167.43]); Fri, 05 Aug 2011 14:15:19 +0000 (UTC) X-Greylist: delayed 338 seconds by postgrey-1.27 at vger.kernel.org; Fri, 05 Aug 2011 10:15:16 EDT Received: from jcn (87.11.136.101) by smtp207.alice.it (8.5.124.08) id 4DFA189A04C934BA; Fri, 5 Aug 2011 16:09:54 +0200 Received: from ao2 by jcn with local (Exim 4.76) (envelope-from ) id 1QpL5z-0006qh-5t; Fri, 05 Aug 2011 16:09:51 +0200 From: Antonio Ospite To: linux-bluetooth@vger.kernel.org Cc: Antonio Ospite , Bastien Nocera , linux-input@vger.kernel.org, Jim Paris , Ranulf Doswell , "Pascal A . Brisset" , Marcin Tolysz , Christian Birchinger , Filipe Lopes , Alan Ott , Mikko Virkkila , Simon Wood , Arc Riley Subject: [PATCH BlueZ 4/4] plugins/sixaxis: Wait for the PS button before setting the LEDs Date: Fri, 5 Aug 2011 16:09:18 +0200 Message-Id: <1312553358-26280-5-git-send-email-ospite@studenti.unina.it> X-Mailer: git-send-email 1.7.5.4 In-Reply-To: <1312553358-26280-1-git-send-email-ospite@studenti.unina.it> References: <1312553358-26280-1-git-send-email-ospite@studenti.unina.it> X-Face: z*RaLf`X<@C75u6Ig9}{oW$H; 1_\2t5)({*|jhM/Vb; ]yA5\I~93>J<_`<4)A{':UrE Sender: linux-input-owner@vger.kernel.org Precedence: bulk List-ID: X-Mailing-List: linux-input@vger.kernel.org Wait for actual input events, that is PS button has been pressed, before setting the LEDs to indicate the controller number. This makes setting LEDs look more like on the PS3. --- plugins/sixaxis.c | 8 +++++++- 1 files changed, 7 insertions(+), 1 deletions(-) diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 2b0616a..d64ad6d 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -511,8 +511,14 @@ static void handle_device_plug(struct udev_device *udevice) sixpair(fd, adapter); } - if (js_num > 0) + if (js_num > 0) { + char c; + + /* wait for events before setting leds */ + if (read(fd, &c, 1) != 1) + perror("read error"); set_controller_number(fd, js_num); + } close(fd); }