mirror of
https://github.com/m1k1o/neko.git
synced 2024-07-24 14:40:50 +12:00
xf86-input-neko: extract init touch to own func.
This commit is contained in:
parent
d82b640ecc
commit
6f61e0262a
@ -56,9 +56,8 @@
|
||||
#include <xserver-properties.h>
|
||||
#include <pthread.h>
|
||||
|
||||
#define MAXBUTTONS 11 /* > 10 */
|
||||
#define TOUCH_NUM_AXES 3 /* x, y, pressure */
|
||||
#define TOUCH_MAX_SLOTS 10
|
||||
#define MAX_USED_VALUATORS 3 /* x, y, pressure */
|
||||
#define TOUCH_MAX_SLOTS 10 /* max number of simultaneous touches */
|
||||
|
||||
struct neko_message
|
||||
{
|
||||
@ -176,41 +175,38 @@ PointerCtrl(__attribute__ ((unused)) DeviceIntPtr device,
|
||||
}
|
||||
|
||||
static int
|
||||
DeviceControl(DeviceIntPtr device, int what)
|
||||
InitTouch(InputInfoPtr pInfo)
|
||||
{
|
||||
// device pInfo
|
||||
InputInfoPtr pInfo = device->public.devicePrivate;
|
||||
// custom private data
|
||||
struct neko_priv *priv = pInfo->private;
|
||||
|
||||
switch (what) {
|
||||
case DEVICE_INIT:
|
||||
device->public.on = FALSE;
|
||||
const int nbtns = 11;
|
||||
const int naxes = 3;
|
||||
|
||||
unsigned char map[MAXBUTTONS + 1];
|
||||
Atom labels[MAXBUTTONS];
|
||||
Atom axis_labels[TOUCH_NUM_AXES];
|
||||
unsigned char map[nbtns + 1];
|
||||
Atom btn_labels[nbtns];
|
||||
Atom axis_labels[naxes];
|
||||
|
||||
// init button map
|
||||
memset(map, 0, sizeof(map));
|
||||
for (int i = 0; i < MAXBUTTONS; i++)
|
||||
for (int i = 0; i < nbtns; i++)
|
||||
{
|
||||
map[i + 1] = i + 1;
|
||||
}
|
||||
|
||||
// init labels
|
||||
memset(labels, 0, ARRAY_SIZE(labels) * sizeof(Atom));
|
||||
labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
|
||||
labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
|
||||
labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
|
||||
labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
|
||||
labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
|
||||
labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
|
||||
labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
|
||||
labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_SIDE);
|
||||
labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_EXTRA);
|
||||
labels[9] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_FORWARD);
|
||||
labels[10] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_BACK);
|
||||
// init btn_labels
|
||||
memset(btn_labels, 0, ARRAY_SIZE(btn_labels) * sizeof(Atom));
|
||||
btn_labels[0] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_LEFT);
|
||||
btn_labels[1] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_MIDDLE);
|
||||
btn_labels[2] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_RIGHT);
|
||||
btn_labels[3] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_UP);
|
||||
btn_labels[4] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_WHEEL_DOWN);
|
||||
btn_labels[5] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
|
||||
btn_labels[6] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
|
||||
btn_labels[7] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_SIDE);
|
||||
btn_labels[8] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_EXTRA);
|
||||
btn_labels[9] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_FORWARD);
|
||||
btn_labels[10] = XIGetKnownProperty(BTN_LABEL_PROP_BTN_BACK);
|
||||
|
||||
// init axis labels
|
||||
memset(axis_labels, 0, ARRAY_SIZE(axis_labels) * sizeof(Atom));
|
||||
@ -219,12 +215,12 @@ DeviceControl(DeviceIntPtr device, int what)
|
||||
axis_labels[2] = XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_PRESSURE);
|
||||
|
||||
/* initialize mouse emulation valuators */
|
||||
if (InitPointerDeviceStruct((DevicePtr)device,
|
||||
if (InitPointerDeviceStruct((DevicePtr)pInfo->dev,
|
||||
map,
|
||||
MAXBUTTONS, labels,
|
||||
nbtns, btn_labels,
|
||||
PointerCtrl,
|
||||
GetMotionHistorySize(),
|
||||
TOUCH_NUM_AXES, axis_labels) == FALSE)
|
||||
naxes, axis_labels) == FALSE)
|
||||
{
|
||||
xf86IDrvMsg(pInfo, X_ERROR,
|
||||
"unable to allocate PointerDeviceStruct\n");
|
||||
@ -251,7 +247,7 @@ DeviceControl(DeviceIntPtr device, int what)
|
||||
int maxval;
|
||||
int resolution;
|
||||
*/
|
||||
xf86InitValuatorAxisStruct(device, 0,
|
||||
xf86InitValuatorAxisStruct(pInfo->dev, 0,
|
||||
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_X),
|
||||
0, /* min val */
|
||||
priv->width - 1, /* max val */
|
||||
@ -260,7 +256,7 @@ DeviceControl(DeviceIntPtr device, int what)
|
||||
priv->width, /* max_res */
|
||||
Absolute);
|
||||
|
||||
xf86InitValuatorAxisStruct(device, 1,
|
||||
xf86InitValuatorAxisStruct(pInfo->dev, 1,
|
||||
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_POSITION_Y),
|
||||
0, /* min val */
|
||||
priv->height - 1, /* max val */
|
||||
@ -269,7 +265,7 @@ DeviceControl(DeviceIntPtr device, int what)
|
||||
priv->height, /* max_res */
|
||||
Absolute);
|
||||
|
||||
xf86InitValuatorAxisStruct(device, 2,
|
||||
xf86InitValuatorAxisStruct(pInfo->dev, 2,
|
||||
XIGetKnownProperty(AXIS_LABEL_PROP_ABS_MT_PRESSURE),
|
||||
0, /* min val */
|
||||
priv->pmax, /* max val */
|
||||
@ -290,16 +286,36 @@ DeviceControl(DeviceIntPtr device, int what)
|
||||
simultaneous touches is undefined or unspecified. This field should be
|
||||
used as a guide only, devices will lie about their capabilities.
|
||||
*/
|
||||
if (InitTouchClassDeviceStruct(device,
|
||||
if (InitTouchClassDeviceStruct(pInfo->dev,
|
||||
priv->slots,
|
||||
XIDirectTouch,
|
||||
TOUCH_NUM_AXES) == FALSE)
|
||||
naxes) == FALSE)
|
||||
{
|
||||
xf86IDrvMsg(pInfo, X_ERROR,
|
||||
"unable to allocate TouchClassDeviceStruct\n");
|
||||
return !Success;
|
||||
}
|
||||
|
||||
return Success;
|
||||
}
|
||||
|
||||
static int
|
||||
DeviceControl(DeviceIntPtr device, int what)
|
||||
{
|
||||
// device pInfo
|
||||
InputInfoPtr pInfo = device->public.devicePrivate;
|
||||
// custom private data
|
||||
struct neko_priv *priv = pInfo->private;
|
||||
|
||||
switch (what) {
|
||||
case DEVICE_INIT:
|
||||
device->public.on = FALSE;
|
||||
|
||||
if (InitTouch(pInfo) != Success)
|
||||
{
|
||||
xf86IDrvMsg(pInfo, X_ERROR, "unable to init touch\n");
|
||||
return !Success;
|
||||
}
|
||||
break;
|
||||
|
||||
case DEVICE_ON:
|
||||
@ -402,7 +418,7 @@ PreInit(__attribute__ ((unused)) InputDriverPtr drv,
|
||||
xf86ProcessCommonOptions(pInfo, pInfo->options);
|
||||
|
||||
/* create valuators */
|
||||
priv->valuators = valuator_mask_new(TOUCH_NUM_AXES);
|
||||
priv->valuators = valuator_mask_new(MAX_USED_VALUATORS);
|
||||
if (!priv->valuators)
|
||||
{
|
||||
xf86IDrvMsg(pInfo, X_ERROR, "%s: out of memory\n", __FUNCTION__);
|
||||
|
Loading…
Reference in New Issue
Block a user