From d4a4d3309165bbdd97f6334e1166be00fb5413cb Mon Sep 17 00:00:00 2001 From: Robin Haberkorn Date: Fri, 14 Sep 2012 18:41:23 +0200 Subject: integrated liblo --- main.c | 60 +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++- 1 file changed, 59 insertions(+), 1 deletion(-) (limited to 'main.c') diff --git a/main.c b/main.c index 1300b35..97b374e 100644 --- a/main.c +++ b/main.c @@ -1,6 +1,7 @@ #include #include #include +#include #include #include @@ -11,6 +12,8 @@ #include +#include + #define NARRAY(ARRAY) \ (sizeof(ARRAY) / sizeof((ARRAY)[0])) @@ -38,8 +41,60 @@ #define SCREEN_HEIGHT 480 #define FRAMERATE 20 /* Hz */ +static inline void effect_bg_change(SDL_Color color); + static SDL_Surface *screen; +static void +osc_error(int num, const char *msg, const char *path) +{ + printf("liblo server error %d in path %s: %s\n", num, path, msg); +} + +/* catch any incoming messages and display them. returning 1 means that the + * message has not been fully handled and the server should try other methods */ +static int +osc_generic_handler(const char *path, const char *types, lo_arg **argv, + int argc, void *data, + void *user_data __attribute__((unused))) +{ + int i; + + printf("path: <%s>\n", path); + for (i=0; ii, (Uint8)argv[1]->i, (Uint8)argv[2]->i}); + return 0; +} + +static inline int +osc_init(const char *port) +{ + lo_server_thread st = lo_server_thread_new(port, osc_error); + + lo_server_thread_add_method(st, NULL, NULL, osc_generic_handler, NULL); + + lo_server_thread_add_method(st, "/background/color", "iii", + osc_bg_change, NULL); + + lo_server_thread_start(st); + + return 0; +} + static SDL_Surface *image_surface = NULL; static void @@ -250,7 +305,10 @@ process_events(void) int main(int argc, char **argv) { - FPSmanager fpsm; + FPSmanager fpsm; + + if (osc_init("7770")) + return EXIT_FAILURE; if (SDL_Init(SDL_INIT_VIDEO)) { SDL_ERROR("SDL_Init"); -- cgit v1.2.3