diff options
Diffstat (limited to 'apps/plugins/lua/rocklib_events.c')
-rw-r--r-- | apps/plugins/lua/rocklib_events.c | 10 |
1 files changed, 7 insertions, 3 deletions
diff --git a/apps/plugins/lua/rocklib_events.c b/apps/plugins/lua/rocklib_events.c index 9e363edbdd..270c4ab393 100644 --- a/apps/plugins/lua/rocklib_events.c +++ b/apps/plugins/lua/rocklib_events.c | |||
@@ -137,6 +137,7 @@ struct event_data { | |||
137 | int thread_state; | 137 | int thread_state; |
138 | long *event_stack; | 138 | long *event_stack; |
139 | long timer_ticks; | 139 | long timer_ticks; |
140 | short freq_input; | ||
140 | short next_input; | 141 | short next_input; |
141 | short next_event; | 142 | short next_event; |
142 | /* callbacks */ | 143 | /* callbacks */ |
@@ -171,8 +172,9 @@ static void init_event_data(lua_State *L, struct event_data *ev_data) | |||
171 | ev_data->thread_state = THREAD_YIELD; | 172 | ev_data->thread_state = THREAD_YIELD; |
172 | //ev_data->event_stack = NULL; | 173 | //ev_data->event_stack = NULL; |
173 | //ev_data->timer_ticks = 0; | 174 | //ev_data->timer_ticks = 0; |
174 | ev_data->next_input = EV_TICKS; | 175 | ev_data->freq_input = EV_INPUT; |
175 | ev_data->next_event = EV_INPUT; | 176 | ev_data->next_input = EV_INPUT; |
177 | ev_data->next_event = EV_TICKS; | ||
176 | /* callbacks */ | 178 | /* callbacks */ |
177 | for (int i= 0; i < EVENT_CT; i++) | 179 | for (int i= 0; i < EVENT_CT; i++) |
178 | ev_data->cb[i] = NULL; | 180 | ev_data->cb[i] = NULL; |
@@ -336,7 +338,7 @@ static void rev_timer_isr(void) | |||
336 | if (ev_data.next_input <=0) | 338 | if (ev_data.next_input <=0) |
337 | { | 339 | { |
338 | ev_data.thread_state |= ((ev_data.thread_state & THREAD_INPUTMASK) >> 16); | 340 | ev_data.thread_state |= ((ev_data.thread_state & THREAD_INPUTMASK) >> 16); |
339 | ev_data.next_input = EV_INPUT; | 341 | ev_data.next_input = ev_data.freq_input; |
340 | } | 342 | } |
341 | 343 | ||
342 | if (ev_data.cb[TIMEREVENT] != NULL && !is_suspend(TIMEREVENT)) | 344 | if (ev_data.cb[TIMEREVENT] != NULL && !is_suspend(TIMEREVENT)) |
@@ -535,6 +537,8 @@ static int rockev_register(lua_State *L) | |||
535 | case ACTEVENT: | 537 | case ACTEVENT: |
536 | /* fall through */ | 538 | /* fall through */ |
537 | case BUTEVENT: | 539 | case BUTEVENT: |
540 | ev_data.freq_input = luaL_optinteger(L, 3, EV_INPUT); | ||
541 | if (ev_data.freq_input < HZ / 20) ev_data.freq_input = HZ / 20; | ||
538 | ev_data.thread_state |= (ev_flag | (ev_flag << 16)); | 542 | ev_data.thread_state |= (ev_flag | (ev_flag << 16)); |
539 | break; | 543 | break; |
540 | case CUSTOMEVENT: | 544 | case CUSTOMEVENT: |