oops many changes
This commit is contained in:
25 files changed
+1413
-1234
No files matched your search
@@ -0,0 +1,23 @@
|
||||
#ifndef KEYVIBE_CLI_H
|
||||
#define KEYVIBE_CLI_H
|
||||
|
||||
typedef struct {
|
||||
char *sound;
|
||||
char *mouse_sound;
|
||||
int volume;
|
||||
int keyboard_volume;
|
||||
int mouse_volume;
|
||||
int daemon_flag;
|
||||
int stop_flag;
|
||||
int list_flag;
|
||||
int verbose;
|
||||
int keyboard_mute; // -1 unchanged, 0 unmute, 1 mute
|
||||
int mouse_mute; // -1 unchanged, 0 unmute, 1 mute
|
||||
} CliOptions;
|
||||
|
||||
void print_usage(const char *program_name);
|
||||
int parse_cli(int argc, char **argv, CliOptions *out);
|
||||
|
||||
#endif // KEYVIBE_CLI_H
|
||||
|
||||
|
||||
@@ -0,0 +1,23 @@
|
||||
#ifndef KEYVIBE_PROCESS_H
|
||||
#define KEYVIBE_PROCESS_H
|
||||
|
||||
#include <signal.h>
|
||||
#include <sys/types.h>
|
||||
|
||||
extern pid_t keyboard_pid;
|
||||
extern pid_t sound_pid;
|
||||
extern char pidfile_path[];
|
||||
extern int is_daemon;
|
||||
extern volatile sig_atomic_t reload_requested;
|
||||
|
||||
void cleanup_processes(int sig);
|
||||
int require_running_pid(pid_t *out_pid);
|
||||
void daemonize_self(void);
|
||||
void stop_children(void);
|
||||
int start_children(const char *sound_dir, const char *config_path, int volume,
|
||||
int verbose, int mute, const char *mouse_sound_dir,
|
||||
const char *mouse_config_path, int mouse_volume,
|
||||
int keyboard_mute, int mouse_mute);
|
||||
void handle_sighup(int sig);
|
||||
|
||||
#endif // KEYVIBE_PROCESS_H
|
||||
@@ -0,0 +1,15 @@
|
||||
#ifndef KEYVIBE_RELOAD_H
|
||||
#define KEYVIBE_RELOAD_H
|
||||
|
||||
int handle_reload(const char *user_cfg_path,
|
||||
char *current_sound_name, char *current_mouse_sound_name,
|
||||
int *current_keyboard_volume, int *current_mouse_volume,
|
||||
char *current_config_path, char *current_sound_dir,
|
||||
char *current_mouse_config_path, char *current_mouse_sound_dir,
|
||||
int current_mute, int current_verbose,
|
||||
int current_mouse_volume_arg, int current_keyboard_mute,
|
||||
int current_mouse_mute);
|
||||
|
||||
#endif // KEYVIBE_RELOAD_H
|
||||
|
||||
|
||||
@@ -0,0 +1,6 @@
|
||||
#ifndef KEYVIBE_WATCH_H
|
||||
#define KEYVIBE_WATCH_H
|
||||
|
||||
int start_config_watcher(const char *path);
|
||||
|
||||
#endif // KEYVIBE_WATCH_H
|
||||
@@ -0,0 +1,10 @@
|
||||
#ifndef KEYVIBE_AUDIO_PLAYBACK_H
|
||||
#define KEYVIBE_AUDIO_PLAYBACK_H
|
||||
|
||||
int init_audio(void);
|
||||
int parse_keyboard_event(const char *json_line, int *key_code, int *is_pressed);
|
||||
void play_sound_segment(int key_code, int is_pressed);
|
||||
|
||||
#endif // KEYVIBE_AUDIO_PLAYBACK_H
|
||||
|
||||
|
||||
@@ -0,0 +1,43 @@
|
||||
#ifndef KEYVIBE_AUDIO_TYPES_H
|
||||
#define KEYVIBE_AUDIO_TYPES_H
|
||||
|
||||
#include <sndfile.h>
|
||||
|
||||
#define MAX_CONCURRENT_SOUNDS 10
|
||||
|
||||
typedef struct {
|
||||
int start_ms;
|
||||
int duration_ms;
|
||||
} SoundMapping;
|
||||
|
||||
typedef struct {
|
||||
char press_file[256];
|
||||
char release_file[256];
|
||||
char generic_press_files[5][256];
|
||||
int num_generic_press_files;
|
||||
char sound_file[256];
|
||||
SoundMapping key_mappings[512];
|
||||
struct {
|
||||
char *press;
|
||||
char *release;
|
||||
} multi_key_mappings[512];
|
||||
int is_multi;
|
||||
SF_INFO sf_info;
|
||||
} SoundPack;
|
||||
|
||||
typedef struct {
|
||||
int key_code;
|
||||
int thread_id;
|
||||
int is_pressed;
|
||||
} PlaybackData;
|
||||
|
||||
extern SoundPack g_sound_pack;
|
||||
extern SoundPack g_mouse_sound_pack;
|
||||
extern float g_volume;
|
||||
extern float g_mouse_volume;
|
||||
extern int g_verbose;
|
||||
extern int g_mute;
|
||||
extern int g_keyboard_mute;
|
||||
extern int g_mouse_mute;
|
||||
|
||||
#endif // KEYVIBE_AUDIO_TYPES_H
|
||||
@@ -7,5 +7,3 @@ void write_runtime_keyboard_mute_file(int mute);
|
||||
void write_runtime_mouse_mute_file(int mute);
|
||||
|
||||
#endif // KEYVIBE_MUTE_H
|
||||
|
||||
|
||||
@@ -7,7 +7,8 @@
|
||||
// Returns 1 on success, 0 on truncation/error
|
||||
int safe_snprintf(char *dst, size_t dst_sz, const char *fmt, ...);
|
||||
|
||||
// fprintf to stderr with printf-style formatting. Returns 1 for convenient `return errorf(...)` usage.
|
||||
// fprintf to stderr with printf-style formatting. Returns 1 for convenient
|
||||
// `return errorf(...)` usage.
|
||||
int errorf(const char *fmt, ...);
|
||||
|
||||
// Common runtime helpers
|
||||
@@ -24,4 +25,3 @@ void write_runtime_keyboard_mute_file(int mute);
|
||||
void write_runtime_mouse_mute_file(int mute);
|
||||
|
||||
#endif // KEYVIBE_UTILS_H
|
||||
|
||||
@@ -18,5 +18,3 @@
|
||||
#define KeyVibe_BIN_DIR PACKAGE_PREFIX "/bin"
|
||||
|
||||
#endif
|
||||
|
||||
|
||||
+10
-6
@@ -2,14 +2,18 @@
|
||||
#define KEYVIBE_SOUNDPACKS_H
|
||||
#include <stddef.h>
|
||||
|
||||
int resolve_keyboard_sound_base_dir(const char *sound_name, char *out_basedir, size_t out_sz);
|
||||
int resolve_mouse_sound_base_dir(const char *sound_name, char *out_basedir, size_t out_sz);
|
||||
int build_paths_for_keyboard_sound(const char *sound_name, char *out_config_path, size_t out_config_sz, char *out_sound_dir, size_t out_sound_sz);
|
||||
int build_paths_for_mouse_sound(const char *sound_name, char *out_config_path, size_t out_config_sz, char *out_sound_dir, size_t out_sound_sz);
|
||||
int resolve_keyboard_sound_base_dir(const char *sound_name, char *out_basedir,
|
||||
size_t out_sz);
|
||||
int resolve_mouse_sound_base_dir(const char *sound_name, char *out_basedir,
|
||||
size_t out_sz);
|
||||
int build_paths_for_keyboard_sound(const char *sound_name,
|
||||
char *out_config_path, size_t out_config_sz,
|
||||
char *out_sound_dir, size_t out_sound_sz);
|
||||
int build_paths_for_mouse_sound(const char *sound_name, char *out_config_path,
|
||||
size_t out_config_sz, char *out_sound_dir,
|
||||
size_t out_sound_sz);
|
||||
int validate_keyboard_sound_pack(const char *sound_name);
|
||||
int validate_mouse_sound_pack(const char *sound_name);
|
||||
int list_sound_packs(void);
|
||||
|
||||
#endif // KEYVIBE_SOUNDPACKS_H
|
||||
|
||||
|
||||
@@ -6,11 +6,13 @@
|
||||
char *get_user_config_path(char *buffer, size_t buflen);
|
||||
|
||||
// Write ~/.keyvibe.json in new format
|
||||
int write_user_config(const char *path, const char *keyboard_sound, const char *mouse_sound, int keyboard_volume, int mouse_volume);
|
||||
int write_user_config(const char *path, const char *keyboard_sound,
|
||||
const char *mouse_sound, int keyboard_volume,
|
||||
int mouse_volume);
|
||||
|
||||
// Read ~/.keyvibe.json supporting new and legacy formats
|
||||
int read_user_config(const char *path, char **out_keyboard_sound, char **out_mouse_sound, int *out_keyboard_volume, int *out_mouse_volume);
|
||||
int read_user_config(const char *path, char **out_keyboard_sound,
|
||||
char **out_mouse_sound, int *out_keyboard_volume,
|
||||
int *out_mouse_volume);
|
||||
|
||||
#endif // KEYVIBE_CONFIG_IO_H
|
||||
|
||||
|
||||
Reference in new issue
Block a user