这是indexloc提供的服务,不要输入任何密码
Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
106 changes: 93 additions & 13 deletions app/src/main/cpp/lorie/InitInput.c
Original file line number Diff line number Diff line change
Expand Up @@ -31,23 +31,25 @@ from The Open Group.
#include "scrnintstr.h"
#include "inputstr.h"
#include <X11/Xos.h>
#include <android/log.h>
#include "mipointer.h"
#include "xkbsrv.h"
#include "xserver-properties.h"
#include "exevents.h"
#include "renderer.h"

#define unused __attribute__((unused))
#define XI_PEN "TERMUX-X11 PEN"
#define XI_ERASER "TERMUX-X11 ERASER"

unused DeviceIntPtr lorieMouse, lorieTouch, lorieKeyboard;
__unused DeviceIntPtr lorieMouse, lorieTouch, lorieKeyboard, loriePen, lorieEraser;

void
ProcessInputEvents(void) {
mieqProcessInputEvents();
}

void
DDXRingBell(unused int volume, unused int pitch, unused int duration) {}
DDXRingBell(__unused int volume, __unused int pitch, __unused int duration) {}

static int
lorieKeybdProc(DeviceIntPtr pDevice, int onoff) {
Expand All @@ -72,8 +74,7 @@ lorieKeybdProc(DeviceIntPtr pDevice, int onoff) {
}

static Bool
lorieInitPointerButtons(DeviceIntPtr device)
{
lorieInitPointerButtons(DeviceIntPtr device) {
#define NBUTTONS 10
BYTE map[NBUTTONS + 1];
int i;
Expand All @@ -98,9 +99,8 @@ lorieInitPointerButtons(DeviceIntPtr device)
#undef NBUTTONS
}

unused static int
lorieMouseProc(DeviceIntPtr device, int what)
{
__unused static int
lorieMouseProc(DeviceIntPtr device, int what) {
#define NAXES 4
Atom axes_labels[NAXES] = { 0 };

Expand Down Expand Up @@ -142,8 +142,7 @@ lorieMouseProc(DeviceIntPtr device, int what)
}

static int
lorieTouchProc(DeviceIntPtr device, int what)
{
lorieTouchProc(DeviceIntPtr device, int what) {
#define NTOUCHPOINTS 20
#define NBUTTONS 1
#define NAXES 2
Expand Down Expand Up @@ -185,8 +184,90 @@ lorieTouchProc(DeviceIntPtr device, int what)
#undef NTOUCHPOINTS
}

static int
lorieStylusProc(DeviceIntPtr device, int what) {
#define NBUTTONS 3
#define NAXES 6
Atom btn_labels[NBUTTONS] = { 0 };
Atom axes_labels[NAXES] = { 0 };
BYTE map[NBUTTONS + 1] = { 0 };
int i;

switch (what) {
case DEVICE_INIT:
device->public.on = FALSE;

for (i = 1; i <= NBUTTONS; i++)
map[i] = i;

axes_labels[0] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_X);
axes_labels[1] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_Y);
axes_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_PRESSURE);
axes_labels[3] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_X);
axes_labels[4] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_TILT_Y);
axes_labels[5] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_WHEEL);

/* Valuators - match the xf86-input-wacom ranges */
if (!InitValuatorClassDeviceStruct(device, NAXES, axes_labels, GetMotionHistorySize(), Absolute)
|| !InitValuatorAxisStruct(device, 0, axes_labels[0], 0, 0x3FFFF, 10000, 0, 10000, Absolute)
|| !InitValuatorAxisStruct(device, 1, axes_labels[1], 0, 0x3FFFF, 10000, 0, 10000, Absolute)
|| !InitValuatorAxisStruct(device, 2, axes_labels[2], 0, 0xFFFF, 1, 0, 1, Absolute) // pressure
|| !InitValuatorAxisStruct(device, 3, axes_labels[3], -64, 63, 57, 0, 57, Absolute) // tilt x
|| !InitValuatorAxisStruct(device, 4, axes_labels[4], -64, 63, 57, 0, 57, Absolute) // tilt y
|| !InitValuatorAxisStruct(device, 5, axes_labels[5], -900, 899, 1, 0, 1, Absolute) // abs wheel (airbrush) or rotation (artpen)
|| !InitPtrFeedbackClassDeviceStruct(device, (PtrCtrlProcPtr) NoopDDA)
|| !InitButtonClassDeviceStruct(device, NBUTTONS, btn_labels, map))
return BadValue;

return Success;

case DEVICE_ON:
device->public.on = TRUE;
return Success;

case DEVICE_OFF:
case DEVICE_CLOSE:
device->public.on = FALSE;
return Success;
}

return BadMatch;
#undef NAXES
#undef NBUTTONS
}

void
lorieSetStylusEnabled(Bool enabled) {
__android_log_print(ANDROID_LOG_DEBUG, "LorieNative", "Requested stylus: %d, current loriePen %p, current lorieEraser %p\n", enabled, loriePen, lorieEraser);
if (enabled) {
if (loriePen == NULL) {
loriePen = AddInputDevice(serverClient, lorieStylusProc, TRUE);
AssignTypeAndName(loriePen, MakeAtom(XI_PEN, sizeof(XI_PEN) - 1, TRUE), "Lorie pen");
ActivateDevice(loriePen, FALSE);
EnableDevice(loriePen, TRUE);
AttachDevice(NULL, loriePen, inputInfo.pointer);
}
if (lorieEraser == NULL) {
lorieEraser = AddInputDevice(serverClient, lorieStylusProc, TRUE);
AssignTypeAndName(lorieEraser, MakeAtom(XI_ERASER, sizeof(XI_ERASER) - 1, TRUE), "Lorie eraser");
ActivateDevice(lorieEraser, FALSE);
EnableDevice(lorieEraser, TRUE);
AttachDevice(NULL, lorieEraser, inputInfo.pointer);
}
} else {
if (loriePen != NULL) {
RemoveDevice(loriePen, TRUE);
loriePen = NULL;
}
if (lorieEraser != NULL) {
RemoveDevice(lorieEraser, TRUE);
lorieEraser = NULL;
}
}
}

void
InitInput(unused int argc, unused char *argv[]) {
InitInput(__unused int argc, __unused char *argv[]) {
lorieMouse = AddInputDevice(serverClient, lorieMouseProc, TRUE);
lorieTouch = AddInputDevice(serverClient, lorieTouchProc, TRUE);
lorieKeyboard = AddInputDevice(serverClient, lorieKeybdProc, TRUE);
Expand All @@ -197,7 +278,6 @@ InitInput(unused int argc, unused char *argv[]) {
}

void
CloseInput(void)
{
CloseInput(void) {
mieqFini();
}
Loading