//============================================================================ // // SSSS tt lll lll // SS SS tt ll ll // SS tttttt eeee ll ll aaaa // SSSS tt ee ee ll ll aa // SS tt eeeeee ll ll aaaaa -- "An Atari 2600 VCS Emulator" // SS SS tt ee ll ll aa aa // SSSS ttt eeeee llll llll aaaaa // // Copyright (c) 1995-2007 by Bradford W. Mott and the Stella team // // See the file "license" for information on usage and redistribution of // this file, and for a DISCLAIMER OF ALL WARRANTIES. // // Windows CE Port by Kostas Nakos // $Id: missing.cpp,v 1.10 2007/01/27 10:52:49 knakos Exp $ //============================================================================ #include #include "bspf.hxx" #include "SDL.h" #include "OSystemWinCE.hxx" #include "FrameBufferWinCE.hxx" #include "EventHandler.hxx" char *msg = NULL; extern OSystemWinCE *theOSystem; extern SDLKey VK_keymap[SDLK_LAST]; queue eventqueue; int time(int dummy) { return GetTickCount(); } char *getcwd(void) { TCHAR fileUnc[MAX_PATH+1]; static char cwd[MAX_PATH+1] = ""; char *plast; GetModuleFileName(NULL, fileUnc, MAX_PATH); WideCharToMultiByte(CP_ACP, 0, fileUnc, -1, cwd, MAX_PATH, NULL, NULL); plast = strrchr(cwd, '\\'); if(plast) *plast = 0; return cwd; } SDLKey RotateKey(SDLKey key) { uInt8 dir = 0; uInt8 mode = ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->getmode(); uInt8 state = theOSystem->eventHandler().state(); bool lscp = ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->IsLandscape(); if (!(lscp && mode == 0)) if (state != EventHandler::S_EMULATE) if (mode != 2) dir = 1; else dir = 2; else dir = mode; switch (dir) { case 0: return key; case 1: switch (key) { case SDLK_LEFT: return SDLK_UP; case SDLK_DOWN: return SDLK_LEFT; case SDLK_RIGHT: return SDLK_DOWN; case SDLK_UP: return SDLK_RIGHT; } break; case 2: switch (key) { case SDLK_LEFT: return SDLK_DOWN; case SDLK_DOWN: return SDLK_RIGHT; case SDLK_RIGHT: return SDLK_UP; case SDLK_UP: return SDLK_LEFT; } break; } return key; } void KeySetup(void) { // Map the VK keysyms // stolen from SDL_dibevents.c :-) for (int i=0; i SDLK_F3 is call button, VK_F4 => SDLK_F4 is end call button VK_keymap[klist.vkC] = SDLK_F5; VK_keymap[klist.vkStart] = SDLK_F6; } // SDL DECLSPEC Uint32 SDLCALL SDL_WasInit(Uint32 flags) { return 0xFFFFFFFF; } DECLSPEC int SDLCALL SDL_EnableUNICODE(int enable) { return 1; } DECLSPEC int SDLCALL SDL_Init(Uint32 flags) { return 1; } DECLSPEC int SDLCALL SDL_ShowCursor(int toggle) { return 1; } DECLSPEC SDL_GrabMode SDLCALL SDL_WM_GrabInput(SDL_GrabMode mode) { return SDL_GRAB_ON; } DECLSPEC void SDLCALL SDL_WM_SetCaption(const char *title, const char *icon) { return; } DECLSPEC void SDLCALL SDL_FreeSurface(SDL_Surface *surface) { return; } DECLSPEC void SDLCALL SDL_WM_SetIcon(SDL_Surface *icon, Uint8 *mask) { return; } DECLSPEC SDL_Surface * SDLCALL SDL_CreateRGBSurfaceFrom(void *pixels, int width, int height, int depth, int pitch, Uint32 Rmask, Uint32 Gmask, Uint32 Bmask, Uint32 Amask) { return NULL; } DECLSPEC void SDLCALL SDL_WarpMouse(Uint16 x, Uint16 y) { return; } DECLSPEC void SDL_Delay(Uint32 ms) { Sleep(ms); } DECLSPEC int SDLCALL SDL_PollEvent(SDL_Event *event) { static bool cornertap[4] = {false, false, false, false}; while (!eventqueue.empty()) { memcpy(event, &(eventqueue.front()), sizeof(SDL_Event)); eventqueue.pop(); // tap in corners if ((event->type == SDL_MOUSEBUTTONDOWN || event->type == SDL_MOUSEBUTTONUP) && theOSystem->eventHandler().state() == EventHandler::S_EMULATE) if (event->type == SDL_MOUSEBUTTONDOWN) { uInt16 cs = ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->IsVGA() ? 40 : 20; uInt16 x = event->motion.x; uInt16 y = event->motion.y; uInt16 sx, sy; ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->GetScreenExtents(&sx, &sy); if (x > (sx - cs) && y > (sy - cs) && !cornertap[0]) { // bottom right corner for rotate ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay(); cornertap[0] = true; continue; } else if (x < cs && y > (sy - cs) && !cornertap[1]) { // bottom left corner for launcher theOSystem->eventHandler().handleEvent(Event::LauncherMode, EventHandler::S_EMULATE); cornertap[1] = true; } else if (x < cs && y < cs && !cornertap[2]) { // top left for menu theOSystem->eventHandler().enterMenuMode(EventHandler::S_MENU); cornertap[2] = true; continue; } } else { cornertap[0] = cornertap[1] = cornertap[2] = false; } return 1; } event->type = SDL_NOEVENT; return 0; }