1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
122
123
124
125
126
127
128
129
130
131
132
133
134
135
136
137
138
139
140
141
142
143
144
145
146
147
148
149
150
151
152
153
154
155
156
157
158
159
160
161
162
163
|
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#define _GNU_SOURCE /* See feature_test_macros(7) */
#include <dlfcn.h>
#include "wrappedlibs.h"
#include "debug.h"
#include "wrapper32.h"
#include "bridge.h"
#include "librarian/library_private.h"
#include "x64emu.h"
#include "emu/x64emu_private.h"
#include "callback.h"
#include "librarian.h"
#include "box32context.h"
#include "emu/x64emu_private.h"
#include "converter32.h"
#ifdef ANDROID
static const char* libxiName = "libXi.so";
#else
static const char* libxiName = "libXi.so.6";
#endif
#define LIBNAME libxi
#ifdef ANDROID
#define NEEDED_LIBS "libX11.so", "libXext.so"
#else
#define NEEDED_LIBS "libX11.so.6", "libXext.so.6"
#endif
#include "libtools/my_x11_conv.h"
#include "generated/wrappedlibxitypes32.h"
#include "wrappercallback32.h"
EXPORT void* my32_XIQueryDevice(x64emu_t* emu, void* dpy, int deviceid, int* ndevices)
{
void* ret = my->XIQueryDevice(dpy, deviceid, ndevices);
inplace_XIDeviceInfo_shrink(ret, *ndevices);
return ret;
}
EXPORT void my32_XIFreeDeviceInfo(x64emu_t* emu, void* d)
{
inplace_XIDeviceInfo_enlarge(d);
my->XIFreeDeviceInfo(d);
}
EXPORT int my32_XISelectEvents(x64emu_t* emu, void* dpy, XID window, my_XIEventMask_32_t* masks, int num)
{
my_XIEventMask_t masks_l[num];
for(int i=0; i<num; ++i) {
masks_l[i].deviceid = masks[i].deviceid;
masks_l[i].mask_len = masks[i].mask_len;
masks_l[i].mask = from_ptrv(masks[i].mask);
}
return my->XISelectEvents(dpy, window, masks_l, num);
}
EXPORT void* my32_XIGetSelectedEvents(x64emu_t* emu, void* dpy, XID window, int* num)
{
void* ret = my->XIGetSelectedEvents(dpy, window, num);
if(!ret) return NULL;
//inplace shrink
my_XIEventMask_t* src = ret;
my_XIEventMask_32_t* dst = ret;
for(int i=0; i<*num; ++i, ++src, ++dst) {
dst->deviceid = src->deviceid;
dst->mask_len = src->mask_len;
dst->mask = to_ptrv(src->mask);
}
return ret;
}
EXPORT void* my32_XOpenDevice(x64emu_t* emu, void* dpy, XID id)
{
void* ret = my->XOpenDevice(dpy, id);
register_XDevice_events(ret);
inplace_XDevice_shrink(ret);
return ret;
}
EXPORT int my32_XCloseDevice(x64emu_t* emu, void* dpy, void* d)
{
inplace_XDevice_enlarge(d);
unregister_XDevice_events(d);
return my->XCloseDevice(dpy, d);
}
EXPORT int my32_XGetDeviceButtonMapping(x64emu_t* emu, void* dpy, void* d, void* map, int nmap)
{
inplace_XDevice_enlarge(d);
return my->XGetDeviceButtonMapping(dpy, d, map, nmap);
inplace_XDevice_shrink(d);
}
EXPORT void* my32_XQueryDeviceState(x64emu_t* emu, void* dpy, void* d)
{
void* ret = inplace_XDeviceState_shrink(my->XQueryDeviceState(dpy, inplace_XDevice_enlarge(d)));
inplace_XDevice_shrink(d);
return ret;
}
EXPORT void my32_XFreeDeviceState(x64emu_t* emu, void* ds)
{
my->XFreeDeviceState(inplace_XDeviceState_enlarge(ds));
}
EXPORT void* my32_XListInputDevices(x64emu_t* emu, void* dpy, int* n)
{
void* ret = my->XListInputDevices(dpy, n);
return inplace_XDeviceInfo_shrink(ret, *n);
}
EXPORT void my32_XFreeDeviceList(x64emu_t* emu, void* l)
{
my->XFreeDeviceList(inplace_XDeviceInfo_enlarge(l));
}
EXPORT void* my32_XGetDeviceMotionEvents(x64emu_t* emu, void* dpy, void* d, unsigned long start, unsigned long stop, int* n, int* mode, int* axis)
{
void* ret = my->XGetDeviceMotionEvents(dpy, inplace_XDevice_enlarge(d), start, stop, n, mode, axis);
inplace_XDevice_shrink(d);
if(ret) {
my_XDeviceTimeCoord_t* src = ret;
my_XDeviceTimeCoord_32_t* dst = ret;
for(int i=0; i<*n; ++i) {
dst[i].time = to_ulong(src[i].time);
dst[i].data = to_ptrv(src[i].data);
}
if(*n) {
dst[*n].time = 0; dst[*n].data = 0; // mark the end
}
}
}
EXPORT void my32_XFreeDeviceMotionEvents(x64emu_t* emu, void* l)
{
int n=0;
my_XDeviceTimeCoord_32_t* src = l;
my_XDeviceTimeCoord_t* dst = l;
// search length first
while(src[n].time || src[n].data) ++n;
for(int i=n; i>=0; --i) {
dst[i].data = from_ptrv(src[i].data);
dst[i].time = from_ulong(src[i].time);
}
my->XFreeDeviceMotionEvents(l);
}
EXPORT int my32_XGrabDevice(x64emu_t* emu, void* dpy, void* d, XID w, int owner, int count, void* evt, int this_mode, int other_modes, unsigned long time)
{
int ret = my->XGrabDevice(dpy, inplace_XDevice_enlarge(d), w, owner, count, evt, this_mode, other_modes, time);
inplace_XDevice_shrink(d);
return ret;
}
#include "wrappedlib_init32.h"
|