Преглед на файлове

fix sdl_fb.c to support gcc under linux

prife преди 12 години
родител
ревизия
7c3f2fd6c7
променени са 1 файла, в които са добавени 26 реда и са изтрити 2 реда
  1. 26 2
      bsp/simlinux/drivers/sdl_fb.c

+ 26 - 2
bsp/simlinux/drivers/sdl_fb.c

@@ -1,6 +1,10 @@
 #include <rtthread.h>
 
+#ifdef _WIN32
 #include <sdl.h>
+#else
+#include <SDL/SDL.h>
+#endif
 #include <rtdevice.h>
 #include <rtgui/driver.h>
 
@@ -104,7 +108,7 @@ static void sdlfb_hw_init(void)
     //_putenv("SDL_VIDEODRIVER=windib");
 
     //if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_TIMER | SDL_INIT_AUDIO) < 0)
-    if (SDL_Init(SDL_INIT_EVERYTHING) < 0)
+    if (SDL_Init(SDL_INIT_VIDEO) < 0)
     {
         fprintf(stderr, "Couldn't initialize SDL: %s\n", SDL_GetError());
         exit(1);
@@ -132,16 +136,24 @@ static void sdlfb_hw_init(void)
     sdllock = rt_mutex_create("fb", RT_IPC_FLAG_FIFO);
 }
 
+#ifdef _WIN32
 #include  <windows.h>
 #include  <mmsystem.h>
+#else
+#include <pthread.h>
+#endif
+
 #include  <stdio.h>
-#include <sdl.h>
 #include <rtgui/event.h>
 #include <rtgui/kbddef.h>
 #include <rtgui/rtgui_server.h>
 #include <rtgui/rtgui_system.h>
 
+#ifdef _WIN32
 static DWORD WINAPI sdl_loop(LPVOID lpParam)
+#else
+static void *sdl_loop(void *lpParam)
+#endif
 {
     int quit = 0;
     SDL_Event event;
@@ -284,6 +296,7 @@ static DWORD WINAPI sdl_loop(LPVOID lpParam)
 /* start sdl thread */
 void rt_hw_sdl_start(void)
 {
+#ifdef _WIN32
     HANDLE thread;
     DWORD  thread_id;
 
@@ -301,4 +314,15 @@ void rt_hw_sdl_start(void)
         return;
     }
     ResumeThread(thread);
+#else
+	/* Linux */
+	pthread_t pid;
+    int res;
+    res = pthread_create(&pid, NULL, &sdl_loop, NULL);
+    if (res)
+    {
+        printf("pthread create sdl thread faild, <%d>\n", res);
+        exit(EXIT_FAILURE);
+	}
+#endif
 }