mirror of
https://repo.dec05eba.com/gpu-screen-recorder-ui
synced 2026-03-31 09:17:04 +09:00
Attempt to fix global hotkeys not working on steam deck (grabs keys, cant press buttons)
This commit is contained in:
@@ -74,6 +74,7 @@ executable(
|
||||
[
|
||||
'tools/gsr-global-hotkeys/hotplug.c',
|
||||
'tools/gsr-global-hotkeys/keyboard_event.c',
|
||||
'tools/gsr-global-hotkeys/keys.c',
|
||||
'tools/gsr-global-hotkeys/main.c'
|
||||
],
|
||||
c_args : '-fstack-protector-all',
|
||||
|
||||
@@ -1,4 +1,5 @@
|
||||
#include "keyboard_event.h"
|
||||
#include "keys.h"
|
||||
|
||||
/* C stdlib */
|
||||
#include <stdio.h>
|
||||
@@ -154,12 +155,6 @@ 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)) {
|
||||
@@ -177,7 +172,7 @@ 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 && !key_is_mouse_button(event.code)) {
|
||||
if(event.type == EV_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) {
|
||||
@@ -408,7 +403,8 @@ static int setup_virtual_keyboard_input(const char *name) {
|
||||
|
||||
success &= (ioctl(fd, UI_SET_MSCBIT, MSC_SCAN) != -1);
|
||||
for(int i = 1; i < KEY_MAX; ++i) {
|
||||
success &= (ioctl(fd, UI_SET_KEYBIT, i) != -1);
|
||||
if(is_key_or_mouse_button(i))
|
||||
success &= (ioctl(fd, UI_SET_KEYBIT, i) != -1);
|
||||
}
|
||||
for(int i = 0; i < REL_MAX; ++i) {
|
||||
success &= (ioctl(fd, UI_SET_RELBIT, i) != -1);
|
||||
|
||||
27
tools/gsr-global-hotkeys/keys.c
Normal file
27
tools/gsr-global-hotkeys/keys.c
Normal file
@@ -0,0 +1,27 @@
|
||||
#include "keys.h"
|
||||
#include <linux/input-event-codes.h>
|
||||
|
||||
bool is_key_or_mouse_button(uint32_t keycode) {
|
||||
return (keycode >= KEY_ESC && keycode <= KEY_KPDOT)
|
||||
|| (keycode >= KEY_ZENKAKUHANKAKU && keycode <= KEY_F24)
|
||||
|| (keycode >= KEY_PLAYCD && keycode <= KEY_MICMUTE)
|
||||
|| (keycode >= BTN_MISC && keycode <= BTN_TASK)
|
||||
|| (keycode >= BTN_JOYSTICK && keycode <= BTN_THUMBR)
|
||||
|| (keycode >= BTN_DIGI && keycode <= BTN_GEAR_UP)
|
||||
|| (keycode >= KEY_OK && keycode <= KEY_HANGUP_PHONE)
|
||||
|| (keycode >= KEY_DEL_EOL && keycode <= KEY_DEL_LINE)
|
||||
|| (keycode >= KEY_FN && keycode <= KEY_FN_RIGHT_SHIFT)
|
||||
|| (keycode >= KEY_BRL_DOT1 && keycode <= KEY_BRL_DOT10)
|
||||
|| (keycode >= KEY_NUMERIC_0 && keycode <= KEY_LIGHTS_TOGGLE)
|
||||
|| (keycode >= BTN_DPAD_UP && keycode <= KEY_BRIGHTNESS_MAX)
|
||||
|| (keycode >= KEY_KBDINPUTASSIST_PREV && keycode <= KEY_MACRO30)
|
||||
|| (keycode >= KEY_MACRO_RECORD_START && keycode <= KEY_MACRO_PRESET3)
|
||||
|| (keycode >= KEY_KBD_LCD_MENU1 && keycode <= KEY_KBD_LCD_MENU5)
|
||||
|| (keycode >= BTN_TRIGGER_HAPPY && keycode <= BTN_TRIGGER_HAPPY40);
|
||||
}
|
||||
|
||||
bool 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);
|
||||
}
|
||||
10
tools/gsr-global-hotkeys/keys.h
Normal file
10
tools/gsr-global-hotkeys/keys.h
Normal file
@@ -0,0 +1,10 @@
|
||||
#ifndef KEYS_H
|
||||
#define KEYS_H
|
||||
|
||||
#include <stdbool.h>
|
||||
#include <stdint.h>
|
||||
|
||||
bool is_key_or_mouse_button(uint32_t keycode);
|
||||
bool is_mouse_button(uint32_t keycode);
|
||||
|
||||
#endif /* KEYS_H */
|
||||
Reference in New Issue
Block a user