aboutsummaryrefslogtreecommitdiffstats
diff options
context:
space:
mode:
authorHenrik Rydberg <rydberg@alnilam.(none)>2010-02-01 22:03:33 +0100
committerHenrik Rydberg <rydberg@alnilam.(none)>2010-02-01 22:03:33 +0100
commitf0b1dbdc00bda57c62199cbdc44acbadbb1121b0 (patch)
tree5234055bf794c28662b139c22e153f7a720a37bc
parent30869603dc5d36ad2d82cff82900c7e05a4b35c1 (diff)
downloadxorg-input-kobomultitouch-f0b1dbdc00bda57c62199cbdc44acbadbb1121b0.tar.gz
xorg-input-kobomultitouch-f0b1dbdc00bda57c62199cbdc44acbadbb1121b0.tar.bz2
xorg-input-kobomultitouch-f0b1dbdc00bda57c62199cbdc44acbadbb1121b0.zip
janitor: stick to kernel-style formatting
With this commit, the whole code base complies with the kernel format style, and patches can be checked against the kernel-provided ./scripts/checkpatch.pl
-rw-r--r--src/capabilities.c16
-rw-r--r--src/capabilities.h18
-rw-r--r--src/common.h8
-rw-r--r--src/gestures.c3
-rw-r--r--src/gestures.h11
-rw-r--r--src/hwdata.c10
-rw-r--r--src/hwdata.h14
-rw-r--r--src/iobuffer.c8
-rw-r--r--src/iobuffer.h8
-rw-r--r--src/mtouch.c20
-rw-r--r--src/mtouch.h8
-rw-r--r--src/multitouch.c97
-rw-r--r--src/state.c37
-rw-r--r--src/state.h14
-rw-r--r--src/test.c2
15 files changed, 73 insertions, 201 deletions
diff --git a/src/capabilities.c b/src/capabilities.c
index 201c127..cdd05c5 100644
--- a/src/capabilities.c
+++ b/src/capabilities.c
@@ -21,15 +21,11 @@
#include "capabilities.h"
-////////////////////////////////////////////////////////
-
#define SETABS(c, x, map, key, fd) \
- c->has_##x = getbit(map, key) && getabs(&c->abs_##x, key, fd)
+ (c->has_##x = getbit(map, key) && getabs(&c->abs_##x, key, fd))
#define ADDCAP(s, c, x) strcat(s, c->has_##x ? " " #x : "")
-////////////////////////////////////////////////////////
-
static const int bits_per_long = 8 * sizeof(long);
static inline int nlongs(int nbit)
@@ -37,20 +33,18 @@ static inline int nlongs(int nbit)
return (nbit + bits_per_long - 1) / bits_per_long;
}
-static inline bool getbit(const unsigned long* map, int key)
+static inline int getbit(const unsigned long *map, int key)
{
return (map[key / bits_per_long] >> (key % bits_per_long)) & 0x01;
}
-static bool getabs(struct input_absinfo *abs, int key, int fd)
+static int getabs(struct input_absinfo *abs, int key, int fd)
{
int rc;
SYSCALL(rc = ioctl(fd, EVIOCGABS(key), abs));
return rc >= 0;
}
-////////////////////////////////////////////////////////
-
int read_capabilities(struct Capabilities *cap, int fd)
{
unsigned long evbits[nlongs(EV_MAX)];
@@ -87,8 +81,6 @@ int read_capabilities(struct Capabilities *cap, int fd)
return 0;
}
-////////////////////////////////////////////////////////
-
void output_capabilities(const struct Capabilities *cap)
{
char line[1024];
@@ -126,5 +118,3 @@ void output_capabilities(const struct Capabilities *cap)
cap->abs_position_y.minimum,
cap->abs_position_y.maximum);
}
-
-////////////////////////////////////////////////////////
diff --git a/src/capabilities.h b/src/capabilities.h
index 63dada5..66ce29b 100644
--- a/src/capabilities.h
+++ b/src/capabilities.h
@@ -24,15 +24,13 @@
#include "common.h"
-////////////////////////////////////////////////////////
-
struct Capabilities {
- bool has_left, has_middle;
- bool has_right, has_mtdata;
- bool has_touch_major, has_touch_minor;
- bool has_width_major, has_width_minor;
- bool has_orientation, has_dummy;
- bool has_position_x, has_position_y;
+ int has_left, has_middle;
+ int has_right, has_mtdata;
+ int has_touch_major, has_touch_minor;
+ int has_width_major, has_width_minor;
+ int has_orientation, has_dummy;
+ int has_position_x, has_position_y;
struct input_absinfo abs_touch_major;
struct input_absinfo abs_touch_minor;
struct input_absinfo abs_width_major;
@@ -42,11 +40,7 @@ struct Capabilities {
struct input_absinfo abs_position_y;
};
-////////////////////////////////////////////////////////
-
int read_capabilities(struct Capabilities *cap, int fd);
void output_capabilities(const struct Capabilities *cap);
-////////////////////////////////////////////////////////
-
#endif
diff --git a/src/common.h b/src/common.h
index b1c3273..f64e114 100644
--- a/src/common.h
+++ b/src/common.h
@@ -30,9 +30,7 @@
#include <errno.h>
#include <match/match.h>
-////////////////////////////////////////////////////////
-
-// includes available in 2.6.30-rc5
+/* includes available in 2.6.30-rc5 */
#ifndef BTN_TOOL_QUADTAP
#define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */
@@ -50,8 +48,6 @@
#define MT_TOOL_PEN 1
#endif
-////////////////////////////////////////////////////////
-
#define SYSCALL(call) while (((call) == -1) && (errno == EINTR))
#define BITMASK(x) (1U << (x))
@@ -60,6 +56,4 @@
#define SETBIT(m, x) (m |= BITMASK(x))
#define CLEARBIT(m, x) (m &= ~BITMASK(x))
-////////////////////////////////////////////////////////
-
#endif
diff --git a/src/gestures.c b/src/gestures.c
index 0b0ba1d..2390d35 100644
--- a/src/gestures.c
+++ b/src/gestures.c
@@ -34,7 +34,8 @@ void extract_gestures(struct Gestures *gs, struct MTouch* mt)
memset(gs, 0, sizeof(struct Gestures));
if (nof == nsf) {
for (p = b; p != e; p++) {
- if (fs = find_finger(&mt->os, p->id)) {
+ fs = find_finger(&mt->os, p->id);
+ if (fs) {
gs->dx += p->hw.position_x - fs->hw.position_x;
gs->dy += p->hw.position_y - fs->hw.position_y;
dn++;
diff --git a/src/gestures.h b/src/gestures.h
index 0e2a49e..0428195 100644
--- a/src/gestures.h
+++ b/src/gestures.h
@@ -24,25 +24,16 @@
#include "mtouch.h"
-////////////////////////////////////////////////////////
-
#define GS_BUTTON 0
#define GS_MOVE 1
#define GS_VSCROLL 2
#define GS_HSCROLL 3
-////////////////////////////////////////////////////////
-
struct Gestures {
- unsigned type;
+ unsigned type, btmask, btdata;
int dx, dy;
- button_t btmask, btdata;
};
-////////////////////////////////////////////////////////
-
void extract_gestures(struct Gestures *gs, struct MTouch* mt);
-////////////////////////////////////////////////////////
-
#endif
diff --git a/src/hwdata.c b/src/hwdata.c
index 3b7c41c..bd42710 100644
--- a/src/hwdata.c
+++ b/src/hwdata.c
@@ -21,16 +21,12 @@
#include "hwdata.h"
-/******************************************************/
-
void init_hwdata(struct HWData *hw)
{
memset(hw, 0, sizeof(struct HWData));
}
-/******************************************************/
-
-bool read_hwdata(struct HWData *hw, const struct input_event* ev)
+int read_hwdata(struct HWData *hw, const struct input_event* ev)
{
switch (ev->type) {
case EV_SYN:
@@ -97,10 +93,6 @@ bool read_hwdata(struct HWData *hw, const struct input_event* ev)
return 0;
}
-/******************************************************/
-
void output_hwdata(const struct HWData *hw)
{
}
-
-/******************************************************/
diff --git a/src/hwdata.h b/src/hwdata.h
index d552b1b..9b46073 100644
--- a/src/hwdata.h
+++ b/src/hwdata.h
@@ -34,10 +34,6 @@
#define MT_BUTTON_HWHEEL_LEFT 5
#define MT_BUTTON_HWHEEL_RIGHT 6
-typedef unsigned int button_t;
-
-////////////////////////////////////////////////////////
-
struct FingerData {
int touch_major, touch_minor;
int width_major, width_minor;
@@ -45,20 +41,14 @@ struct FingerData {
int position_x, position_y;
};
-////////////////////////////////////////////////////////
-
struct HWData {
struct FingerData finger[DIM_FINGER];
- button_t button;
+ unsigned button;
int nfinger, nread;
};
-////////////////////////////////////////////////////////
-
void init_hwdata(struct HWData *hw);
-bool read_hwdata(struct HWData *hw, const struct input_event* ev);
+int read_hwdata(struct HWData *hw, const struct input_event* ev);
void output_hwdata(const struct HWData *hw);
-////////////////////////////////////////////////////////
-
#endif
diff --git a/src/iobuffer.c b/src/iobuffer.c
index 54955d6..35b61e9 100644
--- a/src/iobuffer.c
+++ b/src/iobuffer.c
@@ -21,8 +21,6 @@
#include "iobuffer.h"
-////////////////////////////////////////////////////////
-
void init_iobuf(struct IOBuffer *buf)
{
memset(buf, 0, sizeof(struct IOBuffer));
@@ -31,9 +29,7 @@ void init_iobuf(struct IOBuffer *buf)
buf->end = buf->begin + DIM_BUFFER;
}
-////////////////////////////////////////////////////////
-
-const struct input_event* get_iobuf_event(struct IOBuffer *buf, int fd)
+const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd)
{
const struct input_event *ev;
int n = buf->top - buf->at;
@@ -56,5 +52,3 @@ const struct input_event* get_iobuf_event(struct IOBuffer *buf, int fd)
buf->at += EVENT_SIZE;
return ev;
}
-
-////////////////////////////////////////////////////////
diff --git a/src/iobuffer.h b/src/iobuffer.h
index 05f412c..2e3d0c8 100644
--- a/src/iobuffer.h
+++ b/src/iobuffer.h
@@ -28,17 +28,11 @@
#define DIM_EVENTS 64
#define DIM_BUFFER (DIM_EVENTS * EVENT_SIZE)
-////////////////////////////////////////////////////////
-
struct IOBuffer {
char begin[DIM_BUFFER], *at, *top, *end;
};
-////////////////////////////////////////////////////////
-
void init_iobuf(struct IOBuffer *buf);
-const struct input_event* get_iobuf_event(struct IOBuffer *buf, int fd);
-
-////////////////////////////////////////////////////////
+const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd);
#endif
diff --git a/src/mtouch.c b/src/mtouch.c
index 5cb84fe..f7ffb12 100644
--- a/src/mtouch.c
+++ b/src/mtouch.c
@@ -21,8 +21,6 @@
#include "mtouch.h"
-/******************************************************/
-
int configure_mtouch(struct MTouch *mt, int fd)
{
int rc = read_capabilities(&mt->caps, fd);
@@ -32,8 +30,6 @@ int configure_mtouch(struct MTouch *mt, int fd)
return 0;
}
-/******************************************************/
-
int open_mtouch(struct MTouch *mt, int fd)
{
int rc;
@@ -45,8 +41,6 @@ int open_mtouch(struct MTouch *mt, int fd)
return rc;
}
-/******************************************************/
-
int close_mtouch(struct MTouch *mt, int fd)
{
int rc;
@@ -54,22 +48,16 @@ int close_mtouch(struct MTouch *mt, int fd)
return rc;
}
-/******************************************************/
-
-bool read_synchronized_event(struct MTouch *mt, int fd)
+int read_synchronized_event(struct MTouch *mt, int fd)
{
- const struct input_event* ev;
- while(ev = get_iobuf_event(&mt->buf, fd))
+ const struct input_event *ev;
+ while (ev = get_iobuf_event(&mt->buf, fd))
if (read_hwdata(&mt->hw, ev))
- return 1;
+ return 1;
return 0;
}
-/******************************************************/
-
void parse_event(struct MTouch *mt)
{
modify_state(&mt->ns, &mt->hw, &mt->caps);
}
-
-/******************************************************/
diff --git a/src/mtouch.h b/src/mtouch.h
index 900d825..753a400 100644
--- a/src/mtouch.h
+++ b/src/mtouch.h
@@ -27,8 +27,6 @@
#include "hwdata.h"
#include "state.h"
-////////////////////////////////////////////////////////
-
struct MTouch {
struct Capabilities caps;
struct IOBuffer buf;
@@ -36,15 +34,11 @@ struct MTouch {
struct State os, ns;
};
-////////////////////////////////////////////////////////
-
int configure_mtouch(struct MTouch *mt, int fd);
int open_mtouch(struct MTouch *mt, int fd);
int close_mtouch(struct MTouch *mt, int fd);
-bool read_synchronized_event(struct MTouch *mt, int fd);
+int read_synchronized_event(struct MTouch *mt, int fd);
void parse_event(struct MTouch *mt);
-////////////////////////////////////////////////////////
-
#endif
diff --git a/src/multitouch.c b/src/multitouch.c
index acaeea1..2919b9d 100644
--- a/src/multitouch.c
+++ b/src/multitouch.c
@@ -26,13 +26,11 @@
#include <xserver-properties.h>
#endif
-////////////////////////////////////////////////////////////////////////////
-
-// these should be user-configurable at some point
+/* these should be user-configurable at some point */
static const float vscroll_fraction = 0.05;
static const float hscroll_fraction = 0.2;
-// flip these to enable event debugging
+/* flip these to enable event debugging */
#if 1
#define TRACE1(format, arg1)
#define TRACE2(format, arg1, arg2)
@@ -41,18 +39,14 @@ static const float hscroll_fraction = 0.2;
#define TRACE2(format, arg1, arg2) xf86Msg(X_INFO, format, arg1, arg2)
#endif
-// button mapping simplified
+/* button mapping simplified */
#define PROPMAP(m, x, y) m[x] = XIGetKnownProperty(y)
-////////////////////////////////////////////////////////////////////////////
-
static void pointer_control(DeviceIntPtr dev, PtrCtrl *ctrl)
{
xf86Msg(X_INFO, "pointer_control\n");
}
-////////////////////////////////////////////////////////////////////////////
-
static int pointer_property(DeviceIntPtr dev,
Atom property,
XIPropertyValuePtr prop,
@@ -62,36 +56,34 @@ static int pointer_property(DeviceIntPtr dev,
return Success;
}
-////////////////////////////////////////////////////////////////////////////
-
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
static void initAxesLabels(Atom map[2])
{
- memset(map, 0, 2 * sizeof(Atom));
- PROPMAP(map, 0, AXIS_LABEL_PROP_REL_X);
- PROPMAP(map, 1, AXIS_LABEL_PROP_REL_Y);
+ memset(map, 0, 2 * sizeof(Atom));
+ PROPMAP(map, 0, AXIS_LABEL_PROP_REL_X);
+ PROPMAP(map, 1, AXIS_LABEL_PROP_REL_Y);
}
static void initButtonLabels(Atom map[DIM_BUTTON])
{
- memset(map, 0, DIM_BUTTON * sizeof(Atom));
- PROPMAP(map, MT_BUTTON_LEFT, BTN_LABEL_PROP_BTN_LEFT);
- PROPMAP(map, MT_BUTTON_MIDDLE, BTN_LABEL_PROP_BTN_MIDDLE);
- PROPMAP(map, MT_BUTTON_RIGHT, BTN_LABEL_PROP_BTN_RIGHT);
- PROPMAP(map, MT_BUTTON_WHEEL_UP, BTN_LABEL_PROP_BTN_WHEEL_UP);
- PROPMAP(map, MT_BUTTON_WHEEL_DOWN, BTN_LABEL_PROP_BTN_WHEEL_DOWN);
- PROPMAP(map, MT_BUTTON_HWHEEL_LEFT, BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
- PROPMAP(map, MT_BUTTON_HWHEEL_RIGHT, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
+ memset(map, 0, DIM_BUTTON * sizeof(Atom));
+ PROPMAP(map, MT_BUTTON_LEFT, BTN_LABEL_PROP_BTN_LEFT);
+ PROPMAP(map, MT_BUTTON_MIDDLE, BTN_LABEL_PROP_BTN_MIDDLE);
+ PROPMAP(map, MT_BUTTON_RIGHT, BTN_LABEL_PROP_BTN_RIGHT);
+ PROPMAP(map, MT_BUTTON_WHEEL_UP, BTN_LABEL_PROP_BTN_WHEEL_UP);
+ PROPMAP(map, MT_BUTTON_WHEEL_DOWN, BTN_LABEL_PROP_BTN_WHEEL_DOWN);
+ PROPMAP(map, MT_BUTTON_HWHEEL_LEFT, BTN_LABEL_PROP_BTN_HWHEEL_LEFT);
+ PROPMAP(map, MT_BUTTON_HWHEEL_RIGHT, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT);
}
#endif
static int device_init(DeviceIntPtr dev, LocalDevicePtr local)
{
struct MTouch *mt = local->private;
- unsigned char btmap[DIM_BUTTON + 1]={0,1,2,3,4,5,6,7};
+ unsigned char btmap[DIM_BUTTON + 1] = { 0, 1, 2, 3, 4, 5, 6, 7 };
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
Atom axes_labels[2], btn_labels[DIM_BUTTON];
- initAxesLabels(axes_labels);
+ initAxesLabels(axes_labels);
initButtonLabels(btn_labels);
#endif
@@ -131,7 +123,7 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local)
xf86InitValuatorAxisStruct(dev, 0,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
- axes_labels[0],
+ axes_labels[0],
#endif
mt->caps.abs_position_x.minimum,
mt->caps.abs_position_x.maximum,
@@ -139,7 +131,7 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local)
xf86InitValuatorDefaults(dev, 0);
xf86InitValuatorAxisStruct(dev, 1,
#if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7
- axes_labels[1],
+ axes_labels[1],
#endif
mt->caps.abs_position_y.minimum,
mt->caps.abs_position_y.maximum,
@@ -151,8 +143,6 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local)
return Success;
}
-////////////////////////////////////////////////////////////////////////////
-
static int device_on(LocalDevicePtr local)
{
struct MTouch *mt = local->private;
@@ -169,54 +159,45 @@ static int device_on(LocalDevicePtr local)
return Success;
}
-////////////////////////////////////////////////////////////////////////////
-
static int device_off(LocalDevicePtr local)
{
struct MTouch *mt = local->private;
xf86RemoveEnabledDevice(local);
- if(close_mtouch(mt, local->fd)) {
+ if (close_mtouch(mt, local->fd))
xf86Msg(X_WARNING, "multitouch: cannot ungrab device\n");
- }
xf86CloseSerial(local->fd);
return Success;
}
-////////////////////////////////////////////////////////////////////////////
-
static int device_close(LocalDevicePtr local)
{
return Success;
}
-////////////////////////////////////////////////////////////////////////////
-
static void tickle_button(LocalDevicePtr local, int id)
{
xf86PostButtonEvent(local->dev, FALSE, id, 1, 0, 0);
xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0);
}
-////////////////////////////////////////////////////////////////////////////
-
static void handle_gestures(LocalDevicePtr local,
const struct Gestures *gs,
const struct Capabilities *caps)
{
static int vscroll, hscroll;
- int vstep = 1 +
- vscroll_fraction * (caps->abs_position_y.maximum -
- caps->abs_position_y.minimum);
- int hstep = 1 +
- hscroll_fraction * (caps->abs_position_x.maximum -
- caps->abs_position_x.minimum);
- int i;
- for (i = 0; i < DIM_BUTTON; i++) {
- if (GETBIT(gs->btmask, i)) {
- xf86PostButtonEvent(local->dev, FALSE,
- i + 1, GETBIT(gs->btdata, i), 0, 0);
- TRACE2("button bit: %d %d\n", i, GETBIT(gs->btdata, i));
- }
+ int vstep = 1 +
+ vscroll_fraction * (caps->abs_position_y.maximum -
+ caps->abs_position_y.minimum);
+ int hstep = 1 +
+ hscroll_fraction * (caps->abs_position_x.maximum -
+ caps->abs_position_x.minimum);
+ int i;
+ for (i = 0; i < DIM_BUTTON; i++) {
+ if (GETBIT(gs->btmask, i)) {
+ xf86PostButtonEvent(local->dev, FALSE,
+ i + 1, GETBIT(gs->btdata, i), 0, 0);
+ TRACE2("button bit: %d %d\n", i, GETBIT(gs->btdata, i));
+ }
}
if (GETBIT(gs->type, GS_MOVE)) {
xf86PostMotionEvent(local->dev, 0, 0, 2,
@@ -249,8 +230,6 @@ static void handle_gestures(LocalDevicePtr local,
}
}
-////////////////////////////////////////////////////////////////////////////
-
/* called for each full received packet from the touchpad */
static void read_input(LocalDevicePtr local)
{
@@ -263,8 +242,6 @@ static void read_input(LocalDevicePtr local)
}
}
-////////////////////////////////////////////////////////////////////////////
-
static Bool device_control(DeviceIntPtr dev, int mode)
{
LocalDevicePtr local = dev->public.devicePrivate;
@@ -288,8 +265,6 @@ static Bool device_control(DeviceIntPtr dev, int mode)
}
-////////////////////////////////////////////////////////////////////////////
-
static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags)
{
struct MTouch *mt;
@@ -309,7 +284,7 @@ static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags)
local->conf_idev = dev;
xf86CollectInputOptions(local, NULL, NULL);
- //xf86OptionListReport(local->options);
+ /* xf86OptionListReport(local->options); */
xf86ProcessCommonOptions(local, local->options);
local->flags |= XI86_CONFIGURED;
@@ -320,12 +295,10 @@ static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags)
static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags)
{
xfree(local->private);
- local->private = 0;
+ local->private = 0;
xf86DeleteInput(local, 0);
}
-////////////////////////////////////////////////////////////////////////////
-
static InputDriverRec MULTITOUCH = {
1,
"multitouch",
@@ -356,5 +329,3 @@ static pointer setup(pointer module, pointer options, int *errmaj, int *errmin)
}
XF86ModuleData multitouchModuleData = {&VERSION, &setup, NULL };
-
-////////////////////////////////////////////////////////////////////////////
diff --git a/src/state.c b/src/state.c
index 4c8370f..5387828 100644
--- a/src/state.c
+++ b/src/state.c
@@ -26,21 +26,17 @@
const double FTW = 0.05;
const double FTS = 0.05;
-/******************************************************/
-
void init_state(struct State *s)
{
memset(s, 0, sizeof(struct State));
}
-/******************************************************/
-
-static int fincmp(const void* a,const void* b)
+static int fincmp(const void *a, const void *b)
{
return ((struct FingerState *)a)->id - ((struct FingerState *)b)->id;
}
-inline float dist2(const struct FingerData* a,const struct FingerData* b)
+inline float dist2(const struct FingerData *a, const struct FingerData *b)
{
float dx = a->position_x - b->position_x;
float dy = a->position_y - b->position_y;
@@ -48,9 +44,9 @@ inline float dist2(const struct FingerData* a,const struct FingerData* b)
return dx * dx + dy * dy;
}
-static void set_finger(struct FingerState* fs,
- const struct FingerData* hw, int id,
- const struct Capabilities* caps)
+static void set_finger(struct FingerState *fs,
+ const struct FingerData *hw, int id,
+ const struct Capabilities *caps)
{
fs->hw = *hw;
fs->id = id;
@@ -60,8 +56,8 @@ static void set_finger(struct FingerState* fs,
fs->hw.width_minor = hw->width_major;
}
-static bool touching_finger(const struct FingerData* hw,
- const struct Capabilities* caps)
+static int touching_finger(const struct FingerData *hw,
+ const struct Capabilities *caps)
{
if (caps->has_touch_major && caps->has_width_major)
return hw->width_major > 0 &&
@@ -71,11 +67,9 @@ static bool touching_finger(const struct FingerData* hw,
return 1;
}
-/******************************************************/
-
void modify_state(struct State *s,
- const struct HWData* hw,
- const struct Capabilities* caps)
+ const struct HWData *hw,
+ const struct Capabilities *caps)
{
float A[DIM2_FINGER], *row;
int sid[DIM_FINGER], hw2s[DIM_FINGER];
@@ -97,8 +91,9 @@ void modify_state(struct State *s,
id = sk >= 0 ? sid[sk] : 0;
if (!touching_finger(&hw->finger[hwk], caps))
id = 0;
- else while (!id)
- id = ++s->lastid;
+ else
+ while (!id)
+ id = ++s->lastid;
set_finger(&s->finger[hwk], &hw->finger[hwk], id, caps);
}
@@ -109,8 +104,6 @@ void modify_state(struct State *s,
qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp);
}
-/******************************************************/
-
const struct FingerState *find_finger(const struct State *s, int id)
{
int i;
@@ -124,8 +117,6 @@ const struct FingerState *find_finger(const struct State *s, int id)
return NULL;
}
-/******************************************************/
-
int count_fingers(const struct State *s)
{
int i, n = 0;
@@ -135,8 +126,6 @@ int count_fingers(const struct State *s)
return n;
}
-/******************************************************/
-
void output_state(const struct State *s)
{
int i;
@@ -159,5 +148,3 @@ void output_state(const struct State *s)
s->finger[i].hw.position_y);
}
}
-
-/******************************************************/
diff --git a/src/state.h b/src/state.h
index d8e096a..340803a 100644
--- a/src/state.h
+++ b/src/state.h
@@ -25,34 +25,26 @@
#include "capabilities.h"
#include "hwdata.h"
-////////////////////////////////////////////////////////
-
/* zero id means not mapped (not touching) */
struct FingerState {
struct FingerData hw;
int id;
};
-////////////////////////////////////////////////////////
-
struct State {
struct FingerState finger[DIM_FINGER];
- button_t button;
+ unsigned button;
int nfinger;
int lastid;
};
-////////////////////////////////////////////////////////
-
void init_state(struct State *s);
void modify_state(struct State *s,
- const struct HWData* hw,
- const struct Capabilities* caps);
+ const struct HWData *hw,
+ const struct Capabilities *caps);
void output_state(const struct State *s);
const struct FingerState *find_finger(const struct State *s, int id);
int count_fingers(const struct State *s);
-////////////////////////////////////////////////////////
-
#endif
diff --git a/src/test.c b/src/test.c
index 82e30e6..e9b8ce3 100644
--- a/src/test.c
+++ b/src/test.c
@@ -22,7 +22,7 @@
#include <stdio.h>
#include <time.h>
-int main(int argc,char* argv[])
+int main(int argc, char *argv[])
{
return 0;
}