Skip to content

Commit 64ac3ce

Browse files
committed
support paste from clipboard (Ctrl+Shift+V) (only when OSK is off)
1 parent 3b6f986 commit 64ac3ce

1 file changed

Lines changed: 15 additions & 0 deletions

File tree

src/main.c

Lines changed: 15 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1084,6 +1084,21 @@ void main_loop(void) {
10841084
// printf("OSK handled the event.\n");
10851085
} else {
10861086
// printf("OSK passing event to default handler.\n");
1087+
if (ev.type == SDL_KEYDOWN) {
1088+
if (ev.key.keysym.sym == SDLK_v) {
1089+
const Uint8* state = SDL_GetKeyboardState(NULL);
1090+
// Check for Ctrl AND Shift being pressed
1091+
bool ctrlPressed = state[SDL_SCANCODE_LCTRL] || state[SDL_SCANCODE_RCTRL];
1092+
bool shiftPressed = state[SDL_SCANCODE_LSHIFT] || state[SDL_SCANCODE_RSHIFT];
1093+
if (ctrlPressed && shiftPressed) {
1094+
char* clipboardText = SDL_GetClipboardText();
1095+
if (clipboardText) {
1096+
tty_write(clipboardText, strlen(clipboardText));
1097+
SDL_free(clipboardText); // Free memory
1098+
}
1099+
}
1100+
}
1101+
}
10871102
if (event_handler[ev.type]) (event_handler[ev.type])(&ev);
10881103
}
10891104

0 commit comments

Comments
 (0)