diff options
Diffstat (limited to 'apps/plugins/lua/rocklib.c')
-rw-r--r-- | apps/plugins/lua/rocklib.c | 363 |
1 files changed, 3 insertions, 360 deletions
diff --git a/apps/plugins/lua/rocklib.c b/apps/plugins/lua/rocklib.c index 64c1a03d64..69e26fdee6 100644 --- a/apps/plugins/lua/rocklib.c +++ b/apps/plugins/lua/rocklib.c | |||
@@ -258,72 +258,6 @@ RB_WRAP(clear_viewport) | |||
258 | return 0; | 258 | return 0; |
259 | } | 259 | } |
260 | 260 | ||
261 | RB_WRAP(splash) | ||
262 | { | ||
263 | int ticks = luaL_checkint(L, 1); | ||
264 | const char *s = luaL_checkstring(L, 2); | ||
265 | rb->splash(ticks, s); | ||
266 | return 0; | ||
267 | } | ||
268 | |||
269 | RB_WRAP(lcd_update) | ||
270 | { | ||
271 | (void)L; | ||
272 | rb->lcd_update(); | ||
273 | return 0; | ||
274 | } | ||
275 | |||
276 | RB_WRAP(lcd_update_rect) | ||
277 | { | ||
278 | int x = luaL_checkint(L, 1); | ||
279 | int y = luaL_checkint(L, 2); | ||
280 | int width = luaL_checkint(L, 3); | ||
281 | int height = luaL_checkint(L, 4); | ||
282 | rb->lcd_update_rect(x, y, width, height); | ||
283 | return 0; | ||
284 | } | ||
285 | |||
286 | RB_WRAP(lcd_clear_display) | ||
287 | { | ||
288 | (void)L; | ||
289 | rb->lcd_clear_display(); | ||
290 | return 0; | ||
291 | } | ||
292 | |||
293 | RB_WRAP(lcd_putsxy) | ||
294 | { | ||
295 | int x = luaL_checkint(L, 1); | ||
296 | int y = luaL_checkint(L, 2); | ||
297 | const char* string = luaL_checkstring(L, 3); | ||
298 | rb->lcd_putsxy(x, y, string); | ||
299 | return 0; | ||
300 | } | ||
301 | |||
302 | RB_WRAP(lcd_puts) | ||
303 | { | ||
304 | int x = luaL_checkint(L, 1); | ||
305 | int y = luaL_checkint(L, 2); | ||
306 | const char* string = luaL_checkstring(L, 3); | ||
307 | rb->lcd_puts(x, y, string); | ||
308 | return 0; | ||
309 | } | ||
310 | |||
311 | RB_WRAP(lcd_puts_scroll) | ||
312 | { | ||
313 | int x = luaL_checkint(L, 1); | ||
314 | int y = luaL_checkint(L, 2); | ||
315 | const char* string = luaL_checkstring(L, 3); | ||
316 | rb->lcd_puts_scroll(x, y, string); | ||
317 | return 0; | ||
318 | } | ||
319 | |||
320 | RB_WRAP(lcd_stop_scroll) | ||
321 | { | ||
322 | (void)L; | ||
323 | rb->lcd_stop_scroll(); | ||
324 | return 0; | ||
325 | } | ||
326 | |||
327 | #ifdef HAVE_LCD_BITMAP | 261 | #ifdef HAVE_LCD_BITMAP |
328 | RB_WRAP(lcd_framebuffer) | 262 | RB_WRAP(lcd_framebuffer) |
329 | { | 263 | { |
@@ -331,89 +265,6 @@ RB_WRAP(lcd_framebuffer) | |||
331 | return 1; | 265 | return 1; |
332 | } | 266 | } |
333 | 267 | ||
334 | RB_WRAP(lcd_set_drawmode) | ||
335 | { | ||
336 | int drawmode = luaL_checkint(L, 1); | ||
337 | rb->lcd_set_drawmode(drawmode); | ||
338 | return 0; | ||
339 | } | ||
340 | |||
341 | RB_WRAP(lcd_get_drawmode) | ||
342 | { | ||
343 | int result = rb->lcd_get_drawmode(); | ||
344 | lua_pushinteger(L, result); | ||
345 | return 1; | ||
346 | } | ||
347 | |||
348 | RB_WRAP(lcd_setfont) | ||
349 | { | ||
350 | int font = luaL_checkint(L, 1); | ||
351 | rb->lcd_setfont(font); | ||
352 | return 0; | ||
353 | } | ||
354 | |||
355 | RB_WRAP(lcd_drawpixel) | ||
356 | { | ||
357 | int x = luaL_checkint(L, 1); | ||
358 | int y = luaL_checkint(L, 2); | ||
359 | |||
360 | rb->lcd_drawpixel(x, y); | ||
361 | return 0; | ||
362 | } | ||
363 | |||
364 | RB_WRAP(lcd_drawline) | ||
365 | { | ||
366 | int x1 = luaL_checkint(L, 1); | ||
367 | int y1 = luaL_checkint(L, 2); | ||
368 | int x2 = luaL_checkint(L, 3); | ||
369 | int y2 = luaL_checkint(L, 4); | ||
370 | |||
371 | rb->lcd_drawline(x1, y1, x2, y2); | ||
372 | return 0; | ||
373 | } | ||
374 | |||
375 | RB_WRAP(lcd_hline) | ||
376 | { | ||
377 | int x1 = luaL_checkint(L, 1); | ||
378 | int x2 = luaL_checkint(L, 2); | ||
379 | int y = luaL_checkint(L, 3); | ||
380 | |||
381 | rb->lcd_hline(x1, x2, y); | ||
382 | return 0; | ||
383 | } | ||
384 | |||
385 | RB_WRAP(lcd_vline) | ||
386 | { | ||
387 | int x = luaL_checkint(L, 1); | ||
388 | int y1 = luaL_checkint(L, 2); | ||
389 | int y2 = luaL_checkint(L, 3); | ||
390 | |||
391 | rb->lcd_vline(x, y1, y2); | ||
392 | return 0; | ||
393 | } | ||
394 | |||
395 | RB_WRAP(lcd_drawrect) | ||
396 | { | ||
397 | int x = luaL_checkint(L, 1); | ||
398 | int y = luaL_checkint(L, 2); | ||
399 | int width = luaL_checkint(L, 3); | ||
400 | int height = luaL_checkint(L, 4); | ||
401 | |||
402 | rb->lcd_drawrect(x, y, width, height); | ||
403 | return 0; | ||
404 | } | ||
405 | |||
406 | RB_WRAP(lcd_fillrect) | ||
407 | { | ||
408 | int x = luaL_checkint(L, 1); | ||
409 | int y = luaL_checkint(L, 2); | ||
410 | int width = luaL_checkint(L, 3); | ||
411 | int height = luaL_checkint(L, 4); | ||
412 | |||
413 | rb->lcd_fillrect(x, y, width, height); | ||
414 | return 0; | ||
415 | } | ||
416 | |||
417 | RB_WRAP(lcd_mono_bitmap_part) | 268 | RB_WRAP(lcd_mono_bitmap_part) |
418 | { | 269 | { |
419 | struct rocklua_image *src = rli_checktype(L, 1); | 270 | struct rocklua_image *src = rli_checktype(L, 1); |
@@ -442,34 +293,6 @@ RB_WRAP(lcd_mono_bitmap) | |||
442 | } | 293 | } |
443 | 294 | ||
444 | #if LCD_DEPTH > 1 | 295 | #if LCD_DEPTH > 1 |
445 | RB_WRAP(lcd_set_foreground) | ||
446 | { | ||
447 | unsigned foreground = luaL_checkint(L, 1); | ||
448 | rb->lcd_set_foreground(foreground); | ||
449 | return 0; | ||
450 | } | ||
451 | |||
452 | RB_WRAP(lcd_get_foreground) | ||
453 | { | ||
454 | unsigned result = rb->lcd_get_foreground(); | ||
455 | lua_pushinteger(L, result); | ||
456 | return 1; | ||
457 | } | ||
458 | |||
459 | RB_WRAP(lcd_set_background) | ||
460 | { | ||
461 | unsigned background = luaL_checkint(L, 1); | ||
462 | rb->lcd_set_background(background); | ||
463 | return 0; | ||
464 | } | ||
465 | |||
466 | RB_WRAP(lcd_get_background) | ||
467 | { | ||
468 | unsigned result = rb->lcd_get_background(); | ||
469 | lua_pushinteger(L, result); | ||
470 | return 1; | ||
471 | } | ||
472 | |||
473 | RB_WRAP(lcd_bitmap_part) | 296 | RB_WRAP(lcd_bitmap_part) |
474 | { | 297 | { |
475 | struct rocklua_image *src = rli_checktype(L, 1); | 298 | struct rocklua_image *src = rli_checktype(L, 1); |
@@ -541,76 +364,12 @@ RB_WRAP(lcd_bitmap_transparent) | |||
541 | 364 | ||
542 | #endif /* defined(LCD_BITMAP) */ | 365 | #endif /* defined(LCD_BITMAP) */ |
543 | 366 | ||
544 | RB_WRAP(yield) | ||
545 | { | ||
546 | (void)L; | ||
547 | rb->yield(); | ||
548 | return 0; | ||
549 | } | ||
550 | |||
551 | RB_WRAP(sleep) | ||
552 | { | ||
553 | int ticks = luaL_checkint(L, 1); | ||
554 | rb->sleep(ticks); | ||
555 | return 0; | ||
556 | } | ||
557 | |||
558 | RB_WRAP(current_tick) | 367 | RB_WRAP(current_tick) |
559 | { | 368 | { |
560 | lua_pushinteger(L, *rb->current_tick); | 369 | lua_pushinteger(L, *rb->current_tick); |
561 | return 1; | 370 | return 1; |
562 | } | 371 | } |
563 | 372 | ||
564 | RB_WRAP(button_get) | ||
565 | { | ||
566 | bool block = luaL_checkboolean(L, 1); | ||
567 | long result = rb->button_get(block); | ||
568 | lua_pushinteger(L, result); | ||
569 | return 1; | ||
570 | } | ||
571 | |||
572 | RB_WRAP(button_get_w_tmo) | ||
573 | { | ||
574 | int ticks = luaL_checkint(L, 1); | ||
575 | long result = rb->button_get_w_tmo(ticks); | ||
576 | lua_pushinteger(L, result); | ||
577 | return 1; | ||
578 | } | ||
579 | |||
580 | RB_WRAP(button_status) | ||
581 | { | ||
582 | int result = rb->button_status(); | ||
583 | lua_pushinteger(L, result); | ||
584 | return 1; | ||
585 | } | ||
586 | |||
587 | #ifdef HAVE_BUTTON_DATA | ||
588 | RB_WRAP(button_get_data) | ||
589 | { | ||
590 | int result = rb->button_get_data(); | ||
591 | lua_pushinteger(L, result); | ||
592 | return 1; | ||
593 | } | ||
594 | #endif | ||
595 | |||
596 | #ifdef HAS_BUTTON_HOLD | ||
597 | RB_WRAP(button_hold) | ||
598 | { | ||
599 | bool result = rb->button_hold(); | ||
600 | lua_pushboolean(L, result); | ||
601 | return 1; | ||
602 | } | ||
603 | #endif | ||
604 | |||
605 | RB_WRAP(get_action) | ||
606 | { | ||
607 | int context = luaL_checkint(L, 1); | ||
608 | int timeout = luaL_checkint(L, 2); | ||
609 | int result = rb->get_action(context, timeout); | ||
610 | lua_pushinteger(L, result); | ||
611 | return 1; | ||
612 | } | ||
613 | |||
614 | #ifdef HAVE_TOUCHSCREEN | 373 | #ifdef HAVE_TOUCHSCREEN |
615 | RB_WRAP(action_get_touchscreen_press) | 374 | RB_WRAP(action_get_touchscreen_press) |
616 | { | 375 | { |
@@ -624,14 +383,6 @@ RB_WRAP(action_get_touchscreen_press) | |||
624 | } | 383 | } |
625 | #endif | 384 | #endif |
626 | 385 | ||
627 | RB_WRAP(action_userabort) | ||
628 | { | ||
629 | int timeout = luaL_checkint(L, 1); | ||
630 | bool result = rb->action_userabort(timeout); | ||
631 | lua_pushboolean(L, result); | ||
632 | return 1; | ||
633 | } | ||
634 | |||
635 | RB_WRAP(kbd_input) | 386 | RB_WRAP(kbd_input) |
636 | { | 387 | { |
637 | luaL_Buffer b; | 388 | luaL_Buffer b; |
@@ -655,69 +406,6 @@ RB_WRAP(touchscreen_set_mode) | |||
655 | } | 406 | } |
656 | #endif | 407 | #endif |
657 | 408 | ||
658 | RB_WRAP(backlight_on) | ||
659 | { | ||
660 | (void)L; | ||
661 | rb->backlight_on(); | ||
662 | return 0; | ||
663 | } | ||
664 | |||
665 | RB_WRAP(backlight_off) | ||
666 | { | ||
667 | (void)L; | ||
668 | rb->backlight_off(); | ||
669 | return 0; | ||
670 | } | ||
671 | |||
672 | RB_WRAP(backlight_set_timeout) | ||
673 | { | ||
674 | int val = luaL_checkint(L, 1); | ||
675 | rb->backlight_set_timeout(val); | ||
676 | return 0; | ||
677 | } | ||
678 | |||
679 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
680 | RB_WRAP(backlight_set_brightness) | ||
681 | { | ||
682 | int val = luaL_checkint(L, 1); | ||
683 | rb->backlight_set_brightness(val); | ||
684 | return 0; | ||
685 | } | ||
686 | #endif | ||
687 | |||
688 | RB_WRAP(creat) | ||
689 | { | ||
690 | const char* pathname = luaL_checkstring(L, 1); | ||
691 | int result = rb->creat(pathname); | ||
692 | lua_pushinteger(L, result); | ||
693 | return 1; | ||
694 | } | ||
695 | |||
696 | RB_WRAP(remove) | ||
697 | { | ||
698 | const char* pathname = luaL_checkstring(L, 1); | ||
699 | int result = rb->remove(pathname); | ||
700 | lua_pushinteger(L, result); | ||
701 | return 1; | ||
702 | } | ||
703 | |||
704 | RB_WRAP(rename) | ||
705 | { | ||
706 | const char* path = luaL_checkstring(L, 1); | ||
707 | const char* newname = luaL_checkstring(L, 2); | ||
708 | int result = rb->rename(path, newname); | ||
709 | lua_pushinteger(L, result); | ||
710 | return 1; | ||
711 | } | ||
712 | |||
713 | RB_WRAP(file_exists) | ||
714 | { | ||
715 | const char* path = luaL_checkstring(L, 1); | ||
716 | bool result = rb->file_exists(path); | ||
717 | lua_pushboolean(L, result); | ||
718 | return 1; | ||
719 | } | ||
720 | |||
721 | RB_WRAP(font_getstringsize) | 409 | RB_WRAP(font_getstringsize) |
722 | { | 410 | { |
723 | const unsigned char* str = luaL_checkstring(L, 1); | 411 | const unsigned char* str = luaL_checkstring(L, 1); |
@@ -796,32 +484,11 @@ RB_WRAP(current_path) | |||
796 | static const luaL_Reg rocklib[] = | 484 | static const luaL_Reg rocklib[] = |
797 | { | 485 | { |
798 | /* Graphics */ | 486 | /* Graphics */ |
799 | R(lcd_clear_display), | ||
800 | R(lcd_update), | ||
801 | R(lcd_update_rect), | ||
802 | R(lcd_puts), | ||
803 | R(lcd_putsxy), | ||
804 | R(lcd_puts_scroll), | ||
805 | R(lcd_stop_scroll), | ||
806 | R(splash), | ||
807 | #ifdef HAVE_LCD_BITMAP | 487 | #ifdef HAVE_LCD_BITMAP |
808 | R(lcd_framebuffer), | 488 | R(lcd_framebuffer), |
809 | R(lcd_set_drawmode), | ||
810 | R(lcd_get_drawmode), | ||
811 | R(lcd_setfont), | ||
812 | R(lcd_drawline), | ||
813 | R(lcd_drawpixel), | ||
814 | R(lcd_hline), | ||
815 | R(lcd_vline), | ||
816 | R(lcd_drawrect), | ||
817 | R(lcd_fillrect), | ||
818 | R(lcd_mono_bitmap_part), | 489 | R(lcd_mono_bitmap_part), |
819 | R(lcd_mono_bitmap), | 490 | R(lcd_mono_bitmap), |
820 | #if LCD_DEPTH > 1 | 491 | #if LCD_DEPTH > 1 |
821 | R(lcd_set_foreground), | ||
822 | R(lcd_get_foreground), | ||
823 | R(lcd_set_background), | ||
824 | R(lcd_get_background), | ||
825 | R(lcd_get_backdrop), | 492 | R(lcd_get_backdrop), |
826 | R(lcd_bitmap_part), | 493 | R(lcd_bitmap_part), |
827 | R(lcd_bitmap), | 494 | R(lcd_bitmap), |
@@ -836,43 +503,16 @@ static const luaL_Reg rocklib[] = | |||
836 | R(lcd_rgbunpack), | 503 | R(lcd_rgbunpack), |
837 | #endif | 504 | #endif |
838 | 505 | ||
839 | /* File handling */ | ||
840 | R(creat), | ||
841 | R(remove), | ||
842 | R(rename), | ||
843 | R(file_exists), | ||
844 | |||
845 | /* Kernel */ | 506 | /* Kernel */ |
846 | R(sleep), | ||
847 | R(yield), | ||
848 | R(current_tick), | 507 | R(current_tick), |
849 | 508 | ||
850 | /* Buttons */ | 509 | /* Buttons */ |
851 | R(button_get), | ||
852 | R(button_get_w_tmo), | ||
853 | R(button_status), | ||
854 | #ifdef HAVE_BUTTON_DATA | ||
855 | R(button_get_data), | ||
856 | #endif | ||
857 | #ifdef HAS_BUTTON_HOLD | ||
858 | R(button_hold), | ||
859 | #endif | ||
860 | R(get_action), | ||
861 | R(action_userabort), | ||
862 | #ifdef HAVE_TOUCHSCREEN | 510 | #ifdef HAVE_TOUCHSCREEN |
863 | R(action_get_touchscreen_press), | 511 | R(action_get_touchscreen_press), |
864 | R(touchscreen_set_mode), | 512 | R(touchscreen_set_mode), |
865 | #endif | 513 | #endif |
866 | R(kbd_input), | 514 | R(kbd_input), |
867 | 515 | ||
868 | /* Hardware */ | ||
869 | R(backlight_on), | ||
870 | R(backlight_off), | ||
871 | R(backlight_set_timeout), | ||
872 | #ifdef HAVE_BACKLIGHT_BRIGHTNESS | ||
873 | R(backlight_set_brightness), | ||
874 | #endif | ||
875 | |||
876 | R(font_getstringsize), | 516 | R(font_getstringsize), |
877 | R(read_bmp_file), | 517 | R(read_bmp_file), |
878 | R(set_viewport), | 518 | R(set_viewport), |
@@ -884,6 +524,8 @@ static const luaL_Reg rocklib[] = | |||
884 | {NULL, NULL} | 524 | {NULL, NULL} |
885 | }; | 525 | }; |
886 | #undef R | 526 | #undef R |
527 | extern const luaL_Reg rocklib_aux[]; | ||
528 | |||
887 | 529 | ||
888 | #define RB_CONSTANT(x) lua_pushinteger(L, x); lua_setfield(L, -2, #x); | 530 | #define RB_CONSTANT(x) lua_pushinteger(L, x); lua_setfield(L, -2, #x); |
889 | /* | 531 | /* |
@@ -892,6 +534,7 @@ static const luaL_Reg rocklib[] = | |||
892 | LUALIB_API int luaopen_rock(lua_State *L) | 534 | LUALIB_API int luaopen_rock(lua_State *L) |
893 | { | 535 | { |
894 | luaL_register(L, LUA_ROCKLIBNAME, rocklib); | 536 | luaL_register(L, LUA_ROCKLIBNAME, rocklib); |
537 | luaL_register(L, LUA_ROCKLIBNAME, rocklib_aux); | ||
895 | 538 | ||
896 | RB_CONSTANT(HZ); | 539 | RB_CONSTANT(HZ); |
897 | 540 | ||