mirror of
https://github.com/Genymobile/scrcpy.git
synced 2025-04-20 03:25:03 +00:00
commit
911f577563
3 changed files with 34 additions and 9 deletions
|
@ -144,6 +144,7 @@ void input_manager_process_text_input(struct input_manager *input_manager,
|
|||
return;
|
||||
}
|
||||
if (!controller_push_event(input_manager->controller, &control_event)) {
|
||||
SDL_free(control_event.text_event.text);
|
||||
LOGW("Cannot send text event");
|
||||
}
|
||||
}
|
||||
|
@ -151,6 +152,14 @@ void input_manager_process_text_input(struct input_manager *input_manager,
|
|||
void input_manager_process_key(struct input_manager *input_manager,
|
||||
const SDL_KeyboardEvent *event) {
|
||||
SDL_bool ctrl = event->keysym.mod & (KMOD_LCTRL | KMOD_RCTRL);
|
||||
SDL_bool alt = event->keysym.mod & (KMOD_LALT | KMOD_RALT);
|
||||
SDL_bool meta = event->keysym.mod & (KMOD_LGUI | KMOD_RGUI);
|
||||
|
||||
if (alt | meta) {
|
||||
// no shortcut involves Alt or Meta, and they should not be forwarded
|
||||
// to the device
|
||||
return;
|
||||
}
|
||||
|
||||
// capture all Ctrl events
|
||||
if (ctrl) {
|
||||
|
|
|
@ -4,20 +4,27 @@
|
|||
#include "log.h"
|
||||
#include "str_util.h"
|
||||
|
||||
static int build_cmd(char *cmd, size_t len, const char *const argv[]) {
|
||||
// Windows command-line parsing is WTF:
|
||||
// <http://daviddeley.com/autohotkey/parameters/parameters.htm#WINPASS>
|
||||
// only make it work for this very specific program
|
||||
// (don't handle escaping nor quotes)
|
||||
size_t ret = xstrjoin(cmd, argv, ' ', len);
|
||||
if (ret >= len) {
|
||||
LOGE("Command too long (%" PRIsizet " chars)", len - 1);
|
||||
return -1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
enum process_result cmd_execute(const char *path, const char *const argv[], HANDLE *handle) {
|
||||
STARTUPINFO si;
|
||||
PROCESS_INFORMATION pi;
|
||||
memset(&si, 0, sizeof(si));
|
||||
si.cb = sizeof(si);
|
||||
|
||||
// Windows command-line parsing is WTF:
|
||||
// <http://daviddeley.com/autohotkey/parameters/parameters.htm#WINPASS>
|
||||
// only make it work for this very specific program
|
||||
// (don't handle escaping nor quotes)
|
||||
char cmd[256];
|
||||
size_t ret = xstrjoin(cmd, argv, ' ', sizeof(cmd));
|
||||
if (ret >= sizeof(cmd)) {
|
||||
LOGE("Command too long (%" PRIsizet " chars)", sizeof(cmd) - 1);
|
||||
if (build_cmd(cmd, sizeof(cmd), argv)) {
|
||||
*handle = NULL;
|
||||
return PROCESS_ERROR_GENERIC;
|
||||
}
|
||||
|
|
|
@ -14,9 +14,18 @@ public class IO {
|
|||
}
|
||||
|
||||
public static void writeFully(FileDescriptor fd, ByteBuffer from) throws IOException {
|
||||
while (from.hasRemaining()) {
|
||||
// ByteBuffer position is not updated as expected by Os.write() on old Android versions, so
|
||||
// count the remaining bytes manually.
|
||||
// See <https://github.com/Genymobile/scrcpy/issues/291>.
|
||||
int remaining = from.remaining();
|
||||
while (remaining > 0) {
|
||||
try {
|
||||
Os.write(fd, from);
|
||||
int w = Os.write(fd, from);
|
||||
if (BuildConfig.DEBUG && w < 0) {
|
||||
// w should not be negative, since an exception is thrown on error
|
||||
throw new AssertionError("Os.write() returned a negative value (" + w + ")");
|
||||
}
|
||||
remaining -= w;
|
||||
} catch (ErrnoException e) {
|
||||
if (e.errno != OsConstants.EINTR) {
|
||||
throw new IOException(e);
|
||||
|
|
Loading…
Add table
Reference in a new issue