Added hotkey to disable global hotkeys
This commit is contained in:
parent
dae9fe8a10
commit
88524eea4c
18
README.md
18
README.md
@ -1,9 +1,11 @@
|
||||
*Quinn's Utterly Elegant Speedrun Timer*
|
||||
A speedrun timer for *nix terminals
|
||||
# Quinn's Utterly Elegant Speedrun Timer
|
||||
|
||||
**Features**
|
||||
Global hotkeys
|
||||
24-bit terminal color
|
||||
Human readable JSON splits file
|
||||
Splits.io format compliance
|
||||
60+ fps rendering
|
||||
A speedrun timer for \*nix terminals
|
||||
|
||||
## Features
|
||||
|
||||
- Global hotkeys
|
||||
- 24-bit terminal color
|
||||
- Human readable JSON splits file
|
||||
- Import splits from a Splits.io file
|
||||
- High fps rendering
|
||||
|
8
keys.c
8
keys.c
@ -1,5 +1,6 @@
|
||||
#include "keys.h"
|
||||
|
||||
bool hotkeys_enabled = true;
|
||||
char buf;
|
||||
int pipefd[2];
|
||||
struct keymap km;
|
||||
@ -22,6 +23,8 @@ void dispatch_proc(uiohook_event * const event) {
|
||||
buf = K_SPLIT;
|
||||
if (event->data.keyboard.keycode == km.CLOSE)
|
||||
buf = K_CLOSE;
|
||||
if (event->data.keyboard.keycode == km.HOTKS)
|
||||
buf = K_HOTKS;
|
||||
write(pipefd[1], &buf, 1);
|
||||
default:
|
||||
break;
|
||||
@ -30,7 +33,8 @@ void dispatch_proc(uiohook_event * const event) {
|
||||
|
||||
int handleInput()
|
||||
{
|
||||
if (read(pipefd[0], &buf, 1) == -1)
|
||||
ssize_t rd = read(pipefd[0], &buf, 1);
|
||||
if ((!hotkeys_enabled && buf != K_HOTKS) || rd == -1)
|
||||
return 0;
|
||||
if (buf == K_SPLIT)
|
||||
split();
|
||||
@ -40,6 +44,8 @@ int handleInput()
|
||||
stop();
|
||||
if (buf == K_PAUSE)
|
||||
tpause();
|
||||
if (buf == K_HOTKS)
|
||||
hotkeys_enabled = !hotkeys_enabled;
|
||||
if (buf == K_CLOSE)
|
||||
return 1;
|
||||
return 0;
|
||||
|
2
keys.h
2
keys.h
@ -10,6 +10,7 @@
|
||||
#define K_PAUSE 3
|
||||
#define K_SPLIT 4
|
||||
#define K_CLOSE 5
|
||||
#define K_HOTKS 6
|
||||
|
||||
struct keymap
|
||||
{
|
||||
@ -18,6 +19,7 @@ struct keymap
|
||||
uint16_t PAUSE;
|
||||
uint16_t SPLIT;
|
||||
uint16_t CLOSE;
|
||||
uint16_t HOTKS;
|
||||
};
|
||||
|
||||
extern char buf;
|
||||
|
Loading…
Reference in New Issue
Block a user