From 9c4b604074df3a80ad4eb81c7d55904637f3b42d Mon Sep 17 00:00:00 2001 From: Gregory Nutt Date: Sat, 11 Jun 2016 07:22:31 -0600 Subject: [PATCH] Button upper half driver: Add definitions needed for compilation with the poll() interface is not disabled. --- drivers/input/Kconfig | 2 +- drivers/input/button_upper.c | 22 +++++++++++----------- include/nuttx/input/ajoystick.h | 2 ++ include/nuttx/input/buttons.h | 28 ++++++++++++++++++++++++++-- 4 files changed, 40 insertions(+), 14 deletions(-) diff --git a/drivers/input/Kconfig b/drivers/input/Kconfig index ebf00232ee..17cbe285f3 100644 --- a/drivers/input/Kconfig +++ b/drivers/input/Kconfig @@ -331,7 +331,7 @@ config BUTTONS if BUTTONS config BUTTONS_LOWER - bool "Generic Lower Half Button Dirver" + bool "Generic Lower Half Button Driver" default n depends on ARCH_BUTTONS && ARCH_IRQBUTTONS ---help--- diff --git a/drivers/input/button_upper.c b/drivers/input/button_upper.c index 5eadfd87e3..07c11307e0 100644 --- a/drivers/input/button_upper.c +++ b/drivers/input/button_upper.c @@ -1,7 +1,7 @@ /**************************************************************************** * drivers/input/button_upper.c * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -230,8 +230,8 @@ static void btn_enable(FAR struct btn_upperhalf_s *priv) { /* Yes.. OR in the poll event buttons */ - press |= opriv->bo_pollevents.ap_press; - release |= opriv->bo_pollevents.ap_release; + press |= opriv->bo_pollevents.bp_press; + release |= opriv->bo_pollevents.bp_release; break; } } @@ -322,8 +322,8 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv) * newly released. */ - change = sample ^ priv->bu_sample; - press = change & sample; + change = sample ^ priv->bu_sample; + press = change & sample; DEBUGASSERT(lower->bl_supported); release = change & (lower->bl_supported(lower) & ~sample); @@ -335,8 +335,8 @@ static void btn_sample(FAR struct btn_upperhalf_s *priv) #ifndef CONFIG_DISABLE_POLL /* Have any poll events occurred? */ - if ((press & opriv->bo_pollevents.ap_press) != 0 || - (release & opriv->bo_pollevents.ap_release) != 0) + if ((press & opriv->bo_pollevents.bp_press) != 0 || + (release & opriv->bo_pollevents.bp_release) != 0) { /* Yes.. Notify all waiters */ @@ -431,8 +431,8 @@ static int btn_open(FAR struct file *filep) DEBUGASSERT(lower && lower->bl_supported); supported = lower->bl_supported(lower); - opriv->bo_pollevents.ap_press = supported; - opriv->bo_pollevents.ap_release = supported; + opriv->bo_pollevents.bp_press = supported; + opriv->bo_pollevents.bp_release = supported; #endif /* Attach the open structure to the device */ @@ -664,8 +664,8 @@ static int btn_ioctl(FAR struct file *filep, int cmd, unsigned long arg) { /* Save the poll events */ - opriv->bo_pollevents.ap_press = pollevents->ap_press; - opriv->bo_pollevents.ap_release = pollevents->ap_release; + opriv->bo_pollevents.bp_press = pollevents->bp_press; + opriv->bo_pollevents.bp_release = pollevents->bp_release; /* Enable/disable interrupt handling */ diff --git a/include/nuttx/input/ajoystick.h b/include/nuttx/input/ajoystick.h index b672ed57ed..b50d98d56e 100644 --- a/include/nuttx/input/ajoystick.h +++ b/include/nuttx/input/ajoystick.h @@ -61,6 +61,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Configuration ************************************************************/ #ifndef CONFIG_AJOYSTICK_NPOLLWAITERS @@ -159,6 +160,7 @@ /**************************************************************************** * Public Types ****************************************************************************/ + /* This type is a bit set that contains the state of all analog joystick * buttons. */ diff --git a/include/nuttx/input/buttons.h b/include/nuttx/input/buttons.h index f31a197a1e..ee0785ef95 100644 --- a/include/nuttx/input/buttons.h +++ b/include/nuttx/input/buttons.h @@ -1,7 +1,7 @@ /************************************************************************************ * include/nuttx/input/buttons.h * - * Copyright (C) 2015 Gregory Nutt. All rights reserved. + * Copyright (C) 2015-2016 Gregory Nutt. All rights reserved. * Author: Gregory Nutt * * Redistribution and use in source and binary forms, with or without @@ -46,6 +46,7 @@ /**************************************************************************** * Pre-processor Definitions ****************************************************************************/ + /* Configuration ************************************************************/ #ifndef CONFIG_BUTTONS_NPOLLWAITERS @@ -64,6 +65,17 @@ #define BTNIOC_SUPPORTED _BTNIOC(0x0001) +/* Command: BTNIOC_POLLEVENTS + * Description: Specify the set of button events that can cause a poll() + * to awaken. The default is all button depressions and all + * button releases (all supported buttons); + * Argument: A read-only pointer to an instance of struct ajoy_pollevents_s + * Return: Zero (OK) on success. Minus one will be returned on failure + * with the errno value set appropriately. + */ + +#define BTNIOC_POLLEVENTS _BTNIOC(0x0002) + /* Command: BTNIOC_REGISTER * Description: Register to receive a signal whenever there is a change in * the state of button inputs. This feature, of course, depends @@ -73,11 +85,12 @@ * with the errno value set appropriately. */ -#define BTNIOC_REGISTER _BTNIOC(0x0002) +#define BTNIOC_REGISTER _BTNIOC(0x0003) /**************************************************************************** * Public Types ****************************************************************************/ + /* This type is a bit set that contains the state of all buttons as defined * in arch/board/board.h. This is the value that is returned when reading * from the button driver. @@ -85,6 +98,17 @@ typedef uint8_t btn_buttonset_t; +/* A reference to this structure is provided with the BTNIOC_POLLEVENTS IOCTL + * command and describes the conditions under which the client would like + * to receive notification. + */ + +struct btn_pollevents_s +{ + btn_buttonset_t bp_press; /* Set of button depressions to wake up the poll */ + btn_buttonset_t bp_release; /* Set of button releases to wake up the poll */ +}; + /* A reference to this structure is provided with the BTNIOC_REGISTER IOCTL * command and describes the conditions under which the client would like * to receive notification.