diff options
author | Antonio Ospite <ao2@ao2.it> | 2014-05-14 23:40:02 +0200 |
---|---|---|
committer | Szymon Janc <szymon.janc@tieto.com> | 2014-05-16 14:34:47 +0200 |
commit | f6e6850c1e09b5b4dddd360748075fe6bd190680 (patch) | |
tree | 3520c4bda0557970be0317691ea3f01155f2a4e6 /plugins | |
parent | a148b6bbf93056a186b539f4351d2cf125b57002 (diff) | |
download | bluez-f6e6850c1e09b5b4dddd360748075fe6bd190680.tar.gz |
plugins/sixaxis: Factor out a set_leds_hidraw() function
This is in preparation for a set_leds_sysfs() function.
Make set_leds_hidraw() return void, as its return value is never used
by the caller: the setup_leds() callback has to always return FALSE.
Diffstat (limited to 'plugins')
-rw-r--r-- | plugins/sixaxis.c | 31 |
1 files changed, 18 insertions, 13 deletions
diff --git a/plugins/sixaxis.c b/plugins/sixaxis.c index 8045448f1..3a2cadfec 100644 --- a/plugins/sixaxis.c +++ b/plugins/sixaxis.c @@ -125,8 +125,7 @@ static int set_master_bdaddr(int fd, const bdaddr_t *bdaddr) return ret; } -static gboolean setup_leds(GIOChannel *channel, GIOCondition cond, - gpointer user_data) +static void set_leds_hidraw(int fd, int number) { /* * the total time the led is active (0xff means forever) @@ -147,18 +146,11 @@ static gboolean setup_leds(GIOChannel *channel, GIOCondition cond, 0xff, 0x27, 0x10, 0x00, 0x32, /* LED_1 */ 0x00, 0x00, 0x00, 0x00, 0x00, }; - int number = GPOINTER_TO_INT(user_data); int ret; - int fd; - - if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) - return FALSE; - - DBG("number %d", number); /* TODO we could support up to 10 (1 + 2 + 3 + 4) */ if (number > 7) - return FALSE; + return; if (number > 4) { leds_report[10] |= 0x10; @@ -167,16 +159,29 @@ static gboolean setup_leds(GIOChannel *channel, GIOCondition cond, leds_report[10] |= 0x01 << number; - fd = g_io_channel_unix_get_fd(channel); - ret = write(fd, leds_report, sizeof(leds_report)); if (ret == sizeof(leds_report)) - return FALSE; + return; if (ret < 0) error("sixaxis: failed to set LEDS (%s)", strerror(errno)); else error("sixaxis: failed to set LEDS (%d bytes written)", ret); +} + +static gboolean setup_leds(GIOChannel *channel, GIOCondition cond, + gpointer user_data) +{ + int number = GPOINTER_TO_INT(user_data); + int fd; + + if (cond & (G_IO_HUP | G_IO_ERR | G_IO_NVAL)) + return FALSE; + + DBG("number %d", number); + + fd = g_io_channel_unix_get_fd(channel); + set_leds_hidraw(fd, number); return FALSE; } |