diff --git a/rainbow/LinuxFb/LinuxFb.upp b/rainbow/LinuxFb/LinuxFb.upp index db7d895e9..3e77a218d 100644 --- a/rainbow/LinuxFb/LinuxFb.upp +++ b/rainbow/LinuxFb/LinuxFb.upp @@ -6,5 +6,6 @@ file LinuxFbLocal.h, Local.h, Keys.h, + Win.cpp, Proc.cpp; diff --git a/rainbow/LinuxFb/LinuxFbLocal.h b/rainbow/LinuxFb/LinuxFbLocal.h index bc7e7fab8..f456c3b7c 100644 --- a/rainbow/LinuxFb/LinuxFbLocal.h +++ b/rainbow/LinuxFb/LinuxFbLocal.h @@ -1,12 +1,38 @@ #ifndef _LinuxFb_LinuxFbLocal_h #define _LinuxFb_LinuxFbLocal_h +#include +#include +#include +#include +#include +#include + #include NAMESPACE_UPP extern bool fbEndSession; +extern int fbfd; +extern struct fb_var_screeninfo vinfo; +extern struct fb_fix_screeninfo finfo; +extern long int screensize; +extern char *fbp; + +extern int mouse_fd; +extern bool mouse_imps2; +extern Point mousep; +extern int mouseb; + +extern int keyboard_fd; + +int has_imps2(int fd); +int set_imps2(int fd, int b); +int readevents(int ms); +void handle_mouse(); +void handle_keyboard(); + END_UPP_NAMESPACE #endif diff --git a/rainbow/LinuxFb/Proc.cpp b/rainbow/LinuxFb/Proc.cpp index 99434e576..b8678b027 100644 --- a/rainbow/LinuxFb/Proc.cpp +++ b/rainbow/LinuxFb/Proc.cpp @@ -1,125 +1,176 @@ #include "LinuxFbLocal.h" -#include -#include -#include -#include -#include -#include - NAMESPACE_UPP -#define LLOG(x) LOG(x) - - int fbfd = 0; - struct fb_var_screeninfo vinfo; - struct fb_fix_screeninfo finfo; - long int screensize = 0; - char *fbp = 0; - bool fbEndSession = false; +#define LLOG(x) //LOG(x) //FIXME get input events bool GetShift() { return false; }//!!(GetKeyState(VK_SHIFT) & 0x8000); } bool GetCtrl() { return false; }//!!(GetKeyState(VK_CONTROL) & 0x8000); } bool GetAlt() { return false; }//!!(GetKeyState(VK_MENU) & 0x8000); } bool GetCapsLock() { return false; }//!!(GetKeyState(VK_CAPITAL) & 1); } -bool GetMouseLeft() { return false; }//!!(GetKeyState(VK_LBUTTON) & 0x8000); } -bool GetMouseRight() { return false; }//!!(GetKeyState(VK_RBUTTON) & 0x8000); } -bool GetMouseMiddle() { return false; }//!!(GetKeyState(VK_MBUTTON) & 0x8000); } +bool GetMouseLeft() { return mouseb & 0x4; } +bool GetMouseRight() { return mouseb & 0x1; } +bool GetMouseMiddle() { return mouseb & 0x2; } - -bool FBEndSession() +void purgefd(int fd) { - return fbEndSession; + fd_set fdset; + struct timeval tv; + char temp[64]; + + FD_ZERO(&fdset); + FD_SET(fd, &fdset); + tv.tv_sec = 0; + tv.tv_usec = 0; + while(select(fd+1, &fdset, 0, 0, &tv) > 0) + read(fd, temp, sizeof(temp)); } -bool FBIsWaitingEvent() +int set_imps2(int fd, int b) { - //MSG msg; - return false; //PeekMessage(&msg, NULL, 0, 0, PM_NOREMOVE); + uint8 set[] = {0xf3, 200, 0xf3, 100, 0xf3, 80}; + uint8 reset[] = {0xff}; + int retval = 0; + + if(b && write(fd, &set, sizeof(set)) != sizeof(set)) + return 0; + //SDL says not to reset, some mice wont work with it + if(!b && write(fd, &reset, sizeof (reset)) != sizeof(reset)) + return 0; + + purgefd(fd); + return 1; } -bool FBProcessEvent(bool *quit) +int has_imps2(int fd) { -/* - MSG msg; - if(PeekMessageW(&msg, NULL, 0, 0, PM_REMOVE)) { - if(msg.message == WM_QUIT && quit) - *quit = true; - TranslateMessage(&msg); - DispatchMessageW(&msg); - return true; + uint8 query = 0xF2; + purgefd(fd); + if(write(fd, &query, sizeof (query)) != sizeof(query)) + return 0; + + uint8 ch = 0; + fd_set fdset; + struct timeval tv; + while(1) { + FD_ZERO(&fdset); + FD_SET(fd, &fdset); + tv.tv_sec = 1; + tv.tv_usec = 0; + if(select(fd+1, &fdset, 0, 0, &tv) < 1) break; + if(read(fd, &ch, sizeof(ch)) != sizeof(ch)) break; + switch(ch) { + case 0xFA: + case 0xAA: continue; + case 3: + case 4: return 1; + default: return 0; + } } -*/ - static int i = 10; - if(--i > 0) return true; //fake message processing - return false; + return 0; } -void FBSleep(int ms) +void handle_mouse() { -// MsgWaitForMultipleObjects(0, NULL, FALSE, ms, QS_ALLINPUT); -} + static int offs = 0; + static unsigned char buf[BUFSIZ]; + static int rel = 1; -void FBUpdate(const Rect& inv) -{ -// if(fbHWND) -// ::InvalidateRect(fbHWND, inv, false); - const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer(); - memcpy(fbp, (const char*)~framebuffer, framebuffer.GetLength() * sizeof(RGBA)); -} - -void FBFlush() -{ -// ::UpdateWindow(fbHWND); -// GdiFlush(); -} - -void FBInit(const String& fbdevice) -{ - Ctrl::InitFB(); - - // Open the file for reading and writing - fbfd = open(fbdevice, O_RDWR); - if (!fbfd) { - printf("Error: cannot open framebuffer device.\n"); - exit(1); - } - RLOG("The framebuffer device was opened successfully.\n"); - - // Get fixed screen information - if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { - printf("Error reading fixed information.\n"); - exit(2); - } - - // Get variable screen information - if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { - printf("Error reading variable information.\n"); - exit(3); - } - - RLOG(vinfo.xres << "x" << vinfo.yres << " @ " << vinfo.bits_per_pixel); - - // Figure out the size of the screen in bytes - screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; - - // Map the device to memory - fbp = (char *)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, - fbfd, 0); - if ((intptr_t)fbp == -1) { - printf("Error: failed to map framebuffer device to memory.\n"); - exit(4); - } - RLOG("The framebuffer device was mapped to memory successfully.\n"); + int i, n; + int b = 0; + int dx = 0, dy = 0, dz = 0; + int rdsize = (!mouse_imps2)?(3):(4); - Ctrl::SetFramebufferSize(Size(vinfo.xres, vinfo.yres)); + n = read(mouse_fd, &buf[offs], BUFSIZ-offs); + if(n < 0) return; + n += offs; + + for(i=0; i<(n-(rdsize-1)); i += rdsize ) { + if((buf[i] & 0xC0) != 0) { + i -= (rdsize-1); + continue; + } + if(!mouse_imps2) + { + b = (buf[i] & 0x07); /*MRL*/ + dx = (buf[i] & 0x10) ? buf[i+1] - 256 : buf[i+1]; + dy = (buf[i] & 0x20) ? -(buf[i+2] - 256) : -buf[i+2]; + } + else + { + b = (buf[i] & 0xC7); /*54...MRL*/ + dx = (buf[i] & 0x10) ? buf[i+1] - 256 : buf[i+1]; + dy = (buf[i] & 0x20) ? -(buf[i+2] - 256) : -buf[i+2]; + dz = (char)buf[i+3]; + } + + if(dx || dy) + { + mousep.x += dx; + mousep.y += dy; + mousep.x = minmax(mousep.x, 0, int(vinfo.xres)); + mousep.y = minmax(mousep.y, 0, int(vinfo.yres)); + Ctrl::DoMouseFB(Ctrl::MOUSEMOVE, mousep); + } + + int bm = b ^ mouseb; + mouseb = b; //for GetMouse* + if(bm & 0x1) Ctrl::DoMouseFB((mouseb & 0x1)?Ctrl::LEFTDOWN:Ctrl::LEFTUP, mousep); + if(bm & 0x2) Ctrl::DoMouseFB((mouseb & 0x2)?Ctrl::RIGHTDOWN:Ctrl::RIGHTUP, mousep); + if(bm & 0x4) Ctrl::DoMouseFB((mouseb & 0x4)?Ctrl::MIDDLEDOWN:Ctrl::MIDDLEUP, mousep); + if(dz) Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, mousep, dz*120); + } + if(i < n) { + memcpy(buf, &buf[i], (n-i)); + offs = (n-i); + } else { + offs = 0; + } } -void FBDeInit() +void handle_keyboard() { - munmap(fbp, screensize); - close(fbfd); + +} + +//returns 0 if timeout, 1 for mouse, 2 for keyboard +//common for waitforevents and sleep +int readevents(int ms) +{ + fd_set fdset; + int max_fd; + static struct timeval to; + to.tv_sec = ms / 1000; + to.tv_usec = ms % 1000 * 1000; + + FD_ZERO(&fdset); + max_fd = 0; + if(keyboard_fd >= 0) { + FD_SET(keyboard_fd, &fdset); + if(max_fd < keyboard_fd) { + max_fd = keyboard_fd; + } + } + if(mouse_fd >= 0) { + FD_SET(mouse_fd, &fdset); + if(max_fd < mouse_fd) { + max_fd = mouse_fd; + } + } + if(select(max_fd+1, &fdset, NULL, NULL, &to) > 0 ) { + if(keyboard_fd >= 0 ) { + if(FD_ISSET(keyboard_fd, &fdset)) { + return 2; + } + } + if(mouse_fd >= 0) { + if (FD_ISSET(mouse_fd, &fdset)) { + return 1; + } + } + } + return 0; } END_UPP_NAMESPACE diff --git a/rainbow/LinuxFb/Win.cpp b/rainbow/LinuxFb/Win.cpp new file mode 100644 index 000000000..9aeafdc96 --- /dev/null +++ b/rainbow/LinuxFb/Win.cpp @@ -0,0 +1,131 @@ +#include "LinuxFbLocal.h" + +#define LLOG(x) //LOG(x) + +NAMESPACE_UPP + +bool fbEndSession = false; + +//video +int fbfd = -1; +struct fb_var_screeninfo vinfo; +struct fb_fix_screeninfo finfo; +long int screensize = 0; +char *fbp = 0; + +//mouse +int mouse_fd = -1; +bool mouse_imps2 = false; +Point mousep; +int mouseb = 0; + +//keyb +int keyboard_fd = -1; + +//event +int pend = 0; + +bool FBEndSession() +{ + return fbEndSession; +} + +bool FBIsWaitingEvent() +{ + pend = readevents(0); + return pend > 0; +} + +bool FBProcessEvent(bool *quit) +{ + if(pend) + { + if(pend & 1) handle_mouse(); + if(pend & 2) handle_keyboard(); + pend = 0; //need to reset, since with repeated call is not updated here, would stuck + return true; + } + return false; +} + +void FBSleep(int ms) +{ + pend = readevents(ms); //interruptable sleep +} + +void FBUpdate(const Rect& inv) +{ + const ImageBuffer& framebuffer = Ctrl::GetFrameBuffer(); + memcpy(fbp, ~framebuffer, framebuffer.GetLength() * sizeof(RGBA)); +} + +void FBFlush() +{ + +} + +void FBInit(const String& fbdevice) +{ + Ctrl::InitFB(); + + fbfd = open(fbdevice, O_RDWR); + if (!fbfd) { + printf("Error: cannot open framebuffer device.\n"); + exit(1); + } + LLOG("The framebuffer device was opened successfully.\n"); + + if (ioctl(fbfd, FBIOGET_FSCREENINFO, &finfo)) { + printf("Error reading fixed information.\n"); + exit(2); + } + + if (ioctl(fbfd, FBIOGET_VSCREENINFO, &vinfo)) { + printf("Error reading variable information.\n"); + exit(3); + } + RLOG("FB opened: " << fbdevice << ": " << vinfo.xres << "x" << vinfo.yres << " @ " << vinfo.bits_per_pixel); + + screensize = vinfo.xres * vinfo.yres * vinfo.bits_per_pixel / 8; //bytes + + fbp = (char*)mmap(0, screensize, PROT_READ | PROT_WRITE, MAP_SHARED, fbfd, 0); + if ((intptr_t)fbp == -1) { + printf("Error: failed to map framebuffer device to memory.\n"); + exit(4); + } + LLOG("The framebuffer device was mapped to memory successfully.\n"); + + Ctrl::SetFramebufferSize(Size(vinfo.xres, vinfo.yres)); + + //Mouse stuff + mousep.Clear(); + + static const char *mice[] = { + "/dev/input/mice" + , "/dev/usbmouse" + , "/dev/psaux" + , NULL + }; + + for(int i=0; (mouse_fd < 0) && mice[i]; ++i) { + mouse_fd = open(mice[i], O_RDWR, 0); + if(mouse_fd < 0) mouse_fd = open(mice[i], O_RDONLY, 0); + if(mouse_fd >= 0) { + set_imps2(mouse_fd, 1); + if(mouse_imps2 = has_imps2(mouse_fd)) { + RLOG("IMPS2 mouse enabled: " << mice[i]); + } + } + } + + pend = 4; //fake video expose event to cause first paint +} + +void FBDeInit() +{ + Ctrl::ExitFB(); + munmap(fbp, screensize); + close(fbfd); +} + +END_UPP_NAMESPACE diff --git a/rainbow/SDLFb/Proc.cpp b/rainbow/SDLFb/Proc.cpp index 001207cbf..776781127 100644 --- a/rainbow/SDLFb/Proc.cpp +++ b/rainbow/SDLFb/Proc.cpp @@ -2,7 +2,19 @@ NAMESPACE_UPP -#define LLOG(x) LOG(x) +#define LLOG(x) //LOG(x) + +SDL_Surface *CreateScreen(int w, int h, int bpp, int flags) +{ + SDL_Surface * screen = SDL_SetVideoMode(w, h, bpp, flags); + if(!screen) + { + Cout() << Format("Couldn't set display mode: %s\n", SDL_GetError()); + return NULL; + } + Cout() << Format("Screen is in %s mode\n", (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); + return screen; +} //GetModState ?? bool GetShift() { uint8* ka = SDL_GetKeyState(NULL); return ka[SDLK_LSHIFT] || ka[SDLK_RSHIFT]; } @@ -32,7 +44,109 @@ dword fbKEYtoK(dword chr) { return chr; } -void HandleUserEvents(SDL_Event* event) +void HandleSDLEvent(SDL_Event* event) +{ + switch(event->type) { + case SDL_ACTIVEEVENT: //SDL_ActiveEvent + break; + case SDL_KEYDOWN: + case SDL_KEYUP: //SDL_KeyboardEvent + { + String msgdump; + switch(event->type) + { + case SDL_KEYDOWN: msgdump << "SDL_KEYDOWN"; break; + case SDL_KEYUP: msgdump << "SDL_KEYUP"; break; + } + msgdump << (int)event->key.keysym.sym; + LLOG(msgdump); + + bool b = false; + dword keycode = 0; + if(event->type == SDL_KEYDOWN) { + keycode = fbKEYtoK((dword)event->key.keysym.sym); + if(keycode != K_SPACE) //dont send space on keydown + b = Ctrl::DoKeyFB(keycode, 1); + + //send respective keyup things as char events as well + keycode = (dword)event->key.keysym.unicode; + if((keycode != 127 && keycode > 32 && keycode < 255) + || (keycode == 32 && fbKEYtoK(SDLK_SPACE) == K_SPACE)) + b = Ctrl::DoKeyFB(keycode, 1); + } + else + if(event->type == SDL_KEYUP) + { + keycode = fbKEYtoK((dword)event->key.keysym.sym) | K_KEYUP; + b = Ctrl::DoKeyFB(keycode, 1); + } + } + break; + case SDL_MOUSEMOTION: //SDL_MouseMotionEvent + Ctrl::DoMouseFB(Ctrl::MOUSEMOVE, Point(event->motion.x, event->motion.y)); + break; + case SDL_MOUSEBUTTONDOWN: //SDL_MouseButtonEvent, FIXME DoubleClick + { + Point p(event->button.x, event->button.y); + switch(event->button.button) + { + case SDL_BUTTON_LEFT: Ctrl::DoMouseFB(Ctrl::LEFTDOWN, p); break; + case SDL_BUTTON_RIGHT: Ctrl::DoMouseFB(Ctrl::RIGHTDOWN, p); break; + case SDL_BUTTON_MIDDLE: Ctrl::DoMouseFB(Ctrl::MIDDLEDOWN, p); break; + case SDL_BUTTON_WHEELUP: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, +120); break; + case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, -120); break; + } + } + break; + case SDL_MOUSEBUTTONUP: + { + Point p(event->button.x, event->button.y); + switch(event->button.button) + { + case SDL_BUTTON_LEFT: Ctrl::DoMouseFB(Ctrl::LEFTUP, p); break; + case SDL_BUTTON_RIGHT: Ctrl::DoMouseFB(Ctrl::RIGHTUP, p); break; + case SDL_BUTTON_MIDDLE: Ctrl::DoMouseFB(Ctrl::MIDDLEUP, p); break; + case SDL_BUTTON_WHEELUP: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, +120); break; + case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, -120); break; + } + } + break; + case SDL_JOYAXISMOTION: //SDL_JoyAxisEvent + break; + case SDL_JOYBALLMOTION: //SDL_JoyBallEvent + break; + case SDL_JOYHATMOTION: //SDL_JoyHatEvent + break; + case SDL_JOYBUTTONDOWN: + case SDL_JOYBUTTONUP: //SDL_JoyButtonEvent + break; + case SDL_VIDEORESIZE: //SDL_ResizeEvent + { + width = event->resize.w; + height = event->resize.h; + + SDL_FreeSurface(screen); + screen = CreateScreen(width, height, bpp, videoflags); + ASSERT(screen); + Ctrl::SetFramebufferSize(Size(width, height)); + } + break; + case SDL_VIDEOEXPOSE: //SDL_ExposeEvent + break; + case SDL_QUIT: //SDL_QuitEvent + break; + case SDL_USEREVENT: //SDL_UserEvent + HandleUserEvent(event); + break; + case SDL_SYSWMEVENT: //SDL_SysWMEvent + break; + + default: + break; + } // End switch +} + +void HandleUserEvent(SDL_Event* event) { /* switch (event->user.code) { diff --git a/rainbow/SDLFb/SDLFbLocal.h b/rainbow/SDLFb/SDLFbLocal.h index 21bdee683..42525dc9d 100644 --- a/rainbow/SDLFb/SDLFbLocal.h +++ b/rainbow/SDLFb/SDLFbLocal.h @@ -9,7 +9,16 @@ NAMESPACE_UPP extern bool fbEndSession; -void HandleUserEvents(SDL_Event* event); +extern SDL_Surface * screen; +extern int videoflags; +extern int height; +extern int width; +extern int bpp; + +SDL_Surface *CreateScreen(int w, int h, int bpp, int flags); +dword fbKEYtoK(dword chr); +void HandleSDLEvent(SDL_Event* event); +void HandleUserEvent(SDL_Event* event); END_UPP_NAMESPACE diff --git a/rainbow/SDLFb/Win.cpp b/rainbow/SDLFb/Win.cpp index e50a9e485..0d2fa10aa 100644 --- a/rainbow/SDLFb/Win.cpp +++ b/rainbow/SDLFb/Win.cpp @@ -2,27 +2,15 @@ NAMESPACE_UPP -dword fbKEYtoK(dword chr); +#define LLOG(x) //LOG(x) -SDL_Surface * screen = NULL; bool fbEndSession = false; +SDL_Surface * screen = NULL; int videoflags = 0; int height = 0; int width = 0; int bpp = 0; -SDL_Surface *CreateScreen(int w, int h, int bpp, int flags) -{ - SDL_Surface * screen = SDL_SetVideoMode(w, h, bpp, flags); - if(!screen) - { - Cout() << Format("Couldn't set display mode: %s\n", SDL_GetError()); - return NULL; - } - Cout() << Format("Screen is in %s mode\n", (screen->flags & SDL_FULLSCREEN) ? "fullscreen" : "windowed"); - return screen; -} - bool FBEndSession() { return fbEndSession; @@ -40,108 +28,9 @@ bool FBProcessEvent(bool *quit) { SDL_Event event; if(SDL_PollEvent(&event)) { - switch(event.type) { - case SDL_ACTIVEEVENT: //SDL_ActiveEvent - break; - case SDL_KEYDOWN: - case SDL_KEYUP: //SDL_KeyboardEvent - { - String msgdump; - switch(event.type) - { - case SDL_KEYDOWN: msgdump << "SDL_KEYDOWN"; break; - case SDL_KEYUP: msgdump << "SDL_KEYUP"; break; - } - // msgdump << " wParam = 0x" << FormatIntHex(wParam, 8) - // << ", lParam = 0x" << FormatIntHex(lParam, 8); - msgdump << (int)event.key.keysym.sym; - RLOG(msgdump); - - bool b = false; - dword keycode = 0; - if(event.type == SDL_KEYDOWN) { - keycode = fbKEYtoK((dword)event.key.keysym.sym); - if(keycode != K_SPACE) //dont send space on keydown - b = Ctrl::DoKeyFB(keycode, 1); - - //send respective keyup things as char events as well - keycode = (dword)event.key.keysym.unicode; - if((keycode != 127 && keycode > 32 && keycode < 255) - || (keycode == 32 && fbKEYtoK(SDLK_SPACE) == K_SPACE)) - b = Ctrl::DoKeyFB(keycode, 1); - - } - else - if(event.type == SDL_KEYUP) - { - keycode = fbKEYtoK((dword)event.key.keysym.sym) | K_KEYUP; - b = Ctrl::DoKeyFB(keycode, 1); - } - } - break; - case SDL_MOUSEMOTION: //SDL_MouseMotionEvent - Ctrl::DoMouseFB(Ctrl::MOUSEMOVE, Point(event.motion.x, event.motion.y)); - break; - case SDL_MOUSEBUTTONDOWN: //SDL_MouseButtonEvent, FIXME DoubleClick - { - Point p(event.button.x, event.button.y); - switch(event.button.button) - { - case SDL_BUTTON_LEFT: Ctrl::DoMouseFB(Ctrl::LEFTDOWN, p); break; - case SDL_BUTTON_RIGHT: Ctrl::DoMouseFB(Ctrl::RIGHTDOWN, p); break; - case SDL_BUTTON_MIDDLE: Ctrl::DoMouseFB(Ctrl::MIDDLEDOWN, p); break; - case SDL_BUTTON_WHEELUP: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, +120); break; - case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, -120); break; - } - } - break; - case SDL_MOUSEBUTTONUP: - { - Point p(event.button.x, event.button.y); - switch(event.button.button) - { - case SDL_BUTTON_LEFT: Ctrl::DoMouseFB(Ctrl::LEFTUP, p); break; - case SDL_BUTTON_RIGHT: Ctrl::DoMouseFB(Ctrl::RIGHTUP, p); break; - case SDL_BUTTON_MIDDLE: Ctrl::DoMouseFB(Ctrl::MIDDLEUP, p); break; - case SDL_BUTTON_WHEELUP: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, +120); break; - case SDL_BUTTON_WHEELDOWN: Ctrl::DoMouseFB(Ctrl::MOUSEWHEEL, p, -120); break; - } - } - break; - case SDL_JOYAXISMOTION: //SDL_JoyAxisEvent - break; - case SDL_JOYBALLMOTION: //SDL_JoyBallEvent - break; - case SDL_JOYHATMOTION: //SDL_JoyHatEvent - break; - case SDL_JOYBUTTONDOWN: - case SDL_JOYBUTTONUP: //SDL_JoyButtonEvent - break; - case SDL_VIDEORESIZE: //SDL_ResizeEvent - { - width = event.resize.w; - height = event.resize.h; - - SDL_FreeSurface(screen); - screen = CreateScreen(width, height, bpp, videoflags); - ASSERT(screen); - Ctrl::SetFramebufferSize(Size(width, height)); - } - break; - case SDL_VIDEOEXPOSE: //SDL_ExposeEvent - break; - case SDL_QUIT: //SDL_QuitEvent - if(quit) *quit = true; - break; - case SDL_USEREVENT: //SDL_UserEvent - HandleUserEvents(&event); - break; - case SDL_SYSWMEVENT: //SDL_SysWMEvent - break; - - default: - break; - } // End switch + if(event.type == SDL_QUIT && quit) + *quit = true; + HandleSDLEvent(&event); return true; } // End while return false; @@ -162,7 +51,7 @@ void FBUpdate(const Rect& inv) memcpy(screen->pixels, ~framebuffer, framebuffer.GetLength() * sizeof(RGBA)); #endif -#if 1 +#if 0 ASSERT(Size(screen->w,screen->h) == framebuffer.GetSize()); Size ssz = inv.GetSize(); @@ -183,8 +72,6 @@ void FBUpdate(const Rect& inv) void FBFlush() { -// ::UpdateWindow(fbHWND); -// GdiFlush(); } void FBInit() @@ -199,7 +86,7 @@ void FBInit() return; } - SDL_EnableUNICODE(1); + SDL_EnableUNICODE(1); //for unicode keycode availability SDL_EnableKeyRepeat(SDL_DEFAULT_REPEAT_DELAY, SDL_DEFAULT_REPEAT_INTERVAL/2); const SDL_VideoInfo* vi = SDL_GetVideoInfo(); @@ -207,8 +94,6 @@ void FBInit() width = vi->current_w; height = vi->current_h; - //width = 600; - //height = 400; bpp = vi->vfmt->BitsPerPixel; ASSERT(bpp == 32); @@ -218,12 +103,11 @@ void FBInit() screen = CreateScreen(width, height, bpp, videoflags); ASSERT(screen); Ctrl::SetFramebufferSize(Size(width, height)); - -// Csizeinit(); } void FBDeInit() { + Ctrl::ExitFB(); SDL_FreeSurface(screen); SDL_Quit(); }