/* ScummVM - Scumm Interpreter * Copyright (C) 2001/2002 The ScummVM project * * This program is free software; you can redistribute it and/or * modify it under the terms of the GNU General Public License * as published by the Free Software Foundation; either version 2 * of the License, or (at your option) any later version. * This program is distributed in the hope that it will be useful, * but WITHOUT ANY WARRANTY; without even the implied warranty of * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the * GNU General Public License for more details. * You should have received a copy of the GNU General Public License * along with this program; if not, write to the Free Software * Foundation, Inc., 59 Temple Place - Suite 330, Boston, MA 02111-1307, USA. * * $Header$ * */ #include "wince.h" #ifdef WIN32_PLATFORM_WFSP #include #define IDM_SMARTFON_LIST_BASE 99100 #define IDM_SMARTFON_MAP_BASE 99200 #define SCAN_LOCATION "" #define KEYS_VERSION 1 #define TOTAL_KEYS 10 #define TOTAL_ZONES 3 typedef struct zoneDesc { int x; int y; int width; int height; } zoneDesc; typedef BOOL (*tSHCreateMenuBar)(void*); typedef void (*tSmartfonAction)(OSystem_WINCE3 *wm, BOOL repeat); extern const char *getBuildDate(); extern tSHCreateMenuBar dynamicSHCreateMenuBar; extern bool need_GAPI; extern void startFindGame(BOOL display, TCHAR *path); extern bool loadGameSettings(BOOL display); extern void sortFoundGames(void); extern int getTotalGames(void); extern void getSelectedGame(int result, char *id, TCHAR *directory, char* is_demo); extern TCHAR* getGameName(int); extern Engine *engine; extern bool is_simon; extern bool is_bass; extern bool sound_activated; extern void Cls(); int game_chosen; HMENU gamesMenu; HMENU optionsMenu; HMENU gamesListMenu; HMENU keysMappingMenu; HWND _hWnd; HWND _hWndMenu; int mouseX; int mouseY; int lastKeyPressed = 0; int lastKeyRepeat = 0; int mapping = -1; int mappingDone = -1; int repeatX; int stepX1; int stepX2; int stepX3; int repeatY; int stepY1; int stepY2; int stepY3; int mouseXZone[TOTAL_ZONES]; int mouseYZone[TOTAL_ZONES]; int currentZone = 0; extern char is_demo; zoneDesc ZONES[TOTAL_ZONES] = { { 0, 0, 320, 145 }, { 0, 145, 150, 55 }, { 150, 145, 170, 55 } }; const char* SMARTFON_KEYS_MAPPING[TOTAL_KEYS] = { "Up", "Down", "Left", "Right", "Left click", "Right click", "Options", "Skip", "Zone", "Boss" }; #define HELP1 \ "USAGE\r\n\r\n" \ \ "Copy your games on your storage card, then do a scan\r\n" \ "Some games must be put in a specific directory\r\n" \ \ "* loomcd for Loom VGA\r\n" \ "* loom for Loom EGA\r\n" \ "* zak256 for Zak Mc Kracken FMTOWNS\r\n" \ "* indy3ega for Indiana Jones 3 EGA\r\n" \ "* indy3 for Indiana Jones 3 VGA\r\n" \ "* monkeyvga for Monkey Island 1 VGA floppy\r\n" \ "* monkeyega for Monkey Island 1 EGA\r\n" \ \ "\r\nKEYS MAPPING\r\n\r\n" \ \ "Map some actions to the keys you'd like\r\n" \ "* Up, Down, Left, Right : mouse cursor movement - keeping the key pressed makes the cursor move faster\r\n" \ "* Left click, Right click : mouse click\r\n" \ "* Zone : jump cursor to game/verbs/inventory - VERY useful :)\r\n" \ "* Options : open options dialog, to save/load/quit\r\n" \ "* Skip : skip the current non-interactive sequence or dialog\r\n" \ "* Boss : save and exit quickly :)\r\n" #define HELP2 \ "\r\nMORE INFORMATION HELP \r\n\r\n" \ "* http://scummvm.sf.net : official ScummVM site\r\n" \ "* http://arisme.free.fr/PocketScumm : latest version of this port\r\n" \ "* http://www.pocketmatrix.com : PocketMatrix forums (preferred help forums for PocketPC & Smartphone versions)\r\n" \ "* http://www.smartphony.org : Smartphony news & forums (french help forum for Smartphone version)\r\n" \ "* http://www.modaco.com : MoDaCo forums (english help forum for Smartphone version)\r\n" \ "\r\nHAPPY ADVENTURING :)\r\n" #define HELP HELP1 HELP2 void SmartfonUp(OSystem_WINCE3 *wm, int repeat); void SmartfonDown(OSystem_WINCE3 *wm, int repeat); void SmartfonLeft(OSystem_WINCE3 *wm, int repeat); void SmartfonRight(OSystem_WINCE3 *wm, int repeat); void SmartfonLeftClick(OSystem_WINCE3 *wm, int repeat); void SmartfonLeftUp(OSystem_WINCE3 *wm, int repeat); void SmartfonRightClick(OSystem_WINCE3 *wm, int repeat); void SmartfonRightUp(OSystem_WINCE3 *wm, int repeat); void SmartfonSave(OSystem_WINCE3 *wm, int repeat); void SmartfonSkip(OSystem_WINCE3 *wm, int repeat); void SmartfonBoss(OSystem_WINCE3 *wm, int repeat); void SmartfonZone(OSystem_WINCE3 *wm, int repeat); const tSmartfonAction SMARTFON_ACTIONS[TOTAL_KEYS] = { SmartfonUp, SmartfonDown, SmartfonLeft, SmartfonRight, SmartfonLeftClick, SmartfonRightClick, SmartfonSave, SmartfonSkip, SmartfonZone, SmartfonBoss, }; const tSmartfonAction SMARTFON_DEACTIONS[TOTAL_KEYS] = { NULL, NULL, NULL, NULL, SmartfonLeftUp, SmartfonRightUp, NULL, NULL, NULL, NULL }; const char* KEYS_NAME[] = { "1", "2", "3","4", "5", "6", "7", "8", "9", "*", "0", "#", "Home", "Back", "Up", "Down", "Left", "Right", "Action", "Hang up", "Call", "Soft 1", "Soft 2", "Power", "Volume Up" ,"Volume Down", "Record", "None", 0 }; const int KEYS_MAPPING[] = { '1', '2', '3', '4', '5', '6', '7', '8', '9', VK_F8, '0', VK_F9, VK_LWIN, VK_ESCAPE, VK_UP, VK_DOWN, VK_LEFT, VK_RIGHT, VK_RETURN, VK_F4, VK_F3, VK_F1, VK_F2, VK_F18, VK_F6, VK_F7, VK_F10, 0xff, 0 }; const int DEFAULT_MAPPING[TOTAL_KEYS] = { '4', '6', '8', '2', VK_F1, VK_F2, VK_LWIN, VK_ESCAPE, VK_F8, 0xff }; int current_mapping[TOTAL_KEYS]; // Actions void SmartfonUp(OSystem_WINCE3 *wm, int repeat) { if (repeat > repeatY) mouseY -= stepY3; else if (repeat) mouseY -= stepY2; else mouseY -= stepY1; if (mouseY < 0) mouseY = 0; wm->_event.event_code = OSystem::EVENT_MOUSEMOVE; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } void SmartfonDown(OSystem_WINCE3 *wm, int repeat) { if (repeat > repeatY) mouseY += stepY3; else if (repeat) mouseY += stepY2; else mouseY += stepY1; if (mouseY > 200) mouseY = 200; wm->_event.event_code = OSystem::EVENT_MOUSEMOVE; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } void SmartfonLeft(OSystem_WINCE3 *wm, int repeat) { if (repeat > repeatX) mouseX -= stepX3; else if (repeat) mouseX -= stepX2; else mouseX -= stepX1; if (mouseX < 0) mouseX = 0; wm->_event.event_code = OSystem::EVENT_MOUSEMOVE; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } void SmartfonRight(OSystem_WINCE3 *wm, int repeat) { if (repeat > repeatX) mouseX += stepX3; else if (repeat) mouseX += stepX2; else mouseX += stepX1; if (mouseX > 320) mouseX = 320; wm->_event.event_code = OSystem::EVENT_MOUSEMOVE; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } void SmartfonLeftClick(OSystem_WINCE3 *wm, int repeat) { wm->_event.event_code = OSystem::EVENT_LBUTTONDOWN; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } void SmartfonLeftUp(OSystem_WINCE3 *wm, int repeat) { wm->_event.event_code = OSystem::EVENT_LBUTTONUP; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } void SmartfonRightClick(OSystem_WINCE3 *wm, int repeat) { wm->_event.event_code = OSystem::EVENT_RBUTTONDOWN; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } void SmartfonRightUp(OSystem_WINCE3 *wm, int repeat) { wm->_event.event_code = OSystem::EVENT_RBUTTONUP; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } void SmartfonSave(OSystem_WINCE3 *wm, int repeat) { if (is_simon) return; wm->_event.event_code = OSystem::EVENT_KEYDOWN; if (is_bass) wm->_event.kbd.ascii = 63; else wm->_event.kbd.ascii = 319; // "F5" key; opens up the save menu in Scumm games } void SmartfonSkip(OSystem_WINCE3 *wm, int repeat) { wm->_event.event_code = OSystem::EVENT_KEYDOWN; if (is_simon || is_bass) { wm->_event.kbd.ascii = VK_ESCAPE; wm->_event.kbd.keycode = VK_ESCAPE; return; } /* if (g_scumm->vm.cutScenePtr[g_scumm->vm.cutSceneStackPointer] || g_scumm->_insaneState) wm->_event.kbd.ascii = g_scumm->_vars[g_scumm->VAR_CUTSCENEEXIT_KEY]; else if (g_scumm->_talkDelay > 0) wm->_event.kbd.ascii = g_scumm->VAR_TALKSTOP_KEY; else wm->_event.kbd.ascii = VK_ESCAPE; */ wm->_event.kbd.ascii = Scumm::KEY_ALL_SKIP; } void SmartfonBoss(OSystem_WINCE3 *wm, int repeat) { SHELLEXECUTEINFO se; sound_activated = false; Cls(); Scumm::g_scumm->requestSave(0, "BOSS"); Scumm::g_scumm->scummLoop(0); dynamicGXCloseInput(); dynamicGXCloseDisplay(); SDL_AudioQuit(); memset(&se, 0, sizeof(se)); se.cbSize = sizeof(se); se.hwnd = NULL; se.lpFile = TEXT("tasks.exe"); se.lpVerb = TEXT("open"); se.lpDirectory = TEXT("\\windows"); ShellExecuteEx(&se); exit(1); } void updateZone(int x, int y) { int i; for (i=0; i= ZONES[i].x && y >= ZONES[i].y && x <= ZONES[i].x + ZONES[i].width && y <= ZONES[i].y + ZONES[i].height ) { mouseXZone[i] = x; mouseYZone[i] = y; break; } } void initZone() { int i; for (i=0; i= TOTAL_ZONES) currentZone = 0; mouseX = mouseXZone[currentZone]; mouseY = mouseYZone[currentZone]; wm->_event.event_code = OSystem::EVENT_MOUSEMOVE; wm->_event.mouse.x = mouseX; wm->_event.mouse.y = mouseY; } // char *getKeyName(int key) { int i; for (i=0; KEYS_MAPPING[i]; i++) if (KEYS_MAPPING[i] == key) return (char*)KEYS_NAME[i]; return NULL; } void updateMapping(int mapping, int key) { int i; for (i=0; i= IDM_SMARTFON_MAP_BASE) { mapping = wParam - IDM_SMARTFON_MAP_BASE; disableHotKeys(); return TRUE; } if (wParam >= IDM_SMARTFON_LIST_BASE) { game_chosen = wParam - IDM_SMARTFON_LIST_BASE; saveKeyMapping(); return TRUE; } switch(wParam) { case IDM_SMARTFON_QUIT: exit(0); break; case IDM_SMARTFON_SCAN: doSmartphoneScan(); break; case IDM_SMARTFON_HELP: TCHAR *help; help = (TCHAR*)malloc((strlen(HELP) + 1) * sizeof(TCHAR)); MultiByteToWideChar(CP_ACP, 0, HELP, strlen(HELP) + 1, help, (strlen(HELP) + 1) * sizeof(TCHAR)); MessageBox(hWnd, help, TEXT("PocketScumm help"), MB_OK | MB_ICONINFORMATION); free(help); break; case IDM_SMARTFON_SOUND: if (ConfMan.getBool("Sound", "wince") || ConfMan.get("Sound", "wince").c_str() == NULL) { sound_activated = false; ConfMan.set("Sound", false, "wince"); CheckMenuItem(optionsMenu, IDM_SMARTFON_SOUND, MF_BYCOMMAND | MF_UNCHECKED); } else { sound_activated = true; ConfMan.set("Sound", true, "wince"); CheckMenuItem(optionsMenu, IDM_SMARTFON_SOUND, MF_BYCOMMAND | MF_CHECKED); } break; default: return FALSE; } break; case WM_KEYDOWN: int i; if (!need_GAPI && mapping == -1) break; if (mapping != -1) { mappingDone = wParam; InvalidateRect(_hWnd, NULL, FALSE); enableHotKeys(); return TRUE; } for (i=0; i_event.event_code = OSystem::EVENT_KEYDOWN; wm->_event.kbd.ascii = wParam; wm->_event.kbd.keycode = wParam; break; case WM_KEYUP: if (!need_GAPI) break; for (i=0; i