diff options
author | Uros Majstorovic <majstor@majstor.org> | 2020-06-25 17:42:12 +0200 |
---|---|---|
committer | Uros Majstorovic <majstor@majstor.org> | 2020-06-25 17:42:12 +0200 |
commit | 12a52cf1e334e8d2000be671f30fa243542a056f (patch) | |
tree | 016b4cfff2a3b37c5e3acd1111c73da5b70c396b /code/fe310/eos/eve/eve_touch.c | |
parent | e5fcdeda041831cb326f1d1963c0651b78041788 (diff) |
extendend events implemented for touch
Diffstat (limited to 'code/fe310/eos/eve/eve_touch.c')
-rw-r--r-- | code/fe310/eos/eve/eve_touch.c | 37 |
1 files changed, 20 insertions, 17 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(); |