Swadge 2024 2.0.0
APIs to develop games for the Magfest Swadge
Loading...
Searching...
No Matches
hdw-btn.h
Go to the documentation of this file.
1
88#ifndef _BTN_H_
89#define _BTN_H_
90
91#include <stdbool.h>
92#include <stdint.h>
93
94#include <driver/gpio.h>
95#include <driver/touch_pad.h>
96
100typedef enum __attribute__((packed))
101{
102 PB_UP = 0x0001,
103 PB_DOWN = 0x0002,
104 PB_LEFT = 0x0004,
105 PB_RIGHT = 0x0008,
106 PB_A = 0x0010,
107 PB_B = 0x0020,
108 PB_START = 0x0040,
109 PB_SELECT = 0x0080,
111
116typedef struct
117{
118 uint16_t state;
120 bool down;
122
123void initButtons(gpio_num_t* pushButtons, uint8_t numPushButtons, touch_pad_t* touchPads, uint8_t numTouchPads);
124void deinitButtons(void);
126
127int getTouchJoystick(int32_t* phi, int32_t* r, int32_t* intensity);
128
129#endif
int getTouchJoystick(int32_t *phi, int32_t *r, int32_t *intensity)
Get high-level touch input, an analog input. NOTE: You must have touch callbacks enabled to use this.
Definition hdw-btn.c:464
buttonBit_t button
The button that caused this event.
Definition hdw-btn.h:119
buttonBit_t
Bitmask values for all the different buttons.
Definition hdw-btn.h:101
@ PB_UP
The up button's bit.
Definition hdw-btn.h:102
@ PB_SELECT
The select button's bit.
Definition hdw-btn.h:109
@ PB_DOWN
The down button's bit.
Definition hdw-btn.h:103
@ PB_START
The start button's bit.
Definition hdw-btn.h:108
@ PB_B
The B button's bit.
Definition hdw-btn.h:107
@ PB_LEFT
The left button's bit.
Definition hdw-btn.h:104
@ PB_RIGHT
The right button's bit.
Definition hdw-btn.h:105
@ PB_A
The A button's bit.
Definition hdw-btn.h:106
bool checkButtonQueue(buttonEvt_t *)
Service the queue of button events that caused interrupts This only returns a single event,...
Definition hdw-btn.c:111
void deinitButtons(void)
Free memory used by the buttons.
Definition hdw-btn.c:87
bool down
True if the button was pressed, false if it was released.
Definition hdw-btn.h:120
uint16_t state
A bitmask for the state of all buttons.
Definition hdw-btn.h:118
void initButtons(gpio_num_t *pushButtons, uint8_t numPushButtons, touch_pad_t *touchPads, uint8_t numTouchPads)
Initialize both pushbuttons and touch buttons.
Definition hdw-btn.c:75
A button event containing the button that triggered the event, whether it was pressed or released,...
Definition hdw-btn.h:117