Skip to content

Adds Button Hold Delay on SINGLE Button Routine#24

Open
cgmckeever wants to merge 2 commits intoworkinghard:masterfrom
cgmckeever:delay
Open

Adds Button Hold Delay on SINGLE Button Routine#24
cgmckeever wants to merge 2 commits intoworkinghard:masterfrom
cgmckeever:delay

Conversation

@cgmckeever
Copy link
Contributor

This PR also has the device flag fix #22

What this PR does:

  • add config option delay which ONLY is currently coded to work with a single button push
  • Tracks the time of first push and compares how long it is pressed before trigger file call int rc = system(myKeys[triggerSection].swFilename);

Housekeeping:

  • renamed several variables to be more intuitive (at least for me)

Checked that:

  • Releasing button resets the delay watch loop
  • Using same button in a multi-button combo resets delay watch loop

Did not check:

  • --mode hold works

Struggled with:

True equaling 0
https://github.com/workinghard/jslisten/blob/master/src/jslisten.c#L51

#define true 0
#define false 1

fixing the device flag

fixing the device flag

fixing the device flag

fixing the device flag

fixing the device flag

fix listening

fix listening

fix listening

fix listening

fix listening

fix listening

fix listening

x

x

git commit -q -m x
Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press

Adds delay to button press
//---------------------------------
#define sizearray(a) (sizeof(a) / sizeof((a)[0]))
#define BUTTON_DEFINED_RANGE -2147483647 // sizeof(long)
#define BUTTON_UNSET -1
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This seems clearer for its use case in the conf getter

unsigned long button3Active;
long button4;
int button4Active;
int activeButtons;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed as hotKeyCount

long delay;
long button1;
int button1Active;
unsigned long button1Active;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

store timestamp at press

l = ini_getl(section, str, 0, iniFile);
syslog(LOG_INFO, "Delay: %ld\n", l);
myKeys[hotKeyCombos].delay = l * 1000000;
}
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

delay getter - defaults to 0

//---------------------------------------------
// Reset the keys
//---------------------------------------------
void resetHotkeys() {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

moved up front as I called it before definitiion

syslog (LOG_NOTICE, "Found Device: %s\n", devPath);
if ((joyFD = open(devPath, O_RDONLY)) < 0) { // Open the file descriptor
syslog (LOG_INFO, "error: failed to open fd\n");
if (joyFD < 0 || strcmp(devPath, myDevPath) == 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

code from device flag PR

// Non-blocking reading
struct js_event js;
int needTrigger;
int triggerSection;
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

renamed to call out this is referencing the macro to call ... which now as I write this section renamed as macro globally may be nice --


while (1) {
while (read(joyFD, &js, sizeof(struct js_event)) == sizeof(struct js_event)) {
while (read(joyFD, &js, sizeof(struct js_event)) == sizeof(struct js_event) || delayedSection >= 0) {
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

if delayedSection is true button checker loop continues till either

  • delay button is released
  • macro/section event triggers

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant