audio_controls.h 1.6 KB

1234567891011121314151617181920212223242526272829303132333435363738394041424344
  1. /*
  2. * (c) Philippe G. 2019, philippe_44@outlook.com
  3. *
  4. * This program is free software: you can redistribute it and/or modify
  5. * it under the terms of the GNU General Public License as published by
  6. * the Free Software Foundation, either version 3 of the License, or
  7. * (at your option) any later version.
  8. *
  9. * This program is distributed in the hope that it will be useful,
  10. * but WITHOUT ANY WARRANTY; without even the implied warranty of
  11. * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
  12. * GNU General Public License for more details.
  13. *
  14. * You should have received a copy of the GNU General Public License
  15. * along with this program. If not, see <http://www.gnu.org/licenses/>.
  16. *
  17. */
  18. #pragma once
  19. #include "buttons.h"
  20. // BEWARE: this is the index of the array of action below
  21. typedef enum { ACTRLS_NONE = -1, ACTRLS_VOLUP, ACTRLS_VOLDOWN, ACTRLS_TOGGLE, ACTRLS_PLAY,
  22. ACTRLS_PAUSE, ACTRLS_STOP, ACTRLS_REW, ACTRLS_FWD, ACTRLS_PREV, ACTRLS_NEXT,
  23. BCTRLS_PUSH, BCTRLS_UP, BCTRLS_DOWN, BCTRLS_LEFT, BCTRLS_RIGHT,
  24. ACTRLS_MAX
  25. } actrls_action_e;
  26. typedef void (*actrls_handler)(void);
  27. typedef actrls_handler actrls_t[ACTRLS_MAX - ACTRLS_NONE - 1];
  28. typedef struct {
  29. int gpio;
  30. int type;
  31. bool pull;
  32. int debounce;
  33. int long_press;
  34. int shifter_gpio;
  35. actrls_action_e normal[2], longpress[2], shifted[2], longshifted[2]; // [0] keypressed, [1] keyreleased
  36. } actrls_config_t;
  37. void actrls_init(int n, const actrls_config_t *config);
  38. void actrls_set_default(const actrls_t controls);
  39. void actrls_set(const actrls_t controls);
  40. void actrls_unset(void);