mirror of
https://github.com/Droid-Deck/DroidDeck.git
synced 2026-11-18 20:36:04 +00:00
Move the Linux runtime to Ubuntu 26.04 LTS with a separate Kubuntu desktop (#1733)
This commit is contained in:
1 parent
5de690ef39
commit
29c83976d0
305 files changed
+9383
-462
No files matched your search
@@ -93,6 +93,7 @@ static constexpr unsigned int FAKE_INPUT_MAJOR = 13;
|
||||
static constexpr unsigned int FAKE_INPUT_EVENT_MINOR_BASE = 64;
|
||||
static constexpr unsigned int FAKE_INPUT_JS_MINOR_BASE = 0;
|
||||
static constexpr int UINPUT_EVENT_BASE = 16;
|
||||
static constexpr int MOUSE_EVENT_SLOT = 4;
|
||||
static constexpr int UINPUT_EVENT_LIMIT = 64;
|
||||
static constexpr uint32_t UINPUT_DESCRIPTION_MAGIC = 0x46495544;
|
||||
|
||||
@@ -121,6 +122,12 @@ static constexpr size_t FAKE_INPUT_RING_HEADER_SIZE =
|
||||
static constexpr size_t FAKE_INPUT_RING_SIZE =
|
||||
FAKE_INPUT_RING_HEADER_SIZE +
|
||||
(FAKE_INPUT_RING_CAPACITY * FAKE_INPUT_EVENT_SIZE);
|
||||
static constexpr size_t DECK_IMU_BLOCK_SIZE = 64;
|
||||
static constexpr size_t FAKE_INPUT_RING_PAD_TYPE_OFFSET = 44;
|
||||
static constexpr uint32_t PAD_TYPE_DECK = 0, PAD_TYPE_STEAM = 1, PAD_TYPE_XBOX = 2, PAD_TYPE_DS4 = 3,
|
||||
PAD_TYPE_DUALSENSE = 4, PAD_TYPE_LAST = PAD_TYPE_DUALSENSE,
|
||||
PAD_TYPE_MOUSE = 5;
|
||||
static constexpr uint32_t PAD_TYPE_SET = 0x80000000u;
|
||||
|
||||
struct UinputDescription {
|
||||
uint32_t magic;
|
||||
@@ -149,6 +156,7 @@ struct FakeController {
|
||||
size_t mapping_size = 0;
|
||||
bool closed = false;
|
||||
bool needs_keyframe = true;
|
||||
bool mouse = false;
|
||||
|
||||
~FakeController() {
|
||||
if (ring) munmap(ring, mapping_size);
|
||||
@@ -607,7 +615,7 @@ open_fake_input_ring(const char *event, int flags) {
|
||||
int slot = get_event_number(event);
|
||||
bool virtual_pad = slot >= UINPUT_EVENT_BASE;
|
||||
std::string ring_path = virtual_pad ? uinput_ring_path(slot) : get_ring_path_for_slot(slot);
|
||||
size_t mapping_size = virtual_pad ? UINPUT_FILE_SIZE : FAKE_INPUT_RING_SIZE;
|
||||
size_t mapping_size = virtual_pad ? UINPUT_FILE_SIZE : FAKE_INPUT_RING_SIZE + DECK_IMU_BLOCK_SIZE;
|
||||
if (ring_path.empty()) {
|
||||
Logger::log("No input ring is configured for %s (slot %d)\n", event, slot);
|
||||
errno = ENODEV;
|
||||
@@ -651,9 +659,22 @@ open_fake_input_ring(const char *event, int flags) {
|
||||
controller->uinput = description;
|
||||
controller->mapping_size = mapping_size;
|
||||
controller->generation = ring_generation(ring);
|
||||
if (!virtual_pad) {
|
||||
uint32_t pad_type = __atomic_load_n(
|
||||
reinterpret_cast<volatile uint32_t *>(static_cast<uint8_t *>(mapping) + FAKE_INPUT_RING_SIZE +
|
||||
FAKE_INPUT_RING_PAD_TYPE_OFFSET),
|
||||
__ATOMIC_ACQUIRE);
|
||||
controller->mouse = (pad_type & PAD_TYPE_SET) && (pad_type & ~PAD_TYPE_SET) == PAD_TYPE_MOUSE;
|
||||
}
|
||||
SnapshotState snap;
|
||||
if (read_snapshot(ring, snap) && snap.generation == controller->generation)
|
||||
capture_keyframe(*controller, snap);
|
||||
if (read_snapshot(ring, snap) && snap.generation == controller->generation) {
|
||||
if (controller->mouse) {
|
||||
controller->read_seq = snap.write_seq;
|
||||
controller->needs_keyframe = false;
|
||||
} else {
|
||||
capture_keyframe(*controller, snap);
|
||||
}
|
||||
}
|
||||
{
|
||||
std::lock_guard<std::recursive_mutex> guard(controller_mutex());
|
||||
controller_map()[fd] = controller;
|
||||
@@ -1156,7 +1177,8 @@ struct DeckImu {
|
||||
uint32_t pad_type;
|
||||
uint32_t latency;
|
||||
};
|
||||
static_assert(offsetof(DeckImu, pad_type) == 44, "DeckImu::pad_type matches FakeInputWriter");
|
||||
static_assert(offsetof(DeckImu, pad_type) == FAKE_INPUT_RING_PAD_TYPE_OFFSET,
|
||||
"DeckImu::pad_type matches FakeInputWriter and the ring reader");
|
||||
static_assert(offsetof(DeckImu, latency) == 48, "DeckImu::latency matches FakeInputWriter");
|
||||
static constexpr uint32_t LATENCY_CONTROLLER = 1, LATENCY_TOUCH = 2;
|
||||
static constexpr int LOW_LATENCY_REPORT_INTERVAL_US = 1000;
|
||||
@@ -1173,7 +1195,6 @@ struct DeckExtras {
|
||||
uint32_t controls = 0;
|
||||
};
|
||||
static constexpr uint32_t DECK_IMU_MAGIC = 0x31554D49;
|
||||
static constexpr size_t DECK_IMU_BLOCK_SIZE = 64;
|
||||
static_assert(sizeof(DeckImu) <= DECK_IMU_BLOCK_SIZE, "the IMU block is 64 bytes in the ring file");
|
||||
|
||||
struct TritonSharedData {
|
||||
@@ -1270,10 +1291,6 @@ static bool fake_deck_enabled() {
|
||||
return enabled == 1;
|
||||
}
|
||||
|
||||
static constexpr uint32_t PAD_TYPE_DECK = 0, PAD_TYPE_STEAM = 1, PAD_TYPE_XBOX = 2, PAD_TYPE_DS4 = 3,
|
||||
PAD_TYPE_DUALSENSE = 4, PAD_TYPE_LAST = PAD_TYPE_DUALSENSE;
|
||||
static constexpr uint32_t PAD_TYPE_SET = 0x80000000u;
|
||||
|
||||
__attribute__((visibility("hidden"))) static uint32_t session_pad_type() {
|
||||
static int type = -1;
|
||||
if (type < 0) {
|
||||
@@ -1408,6 +1425,12 @@ __attribute__((visibility("hidden"))) static bool is_withdrawn_pad_path(const ch
|
||||
if (strncmp(event, "event", 5) && strncmp(event, "js", 2)) return false;
|
||||
int number = get_event_number(event);
|
||||
if (number < 0 || number >= UINPUT_EVENT_BASE) return false;
|
||||
if (number == MOUSE_EVENT_SLOT && !strncmp(event, "event", 5)) {
|
||||
char *fake = from_real_to_fake_path(pathname);
|
||||
bool exposed = fake && path_exists(fake);
|
||||
free(fake);
|
||||
return !exposed;
|
||||
}
|
||||
return number == 0 || !process_is_steam_client();
|
||||
}
|
||||
|
||||
@@ -3351,6 +3374,85 @@ static int copy_ioctl_bits(int op, void *destination, const unsigned char (&bits
|
||||
return static_cast<int>(size);
|
||||
}
|
||||
|
||||
static constexpr uint16_t MOUSE_VENDOR_ID = 0x1dd1;
|
||||
static constexpr uint16_t MOUSE_PRODUCT_ID = 0x0004;
|
||||
|
||||
static int ioctl_mouse(int op, void *argp) {
|
||||
int type = (op >> 8 & 0xFF);
|
||||
int number = (op >> 0 & 0xFF);
|
||||
if (type != 0x45) {
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
switch (number) {
|
||||
case 0x01: {
|
||||
int version = 65536;
|
||||
memcpy(argp, &version, sizeof(int));
|
||||
return 0;
|
||||
}
|
||||
case 0x02: {
|
||||
struct input_id id;
|
||||
memset(&id, 0, sizeof(id));
|
||||
id.bustype = 0x03;
|
||||
id.vendor = MOUSE_VENDOR_ID;
|
||||
id.product = MOUSE_PRODUCT_ID;
|
||||
id.version = 1;
|
||||
memcpy(argp, &id, sizeof(id));
|
||||
return 0;
|
||||
}
|
||||
case 0x06:
|
||||
if (argp && _IOC_SIZE(op)) snprintf(static_cast<char *>(argp), _IOC_SIZE(op), "DroidDeck Mouse");
|
||||
return 0;
|
||||
case 0x07:
|
||||
if (argp && _IOC_SIZE(op)) snprintf(static_cast<char *>(argp), _IOC_SIZE(op), "usb-droiddeck/mouse");
|
||||
return 0;
|
||||
case 0x08:
|
||||
if (argp && _IOC_SIZE(op)) static_cast<char *>(argp)[0] = '\0';
|
||||
return 0;
|
||||
case 0x09: {
|
||||
unsigned char bitmask[(INPUT_PROP_MAX + 8) / 8] = {};
|
||||
bitmask[INPUT_PROP_POINTER / 8] |= 1 << (INPUT_PROP_POINTER % 8);
|
||||
return copy_ioctl_bits(op, argp, bitmask);
|
||||
}
|
||||
case 0x18: {
|
||||
unsigned char bitmask[(KEY_MAX + 8) / 8] = {};
|
||||
return copy_ioctl_bits(op, argp, bitmask);
|
||||
}
|
||||
case 0x20: {
|
||||
unsigned char bitmask[(EV_MAX + 8) / 8] = {};
|
||||
bitmask[EV_SYN / 8] |= 1 << (EV_SYN % 8);
|
||||
bitmask[EV_KEY / 8] |= 1 << (EV_KEY % 8);
|
||||
bitmask[EV_REL / 8] |= 1 << (EV_REL % 8);
|
||||
bitmask[EV_MSC / 8] |= 1 << (EV_MSC % 8);
|
||||
return copy_ioctl_bits(op, argp, bitmask);
|
||||
}
|
||||
case 0x21: {
|
||||
unsigned char bitmask[(KEY_MAX + 8) / 8] = {};
|
||||
for (int button = BTN_LEFT; button <= BTN_TASK; button++)
|
||||
if (button <= BTN_MIDDLE || button == BTN_SIDE || button == BTN_EXTRA)
|
||||
bitmask[button / 8] |= 1 << (button % 8);
|
||||
return copy_ioctl_bits(op, argp, bitmask);
|
||||
}
|
||||
case 0x22: {
|
||||
unsigned char bitmask[(REL_MAX + 8) / 8] = {};
|
||||
for (uint16_t code : {REL_X, REL_Y, REL_WHEEL, REL_HWHEEL, REL_WHEEL_HI_RES, REL_HWHEEL_HI_RES})
|
||||
bitmask[code / 8] |= 1 << (code % 8);
|
||||
return copy_ioctl_bits(op, argp, bitmask);
|
||||
}
|
||||
case 0x23: {
|
||||
unsigned char bitmask[(ABS_MAX + 8) / 8] = {};
|
||||
return copy_ioctl_bits(op, argp, bitmask);
|
||||
}
|
||||
case 0x35: {
|
||||
unsigned char bitmask[(FF_MAX + 8) / 8] = {};
|
||||
return copy_ioctl_bits(op, argp, bitmask);
|
||||
}
|
||||
default:
|
||||
errno = EINVAL;
|
||||
return -1;
|
||||
}
|
||||
}
|
||||
|
||||
static bool wait_snapshot(std::shared_ptr<FakeController> fake,
|
||||
std::unique_lock<std::recursive_mutex> &guard,
|
||||
SnapshotState &snap) {
|
||||
@@ -3417,6 +3519,13 @@ EXPORT int ioctl(int fd, ioctl_request_t op, ...) {
|
||||
int event_number = controller->second->slot;
|
||||
const UinputDescription *made = controller->second->uinput;
|
||||
|
||||
if (controller->second->mouse) {
|
||||
int result = ioctl_mouse(op, argp);
|
||||
if (result >= 0) return result;
|
||||
guard.unlock();
|
||||
return forward_ioctl(fd, op, argp);
|
||||
}
|
||||
|
||||
if (type == 0x45 && number == 0x1) {
|
||||
Logger::log("Hooking ioctl EVIOCGVERSION for event %s\n", event);
|
||||
int version = 65536;
|
||||
@@ -3680,6 +3789,12 @@ static ssize_t read_input(int fd, void *buf, size_t count) {
|
||||
if (fake.needs_keyframe || snap.resync_seq != fake.resync_seq ||
|
||||
snap.write_seq < fake.read_seq ||
|
||||
snap.write_seq - fake.read_seq > FAKE_INPUT_RING_CAPACITY) {
|
||||
if (fake.mouse) {
|
||||
fake.read_seq = snap.write_seq;
|
||||
fake.resync_seq = snap.resync_seq;
|
||||
fake.needs_keyframe = false;
|
||||
continue;
|
||||
}
|
||||
capture_keyframe(fake, snap);
|
||||
} else {
|
||||
size_t events = std::min<uint64_t>(requested, snap.write_seq - fake.read_seq);
|
||||
|
||||
@@ -503,6 +503,7 @@ struct active_touch { struct surface *surface; int pointer_fallback; };
|
||||
static struct active_touch g_touch_points[MAX_TOUCH_POINTS];
|
||||
static void touch_cancel_surface(struct surface *surface);
|
||||
static struct surface *g_grab;
|
||||
static void publish_query_state(void);
|
||||
static struct surface *g_key_target;
|
||||
static struct surface *g_ime_click;
|
||||
static int g_input_pipe[2] = {-1, -1};
|
||||
@@ -596,6 +597,7 @@ static void map_toplevel(struct surface *s) {
|
||||
raise_kept_on_top();
|
||||
if (!g_desktop) g_key_target = s;
|
||||
apply_zorder();
|
||||
publish_query_state();
|
||||
}
|
||||
|
||||
static void unmap_toplevel(struct surface *s) {
|
||||
@@ -2432,6 +2434,7 @@ static const struct wl_touch_interface touch_impl = { .release = touch_release }
|
||||
static void touch_res_destroy(struct wl_resource *r) {
|
||||
for (int i = 0; i < g_ntouches; i++)
|
||||
if (g_touches[i].touch == r) { g_touches[i] = g_touches[--g_ntouches]; break; }
|
||||
publish_query_state();
|
||||
}
|
||||
|
||||
static void seat_get_pointer(struct wl_client *c, struct wl_resource *r, uint32_t id) {
|
||||
@@ -2469,6 +2472,7 @@ static void seat_get_touch(struct wl_client *c, struct wl_resource *r, uint32_t
|
||||
g_touches[g_ntouches].focus = NULL;
|
||||
g_ntouches++;
|
||||
}
|
||||
publish_query_state();
|
||||
}
|
||||
static void seat_release(struct wl_client *c, struct wl_resource *r) { wl_resource_destroy(r); }
|
||||
static const struct wl_seat_interface seat_impl = {
|
||||
@@ -2584,6 +2588,7 @@ struct relative_pointer {
|
||||
static struct wl_list g_relative_pointers;
|
||||
|
||||
static double g_ptr_x, g_ptr_y;
|
||||
static int g_ptr_known;
|
||||
static double g_raw_x, g_raw_y;
|
||||
static int g_raw_valid;
|
||||
|
||||
@@ -2648,6 +2653,7 @@ static void constraint_end(struct constraint *k, int tell_client, const char *wh
|
||||
constraint_origin(k, &ox, &oy);
|
||||
g_ptr_x = ox + k->hint_x;
|
||||
g_ptr_y = oy + k->hint_y;
|
||||
g_ptr_known = 1;
|
||||
}
|
||||
g_raw_valid = 0;
|
||||
if (k->gave_keys) {
|
||||
@@ -2744,6 +2750,7 @@ static void constraints_surface_commit(struct surface *s) {
|
||||
constraint_origin(k, &ox, &oy);
|
||||
g_ptr_x = ox + k->hint_x;
|
||||
g_ptr_y = oy + k->hint_y;
|
||||
g_ptr_known = 1;
|
||||
if (log_budget())
|
||||
droiddeck_log("pointer", "position hint: pointer moved to %d,%d", (int)g_ptr_x, (int)g_ptr_y);
|
||||
}
|
||||
@@ -2938,6 +2945,7 @@ static void pointer_input(double x, double y, int relative, uint32_t button, int
|
||||
}
|
||||
if (k) confine_clamp(k, &x, &y);
|
||||
g_ptr_x = x; g_ptr_y = y;
|
||||
g_ptr_known = 1;
|
||||
if (k) {
|
||||
target = k->surface;
|
||||
} else if (g_desktop) {
|
||||
@@ -2948,6 +2956,7 @@ static void pointer_input(double x, double y, int relative, uint32_t button, int
|
||||
if (button && !pressed) g_grab = NULL;
|
||||
}
|
||||
}
|
||||
publish_query_state();
|
||||
if (!target) return;
|
||||
|
||||
struct wl_client *client = wl_resource_get_client(target->resource);
|
||||
@@ -2963,9 +2972,9 @@ static void pointer_input(double x, double y, int relative, uint32_t button, int
|
||||
// may have warped its cursor since the last motion (before taking lock,
|
||||
// or while releasing it), so that replay can become an unintended pan.
|
||||
// Absolute touch events still carry their position, including on clicks.
|
||||
if (!(k && k->is_lock) && (!relative || dx != 0 || dy != 0))
|
||||
int rel_consumed = send_relative_motion(client, dx, dy);
|
||||
if (!(k && k->is_lock) && !(relative && rel_consumed) && (!relative || dx != 0 || dy != 0))
|
||||
for_each_pointer_of(client, sp) wl_pointer_send_motion(sp->ptr, t, fx, fy);
|
||||
send_relative_motion(client, dx, dy);
|
||||
for_each_pointer_of(client, sp) {
|
||||
if (button)
|
||||
wl_pointer_send_button(sp->ptr, wl_display_next_serial(g_display), t, button,
|
||||
@@ -3104,6 +3113,63 @@ static struct surface *touch_target_at(double x, double y) {
|
||||
return g_grab ? g_grab : g_key_target;
|
||||
}
|
||||
|
||||
static pthread_mutex_t g_query_lock = PTHREAD_MUTEX_INITIALIZER;
|
||||
struct query_snapshot {
|
||||
int has_position;
|
||||
int input_x, input_y;
|
||||
int focus_takes_touch;
|
||||
};
|
||||
static struct query_snapshot g_query = { 0, 0, 0, 1 };
|
||||
|
||||
static void publish_query_state(void) {
|
||||
struct surface *target = g_key_target ? g_key_target : (g_grab ? g_grab : toplevel_at(g_ptr_x, g_ptr_y));
|
||||
int takes_touch = 1;
|
||||
if (target) {
|
||||
struct wl_client *client = wl_resource_get_client(target->resource);
|
||||
struct seat_touch *st;
|
||||
takes_touch = 0;
|
||||
for_each_touch_of(client, st) takes_touch = 1;
|
||||
}
|
||||
int w = 0, h = 0, ow = 0, oh = 0, input_x = 0, input_y = 0, has_position = 0;
|
||||
scene_size(&w, &h);
|
||||
vkp_output_size(&ow, &oh);
|
||||
if (g_ptr_known && w > 0 && h > 0) {
|
||||
double ox, oy;
|
||||
if (ow > 0 && oh > 0 && vkp_scene_to_output(g_ptr_x, g_ptr_y, &ox, &oy)) {
|
||||
input_x = (int)(ox * INPUT_SPACE_W / ow);
|
||||
input_y = (int)(oy * INPUT_SPACE_H / oh);
|
||||
} else {
|
||||
input_x = (int)(g_ptr_x * INPUT_SPACE_W / w);
|
||||
input_y = (int)(g_ptr_y * INPUT_SPACE_H / h);
|
||||
}
|
||||
has_position = 1;
|
||||
}
|
||||
pthread_mutex_lock(&g_query_lock);
|
||||
g_query.focus_takes_touch = takes_touch;
|
||||
g_query.has_position = has_position;
|
||||
g_query.input_x = input_x;
|
||||
g_query.input_y = input_y;
|
||||
pthread_mutex_unlock(&g_query_lock);
|
||||
}
|
||||
|
||||
int droiddeck_focus_takes_touch(void) {
|
||||
pthread_mutex_lock(&g_query_lock);
|
||||
int takes_touch = g_query.focus_takes_touch;
|
||||
pthread_mutex_unlock(&g_query_lock);
|
||||
return takes_touch;
|
||||
}
|
||||
|
||||
int droiddeck_cursor_input_pos(int *x, int *y) {
|
||||
pthread_mutex_lock(&g_query_lock);
|
||||
int has_position = g_query.has_position;
|
||||
int input_x = g_query.input_x, input_y = g_query.input_y;
|
||||
pthread_mutex_unlock(&g_query_lock);
|
||||
if (!has_position) return 0;
|
||||
*x = input_x;
|
||||
*y = input_y;
|
||||
return 1;
|
||||
}
|
||||
|
||||
static void touch_down(int id, double x, double y) {
|
||||
if (id < 0 || id >= MAX_TOUCH_POINTS) return;
|
||||
struct surface *target = touch_target_at(x, y);
|
||||
@@ -3203,6 +3269,7 @@ static void deliver_touch(const struct input_msg *m) {
|
||||
else if (m->p1 == 1) touch_motion(m->p2, x, y);
|
||||
else if (m->p1 == 2) touch_up(m->p2, x, y);
|
||||
else if (m->p1 == 3) touch_cancel_all();
|
||||
publish_query_state();
|
||||
}
|
||||
|
||||
static void key_event(uint32_t evdev, int pressed);
|
||||
@@ -3220,10 +3287,10 @@ static void send_axis(struct seat_pointer *sp, uint32_t t, uint32_t axis, int va
|
||||
wl_pointer_send_axis(sp->ptr, t, axis, wl_fixed_from_double(value120 / 12.0));
|
||||
}
|
||||
|
||||
static void axis_event(int vertical120, int horizontal120) {
|
||||
static void axis_event(int vertical120, int horizontal120, int finger) {
|
||||
struct surface *target = g_active_constraint ? g_active_constraint->surface
|
||||
: g_desktop ? g_desktop : (g_grab ? g_grab : toplevel_at(g_ptr_x, g_ptr_y));
|
||||
if (!target || (!vertical120 && !horizontal120)) return;
|
||||
if (!target || (!finger && !vertical120 && !horizontal120)) return;
|
||||
struct wl_client *client = wl_resource_get_client(target->resource);
|
||||
struct seat_pointer *sp;
|
||||
if (!pointer_for(client)) return;
|
||||
@@ -3232,16 +3299,33 @@ static void axis_event(int vertical120, int horizontal120) {
|
||||
uint32_t t = now_ms();
|
||||
pointer_focus(target->resource, wl_fixed_from_double(g_ptr_x - tx), wl_fixed_from_double(g_ptr_y - ty));
|
||||
for_each_pointer_of(client, sp) {
|
||||
send_axis(sp, t, WL_POINTER_AXIS_VERTICAL_SCROLL, vertical120);
|
||||
send_axis(sp, t, WL_POINTER_AXIS_HORIZONTAL_SCROLL, horizontal120);
|
||||
if (wl_resource_get_version(sp->ptr) >= WL_POINTER_FRAME_SINCE_VERSION)
|
||||
int version = wl_resource_get_version(sp->ptr);
|
||||
if (!finger) {
|
||||
send_axis(sp, t, WL_POINTER_AXIS_VERTICAL_SCROLL, vertical120);
|
||||
send_axis(sp, t, WL_POINTER_AXIS_HORIZONTAL_SCROLL, horizontal120);
|
||||
} else {
|
||||
if (version >= WL_POINTER_AXIS_SOURCE_SINCE_VERSION)
|
||||
wl_pointer_send_axis_source(sp->ptr, WL_POINTER_AXIS_SOURCE_FINGER);
|
||||
if (!vertical120 && !horizontal120) {
|
||||
if (version >= WL_POINTER_AXIS_STOP_SINCE_VERSION) {
|
||||
wl_pointer_send_axis_stop(sp->ptr, t, WL_POINTER_AXIS_VERTICAL_SCROLL);
|
||||
wl_pointer_send_axis_stop(sp->ptr, t, WL_POINTER_AXIS_HORIZONTAL_SCROLL);
|
||||
}
|
||||
} else {
|
||||
if (vertical120)
|
||||
wl_pointer_send_axis(sp->ptr, t, WL_POINTER_AXIS_VERTICAL_SCROLL, wl_fixed_from_double(vertical120 / 12.0));
|
||||
if (horizontal120)
|
||||
wl_pointer_send_axis(sp->ptr, t, WL_POINTER_AXIS_HORIZONTAL_SCROLL, wl_fixed_from_double(horizontal120 / 12.0));
|
||||
}
|
||||
}
|
||||
if (version >= WL_POINTER_FRAME_SINCE_VERSION)
|
||||
wl_pointer_send_frame(sp->ptr);
|
||||
}
|
||||
wl_display_flush_clients(g_display);
|
||||
}
|
||||
|
||||
static void scroll_event(int steps) {
|
||||
axis_event(steps * 120, 0);
|
||||
axis_event(steps * 120, 0, 0);
|
||||
}
|
||||
|
||||
static int update_modifiers(uint32_t evdev, int pressed) {
|
||||
@@ -3337,7 +3421,8 @@ static int on_input_readable(int fd, uint32_t mask, void *data) {
|
||||
schedule_render();
|
||||
break;
|
||||
case 10: break;
|
||||
case 11: axis_event(m.p1, m.p2); break;
|
||||
case 11: axis_event(m.p1, m.p2, 0); break;
|
||||
case 12: axis_event(m.p1, m.p2, 1); break;
|
||||
case 20: stream_take(); break;
|
||||
case 21: if (!m.p1) stream_forget_all(); schedule_render(); break;
|
||||
default: deliver_pointer(&m); break;
|
||||
|
||||
@@ -384,6 +384,13 @@ int vkp_output_to_scene(double ox, double oy, double *sx, double *sy) {
|
||||
return 1;
|
||||
}
|
||||
|
||||
int vkp_scene_to_output(double sx, double sy, double *ox, double *oy) {
|
||||
if (!g_map.valid || g_map.kx <= 0 || g_map.ky <= 0) return 0;
|
||||
*ox = sx * g_map.kx + g_map.off_x;
|
||||
*oy = sy * g_map.ky + g_map.off_y;
|
||||
return 1;
|
||||
}
|
||||
|
||||
void vkp_output_size(int *w, int *h) {
|
||||
*w = (int)g_extent.width;
|
||||
*h = (int)g_extent.height;
|
||||
|
||||
@@ -16,6 +16,7 @@ enum vkp_align { VKP_ALIGN_CENTER = 0, VKP_ALIGN_TOP = 1, VKP_ALIGN_BOTTOM = 2,
|
||||
void vk_present_set_scale_mode(int mode, int alignment);
|
||||
int vkp_game_picture_rect(float rect[4]);
|
||||
int vkp_output_to_scene(double ox, double oy, double *sx, double *sy);
|
||||
int vkp_scene_to_output(double sx, double sy, double *ox, double *oy);
|
||||
void vkp_output_size(int *w, int *h);
|
||||
|
||||
struct vkp_image;
|
||||
|
||||
@@ -27,6 +27,8 @@ extern int droiddeck_cursor_snapshot(int *out, int cap);
|
||||
extern int droiddeck_cursor_serial(void);
|
||||
extern int droiddeck_hud_frame_times(float *out, int len, int64_t *total);
|
||||
extern void droiddeck_wayland_send_key(int evdev, int state);
|
||||
extern int droiddeck_focus_takes_touch(void);
|
||||
extern int droiddeck_cursor_input_pos(int *x, int *y);
|
||||
extern void droiddeck_wayland_send_scene_input(int type, int a, int b);
|
||||
extern void droiddeck_wayland_vsync(int64_t frame_time_ns);
|
||||
extern void droiddeck_stream_set(int on);
|
||||
@@ -296,6 +298,25 @@ Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendKey(
|
||||
droiddeck_wayland_send_key(evdev, state);
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeFocusTakesTouch(
|
||||
JNIEnv *env, jclass clazz) {
|
||||
(void)env; (void)clazz;
|
||||
return droiddeck_focus_takes_touch() ? JNI_TRUE : JNI_FALSE;
|
||||
}
|
||||
|
||||
JNIEXPORT jboolean JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeCursorInputPos(
|
||||
JNIEnv *env, jclass clazz, jintArray out) {
|
||||
(void)clazz;
|
||||
if (!out || (*env)->GetArrayLength(env, out) < 2) return JNI_FALSE;
|
||||
int pos[2];
|
||||
if (!droiddeck_cursor_input_pos(&pos[0], &pos[1])) return JNI_FALSE;
|
||||
jint jpos[2] = {pos[0], pos[1]};
|
||||
(*env)->SetIntArrayRegion(env, out, 0, 2, jpos);
|
||||
return JNI_TRUE;
|
||||
}
|
||||
|
||||
JNIEXPORT void JNICALL
|
||||
Java_com_droiddeck_launcher_wayland_WaylandCompositor_nativeSendSceneInput(
|
||||
JNIEnv *env, jclass clazz, jint type, jint a, jint b) {
|
||||
|
||||
Reference in new issue
Block a user