group::BUTTON_DEV

The Button driver interface defines a way to read the status of buttons in a system.

Buttons are binary on/off inputs. The button is a block device where each location represents different button. The status of all the buttons can be read in a single command.

Details

defineBUTTON_VERSION


defineBUTTON_IOC_IDENT_CHAR


defineI_BUTTON_GETVERSION


defineI_BUTTON_GETINFO


defineI_BUTTON_SETATTR


enum@4

  • BUTTON_NONE No Button
  • BUTTON_UP Up Button
  • BUTTON_DOWN Down Button
  • BUTTON_LEFT LeftButton
  • BUTTON_RIGHT Right Button
  • BUTTON_SELECT Select Button
  • BUTTON_BACK Back Button
  • BUTTON_EXIT Exit Button
  • BUTTON_USER0 User button 0
  • BUTTON_USER1 User button 1
  • BUTTON_USER2 User button 2
  • BUTTON_USER3 User button 3
  • BUTTON_USER4 User button 4
  • BUTTON_USER5 User button 5
  • BUTTON_USER6 User button 6
  • BUTTON_USER7 User button 7
  • BUTTON_USER8 User button 8
  • BUTTON_USER9 User button 9
  • BUTTON_USER10 User button 10
  • BUTTON_USER11 User button 11
  • BUTTON_USER12 User button 12
  • BUTTON_USER13 User button 13
  • BUTTON_USER14 User button 14
  • BUTTON_USER15 User button 15

enum@5

  • BUTTON_FLAG_IS_PRESSED Set if button was activated (set only once per button press)
  • BUTTON_FLAG_IS_RELEASED Set if the button was released (set only once per button press)
  • BUTTON_FLAG_IS_ACTUATED Set if the button was actuated (set only once per button press)
  • BUTTON_FLAG_IS_HELD Set if the button was held for more than the specified threshold (set only once per button press)
  • BUTTON_FLAG_IS_ACTIVE Set if the button is active when read
  • BUTTON_FLAG_IS_ACTIVE_HIGH Set if the button is active high
  • BUTTON_FLAG_SET_ID Sets the button ID (used in button_attr_t only)
  • BUTTON_FLAG_INITIALIZE Initialize the button driver (used in button_attr_t only)
  • BUTTON_FLAG_INIT
  • BUTTON_FLAG_DEINITIALIZE Deinitialize the driver (used in button_attr_t only)
  • BUTTON_FLAG_DEINIT
  • BUTTON_FLAG_SET_HELD_THRESHOLD Sets the threshold in microseconds to trigger a button held event
  • BUTTON_FLAG_SET_ACTUATED_THRESHOLD Sets the threshold in microseconds to trigger a button held event


date: “2019-06-27” layout: post title: struct::button_status_t katex: true

categories: struct

This data structure is used when reading the buttons.

button_status_t status;
int fd = open("/dev/button0", O_RDWR);
lseek(fd, 0, SEEK_SET);
while( read(fd, &status, sizeof(status)) == sizeof(status) ){
  printf("Button is active? %d\n", (status.o_flags & BUTTON_FLAG_IS_ACTIVE) != 0);
}

close(fd);

Methods

Details

public u32o_flags

Button Flags e.g., BUTTON_FLAG_IS_PRESSED


public u32active_duration_msec

Number of milliseconds the button has been active


public u16id

Button ID assigned using set attributes


public u16resd



date: “2019-06-27” layout: post title: struct::button_info_t katex: true

categories: struct

This structure contains the info for the button driver.

Methods

Details

public u32o_flags

Set if the flag is supported in this driver



date: “2019-06-27” layout: post title: struct::button_attr_t katex: true

categories: struct

This structure contains data used with I_BUTTON_SETATTR.

Methods

Details

public u32o_flags

Flags to apply to attributes setting e.g.BUTTON_FLAG_SET_ID


public u32threshold_msec

Used when setting the button held or actuated thresholds


public u16loc

The applicable location when setting the ID or a threshold (same as lseek())


public u16id

Sets the button ID when BUTTON_FLAG_SET_ID is set in o_flags


X

Thanks for Coming!

Subscribe to news and updates