2019-09-15 16:29:11 +00:00
|
|
|
/*
|
|
|
|
* This file is part of espanso.
|
|
|
|
*
|
|
|
|
* Copyright (C) 2019 Federico Terzi
|
|
|
|
*
|
|
|
|
* espanso is free software: you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation, either version 3 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* espanso is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with espanso. If not, see <https://www.gnu.org/licenses/>.
|
|
|
|
*/
|
|
|
|
|
2019-08-30 12:33:40 +00:00
|
|
|
#ifndef ESPANSO_BRIDGE_H
|
|
|
|
#define ESPANSO_BRIDGE_H
|
|
|
|
|
|
|
|
#include <stdio.h>
|
2019-08-30 16:32:10 +00:00
|
|
|
#include <stdint.h>
|
|
|
|
|
2019-09-16 08:56:14 +00:00
|
|
|
// SYSTEM
|
|
|
|
|
|
|
|
extern "C" int32_t start_daemon_process();
|
|
|
|
|
2019-09-12 20:14:41 +00:00
|
|
|
extern void * manager_instance;
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Initialize the Windows parameters
|
|
|
|
* return: 1 if OK, -1 otherwise.
|
|
|
|
*/
|
2020-04-15 15:24:40 +00:00
|
|
|
extern "C" int32_t initialize(void * self, wchar_t * ico_path, wchar_t * bmp_path, int32_t show_icon);
|
2019-09-12 20:14:41 +00:00
|
|
|
|
2020-03-10 16:22:50 +00:00
|
|
|
#define LEFT_VARIANT 1
|
|
|
|
#define RIGHT_VARIANT 2
|
|
|
|
|
2019-08-30 16:32:10 +00:00
|
|
|
/*
|
|
|
|
* Called when a new keypress is made, the first argument is an int array,
|
|
|
|
* while the second is the size of the array.
|
|
|
|
*/
|
2020-03-10 18:00:28 +00:00
|
|
|
typedef void (*KeypressCallback)(void * self, uint16_t *buffer, int32_t len, int32_t event_type, int32_t key_code, int32_t variant, int32_t is_key_down);
|
2019-09-05 17:36:53 +00:00
|
|
|
extern KeypressCallback keypress_callback;
|
2019-08-30 16:32:10 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Register the callback that will be called when a keypress was made
|
|
|
|
*/
|
2019-09-12 20:14:41 +00:00
|
|
|
extern "C" void register_keypress_callback(KeypressCallback callback);
|
2019-08-30 15:58:18 +00:00
|
|
|
|
|
|
|
/*
|
|
|
|
* Start the event loop indefinitely. Blocking call.
|
|
|
|
*/
|
|
|
|
extern "C" void eventloop();
|
2019-08-30 12:33:40 +00:00
|
|
|
|
2019-09-12 20:14:41 +00:00
|
|
|
// Keyboard Manager
|
|
|
|
|
2019-08-30 19:24:03 +00:00
|
|
|
/*
|
|
|
|
* Type the given string by simulating Key Presses
|
|
|
|
*/
|
|
|
|
extern "C" void send_string(const wchar_t * string);
|
|
|
|
|
2019-09-06 08:21:33 +00:00
|
|
|
/*
|
|
|
|
* Send the given Virtual Key press
|
|
|
|
*/
|
|
|
|
extern "C" void send_vkey(int32_t vk);
|
|
|
|
|
2019-10-22 21:03:58 +00:00
|
|
|
/*
|
|
|
|
* Send the given Virtual Key press multiple times
|
|
|
|
*/
|
|
|
|
extern "C" void send_multi_vkey(int32_t vk, int32_t count);
|
|
|
|
|
2020-05-05 18:17:45 +00:00
|
|
|
/*
|
|
|
|
* Send the given Virtual Key press multiple times adding a delay between each keypress
|
|
|
|
*/
|
|
|
|
extern "C" void send_multi_vkey_with_delay(int32_t vk, int32_t count, int32_t delay);
|
|
|
|
|
2019-08-31 14:07:45 +00:00
|
|
|
/*
|
|
|
|
* Send the backspace keypress, *count* times.
|
|
|
|
*/
|
2020-05-05 18:17:45 +00:00
|
|
|
extern "C" void delete_string(int32_t count, int32_t delay);
|
2019-08-31 14:07:45 +00:00
|
|
|
|
2019-09-16 09:35:05 +00:00
|
|
|
/*
|
|
|
|
* Send the Paste keyboard shortcut (CTRL+V)
|
|
|
|
*/
|
|
|
|
extern "C" void trigger_paste();
|
|
|
|
|
2020-01-20 23:22:22 +00:00
|
|
|
/*
|
|
|
|
* Send the copy keyboard shortcut (CTRL+C)
|
|
|
|
*/
|
|
|
|
extern "C" void trigger_copy();
|
|
|
|
|
2019-09-12 20:14:41 +00:00
|
|
|
// Detect current application commands
|
|
|
|
|
2019-09-07 20:23:04 +00:00
|
|
|
/*
|
|
|
|
* Return the active windows's title
|
|
|
|
*/
|
|
|
|
extern "C" int32_t get_active_window_name(wchar_t * buffer, int32_t size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the active windows's executable path
|
|
|
|
*/
|
|
|
|
extern "C" int32_t get_active_window_executable(wchar_t * buffer, int32_t size);
|
|
|
|
|
2019-09-07 22:51:08 +00:00
|
|
|
// UI
|
|
|
|
|
2019-09-12 21:24:55 +00:00
|
|
|
/*
|
|
|
|
* Called when the tray icon is clicked
|
|
|
|
*/
|
|
|
|
typedef void (*IconClickCallback)(void * self);
|
|
|
|
extern IconClickCallback icon_click_callback;
|
|
|
|
extern "C" void register_icon_click_callback(IconClickCallback callback);
|
|
|
|
|
2019-09-11 13:51:45 +00:00
|
|
|
// CONTEXT MENU
|
|
|
|
|
|
|
|
typedef struct {
|
|
|
|
int32_t id;
|
|
|
|
int32_t type;
|
|
|
|
wchar_t name[100];
|
|
|
|
} MenuItem;
|
|
|
|
|
2019-09-12 21:24:55 +00:00
|
|
|
extern "C" int32_t show_context_menu(MenuItem * items, int32_t count);
|
|
|
|
|
2019-09-11 13:51:45 +00:00
|
|
|
/*
|
2019-09-12 21:24:55 +00:00
|
|
|
* Called when the context menu is clicked
|
2019-09-11 13:51:45 +00:00
|
|
|
*/
|
2019-09-12 21:24:55 +00:00
|
|
|
typedef void (*ContextMenuClickCallback)(void * self, int32_t id);
|
|
|
|
extern ContextMenuClickCallback context_menu_click_callback;
|
|
|
|
extern "C" void register_context_menu_click_callback(ContextMenuClickCallback callback);
|
2019-09-11 13:51:45 +00:00
|
|
|
|
2019-09-16 09:59:23 +00:00
|
|
|
/*
|
|
|
|
* Hide the tray icon
|
|
|
|
*/
|
|
|
|
extern "C" void cleanup_ui();
|
|
|
|
|
2019-09-11 13:51:45 +00:00
|
|
|
// NOTIFICATION
|
2019-09-08 11:37:58 +00:00
|
|
|
|
2019-09-08 10:31:36 +00:00
|
|
|
/*
|
|
|
|
* Show a window containing the notification.
|
|
|
|
*/
|
2019-09-08 11:37:58 +00:00
|
|
|
extern "C" int32_t show_notification(wchar_t * message);
|
2019-09-07 22:51:08 +00:00
|
|
|
|
2019-09-08 10:31:36 +00:00
|
|
|
/*
|
|
|
|
* Close the notification if present
|
|
|
|
*/
|
|
|
|
extern "C" void close_notification();
|
|
|
|
|
2019-09-16 09:35:05 +00:00
|
|
|
// CLIPBOARD
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Return the clipboard text
|
|
|
|
*/
|
|
|
|
extern "C" int32_t get_clipboard(wchar_t * buffer, int32_t size);
|
|
|
|
|
|
|
|
/*
|
|
|
|
* Set the clipboard text
|
|
|
|
*/
|
|
|
|
extern "C" int32_t set_clipboard(wchar_t * text);
|
2019-09-08 10:31:36 +00:00
|
|
|
|
2019-11-28 23:01:26 +00:00
|
|
|
/*
|
|
|
|
* Set the clipboard image to the given path
|
|
|
|
*/
|
|
|
|
extern "C" int32_t set_clipboard_image(wchar_t * path);
|
|
|
|
|
2019-09-01 16:49:08 +00:00
|
|
|
#endif //ESPANSO_BRIDGE_H
|