aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
-rw-r--r--README.md2
-rw-r--r--TODO5
-rw-r--r--images/default.curbin0 -> 69120 bytes
-rw-r--r--meson.build2
-rw-r--r--project.conf2
-rw-r--r--src/Overlay.cpp25
-rw-r--r--tools/gsr-global-hotkeys/keyboard_event.c37
7 files changed, 56 insertions, 17 deletions
diff --git a/README.md b/README.md
index a28bcc3..dd9805d 100644
--- a/README.md
+++ b/README.md
@@ -39,7 +39,7 @@ This program has to grab all keyboards and create a virtual keyboard (`gsr-ui vi
This might cause issues for you if you use input remapping software. To workaround this you can go into settings and select "Only grab virtual devices"
# License
-This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`.
+This software is licensed under GPL3.0-only. Files under `fonts/` directory belong to the Noto Sans Google fonts project and they are licensed under `SIL Open Font License`. `images/default.cur` it part of the [Adwaita icon theme](https://gitlab.gnome.org/GNOME/adwaita-icon-theme/-/tree/master) which is licensed under `Creative Commons Attribution-Share Alike 3.0`.
# Demo
[![Click here to watch a demo video on youtube](https://img.youtube.com/vi/SOqXusCTXXA/0.jpg)](https://www.youtube.com/watch?v=SOqXusCTXXA)
diff --git a/TODO b/TODO
index 8b9cad0..221a9f9 100644
--- a/TODO
+++ b/TODO
@@ -107,4 +107,7 @@ When adding window capture only add it to recording and streaming and do the win
Show an error that prime run will be disabled when using desktop portal capture option. This can cause issues as the user may have selected a video codec option that isn't available on their iGPU but is available on the prime-run dGPU.
-Is it possible to configure hotkey and the new hotkey to get triggered immediately? \ No newline at end of file
+Is it possible to configure hotkey and the new hotkey to get triggered immediately?
+
+For keyboards that report supporting mice the keyboard grab will be delayed until any key has been pressed (and then released), see: https://github.com/dec05eba/gpu-screen-recorder-issues/issues/97
+ See if there is any way around this.
diff --git a/images/default.cur b/images/default.cur
new file mode 100644
index 0000000..c7da315
--- /dev/null
+++ b/images/default.cur
Binary files differ
diff --git a/meson.build b/meson.build
index 489763d..b0f70eb 100644
--- a/meson.build
+++ b/meson.build
@@ -1,4 +1,4 @@
-project('gsr-ui', ['c', 'cpp'], version : '1.1.3', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
+project('gsr-ui', ['c', 'cpp'], version : '1.1.4', default_options : ['warning_level=2', 'cpp_std=c++17'], subproject_dir : 'depends')
if get_option('buildtype') == 'debug'
add_project_arguments('-g3', language : ['c', 'cpp'])
diff --git a/project.conf b/project.conf
index bb5de50..e71a2fd 100644
--- a/project.conf
+++ b/project.conf
@@ -1,7 +1,7 @@
[package]
name = "gsr-ui"
type = "executable"
-version = "1.1.3"
+version = "1.1.4"
platforms = ["posix"]
[lang.cpp]
diff --git a/src/Overlay.cpp b/src/Overlay.cpp
index c8e8b8f..f542374 100644
--- a/src/Overlay.cpp
+++ b/src/Overlay.cpp
@@ -772,9 +772,32 @@ namespace gsr {
if(cursor_size <= 1)
cursor_size = 24;
- XcursorImage *cursor_image = XcursorShapeLoadImage(XC_left_ptr, cursor_theme, cursor_size);
+ XcursorImage *cursor_image = nullptr;
+ for(int cursor_size_test : {cursor_size, 24}) {
+ for(const char *cursor_theme_test : {cursor_theme, "default", "Adwaita"}) {
+ for(unsigned int shape : {XC_left_ptr, XC_arrow}) {
+ cursor_image = XcursorShapeLoadImage(shape, cursor_theme_test, cursor_size_test);
+ if(cursor_image)
+ goto done;
+ }
+ }
+ }
+
+ done:
+ if(!cursor_image) {
+ fprintf(stderr, "Error: failed to get cursor, loading bundled default cursor instead\n");
+ const std::string default_cursor_path = resources_path + "images/default.cur";
+ for(int cursor_size_test : {cursor_size, 24}) {
+ cursor_image = XcursorFilenameLoadImage(default_cursor_path.c_str(), cursor_size_test);
+ if(cursor_image)
+ break;
+ }
+ }
+
if(!cursor_image) {
fprintf(stderr, "Error: failed to get cursor\n");
+ XFixesShowCursor(xi_display, DefaultRootWindow(xi_display));
+ XFlush(xi_display);
return;
}
diff --git a/tools/gsr-global-hotkeys/keyboard_event.c b/tools/gsr-global-hotkeys/keyboard_event.c
index b9bb231..99f33ee 100644
--- a/tools/gsr-global-hotkeys/keyboard_event.c
+++ b/tools/gsr-global-hotkeys/keyboard_event.c
@@ -81,19 +81,19 @@ static void keyboard_event_fetch_update_key_states(keyboard_event *self, event_e
}
}
-static void keyboard_event_process_key_state_change(keyboard_event *self, struct input_event event, event_extra_data *extra_data, int fd) {
- if(event.type != EV_KEY)
+static void keyboard_event_process_key_state_change(keyboard_event *self, const struct input_event *event, event_extra_data *extra_data, int fd) {
+ if(event->type != EV_KEY)
return;
- if(!extra_data->key_states || event.code >= KEY_STATES_SIZE * 8)
+ if(!extra_data->key_states || event->code >= KEY_STATES_SIZE * 8)
return;
- const unsigned int byte_index = event.code / 8;
- const unsigned char bit_index = event.code % 8;
+ const unsigned int byte_index = event->code / 8;
+ const unsigned char bit_index = event->code % 8;
unsigned char key_byte_state = extra_data->key_states[byte_index];
const bool prev_key_pressed = (key_byte_state & (1 << bit_index)) != KEY_RELEASE;
- if(event.value == KEY_RELEASE) {
+ if(event->value == KEY_RELEASE) {
key_byte_state &= ~(1 << bit_index);
if(prev_key_pressed)
--extra_data->num_keys_pressed;
@@ -154,6 +154,12 @@ static uint32_t keycode_to_modifier_bit(uint32_t keycode) {
return 0;
}
+static bool key_is_mouse_button(uint32_t keycode) {
+ return (keycode >= BTN_MISC && keycode <= BTN_GEAR_UP)
+ || (keycode >= BTN_TRIGGER_HAPPY && keycode <= BTN_TRIGGER_HAPPY40)
+ || (keycode >= BTN_DPAD_UP && keycode <= BTN_DPAD_RIGHT);
+}
+
static void keyboard_event_process_input_event_data(keyboard_event *self, event_extra_data *extra_data, int fd) {
struct input_event event;
if(read(fd, &event, sizeof(event)) != sizeof(event)) {
@@ -171,8 +177,8 @@ static void keyboard_event_process_input_event_data(keyboard_event *self, event_
//fprintf(stderr, "fd: %d, type: %d, pressed %d, value: %d\n", fd, event.type, event.code, event.value);
//}
- if(event.type == EV_KEY) {
- keyboard_event_process_key_state_change(self, event, extra_data, fd);
+ if(event.type == EV_KEY && !key_is_mouse_button(event.code)) {
+ keyboard_event_process_key_state_change(self, &event, extra_data, fd);
const uint32_t modifier_bit = keycode_to_modifier_bit(event.code);
if(modifier_bit == 0) {
if(keyboard_event_on_key_pressed(self, &event, self->modifier_button_states))
@@ -297,7 +303,7 @@ static bool keyboard_event_try_add_device_if_keyboard(keyboard_event *self, cons
//const bool supports_touch_events = key_bits[BTN_TOUCH/8] & (1 << (BTN_TOUCH % 8));
const bool supports_joystick_events = key_bits[BTN_JOYSTICK/8] & (1 << (BTN_JOYSTICK % 8));
const bool supports_wheel_events = key_bits[BTN_WHEEL/8] & (1 << (BTN_WHEEL % 8));
- if(supports_key_events && !supports_mouse_events && !supports_joystick_events && !supports_wheel_events) {
+ if(supports_key_events && !supports_joystick_events && !supports_wheel_events) {
unsigned char *key_states = calloc(1, KEY_STATES_SIZE);
if(key_states && self->num_event_polls < MAX_EVENT_POLLS) {
//fprintf(stderr, "%s (%s) supports key inputs\n", dev_input_filepath, device_name);
@@ -314,9 +320,16 @@ static bool keyboard_event_try_add_device_if_keyboard(keyboard_event *self, cons
.num_keys_pressed = 0
};
- keyboard_event_fetch_update_key_states(self, &self->event_extra_data[self->num_event_polls], fd);
- if(self->event_extra_data[self->num_event_polls].num_keys_pressed > 0)
- fprintf(stderr, "Info: device not grabbed yet because some keys are still being pressed: /dev/input/event%d\n", dev_input_id);
+ if(supports_mouse_events) {
+ fprintf(stderr, "Info: device not grabbed yet because it might be a mouse: /dev/input/event%d\n", dev_input_id);
+ fsync(fd);
+ if(ioctl(fd, EVIOCGKEY(KEY_STATES_SIZE), self->event_extra_data[self->num_event_polls].key_states) == -1)
+ fprintf(stderr, "Warning: failed to fetch key states for device: /dev/input/event%d\n", dev_input_id);
+ } else {
+ keyboard_event_fetch_update_key_states(self, &self->event_extra_data[self->num_event_polls], fd);
+ if(self->event_extra_data[self->num_event_polls].num_keys_pressed > 0)
+ fprintf(stderr, "Info: device not grabbed yet because some keys are still being pressed: /dev/input/event%d\n", dev_input_id);
+ }
++self->num_event_polls;
return true;