diff options
Diffstat (limited to 'src')
| -rw-r--r-- | src/capabilities.c | 16 | ||||
| -rw-r--r-- | src/capabilities.h | 18 | ||||
| -rw-r--r-- | src/common.h | 8 | ||||
| -rw-r--r-- | src/gestures.c | 3 | ||||
| -rw-r--r-- | src/gestures.h | 11 | ||||
| -rw-r--r-- | src/hwdata.c | 10 | ||||
| -rw-r--r-- | src/hwdata.h | 14 | ||||
| -rw-r--r-- | src/iobuffer.c | 8 | ||||
| -rw-r--r-- | src/iobuffer.h | 8 | ||||
| -rw-r--r-- | src/mtouch.c | 20 | ||||
| -rw-r--r-- | src/mtouch.h | 8 | ||||
| -rw-r--r-- | src/multitouch.c | 97 | ||||
| -rw-r--r-- | src/state.c | 37 | ||||
| -rw-r--r-- | src/state.h | 14 | ||||
| -rw-r--r-- | src/test.c | 2 |
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 @@ | |||
| 21 | 21 | ||
| 22 | #include "capabilities.h" | 22 | #include "capabilities.h" |
| 23 | 23 | ||
| 24 | //////////////////////////////////////////////////////// | ||
| 25 | |||
| 26 | #define SETABS(c, x, map, key, fd) \ | 24 | #define SETABS(c, x, map, key, fd) \ |
| 27 | c->has_##x = getbit(map, key) && getabs(&c->abs_##x, key, fd) | 25 | (c->has_##x = getbit(map, key) && getabs(&c->abs_##x, key, fd)) |
| 28 | 26 | ||
| 29 | #define ADDCAP(s, c, x) strcat(s, c->has_##x ? " " #x : "") | 27 | #define ADDCAP(s, c, x) strcat(s, c->has_##x ? " " #x : "") |
| 30 | 28 | ||
| 31 | //////////////////////////////////////////////////////// | ||
| 32 | |||
| 33 | static const int bits_per_long = 8 * sizeof(long); | 29 | static const int bits_per_long = 8 * sizeof(long); |
| 34 | 30 | ||
| 35 | static inline int nlongs(int nbit) | 31 | static inline int nlongs(int nbit) |
| @@ -37,20 +33,18 @@ static inline int nlongs(int nbit) | |||
| 37 | return (nbit + bits_per_long - 1) / bits_per_long; | 33 | return (nbit + bits_per_long - 1) / bits_per_long; |
| 38 | } | 34 | } |
| 39 | 35 | ||
| 40 | static inline bool getbit(const unsigned long* map, int key) | 36 | static inline int getbit(const unsigned long *map, int key) |
| 41 | { | 37 | { |
| 42 | return (map[key / bits_per_long] >> (key % bits_per_long)) & 0x01; | 38 | return (map[key / bits_per_long] >> (key % bits_per_long)) & 0x01; |
| 43 | } | 39 | } |
| 44 | 40 | ||
| 45 | static bool getabs(struct input_absinfo *abs, int key, int fd) | 41 | static int getabs(struct input_absinfo *abs, int key, int fd) |
| 46 | { | 42 | { |
| 47 | int rc; | 43 | int rc; |
| 48 | SYSCALL(rc = ioctl(fd, EVIOCGABS(key), abs)); | 44 | SYSCALL(rc = ioctl(fd, EVIOCGABS(key), abs)); |
| 49 | return rc >= 0; | 45 | return rc >= 0; |
| 50 | } | 46 | } |
| 51 | 47 | ||
| 52 | //////////////////////////////////////////////////////// | ||
| 53 | |||
| 54 | int read_capabilities(struct Capabilities *cap, int fd) | 48 | int read_capabilities(struct Capabilities *cap, int fd) |
| 55 | { | 49 | { |
| 56 | unsigned long evbits[nlongs(EV_MAX)]; | 50 | unsigned long evbits[nlongs(EV_MAX)]; |
| @@ -87,8 +81,6 @@ int read_capabilities(struct Capabilities *cap, int fd) | |||
| 87 | return 0; | 81 | return 0; |
| 88 | } | 82 | } |
| 89 | 83 | ||
| 90 | //////////////////////////////////////////////////////// | ||
| 91 | |||
| 92 | void output_capabilities(const struct Capabilities *cap) | 84 | void output_capabilities(const struct Capabilities *cap) |
| 93 | { | 85 | { |
| 94 | char line[1024]; | 86 | char line[1024]; |
| @@ -126,5 +118,3 @@ void output_capabilities(const struct Capabilities *cap) | |||
| 126 | cap->abs_position_y.minimum, | 118 | cap->abs_position_y.minimum, |
| 127 | cap->abs_position_y.maximum); | 119 | cap->abs_position_y.maximum); |
| 128 | } | 120 | } |
| 129 | |||
| 130 | //////////////////////////////////////////////////////// | ||
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 @@ | |||
| 24 | 24 | ||
| 25 | #include "common.h" | 25 | #include "common.h" |
| 26 | 26 | ||
| 27 | //////////////////////////////////////////////////////// | ||
| 28 | |||
| 29 | struct Capabilities { | 27 | struct Capabilities { |
| 30 | bool has_left, has_middle; | 28 | int has_left, has_middle; |
| 31 | bool has_right, has_mtdata; | 29 | int has_right, has_mtdata; |
| 32 | bool has_touch_major, has_touch_minor; | 30 | int has_touch_major, has_touch_minor; |
| 33 | bool has_width_major, has_width_minor; | 31 | int has_width_major, has_width_minor; |
| 34 | bool has_orientation, has_dummy; | 32 | int has_orientation, has_dummy; |
| 35 | bool has_position_x, has_position_y; | 33 | int has_position_x, has_position_y; |
| 36 | struct input_absinfo abs_touch_major; | 34 | struct input_absinfo abs_touch_major; |
| 37 | struct input_absinfo abs_touch_minor; | 35 | struct input_absinfo abs_touch_minor; |
| 38 | struct input_absinfo abs_width_major; | 36 | struct input_absinfo abs_width_major; |
| @@ -42,11 +40,7 @@ struct Capabilities { | |||
| 42 | struct input_absinfo abs_position_y; | 40 | struct input_absinfo abs_position_y; |
| 43 | }; | 41 | }; |
| 44 | 42 | ||
| 45 | //////////////////////////////////////////////////////// | ||
| 46 | |||
| 47 | int read_capabilities(struct Capabilities *cap, int fd); | 43 | int read_capabilities(struct Capabilities *cap, int fd); |
| 48 | void output_capabilities(const struct Capabilities *cap); | 44 | void output_capabilities(const struct Capabilities *cap); |
| 49 | 45 | ||
| 50 | //////////////////////////////////////////////////////// | ||
| 51 | |||
| 52 | #endif | 46 | #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 @@ | |||
| 30 | #include <errno.h> | 30 | #include <errno.h> |
| 31 | #include <match/match.h> | 31 | #include <match/match.h> |
| 32 | 32 | ||
| 33 | //////////////////////////////////////////////////////// | 33 | /* includes available in 2.6.30-rc5 */ |
| 34 | |||
| 35 | // includes available in 2.6.30-rc5 | ||
| 36 | 34 | ||
| 37 | #ifndef BTN_TOOL_QUADTAP | 35 | #ifndef BTN_TOOL_QUADTAP |
| 38 | #define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ | 36 | #define BTN_TOOL_QUADTAP 0x14f /* Four fingers on trackpad */ |
| @@ -50,8 +48,6 @@ | |||
| 50 | #define MT_TOOL_PEN 1 | 48 | #define MT_TOOL_PEN 1 |
| 51 | #endif | 49 | #endif |
| 52 | 50 | ||
| 53 | //////////////////////////////////////////////////////// | ||
| 54 | |||
| 55 | #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) | 51 | #define SYSCALL(call) while (((call) == -1) && (errno == EINTR)) |
| 56 | 52 | ||
| 57 | #define BITMASK(x) (1U << (x)) | 53 | #define BITMASK(x) (1U << (x)) |
| @@ -60,6 +56,4 @@ | |||
| 60 | #define SETBIT(m, x) (m |= BITMASK(x)) | 56 | #define SETBIT(m, x) (m |= BITMASK(x)) |
| 61 | #define CLEARBIT(m, x) (m &= ~BITMASK(x)) | 57 | #define CLEARBIT(m, x) (m &= ~BITMASK(x)) |
| 62 | 58 | ||
| 63 | //////////////////////////////////////////////////////// | ||
| 64 | |||
| 65 | #endif | 59 | #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) | |||
| 34 | memset(gs, 0, sizeof(struct Gestures)); | 34 | memset(gs, 0, sizeof(struct Gestures)); |
| 35 | if (nof == nsf) { | 35 | if (nof == nsf) { |
| 36 | for (p = b; p != e; p++) { | 36 | for (p = b; p != e; p++) { |
| 37 | if (fs = find_finger(&mt->os, p->id)) { | 37 | fs = find_finger(&mt->os, p->id); |
| 38 | if (fs) { | ||
| 38 | gs->dx += p->hw.position_x - fs->hw.position_x; | 39 | gs->dx += p->hw.position_x - fs->hw.position_x; |
| 39 | gs->dy += p->hw.position_y - fs->hw.position_y; | 40 | gs->dy += p->hw.position_y - fs->hw.position_y; |
| 40 | dn++; | 41 | 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 @@ | |||
| 24 | 24 | ||
| 25 | #include "mtouch.h" | 25 | #include "mtouch.h" |
| 26 | 26 | ||
| 27 | //////////////////////////////////////////////////////// | ||
| 28 | |||
| 29 | #define GS_BUTTON 0 | 27 | #define GS_BUTTON 0 |
| 30 | #define GS_MOVE 1 | 28 | #define GS_MOVE 1 |
| 31 | #define GS_VSCROLL 2 | 29 | #define GS_VSCROLL 2 |
| 32 | #define GS_HSCROLL 3 | 30 | #define GS_HSCROLL 3 |
| 33 | 31 | ||
| 34 | //////////////////////////////////////////////////////// | ||
| 35 | |||
| 36 | struct Gestures { | 32 | struct Gestures { |
| 37 | unsigned type; | 33 | unsigned type, btmask, btdata; |
| 38 | int dx, dy; | 34 | int dx, dy; |
| 39 | button_t btmask, btdata; | ||
| 40 | }; | 35 | }; |
| 41 | 36 | ||
| 42 | //////////////////////////////////////////////////////// | ||
| 43 | |||
| 44 | void extract_gestures(struct Gestures *gs, struct MTouch* mt); | 37 | void extract_gestures(struct Gestures *gs, struct MTouch* mt); |
| 45 | 38 | ||
| 46 | //////////////////////////////////////////////////////// | ||
| 47 | |||
| 48 | #endif | 39 | #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 @@ | |||
| 21 | 21 | ||
| 22 | #include "hwdata.h" | 22 | #include "hwdata.h" |
| 23 | 23 | ||
| 24 | /******************************************************/ | ||
| 25 | |||
| 26 | void init_hwdata(struct HWData *hw) | 24 | void init_hwdata(struct HWData *hw) |
| 27 | { | 25 | { |
| 28 | memset(hw, 0, sizeof(struct HWData)); | 26 | memset(hw, 0, sizeof(struct HWData)); |
| 29 | } | 27 | } |
| 30 | 28 | ||
| 31 | /******************************************************/ | 29 | int read_hwdata(struct HWData *hw, const struct input_event* ev) |
| 32 | |||
| 33 | bool read_hwdata(struct HWData *hw, const struct input_event* ev) | ||
| 34 | { | 30 | { |
| 35 | switch (ev->type) { | 31 | switch (ev->type) { |
| 36 | case EV_SYN: | 32 | case EV_SYN: |
| @@ -97,10 +93,6 @@ bool read_hwdata(struct HWData *hw, const struct input_event* ev) | |||
| 97 | return 0; | 93 | return 0; |
| 98 | } | 94 | } |
| 99 | 95 | ||
| 100 | /******************************************************/ | ||
| 101 | |||
| 102 | void output_hwdata(const struct HWData *hw) | 96 | void output_hwdata(const struct HWData *hw) |
| 103 | { | 97 | { |
| 104 | } | 98 | } |
| 105 | |||
| 106 | /******************************************************/ | ||
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 @@ | |||
| 34 | #define MT_BUTTON_HWHEEL_LEFT 5 | 34 | #define MT_BUTTON_HWHEEL_LEFT 5 |
| 35 | #define MT_BUTTON_HWHEEL_RIGHT 6 | 35 | #define MT_BUTTON_HWHEEL_RIGHT 6 |
| 36 | 36 | ||
| 37 | typedef unsigned int button_t; | ||
| 38 | |||
| 39 | //////////////////////////////////////////////////////// | ||
| 40 | |||
| 41 | struct FingerData { | 37 | struct FingerData { |
| 42 | int touch_major, touch_minor; | 38 | int touch_major, touch_minor; |
| 43 | int width_major, width_minor; | 39 | int width_major, width_minor; |
| @@ -45,20 +41,14 @@ struct FingerData { | |||
| 45 | int position_x, position_y; | 41 | int position_x, position_y; |
| 46 | }; | 42 | }; |
| 47 | 43 | ||
| 48 | //////////////////////////////////////////////////////// | ||
| 49 | |||
| 50 | struct HWData { | 44 | struct HWData { |
| 51 | struct FingerData finger[DIM_FINGER]; | 45 | struct FingerData finger[DIM_FINGER]; |
| 52 | button_t button; | 46 | unsigned button; |
| 53 | int nfinger, nread; | 47 | int nfinger, nread; |
| 54 | }; | 48 | }; |
| 55 | 49 | ||
| 56 | //////////////////////////////////////////////////////// | ||
| 57 | |||
| 58 | void init_hwdata(struct HWData *hw); | 50 | void init_hwdata(struct HWData *hw); |
| 59 | bool read_hwdata(struct HWData *hw, const struct input_event* ev); | 51 | int read_hwdata(struct HWData *hw, const struct input_event* ev); |
| 60 | void output_hwdata(const struct HWData *hw); | 52 | void output_hwdata(const struct HWData *hw); |
| 61 | 53 | ||
| 62 | //////////////////////////////////////////////////////// | ||
| 63 | |||
| 64 | #endif | 54 | #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 @@ | |||
| 21 | 21 | ||
| 22 | #include "iobuffer.h" | 22 | #include "iobuffer.h" |
| 23 | 23 | ||
| 24 | //////////////////////////////////////////////////////// | ||
| 25 | |||
| 26 | void init_iobuf(struct IOBuffer *buf) | 24 | void init_iobuf(struct IOBuffer *buf) |
| 27 | { | 25 | { |
| 28 | memset(buf, 0, sizeof(struct IOBuffer)); | 26 | memset(buf, 0, sizeof(struct IOBuffer)); |
| @@ -31,9 +29,7 @@ void init_iobuf(struct IOBuffer *buf) | |||
| 31 | buf->end = buf->begin + DIM_BUFFER; | 29 | buf->end = buf->begin + DIM_BUFFER; |
| 32 | } | 30 | } |
| 33 | 31 | ||
| 34 | //////////////////////////////////////////////////////// | 32 | const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd) |
| 35 | |||
| 36 | const struct input_event* get_iobuf_event(struct IOBuffer *buf, int fd) | ||
| 37 | { | 33 | { |
| 38 | const struct input_event *ev; | 34 | const struct input_event *ev; |
| 39 | int n = buf->top - buf->at; | 35 | int n = buf->top - buf->at; |
| @@ -56,5 +52,3 @@ const struct input_event* get_iobuf_event(struct IOBuffer *buf, int fd) | |||
| 56 | buf->at += EVENT_SIZE; | 52 | buf->at += EVENT_SIZE; |
| 57 | return ev; | 53 | return ev; |
| 58 | } | 54 | } |
| 59 | |||
| 60 | //////////////////////////////////////////////////////// | ||
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 @@ | |||
| 28 | #define DIM_EVENTS 64 | 28 | #define DIM_EVENTS 64 |
| 29 | #define DIM_BUFFER (DIM_EVENTS * EVENT_SIZE) | 29 | #define DIM_BUFFER (DIM_EVENTS * EVENT_SIZE) |
| 30 | 30 | ||
| 31 | //////////////////////////////////////////////////////// | ||
| 32 | |||
| 33 | struct IOBuffer { | 31 | struct IOBuffer { |
| 34 | char begin[DIM_BUFFER], *at, *top, *end; | 32 | char begin[DIM_BUFFER], *at, *top, *end; |
| 35 | }; | 33 | }; |
| 36 | 34 | ||
| 37 | //////////////////////////////////////////////////////// | ||
| 38 | |||
| 39 | void init_iobuf(struct IOBuffer *buf); | 35 | void init_iobuf(struct IOBuffer *buf); |
| 40 | const struct input_event* get_iobuf_event(struct IOBuffer *buf, int fd); | 36 | const struct input_event *get_iobuf_event(struct IOBuffer *buf, int fd); |
| 41 | |||
| 42 | //////////////////////////////////////////////////////// | ||
| 43 | 37 | ||
| 44 | #endif | 38 | #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 @@ | |||
| 21 | 21 | ||
| 22 | #include "mtouch.h" | 22 | #include "mtouch.h" |
| 23 | 23 | ||
| 24 | /******************************************************/ | ||
| 25 | |||
| 26 | int configure_mtouch(struct MTouch *mt, int fd) | 24 | int configure_mtouch(struct MTouch *mt, int fd) |
| 27 | { | 25 | { |
| 28 | int rc = read_capabilities(&mt->caps, fd); | 26 | int rc = read_capabilities(&mt->caps, fd); |
| @@ -32,8 +30,6 @@ int configure_mtouch(struct MTouch *mt, int fd) | |||
| 32 | return 0; | 30 | return 0; |
| 33 | } | 31 | } |
| 34 | 32 | ||
| 35 | /******************************************************/ | ||
| 36 | |||
| 37 | int open_mtouch(struct MTouch *mt, int fd) | 33 | int open_mtouch(struct MTouch *mt, int fd) |
| 38 | { | 34 | { |
| 39 | int rc; | 35 | int rc; |
| @@ -45,8 +41,6 @@ int open_mtouch(struct MTouch *mt, int fd) | |||
| 45 | return rc; | 41 | return rc; |
| 46 | } | 42 | } |
| 47 | 43 | ||
| 48 | /******************************************************/ | ||
| 49 | |||
| 50 | int close_mtouch(struct MTouch *mt, int fd) | 44 | int close_mtouch(struct MTouch *mt, int fd) |
| 51 | { | 45 | { |
| 52 | int rc; | 46 | int rc; |
| @@ -54,22 +48,16 @@ int close_mtouch(struct MTouch *mt, int fd) | |||
| 54 | return rc; | 48 | return rc; |
| 55 | } | 49 | } |
| 56 | 50 | ||
| 57 | /******************************************************/ | 51 | int read_synchronized_event(struct MTouch *mt, int fd) |
| 58 | |||
| 59 | bool read_synchronized_event(struct MTouch *mt, int fd) | ||
| 60 | { | 52 | { |
| 61 | const struct input_event* ev; | 53 | const struct input_event *ev; |
| 62 | while(ev = get_iobuf_event(&mt->buf, fd)) | 54 | while (ev = get_iobuf_event(&mt->buf, fd)) |
| 63 | if (read_hwdata(&mt->hw, ev)) | 55 | if (read_hwdata(&mt->hw, ev)) |
| 64 | return 1; | 56 | return 1; |
| 65 | return 0; | 57 | return 0; |
| 66 | } | 58 | } |
| 67 | 59 | ||
| 68 | /******************************************************/ | ||
| 69 | |||
| 70 | void parse_event(struct MTouch *mt) | 60 | void parse_event(struct MTouch *mt) |
| 71 | { | 61 | { |
| 72 | modify_state(&mt->ns, &mt->hw, &mt->caps); | 62 | modify_state(&mt->ns, &mt->hw, &mt->caps); |
| 73 | } | 63 | } |
| 74 | |||
| 75 | /******************************************************/ | ||
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 @@ | |||
| 27 | #include "hwdata.h" | 27 | #include "hwdata.h" |
| 28 | #include "state.h" | 28 | #include "state.h" |
| 29 | 29 | ||
| 30 | //////////////////////////////////////////////////////// | ||
| 31 | |||
| 32 | struct MTouch { | 30 | struct MTouch { |
| 33 | struct Capabilities caps; | 31 | struct Capabilities caps; |
| 34 | struct IOBuffer buf; | 32 | struct IOBuffer buf; |
| @@ -36,15 +34,11 @@ struct MTouch { | |||
| 36 | struct State os, ns; | 34 | struct State os, ns; |
| 37 | }; | 35 | }; |
| 38 | 36 | ||
| 39 | //////////////////////////////////////////////////////// | ||
| 40 | |||
| 41 | int configure_mtouch(struct MTouch *mt, int fd); | 37 | int configure_mtouch(struct MTouch *mt, int fd); |
| 42 | int open_mtouch(struct MTouch *mt, int fd); | 38 | int open_mtouch(struct MTouch *mt, int fd); |
| 43 | int close_mtouch(struct MTouch *mt, int fd); | 39 | int close_mtouch(struct MTouch *mt, int fd); |
| 44 | 40 | ||
| 45 | bool read_synchronized_event(struct MTouch *mt, int fd); | 41 | int read_synchronized_event(struct MTouch *mt, int fd); |
| 46 | void parse_event(struct MTouch *mt); | 42 | void parse_event(struct MTouch *mt); |
| 47 | 43 | ||
| 48 | //////////////////////////////////////////////////////// | ||
| 49 | |||
| 50 | #endif | 44 | #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 @@ | |||
| 26 | #include <xserver-properties.h> | 26 | #include <xserver-properties.h> |
| 27 | #endif | 27 | #endif |
| 28 | 28 | ||
| 29 | //////////////////////////////////////////////////////////////////////////// | 29 | /* these should be user-configurable at some point */ |
| 30 | |||
| 31 | // these should be user-configurable at some point | ||
| 32 | static const float vscroll_fraction = 0.05; | 30 | static const float vscroll_fraction = 0.05; |
| 33 | static const float hscroll_fraction = 0.2; | 31 | static const float hscroll_fraction = 0.2; |
| 34 | 32 | ||
| 35 | // flip these to enable event debugging | 33 | /* flip these to enable event debugging */ |
| 36 | #if 1 | 34 | #if 1 |
| 37 | #define TRACE1(format, arg1) | 35 | #define TRACE1(format, arg1) |
| 38 | #define TRACE2(format, arg1, arg2) | 36 | #define TRACE2(format, arg1, arg2) |
| @@ -41,18 +39,14 @@ static const float hscroll_fraction = 0.2; | |||
| 41 | #define TRACE2(format, arg1, arg2) xf86Msg(X_INFO, format, arg1, arg2) | 39 | #define TRACE2(format, arg1, arg2) xf86Msg(X_INFO, format, arg1, arg2) |
| 42 | #endif | 40 | #endif |
| 43 | 41 | ||
| 44 | // button mapping simplified | 42 | /* button mapping simplified */ |
| 45 | #define PROPMAP(m, x, y) m[x] = XIGetKnownProperty(y) | 43 | #define PROPMAP(m, x, y) m[x] = XIGetKnownProperty(y) |
| 46 | 44 | ||
| 47 | //////////////////////////////////////////////////////////////////////////// | ||
| 48 | |||
| 49 | static void pointer_control(DeviceIntPtr dev, PtrCtrl *ctrl) | 45 | static void pointer_control(DeviceIntPtr dev, PtrCtrl *ctrl) |
| 50 | { | 46 | { |
| 51 | xf86Msg(X_INFO, "pointer_control\n"); | 47 | xf86Msg(X_INFO, "pointer_control\n"); |
| 52 | } | 48 | } |
| 53 | 49 | ||
| 54 | //////////////////////////////////////////////////////////////////////////// | ||
| 55 | |||
| 56 | static int pointer_property(DeviceIntPtr dev, | 50 | static int pointer_property(DeviceIntPtr dev, |
| 57 | Atom property, | 51 | Atom property, |
| 58 | XIPropertyValuePtr prop, | 52 | XIPropertyValuePtr prop, |
| @@ -62,36 +56,34 @@ static int pointer_property(DeviceIntPtr dev, | |||
| 62 | return Success; | 56 | return Success; |
| 63 | } | 57 | } |
| 64 | 58 | ||
| 65 | //////////////////////////////////////////////////////////////////////////// | ||
| 66 | |||
| 67 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 | 59 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 |
| 68 | static void initAxesLabels(Atom map[2]) | 60 | static void initAxesLabels(Atom map[2]) |
| 69 | { | 61 | { |
| 70 | memset(map, 0, 2 * sizeof(Atom)); | 62 | memset(map, 0, 2 * sizeof(Atom)); |
| 71 | PROPMAP(map, 0, AXIS_LABEL_PROP_REL_X); | 63 | PROPMAP(map, 0, AXIS_LABEL_PROP_REL_X); |
| 72 | PROPMAP(map, 1, AXIS_LABEL_PROP_REL_Y); | 64 | PROPMAP(map, 1, AXIS_LABEL_PROP_REL_Y); |
| 73 | } | 65 | } |
| 74 | 66 | ||
| 75 | static void initButtonLabels(Atom map[DIM_BUTTON]) | 67 | static void initButtonLabels(Atom map[DIM_BUTTON]) |
| 76 | { | 68 | { |
| 77 | memset(map, 0, DIM_BUTTON * sizeof(Atom)); | 69 | memset(map, 0, DIM_BUTTON * sizeof(Atom)); |
| 78 | PROPMAP(map, MT_BUTTON_LEFT, BTN_LABEL_PROP_BTN_LEFT); | 70 | PROPMAP(map, MT_BUTTON_LEFT, BTN_LABEL_PROP_BTN_LEFT); |
| 79 | PROPMAP(map, MT_BUTTON_MIDDLE, BTN_LABEL_PROP_BTN_MIDDLE); | 71 | PROPMAP(map, MT_BUTTON_MIDDLE, BTN_LABEL_PROP_BTN_MIDDLE); |
| 80 | PROPMAP(map, MT_BUTTON_RIGHT, BTN_LABEL_PROP_BTN_RIGHT); | 72 | PROPMAP(map, MT_BUTTON_RIGHT, BTN_LABEL_PROP_BTN_RIGHT); |
| 81 | PROPMAP(map, MT_BUTTON_WHEEL_UP, BTN_LABEL_PROP_BTN_WHEEL_UP); | 73 | PROPMAP(map, MT_BUTTON_WHEEL_UP, BTN_LABEL_PROP_BTN_WHEEL_UP); |
| 82 | PROPMAP(map, MT_BUTTON_WHEEL_DOWN, BTN_LABEL_PROP_BTN_WHEEL_DOWN); | 74 | PROPMAP(map, MT_BUTTON_WHEEL_DOWN, BTN_LABEL_PROP_BTN_WHEEL_DOWN); |
| 83 | PROPMAP(map, MT_BUTTON_HWHEEL_LEFT, BTN_LABEL_PROP_BTN_HWHEEL_LEFT); | 75 | PROPMAP(map, MT_BUTTON_HWHEEL_LEFT, BTN_LABEL_PROP_BTN_HWHEEL_LEFT); |
| 84 | PROPMAP(map, MT_BUTTON_HWHEEL_RIGHT, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); | 76 | PROPMAP(map, MT_BUTTON_HWHEEL_RIGHT, BTN_LABEL_PROP_BTN_HWHEEL_RIGHT); |
| 85 | } | 77 | } |
| 86 | #endif | 78 | #endif |
| 87 | 79 | ||
| 88 | static int device_init(DeviceIntPtr dev, LocalDevicePtr local) | 80 | static int device_init(DeviceIntPtr dev, LocalDevicePtr local) |
| 89 | { | 81 | { |
| 90 | struct MTouch *mt = local->private; | 82 | struct MTouch *mt = local->private; |
| 91 | unsigned char btmap[DIM_BUTTON + 1]={0,1,2,3,4,5,6,7}; | 83 | unsigned char btmap[DIM_BUTTON + 1] = { 0, 1, 2, 3, 4, 5, 6, 7 }; |
| 92 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 | 84 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 |
| 93 | Atom axes_labels[2], btn_labels[DIM_BUTTON]; | 85 | Atom axes_labels[2], btn_labels[DIM_BUTTON]; |
| 94 | initAxesLabels(axes_labels); | 86 | initAxesLabels(axes_labels); |
| 95 | initButtonLabels(btn_labels); | 87 | initButtonLabels(btn_labels); |
| 96 | #endif | 88 | #endif |
| 97 | 89 | ||
| @@ -131,7 +123,7 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local) | |||
| 131 | 123 | ||
| 132 | xf86InitValuatorAxisStruct(dev, 0, | 124 | xf86InitValuatorAxisStruct(dev, 0, |
| 133 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 | 125 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 |
| 134 | axes_labels[0], | 126 | axes_labels[0], |
| 135 | #endif | 127 | #endif |
| 136 | mt->caps.abs_position_x.minimum, | 128 | mt->caps.abs_position_x.minimum, |
| 137 | mt->caps.abs_position_x.maximum, | 129 | mt->caps.abs_position_x.maximum, |
| @@ -139,7 +131,7 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local) | |||
| 139 | xf86InitValuatorDefaults(dev, 0); | 131 | xf86InitValuatorDefaults(dev, 0); |
| 140 | xf86InitValuatorAxisStruct(dev, 1, | 132 | xf86InitValuatorAxisStruct(dev, 1, |
| 141 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 | 133 | #if GET_ABI_MAJOR(ABI_XINPUT_VERSION) >= 7 |
| 142 | axes_labels[1], | 134 | axes_labels[1], |
| 143 | #endif | 135 | #endif |
| 144 | mt->caps.abs_position_y.minimum, | 136 | mt->caps.abs_position_y.minimum, |
| 145 | mt->caps.abs_position_y.maximum, | 137 | mt->caps.abs_position_y.maximum, |
| @@ -151,8 +143,6 @@ static int device_init(DeviceIntPtr dev, LocalDevicePtr local) | |||
| 151 | return Success; | 143 | return Success; |
| 152 | } | 144 | } |
| 153 | 145 | ||
| 154 | //////////////////////////////////////////////////////////////////////////// | ||
| 155 | |||
| 156 | static int device_on(LocalDevicePtr local) | 146 | static int device_on(LocalDevicePtr local) |
| 157 | { | 147 | { |
| 158 | struct MTouch *mt = local->private; | 148 | struct MTouch *mt = local->private; |
| @@ -169,54 +159,45 @@ static int device_on(LocalDevicePtr local) | |||
| 169 | return Success; | 159 | return Success; |
| 170 | } | 160 | } |
| 171 | 161 | ||
| 172 | //////////////////////////////////////////////////////////////////////////// | ||
| 173 | |||
| 174 | static int device_off(LocalDevicePtr local) | 162 | static int device_off(LocalDevicePtr local) |
| 175 | { | 163 | { |
| 176 | struct MTouch *mt = local->private; | 164 | struct MTouch *mt = local->private; |
| 177 | xf86RemoveEnabledDevice(local); | 165 | xf86RemoveEnabledDevice(local); |
| 178 | if(close_mtouch(mt, local->fd)) { | 166 | if (close_mtouch(mt, local->fd)) |
| 179 | xf86Msg(X_WARNING, "multitouch: cannot ungrab device\n"); | 167 | xf86Msg(X_WARNING, "multitouch: cannot ungrab device\n"); |
| 180 | } | ||
| 181 | xf86CloseSerial(local->fd); | 168 | xf86CloseSerial(local->fd); |
| 182 | return Success; | 169 | return Success; |
| 183 | } | 170 | } |
| 184 | 171 | ||
| 185 | //////////////////////////////////////////////////////////////////////////// | ||
| 186 | |||
| 187 | static int device_close(LocalDevicePtr local) | 172 | static int device_close(LocalDevicePtr local) |
| 188 | { | 173 | { |
| 189 | return Success; | 174 | return Success; |
| 190 | } | 175 | } |
| 191 | 176 | ||
| 192 | //////////////////////////////////////////////////////////////////////////// | ||
| 193 | |||
| 194 | static void tickle_button(LocalDevicePtr local, int id) | 177 | static void tickle_button(LocalDevicePtr local, int id) |
| 195 | { | 178 | { |
| 196 | xf86PostButtonEvent(local->dev, FALSE, id, 1, 0, 0); | 179 | xf86PostButtonEvent(local->dev, FALSE, id, 1, 0, 0); |
| 197 | xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0); | 180 | xf86PostButtonEvent(local->dev, FALSE, id, 0, 0, 0); |
| 198 | } | 181 | } |
| 199 | 182 | ||
| 200 | //////////////////////////////////////////////////////////////////////////// | ||
| 201 | |||
| 202 | static void handle_gestures(LocalDevicePtr local, | 183 | static void handle_gestures(LocalDevicePtr local, |
| 203 | const struct Gestures *gs, | 184 | const struct Gestures *gs, |
| 204 | const struct Capabilities *caps) | 185 | const struct Capabilities *caps) |
| 205 | { | 186 | { |
| 206 | static int vscroll, hscroll; | 187 | static int vscroll, hscroll; |
| 207 | int vstep = 1 + | 188 | int vstep = 1 + |
| 208 | vscroll_fraction * (caps->abs_position_y.maximum - | 189 | vscroll_fraction * (caps->abs_position_y.maximum - |
| 209 | caps->abs_position_y.minimum); | 190 | caps->abs_position_y.minimum); |
| 210 | int hstep = 1 + | 191 | int hstep = 1 + |
| 211 | hscroll_fraction * (caps->abs_position_x.maximum - | 192 | hscroll_fraction * (caps->abs_position_x.maximum - |
| 212 | caps->abs_position_x.minimum); | 193 | caps->abs_position_x.minimum); |
| 213 | int i; | 194 | int i; |
| 214 | for (i = 0; i < DIM_BUTTON; i++) { | 195 | for (i = 0; i < DIM_BUTTON; i++) { |
| 215 | if (GETBIT(gs->btmask, i)) { | 196 | if (GETBIT(gs->btmask, i)) { |
| 216 | xf86PostButtonEvent(local->dev, FALSE, | 197 | xf86PostButtonEvent(local->dev, FALSE, |
| 217 | i + 1, GETBIT(gs->btdata, i), 0, 0); | 198 | i + 1, GETBIT(gs->btdata, i), 0, 0); |
| 218 | TRACE2("button bit: %d %d\n", i, GETBIT(gs->btdata, i)); | 199 | TRACE2("button bit: %d %d\n", i, GETBIT(gs->btdata, i)); |
| 219 | } | 200 | } |
| 220 | } | 201 | } |
| 221 | if (GETBIT(gs->type, GS_MOVE)) { | 202 | if (GETBIT(gs->type, GS_MOVE)) { |
| 222 | xf86PostMotionEvent(local->dev, 0, 0, 2, | 203 | xf86PostMotionEvent(local->dev, 0, 0, 2, |
| @@ -249,8 +230,6 @@ static void handle_gestures(LocalDevicePtr local, | |||
| 249 | } | 230 | } |
| 250 | } | 231 | } |
| 251 | 232 | ||
| 252 | //////////////////////////////////////////////////////////////////////////// | ||
| 253 | |||
| 254 | /* called for each full received packet from the touchpad */ | 233 | /* called for each full received packet from the touchpad */ |
| 255 | static void read_input(LocalDevicePtr local) | 234 | static void read_input(LocalDevicePtr local) |
| 256 | { | 235 | { |
| @@ -263,8 +242,6 @@ static void read_input(LocalDevicePtr local) | |||
| 263 | } | 242 | } |
| 264 | } | 243 | } |
| 265 | 244 | ||
| 266 | //////////////////////////////////////////////////////////////////////////// | ||
| 267 | |||
| 268 | static Bool device_control(DeviceIntPtr dev, int mode) | 245 | static Bool device_control(DeviceIntPtr dev, int mode) |
| 269 | { | 246 | { |
| 270 | LocalDevicePtr local = dev->public.devicePrivate; | 247 | LocalDevicePtr local = dev->public.devicePrivate; |
| @@ -288,8 +265,6 @@ static Bool device_control(DeviceIntPtr dev, int mode) | |||
| 288 | } | 265 | } |
| 289 | 266 | ||
| 290 | 267 | ||
| 291 | //////////////////////////////////////////////////////////////////////////// | ||
| 292 | |||
| 293 | static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags) | 268 | static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags) |
| 294 | { | 269 | { |
| 295 | struct MTouch *mt; | 270 | struct MTouch *mt; |
| @@ -309,7 +284,7 @@ static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags) | |||
| 309 | local->conf_idev = dev; | 284 | local->conf_idev = dev; |
| 310 | 285 | ||
| 311 | xf86CollectInputOptions(local, NULL, NULL); | 286 | xf86CollectInputOptions(local, NULL, NULL); |
| 312 | //xf86OptionListReport(local->options); | 287 | /* xf86OptionListReport(local->options); */ |
| 313 | xf86ProcessCommonOptions(local, local->options); | 288 | xf86ProcessCommonOptions(local, local->options); |
| 314 | 289 | ||
| 315 | local->flags |= XI86_CONFIGURED; | 290 | local->flags |= XI86_CONFIGURED; |
| @@ -320,12 +295,10 @@ static InputInfoPtr preinit(InputDriverPtr drv, IDevPtr dev, int flags) | |||
| 320 | static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags) | 295 | static void uninit(InputDriverPtr drv, InputInfoPtr local, int flags) |
| 321 | { | 296 | { |
| 322 | xfree(local->private); | 297 | xfree(local->private); |
| 323 | local->private = 0; | 298 | local->private = 0; |
| 324 | xf86DeleteInput(local, 0); | 299 | xf86DeleteInput(local, 0); |
| 325 | } | 300 | } |
| 326 | 301 | ||
| 327 | //////////////////////////////////////////////////////////////////////////// | ||
| 328 | |||
| 329 | static InputDriverRec MULTITOUCH = { | 302 | static InputDriverRec MULTITOUCH = { |
| 330 | 1, | 303 | 1, |
| 331 | "multitouch", | 304 | "multitouch", |
| @@ -356,5 +329,3 @@ static pointer setup(pointer module, pointer options, int *errmaj, int *errmin) | |||
| 356 | } | 329 | } |
| 357 | 330 | ||
| 358 | XF86ModuleData multitouchModuleData = {&VERSION, &setup, NULL }; | 331 | XF86ModuleData multitouchModuleData = {&VERSION, &setup, NULL }; |
| 359 | |||
| 360 | //////////////////////////////////////////////////////////////////////////// | ||
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 @@ | |||
| 26 | const double FTW = 0.05; | 26 | const double FTW = 0.05; |
| 27 | const double FTS = 0.05; | 27 | const double FTS = 0.05; |
| 28 | 28 | ||
| 29 | /******************************************************/ | ||
| 30 | |||
| 31 | void init_state(struct State *s) | 29 | void init_state(struct State *s) |
| 32 | { | 30 | { |
| 33 | memset(s, 0, sizeof(struct State)); | 31 | memset(s, 0, sizeof(struct State)); |
| 34 | } | 32 | } |
| 35 | 33 | ||
| 36 | /******************************************************/ | 34 | static int fincmp(const void *a, const void *b) |
| 37 | |||
| 38 | static int fincmp(const void* a,const void* b) | ||
| 39 | { | 35 | { |
| 40 | return ((struct FingerState *)a)->id - ((struct FingerState *)b)->id; | 36 | return ((struct FingerState *)a)->id - ((struct FingerState *)b)->id; |
| 41 | } | 37 | } |
| 42 | 38 | ||
| 43 | inline float dist2(const struct FingerData* a,const struct FingerData* b) | 39 | inline float dist2(const struct FingerData *a, const struct FingerData *b) |
| 44 | { | 40 | { |
| 45 | float dx = a->position_x - b->position_x; | 41 | float dx = a->position_x - b->position_x; |
| 46 | float dy = a->position_y - b->position_y; | 42 | float dy = a->position_y - b->position_y; |
| @@ -48,9 +44,9 @@ inline float dist2(const struct FingerData* a,const struct FingerData* b) | |||
| 48 | return dx * dx + dy * dy; | 44 | return dx * dx + dy * dy; |
| 49 | } | 45 | } |
| 50 | 46 | ||
| 51 | static void set_finger(struct FingerState* fs, | 47 | static void set_finger(struct FingerState *fs, |
| 52 | const struct FingerData* hw, int id, | 48 | const struct FingerData *hw, int id, |
| 53 | const struct Capabilities* caps) | 49 | const struct Capabilities *caps) |
| 54 | { | 50 | { |
| 55 | fs->hw = *hw; | 51 | fs->hw = *hw; |
| 56 | fs->id = id; | 52 | fs->id = id; |
| @@ -60,8 +56,8 @@ static void set_finger(struct FingerState* fs, | |||
| 60 | fs->hw.width_minor = hw->width_major; | 56 | fs->hw.width_minor = hw->width_major; |
| 61 | } | 57 | } |
| 62 | 58 | ||
| 63 | static bool touching_finger(const struct FingerData* hw, | 59 | static int touching_finger(const struct FingerData *hw, |
| 64 | const struct Capabilities* caps) | 60 | const struct Capabilities *caps) |
| 65 | { | 61 | { |
| 66 | if (caps->has_touch_major && caps->has_width_major) | 62 | if (caps->has_touch_major && caps->has_width_major) |
| 67 | return hw->width_major > 0 && | 63 | return hw->width_major > 0 && |
| @@ -71,11 +67,9 @@ static bool touching_finger(const struct FingerData* hw, | |||
| 71 | return 1; | 67 | return 1; |
| 72 | } | 68 | } |
| 73 | 69 | ||
| 74 | /******************************************************/ | ||
| 75 | |||
| 76 | void modify_state(struct State *s, | 70 | void modify_state(struct State *s, |
| 77 | const struct HWData* hw, | 71 | const struct HWData *hw, |
| 78 | const struct Capabilities* caps) | 72 | const struct Capabilities *caps) |
| 79 | { | 73 | { |
| 80 | float A[DIM2_FINGER], *row; | 74 | float A[DIM2_FINGER], *row; |
| 81 | int sid[DIM_FINGER], hw2s[DIM_FINGER]; | 75 | int sid[DIM_FINGER], hw2s[DIM_FINGER]; |
| @@ -97,8 +91,9 @@ void modify_state(struct State *s, | |||
| 97 | id = sk >= 0 ? sid[sk] : 0; | 91 | id = sk >= 0 ? sid[sk] : 0; |
| 98 | if (!touching_finger(&hw->finger[hwk], caps)) | 92 | if (!touching_finger(&hw->finger[hwk], caps)) |
| 99 | id = 0; | 93 | id = 0; |
| 100 | else while (!id) | 94 | else |
| 101 | id = ++s->lastid; | 95 | while (!id) |
| 96 | id = ++s->lastid; | ||
| 102 | set_finger(&s->finger[hwk], &hw->finger[hwk], id, caps); | 97 | set_finger(&s->finger[hwk], &hw->finger[hwk], id, caps); |
| 103 | } | 98 | } |
| 104 | 99 | ||
| @@ -109,8 +104,6 @@ void modify_state(struct State *s, | |||
| 109 | qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp); | 104 | qsort(s->finger, s->nfinger, sizeof(struct FingerState), fincmp); |
| 110 | } | 105 | } |
| 111 | 106 | ||
| 112 | /******************************************************/ | ||
| 113 | |||
| 114 | const struct FingerState *find_finger(const struct State *s, int id) | 107 | const struct FingerState *find_finger(const struct State *s, int id) |
| 115 | { | 108 | { |
| 116 | int i; | 109 | int i; |
| @@ -124,8 +117,6 @@ const struct FingerState *find_finger(const struct State *s, int id) | |||
| 124 | return NULL; | 117 | return NULL; |
| 125 | } | 118 | } |
| 126 | 119 | ||
| 127 | /******************************************************/ | ||
| 128 | |||
| 129 | int count_fingers(const struct State *s) | 120 | int count_fingers(const struct State *s) |
| 130 | { | 121 | { |
| 131 | int i, n = 0; | 122 | int i, n = 0; |
| @@ -135,8 +126,6 @@ int count_fingers(const struct State *s) | |||
| 135 | return n; | 126 | return n; |
| 136 | } | 127 | } |
| 137 | 128 | ||
| 138 | /******************************************************/ | ||
| 139 | |||
| 140 | void output_state(const struct State *s) | 129 | void output_state(const struct State *s) |
| 141 | { | 130 | { |
| 142 | int i; | 131 | int i; |
| @@ -159,5 +148,3 @@ void output_state(const struct State *s) | |||
| 159 | s->finger[i].hw.position_y); | 148 | s->finger[i].hw.position_y); |
| 160 | } | 149 | } |
| 161 | } | 150 | } |
| 162 | |||
| 163 | /******************************************************/ | ||
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 @@ | |||
| 25 | #include "capabilities.h" | 25 | #include "capabilities.h" |
| 26 | #include "hwdata.h" | 26 | #include "hwdata.h" |
| 27 | 27 | ||
| 28 | //////////////////////////////////////////////////////// | ||
| 29 | |||
| 30 | /* zero id means not mapped (not touching) */ | 28 | /* zero id means not mapped (not touching) */ |
| 31 | struct FingerState { | 29 | struct FingerState { |
| 32 | struct FingerData hw; | 30 | struct FingerData hw; |
| 33 | int id; | 31 | int id; |
| 34 | }; | 32 | }; |
| 35 | 33 | ||
| 36 | //////////////////////////////////////////////////////// | ||
| 37 | |||
| 38 | struct State { | 34 | struct State { |
| 39 | struct FingerState finger[DIM_FINGER]; | 35 | struct FingerState finger[DIM_FINGER]; |
| 40 | button_t button; | 36 | unsigned button; |
| 41 | int nfinger; | 37 | int nfinger; |
| 42 | int lastid; | 38 | int lastid; |
| 43 | }; | 39 | }; |
| 44 | 40 | ||
| 45 | //////////////////////////////////////////////////////// | ||
| 46 | |||
| 47 | void init_state(struct State *s); | 41 | void init_state(struct State *s); |
| 48 | void modify_state(struct State *s, | 42 | void modify_state(struct State *s, |
| 49 | const struct HWData* hw, | 43 | const struct HWData *hw, |
| 50 | const struct Capabilities* caps); | 44 | const struct Capabilities *caps); |
| 51 | void output_state(const struct State *s); | 45 | void output_state(const struct State *s); |
| 52 | 46 | ||
| 53 | const struct FingerState *find_finger(const struct State *s, int id); | 47 | const struct FingerState *find_finger(const struct State *s, int id); |
| 54 | int count_fingers(const struct State *s); | 48 | int count_fingers(const struct State *s); |
| 55 | 49 | ||
| 56 | //////////////////////////////////////////////////////// | ||
| 57 | |||
| 58 | #endif | 50 | #endif |
| @@ -22,7 +22,7 @@ | |||
| 22 | #include <stdio.h> | 22 | #include <stdio.h> |
| 23 | #include <time.h> | 23 | #include <time.h> |
| 24 | 24 | ||
| 25 | int main(int argc,char* argv[]) | 25 | int main(int argc, char *argv[]) |
| 26 | { | 26 | { |
| 27 | return 0; | 27 | return 0; |
| 28 | } | 28 | } |
