summaryrefslogtreecommitdiff
path: root/code
diff options
context:
space:
mode:
authorUros Majstorovic <majstor@majstor.org>2020-06-25 17:42:12 +0200
committerUros Majstorovic <majstor@majstor.org>2020-06-25 17:42:12 +0200
commit12a52cf1e334e8d2000be671f30fa243542a056f (patch)
tree016b4cfff2a3b37c5e3acd1111c73da5b70c396b /code
parente5fcdeda041831cb326f1d1963c0651b78041788 (diff)
extendend events implemented for touch
Diffstat (limited to 'code')
-rw-r--r--code/fe310/eos/eve/eve_touch.c37
-rw-r--r--code/fe310/eos/eve/eve_touch.h36
2 files changed, 39 insertions, 34 deletions
diff --git a/code/fe310/eos/eve/eve_touch.c b/code/fe310/eos/eve/eve_touch.c
index fb570bf..a6db581 100644
--- a/code/fe310/eos/eve/eve_touch.c
+++ b/code/fe310/eos/eve/eve_touch.c
@@ -48,10 +48,6 @@ static const uint32_t _reg_track[] = {
REG_TRACKER_4
};
-static inline void _touch_evt_clear(EVETouch *touch) {
- touch->evt &= ~EVE_TOUCH_EVT_MASK;
-}
-
static void _touch_timer_set(uint8_t tag, uint8_t idx, uint16_t evt, int x0, int y0, uint32_t to) {
_touch_timer.tag = tag;
_touch_timer.idx = idx;
@@ -82,7 +78,7 @@ void eve_handle_touch(void) {
uint64_t now = 0;
EVETouch *touch = &_touch[i];
- _touch_evt_clear(touch);
+ touch->evt = 0;
touch_xy = i < 4 ? eve_read32(_reg_touch[i]) : (((uint32_t)eve_read16(REG_CTOUCH_TOUCH4_X) << 16) | eve_read16(REG_CTOUCH_TOUCH4_Y));
if (touch_xy != 0x80008000) {
@@ -90,6 +86,9 @@ void eve_handle_touch(void) {
int16_t touch_y = touch_xy & 0xffff;
now = eve_time_get_tick();
if (touch->x == EVE_NOTOUCH) {
+ uint16_t _evt = 0;
+ uint16_t _eevt = 0;
+
if (!_tag0 && _touch_timer.tag) {
if (_touch_timer.evt & EVE_TOUCH_ETYPE_TAP1) {
int dx = touch_x - touch->x0;
@@ -99,19 +98,21 @@ void eve_handle_touch(void) {
if ((dx > EVE_THRESHOLD_X) || (dy > EVE_THRESHOLD_Y)) {
touch->evt |= EVE_TOUCH_ETYPE_TAP1;
} else {
- touch->evt |= EVE_TOUCH_ETYPE_TAP2;
+ _evt |= EVE_TOUCH_ETYPE_TAP2;
+ _eevt |= EVE_TOUCH_EETYPE_TAP2;
}
}
if (_touch_timer.evt & EVE_TOUCH_ETYPE_TRACK) {
touch->evt |= EVE_TOUCH_ETYPE_TRACK_STOP;
if (_ext_tracker.stop) _ext_tracker.stop(&_touch_timer, touch);
}
- if (_touch_handler && (touch->evt & EVE_TOUCH_EVT_MASK)) {
+ if (_touch_handler && touch->evt) {
_touch_handler(_touch_handler_param, _touch_timer.tag, i);
}
_touch_timer_clear();
}
- touch->evt = EVE_TOUCH_ETYPE_POINT;
+ touch->evt = EVE_TOUCH_ETYPE_POINT | _eevt;
+ touch->eevt = _eevt;
touch->tag0 = 0;
touch->tag = 0;
touch->tag_up = 0;
@@ -203,10 +204,10 @@ void eve_handle_touch(void) {
}
if (touch->tracker.tag && ((dx > EVE_THRESHOLD_X) || (dy > EVE_THRESHOLD_Y))) {
if (dx > EVE_THRESHOLD_X) {
- touch->evt |= touch->x > touch->x0 ? EVE_TOUCH_ETYPE_TRACK_RIGHT : EVE_TOUCH_ETYPE_TRACK_LEFT;
+ touch->eevt |= touch->x > touch->x0 ? EVE_TOUCH_EETYPE_TRACK_RIGHT : EVE_TOUCH_EETYPE_TRACK_LEFT;
}
if (dy > EVE_THRESHOLD_Y) {
- touch->evt |= touch->y > touch->y0 ? EVE_TOUCH_ETYPE_TRACK_DOWN : EVE_TOUCH_ETYPE_TRACK_UP;
+ touch->eevt |= touch->y > touch->y0 ? EVE_TOUCH_EETYPE_TRACK_DOWN : EVE_TOUCH_EETYPE_TRACK_UP;
}
touch->tracker.track = 1;
touch->evt |= EVE_TOUCH_ETYPE_TRACK_START;
@@ -231,7 +232,7 @@ void eve_handle_touch(void) {
}
if (touch->tracker.tag || _touch_timer.tag) int_ccomplete = 1;
}
- if (touch->evt & EVE_TOUCH_EVT_MASK) touch_last = i + 1;
+ if (touch->evt) touch_last = i + 1;
if (!_multitouch) break;
}
@@ -253,7 +254,7 @@ void eve_handle_touch(void) {
for (i=0; i<touch_last; i++) {
EVETouch *touch = &_touch[i];
- if (_touch_handler && (touch->evt & EVE_TOUCH_EVT_MASK)) {
+ if (_touch_handler && touch->evt) {
_touch_handler(_touch_handler_param, tag0, i);
}
}
@@ -270,8 +271,7 @@ void eve_handle_time(void) {
int _x = touch->x;
int _y = touch->y;
- _touch_evt_clear(touch);
- touch->evt |= _touch_timer.evt;
+ touch->evt = _touch_timer.evt;
if (touch->evt & EVE_TOUCH_ETYPE_TRACK) {
if (_ext_tracker.tick) more = _ext_tracker.tick(&_touch_timer, touch);
if (more) {
@@ -280,6 +280,8 @@ void eve_handle_time(void) {
touch->evt |= EVE_TOUCH_ETYPE_TRACK_STOP;
if (_ext_tracker.stop) _ext_tracker.stop(&_touch_timer, touch);
}
+ } else if (touch->evt & EVE_TOUCH_ETYPE_LPRESS) {
+ touch->eevt |= EVE_TOUCH_EETYPE_LPRESS;
}
_touch_handler(_touch_handler_param, _touch_timer.tag, _touch_timer.idx);
@@ -287,6 +289,8 @@ void eve_handle_time(void) {
if (!more) _touch_timer_clear();
touch->x = _x;
touch->y = _y;
+ } else {
+ _touch_timer_clear();
}
}
}
@@ -341,7 +345,7 @@ EVETouch *eve_touch_evt(uint8_t tag0, int touch_idx, uint8_t tag_min, uint8_t ta
}
if (_evt & EVE_TOUCH_ETYPE_TRACK_MASK) {
_tag = ret->tracker.tag;
- if ((_tag >= tag_min) && (_tag < tag_max)) *evt |= _evt & (EVE_TOUCH_ETYPE_TRACK_MASK | EVE_TOUCH_ETYPE_TRACK_XY);
+ if ((_tag >= tag_min) && (_tag < tag_max)) *evt |= _evt & EVE_TOUCH_ETYPE_TRACK_MASK;
}
if (_evt & (EVE_TOUCH_ETYPE_LPRESS | EVE_TOUCH_ETYPE_TAP1 | EVE_TOUCH_ETYPE_TAP2)) {
_tag = _touch_timer.tag;
@@ -385,8 +389,7 @@ void eve_etrack_stop(void) {
if (_ext_tracker.stop) {
EVETouch *touch = &_touch[_touch_timer.idx];
- _touch_evt_clear(touch);
- touch->evt |= EVE_TOUCH_ETYPE_TRACK_STOP;
+ touch->evt = EVE_TOUCH_ETYPE_TRACK_STOP;
_ext_tracker.stop(&_touch_timer, touch);
}
_touch_timer_clear();
diff --git a/code/fe310/eos/eve/eve_touch.h b/code/fe310/eos/eve/eve_touch.h
index 1d9d751..9f935bc 100644
--- a/code/fe310/eos/eve/eve_touch.h
+++ b/code/fe310/eos/eve/eve_touch.h
@@ -13,23 +13,24 @@
#define EVE_TOUCH_ETYPE_TAP1 0x0200
#define EVE_TOUCH_ETYPE_TAP2 0x0400
-#define EVE_TOUCH_EVT_MASK 0x0fff
-
-#define EVE_TOUCH_ETYPE_TAG_MASK (EVE_TOUCH_ETYPE_TAG | EVE_TOUCH_ETYPE_TAG_UP)
-#define EVE_TOUCH_ETYPE_TAP_MASK (EVE_TOUCH_ETYPE_TAP1 | EVE_TOUCH_ETYPE_TAP2)
-#define EVE_TOUCH_ETYPE_TRACK_MASK (EVE_TOUCH_ETYPE_TRACK | EVE_TOUCH_ETYPE_TRACK_START | EVE_TOUCH_ETYPE_TRACK_STOP)
-#define EVE_TOUCH_ETYPE_POINT_MASK (EVE_TOUCH_ETYPE_POINT | EVE_TOUCH_ETYPE_POINT_UP)
-#define EVE_TOUCH_ETYPE_TIMER_MASK (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_DTAP)
+#define EVE_TOUCH_ETYPE_TAG_MASK (EVE_TOUCH_ETYPE_TAG | EVE_TOUCH_ETYPE_TAG_UP)
+#define EVE_TOUCH_ETYPE_TAP_MASK (EVE_TOUCH_ETYPE_TAP1 | EVE_TOUCH_ETYPE_TAP2)
+#define EVE_TOUCH_ETYPE_TRACK_MASK (EVE_TOUCH_ETYPE_TRACK | EVE_TOUCH_ETYPE_TRACK_START | EVE_TOUCH_ETYPE_TRACK_STOP)
+#define EVE_TOUCH_ETYPE_POINT_MASK (EVE_TOUCH_ETYPE_POINT | EVE_TOUCH_ETYPE_POINT_UP)
+#define EVE_TOUCH_ETYPE_TIMER_MASK (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_DTAP)
/* extended events */
-#define EVE_TOUCH_ETYPE_TRACK_LEFT 0x1000
-#define EVE_TOUCH_ETYPE_TRACK_RIGHT 0x2000
-#define EVE_TOUCH_ETYPE_TRACK_UP 0x4000
-#define EVE_TOUCH_ETYPE_TRACK_DOWN 0x8000
+#define EVE_TOUCH_EETYPE_LPRESS 0x0001
+#define EVE_TOUCH_EETYPE_TAP2 0x0002
+
+#define EVE_TOUCH_EETYPE_TRACK_LEFT 0x1000
+#define EVE_TOUCH_EETYPE_TRACK_RIGHT 0x2000
+#define EVE_TOUCH_EETYPE_TRACK_UP 0x4000
+#define EVE_TOUCH_EETYPE_TRACK_DOWN 0x8000
-#define EVE_TOUCH_ETYPE_TRACK_X (EVE_TOUCH_ETYPE_TRACK_LEFT | EVE_TOUCH_ETYPE_TRACK_RIGHT)
-#define EVE_TOUCH_ETYPE_TRACK_Y (EVE_TOUCH_ETYPE_TRACK_UP | EVE_TOUCH_ETYPE_TRACK_DOWN)
-#define EVE_TOUCH_ETYPE_TRACK_XY (EVE_TOUCH_ETYPE_TRACK_X | EVE_TOUCH_ETYPE_TRACK_Y)
+#define EVE_TOUCH_EETYPE_TRACK_X (EVE_TOUCH_EETYPE_TRACK_LEFT | EVE_TOUCH_EETYPE_TRACK_RIGHT)
+#define EVE_TOUCH_EETYPE_TRACK_Y (EVE_TOUCH_EETYPE_TRACK_UP | EVE_TOUCH_EETYPE_TRACK_DOWN)
+#define EVE_TOUCH_EETYPE_TRACK_XY (EVE_TOUCH_EETYPE_TRACK_X | EVE_TOUCH_EETYPE_TRACK_Y)
/* tag options */
#define EVE_TOUCH_OPT_TRACK EVE_TOUCH_ETYPE_TRACK
@@ -40,9 +41,9 @@
#define EVE_TOUCH_OPT_LPRESS 0x40
#define EVE_TOUCH_OPT_DTAP 0x80
-#define EVE_TOUCH_OPT_TRACK_XY (EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_Y)
-#define EVE_TOUCH_OPT_TRACK_MASK (EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_REG)
-#define EVE_TOUCH_OPT_TIMER_MASK (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_DTAP)
+#define EVE_TOUCH_OPT_TRACK_XY (EVE_TOUCH_OPT_TRACK_X | EVE_TOUCH_OPT_TRACK_Y)
+#define EVE_TOUCH_OPT_TRACK_MASK (EVE_TOUCH_OPT_TRACK | EVE_TOUCH_OPT_TRACK_REG)
+#define EVE_TOUCH_OPT_TIMER_MASK (EVE_TOUCH_OPT_LPRESS | EVE_TOUCH_OPT_DTAP)
typedef void (*eve_touch_handler_t) (void *, uint8_t, int);
@@ -55,6 +56,7 @@ typedef struct EVETouch {
int y0;
uint64_t t;
uint16_t evt;
+ uint16_t eevt;
uint8_t tag0;
uint8_t tag;
uint8_t tag_up;