mirror of
https://github.com/libretro/scummvm.git
synced 2025-02-01 16:35:20 +00:00
New CE backend initial commit
svn-id: r12618
This commit is contained in:
parent
cccecd0ee3
commit
bf88c1eae5
250
backends/wince/CEActions.cpp
Normal file
250
backends/wince/CEActions.cpp
Normal file
@ -0,0 +1,250 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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 "stdafx.h"
|
||||
#include "CEActions.h"
|
||||
#include "KeysBuffer.h"
|
||||
|
||||
#include "gui/message.h"
|
||||
|
||||
#include "scumm/scumm.h"
|
||||
|
||||
#include "common/config-manager.h"
|
||||
|
||||
const String actionNames[] = {
|
||||
"none",
|
||||
"Pause",
|
||||
"Save",
|
||||
"Quit",
|
||||
"Skip",
|
||||
"Hide",
|
||||
"Keyboard",
|
||||
"Sound",
|
||||
"Right click",
|
||||
"Cursor",
|
||||
"Free look"
|
||||
};
|
||||
|
||||
CEActions* CEActions::Instance() {
|
||||
return _instance;
|
||||
}
|
||||
|
||||
String CEActions::actionName(ActionType action) {
|
||||
return actionNames[action];
|
||||
}
|
||||
|
||||
int CEActions::size() {
|
||||
return ACTION_LAST - 1;
|
||||
}
|
||||
|
||||
CEActions::CEActions(OSystem_WINCE3 *mainSystem, GameDetector &detector) :
|
||||
_mainSystem(mainSystem), _mapping_active(false), _right_click_needed(false) {
|
||||
int i;
|
||||
bool is_simon = (strcmp(detector._targetName.c_str(), "simon") == 0);
|
||||
bool is_sword1 = (detector._targetName == "sword1");
|
||||
bool is_sword2 = (strcmp(detector._targetName.c_str(), "sword2") == 0);
|
||||
bool is_queen = (detector._targetName == "queen");
|
||||
bool is_sky = (detector._targetName == "sky");
|
||||
|
||||
for (i=0; i<ACTION_LAST; i++)
|
||||
_action_mapping[i] = 0;
|
||||
|
||||
// See if a right click mapping could be needed
|
||||
if (is_sword1 || is_sword2 || is_sky || is_queen || detector._targetName == "comi" ||
|
||||
detector._targetName == "samnmax")
|
||||
_right_click_needed = true;
|
||||
|
||||
// Initialize keys for different actions
|
||||
// Pause
|
||||
_key_action[ACTION_PAUSE].setAscii(VK_SPACE);
|
||||
_action_enabled[ACTION_PAUSE] = true;
|
||||
// Save
|
||||
if (is_simon)
|
||||
_action_enabled[ACTION_SAVE] = false;
|
||||
else
|
||||
if (is_queen) {
|
||||
_action_enabled[ACTION_SAVE] = true;
|
||||
_key_action[ACTION_SAVE].setAscii(282); // F1 key
|
||||
}
|
||||
else
|
||||
if (is_sky) {
|
||||
_action_enabled[ACTION_SAVE] = true;
|
||||
_key_action[ACTION_SAVE].setAscii(63);
|
||||
}
|
||||
else {
|
||||
_action_enabled[ACTION_SAVE] = true;
|
||||
_key_action[ACTION_SAVE].setAscii(319); // F5 key
|
||||
}
|
||||
// Quit
|
||||
_action_enabled[ACTION_QUIT] = true;
|
||||
// Skip
|
||||
_action_enabled[ACTION_SKIP] = true;
|
||||
if (is_simon || is_sky || is_sword2 || is_queen || is_sword1)
|
||||
_key_action[ACTION_SKIP].setAscii(VK_ESCAPE);
|
||||
else
|
||||
_key_action[ACTION_SKIP].setAscii(Scumm::KEY_ALL_SKIP);
|
||||
// Hide
|
||||
_action_enabled[ACTION_HIDE] = true;
|
||||
// Keyboard
|
||||
_action_enabled[ACTION_KEYBOARD] = true;
|
||||
// Sound
|
||||
_action_enabled[ACTION_SOUND] = true;
|
||||
// RightClick
|
||||
_action_enabled[ACTION_RIGHTCLICK] = true;
|
||||
// Cursor
|
||||
_action_enabled[ACTION_CURSOR] = true;
|
||||
// Freelook
|
||||
_action_enabled[ACTION_FREELOOK] = true;
|
||||
}
|
||||
|
||||
|
||||
CEActions::~CEActions() {
|
||||
}
|
||||
|
||||
void CEActions::init(OSystem_WINCE3 *mainSystem, GameDetector &detector) {
|
||||
_instance = new CEActions(mainSystem, detector);
|
||||
}
|
||||
|
||||
bool CEActions::perform(ActionType action) {
|
||||
switch (action) {
|
||||
case ACTION_PAUSE:
|
||||
case ACTION_SAVE:
|
||||
case ACTION_SKIP:
|
||||
KeysBuffer::Instance()->add(&_key_action[action]);
|
||||
return true;
|
||||
case ACTION_KEYBOARD:
|
||||
_mainSystem->swap_panel();
|
||||
return true;
|
||||
case ACTION_HIDE:
|
||||
_mainSystem->swap_panel_visibility();
|
||||
return true;
|
||||
case ACTION_SOUND:
|
||||
_mainSystem->swap_sound_master();
|
||||
return true;
|
||||
case ACTION_RIGHTCLICK:
|
||||
_mainSystem->add_right_click();
|
||||
return true;
|
||||
case ACTION_CURSOR:
|
||||
_mainSystem->swap_mouse_visibility();
|
||||
return true;
|
||||
case ACTION_QUIT:
|
||||
GUI::MessageDialog alert("Do you want to quit ?", "Yes", "No");
|
||||
if (alert.runModal() == 1)
|
||||
_mainSystem->quit();
|
||||
return true;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CEActions::isActive(ActionType action) {
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CEActions::isEnabled(ActionType action) {
|
||||
return _action_enabled[action];
|
||||
}
|
||||
|
||||
void CEActions::beginMapping(bool start) {
|
||||
_mapping_active = start;
|
||||
}
|
||||
|
||||
bool CEActions::mappingActive() {
|
||||
return _mapping_active;
|
||||
}
|
||||
|
||||
bool CEActions::performMapped(unsigned int keyCode, bool pushed) {
|
||||
int i;
|
||||
|
||||
for (i=0; i<ACTION_LAST; i++) {
|
||||
if (_action_mapping[i] == keyCode) {
|
||||
if (pushed)
|
||||
return perform((ActionType)(i + 1));
|
||||
else
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CEActions::loadMapping() {
|
||||
const char *tempo;
|
||||
int version;
|
||||
int i;
|
||||
version = ConfMan.getInt("CE_mapping_version");
|
||||
if (version != ACTIONS_VERSION)
|
||||
return false;
|
||||
tempo = ConfMan.get("CE_mapping").c_str();
|
||||
if (tempo && strlen(tempo)) {
|
||||
for (i=0; i<ACTION_LAST; i++) {
|
||||
char x[6];
|
||||
int j;
|
||||
memset(x, 0, sizeof(x));
|
||||
memcpy(x, tempo + 5 * i, 4);
|
||||
sscanf(x, "%x", &j);
|
||||
_action_mapping[i] = j;
|
||||
}
|
||||
return true;
|
||||
}
|
||||
else
|
||||
return false;
|
||||
}
|
||||
|
||||
bool CEActions::saveMapping() {
|
||||
char tempo[200];
|
||||
int i;
|
||||
tempo[0] = '\0';
|
||||
ConfMan.set("CE_mapping_version", ACTIONS_VERSION);
|
||||
for (i=0; i<ACTION_LAST; i++) {
|
||||
char x[4];
|
||||
sprintf(x, "%.4x ", _action_mapping[i]);
|
||||
strcat(tempo, x);
|
||||
}
|
||||
ConfMan.set("CE_mapping", tempo);
|
||||
ConfMan.flushToDisk();
|
||||
return true;
|
||||
}
|
||||
|
||||
unsigned int CEActions::getMapping(ActionType action) {
|
||||
return _action_mapping[action - 1];
|
||||
}
|
||||
|
||||
|
||||
void CEActions::setMapping(ActionType action, unsigned int keyCode) {
|
||||
int i;
|
||||
|
||||
for (i=0; i<ACTION_LAST; i++) {
|
||||
if (_action_mapping[i] == keyCode)
|
||||
_action_mapping[i] = 0;
|
||||
}
|
||||
|
||||
_action_mapping[action - 1] = keyCode;
|
||||
}
|
||||
|
||||
bool CEActions::needsRightClickMapping() {
|
||||
if (!_right_click_needed)
|
||||
return false;
|
||||
else
|
||||
return (_action_mapping[ACTION_RIGHTCLICK] == 0);
|
||||
}
|
||||
|
||||
CEActions *CEActions::_instance = NULL;
|
91
backends/wince/CEActions.h
Normal file
91
backends/wince/CEActions.h
Normal file
@ -0,0 +1,91 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CEACTIONS
|
||||
#define CEACTIONS
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
|
||||
|
||||
#include "base/gameDetector.h"
|
||||
#include "wince-sdl.h"
|
||||
#include "Key.h"
|
||||
|
||||
enum ActionType {
|
||||
ACTION_NONE = 0,
|
||||
ACTION_PAUSE,
|
||||
ACTION_SAVE,
|
||||
ACTION_QUIT,
|
||||
ACTION_SKIP,
|
||||
ACTION_HIDE,
|
||||
ACTION_KEYBOARD,
|
||||
ACTION_SOUND,
|
||||
ACTION_RIGHTCLICK,
|
||||
ACTION_CURSOR,
|
||||
ACTION_FREELOOK,
|
||||
|
||||
ACTION_LAST
|
||||
};
|
||||
|
||||
#define ACTIONS_VERSION 1
|
||||
|
||||
class OSystem_WINCE3;
|
||||
|
||||
class CEActions {
|
||||
public:
|
||||
static CEActions* Instance();
|
||||
static void init(OSystem_WINCE3 *mainSystem, GameDetector &detector);
|
||||
|
||||
// Actions
|
||||
bool perform(ActionType action);
|
||||
bool isActive(ActionType action);
|
||||
bool isEnabled(ActionType action);
|
||||
String actionName(ActionType action);
|
||||
int size();
|
||||
|
||||
// Mapping
|
||||
void beginMapping(bool start);
|
||||
bool mappingActive();
|
||||
bool performMapped(unsigned int keyCode, bool pushed);
|
||||
bool loadMapping();
|
||||
bool saveMapping();
|
||||
unsigned int getMapping(ActionType action);
|
||||
void setMapping(ActionType action, unsigned int keyCode);
|
||||
|
||||
// Utility
|
||||
bool needsRightClickMapping();
|
||||
|
||||
~CEActions();
|
||||
private:
|
||||
CEActions(OSystem_WINCE3 *mainSystem, GameDetector &detector);
|
||||
static CEActions* _instance;
|
||||
OSystem_WINCE3 *_mainSystem;
|
||||
Key _key_action[ACTION_LAST];
|
||||
bool _action_active[ACTION_LAST];
|
||||
bool _action_enabled[ACTION_LAST];
|
||||
unsigned int _action_mapping[ACTION_LAST];
|
||||
bool _mapping_active;
|
||||
bool _right_click_needed;
|
||||
};
|
||||
|
||||
#endif
|
118
backends/wince/CEDevice.cpp
Normal file
118
backends/wince/CEDevice.cpp
Normal file
@ -0,0 +1,118 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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 "stdafx.h"
|
||||
#include "CEDevice.h"
|
||||
|
||||
bool CEDevice::_hasGAPIMapping = false;
|
||||
struct GXKeyList CEDevice::_portrait_keys = {0};
|
||||
|
||||
#define KEY_CALENDAR 0xc1
|
||||
#define KEY_CONTACTS 0xc2
|
||||
#define KEY_INBOX 0xc3
|
||||
#define KEY_TASK 0xc4
|
||||
|
||||
bool CEDevice::hasPocketPCResolution() {
|
||||
return (GetSystemMetrics(SM_CXSCREEN) < 320 && GetSystemMetrics(SM_CXSCREEN) >= 240);
|
||||
}
|
||||
|
||||
bool CEDevice::hasDesktopResolution() {
|
||||
return (GetSystemMetrics(SM_CXSCREEN) >= 320);
|
||||
}
|
||||
|
||||
bool CEDevice::hasWideResolution() {
|
||||
return (GetSystemMetrics(SM_CXSCREEN) >= 640 && GetSystemMetrics(SM_CYSCREEN) >= 480);
|
||||
}
|
||||
|
||||
bool CEDevice::hasSmartphoneResolution() {
|
||||
return (GetSystemMetrics(SM_CXSCREEN) < 240);
|
||||
}
|
||||
|
||||
bool CEDevice::enableHardwareKeyMapping() {
|
||||
HINSTANCE GAPI_handle;
|
||||
tGXVoidFunction GAPIOpenInput;
|
||||
tGXGetDefaultKeys GAPIGetDefaultKeys;
|
||||
|
||||
_hasGAPIMapping = false;
|
||||
GAPI_handle = LoadLibrary(TEXT("gx.dll"));
|
||||
if (!GAPI_handle)
|
||||
return false;
|
||||
GAPIOpenInput = (tGXVoidFunction)GetProcAddress(GAPI_handle, TEXT("?GXOpenInput@@YAHXZ"));
|
||||
if (!GAPIOpenInput)
|
||||
return false;
|
||||
GAPIGetDefaultKeys = (tGXGetDefaultKeys)GetProcAddress(GAPI_handle, TEXT("?GXGetDefaultKeys@@YA?AUGXKeyList@@H@Z"));
|
||||
if (!GAPIGetDefaultKeys)
|
||||
return false;
|
||||
GAPIOpenInput();
|
||||
_portrait_keys = GAPIGetDefaultKeys(GX_NORMALKEYS);
|
||||
_hasGAPIMapping = true;
|
||||
CloseHandle(GAPI_handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
bool CEDevice::disableHardwareKeyMapping() {
|
||||
HINSTANCE GAPI_handle;
|
||||
tGXVoidFunction GAPICloseInput;
|
||||
|
||||
GAPI_handle = LoadLibrary(TEXT("gx.dll"));
|
||||
if (!GAPI_handle)
|
||||
return false;
|
||||
GAPICloseInput = (tGXVoidFunction)GetProcAddress(GAPI_handle, TEXT("?GXCloseInput@@YAHXZ"));
|
||||
if (!GAPICloseInput)
|
||||
return false;
|
||||
GAPICloseInput();
|
||||
CloseHandle(GAPI_handle);
|
||||
return true;
|
||||
}
|
||||
|
||||
Common::String CEDevice::getKeyName(unsigned int keyCode) {
|
||||
char key_name[10];
|
||||
|
||||
if (!keyCode)
|
||||
return "No key";
|
||||
if (keyCode == (unsigned int)_portrait_keys.vkA)
|
||||
return "Button A";
|
||||
if (keyCode == (unsigned int)_portrait_keys.vkB)
|
||||
return "Button B";
|
||||
if (keyCode == (unsigned int)_portrait_keys.vkC)
|
||||
return "Button C";
|
||||
if (keyCode == (unsigned int)_portrait_keys.vkStart)
|
||||
return "Button Start";
|
||||
if (keyCode == (unsigned int)_portrait_keys.vkUp)
|
||||
return "Pad Up";
|
||||
if (keyCode == (unsigned int)_portrait_keys.vkDown)
|
||||
return "Pad Down";
|
||||
if (keyCode == (unsigned int)_portrait_keys.vkLeft)
|
||||
return "Pad Left";
|
||||
if (keyCode == (unsigned int)_portrait_keys.vkRight)
|
||||
return "Pad Right";
|
||||
if (keyCode == KEY_CALENDAR)
|
||||
return "Button Calendar";
|
||||
if (keyCode == KEY_CONTACTS)
|
||||
return "Button Contacts";
|
||||
if (keyCode == KEY_INBOX)
|
||||
return "Button Inbox";
|
||||
if (keyCode == KEY_TASK)
|
||||
return "Button Tasks";
|
||||
|
||||
sprintf(key_name, "Key %.4x", keyCode);
|
||||
return key_name;
|
||||
}
|
49
backends/wince/CEDevice.h
Normal file
49
backends/wince/CEDevice.h
Normal file
@ -0,0 +1,49 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CEDEVICE
|
||||
#define CEDEVICE
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
#include "common/str.h"
|
||||
|
||||
#include <gx.h>
|
||||
|
||||
class CEDevice {
|
||||
public:
|
||||
static bool hasPocketPCResolution();
|
||||
static bool hasDesktopResolution();
|
||||
static bool hasWideResolution();
|
||||
static bool hasSmartphoneResolution();
|
||||
static bool enableHardwareKeyMapping();
|
||||
static bool disableHardwareKeyMapping();
|
||||
static Common::String getKeyName(unsigned int keyCode);
|
||||
private:
|
||||
static bool _hasGAPIMapping;
|
||||
static struct GXKeyList _portrait_keys;
|
||||
typedef int (*tGXVoidFunction)(void);
|
||||
typedef struct GXKeyList (*tGXGetDefaultKeys)(int);
|
||||
|
||||
};
|
||||
|
||||
#endif
|
123
backends/wince/CEKeysDialog.cpp
Normal file
123
backends/wince/CEKeysDialog.cpp
Normal file
@ -0,0 +1,123 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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 "stdafx.h"
|
||||
#include "CEKeysDialog.h"
|
||||
#include "CEActions.h"
|
||||
|
||||
using GUI::ListWidget;
|
||||
using GUI::kListNumberingZero;
|
||||
using GUI::WIDGET_CLEARBG;
|
||||
using GUI::kListSelectionChangedCmd;
|
||||
using GUI::kCloseCmd;
|
||||
using GUI::StaticTextWidget;
|
||||
using GUI::kTextAlignCenter;
|
||||
using GUI::CommandSender;
|
||||
|
||||
enum {
|
||||
kMapCmd = 'map ',
|
||||
kOKCmd = 'ok '
|
||||
};
|
||||
|
||||
|
||||
CEKeysDialog::CEKeysDialog(const Common::String &title)
|
||||
: GUI::Dialog(30, 20, 260, 160) {
|
||||
addButton(160, 20, "Map", kMapCmd, 'M'); // Map
|
||||
addButton(160, 40, "OK", kOKCmd, 'O'); // OK
|
||||
addButton(160, 60, "Cancel", kCloseCmd, 'C'); // Cancel
|
||||
|
||||
_actionsList = new ListWidget(this, 10, 20, 140, 90);
|
||||
_actionsList->setNumberingMode(kListNumberingZero);
|
||||
|
||||
_actionTitle = new StaticTextWidget(this, 10, 120, 240, 16, title, kTextAlignCenter);
|
||||
_keyMapping = new StaticTextWidget(this, 10, 140, 240, 16, "", kTextAlignCenter);
|
||||
|
||||
_actionTitle->setFlags(WIDGET_CLEARBG);
|
||||
_keyMapping->setFlags(WIDGET_CLEARBG);
|
||||
|
||||
// Get actions names
|
||||
Common::StringList l;
|
||||
|
||||
for (int i = 1; i < CEActions::Instance()->size(); i++)
|
||||
l.push_back(CEActions::Instance()->actionName((ActionType)i));
|
||||
|
||||
_actionsList->setList(l);
|
||||
|
||||
_actionSelected = -1;
|
||||
CEActions::Instance()->beginMapping(false);
|
||||
}
|
||||
|
||||
void CEKeysDialog::handleCommand(CommandSender *sender, uint32 cmd, uint32 data) {
|
||||
switch(cmd) {
|
||||
|
||||
case kListSelectionChangedCmd:
|
||||
if (_actionsList->getSelected() >= 0) {
|
||||
char selection[100];
|
||||
|
||||
sprintf(selection, "Associated key : %s", CEDevice::getKeyName(CEActions::Instance()->getMapping((ActionType)(_actionsList->getSelected() + 1))).c_str());
|
||||
_keyMapping->setLabel(selection);
|
||||
_keyMapping->draw();
|
||||
}
|
||||
break;
|
||||
case kMapCmd:
|
||||
if (_actionsList->getSelected() < 0) {
|
||||
_actionTitle->setLabel("Please select an action");
|
||||
}
|
||||
else {
|
||||
char selection[100];
|
||||
|
||||
_actionSelected = _actionsList->getSelected() + 1;
|
||||
sprintf(selection, "Associated key : %s", CEDevice::getKeyName(CEActions::Instance()->getMapping((ActionType)_actionSelected)).c_str());
|
||||
_actionTitle->setLabel("Press the key to associate");
|
||||
_keyMapping->setLabel(selection);
|
||||
_keyMapping->draw();
|
||||
CEActions::Instance()->beginMapping(true);
|
||||
_actionsList->setEnabled(false);
|
||||
}
|
||||
_actionTitle->draw();
|
||||
break;
|
||||
case kOKCmd:
|
||||
CEActions::Instance()->saveMapping();
|
||||
close();
|
||||
break;
|
||||
case kCloseCmd:
|
||||
CEActions::Instance()->loadMapping();
|
||||
close();
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void CEKeysDialog::handleKeyDown(uint16 ascii, int keycode, int modifiers) {
|
||||
if (modifiers == 0xff && CEActions::Instance()->mappingActive()) {
|
||||
// GAPI key was selected
|
||||
char selection[100];
|
||||
|
||||
CEActions::Instance()->setMapping((ActionType)_actionSelected, (ascii & 0xff));
|
||||
|
||||
sprintf(selection, "Associated key : %s", CEDevice::getKeyName(CEActions::Instance()->getMapping((ActionType)_actionSelected)).c_str());
|
||||
_actionTitle->setLabel("Choose an action to map");
|
||||
_keyMapping->setLabel(selection);
|
||||
_keyMapping->draw();
|
||||
_actionSelected = -1;
|
||||
_actionsList->setEnabled(true);
|
||||
CEActions::Instance()->beginMapping(false);
|
||||
}
|
||||
}
|
45
backends/wince/CEKeysDialog.h
Normal file
45
backends/wince/CEKeysDialog.h
Normal file
@ -0,0 +1,45 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CEKEYSDIALOG
|
||||
#define CEKEYSDIALOG
|
||||
|
||||
#include "gui/newgui.h"
|
||||
#include "gui/dialog.h"
|
||||
#include "gui/ListWidget.h"
|
||||
#include "common/str.h"
|
||||
|
||||
class CEKeysDialog : public GUI::Dialog {
|
||||
public:
|
||||
CEKeysDialog(const Common::String &title = "Choose an action to map");
|
||||
|
||||
virtual void handleCommand(GUI::CommandSender *sender, uint32 cmd, uint32 data);
|
||||
virtual void handleKeyDown(uint16 ascii, int keycode, int modifiers);
|
||||
|
||||
protected:
|
||||
|
||||
GUI::ListWidget *_actionsList;
|
||||
GUI::StaticTextWidget *_actionTitle;
|
||||
GUI::StaticTextWidget *_keyMapping;
|
||||
int _actionSelected;
|
||||
};
|
||||
|
||||
#endif
|
121
backends/wince/CELauncherDialog.cpp
Normal file
121
backends/wince/CELauncherDialog.cpp
Normal file
@ -0,0 +1,121 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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 "stdafx.h"
|
||||
#include "CELauncherDialog.h"
|
||||
|
||||
#include "base/engine.h"
|
||||
|
||||
#include "gui/browser.h"
|
||||
#include "gui/message.h"
|
||||
|
||||
#include "common/config-manager.h"
|
||||
|
||||
using namespace GUI;
|
||||
using namespace Common;
|
||||
|
||||
|
||||
CELauncherDialog::CELauncherDialog(GameDetector &detector) : GUI::LauncherDialog(detector) {
|
||||
}
|
||||
|
||||
void CELauncherDialog::addCandidate(String &path, DetectedGameList &candidates) {
|
||||
int idx = -1;
|
||||
DetectedGame result;
|
||||
|
||||
if (candidates.isEmpty())
|
||||
return;
|
||||
|
||||
if (candidates.size() == 1)
|
||||
idx = 0;
|
||||
else {
|
||||
char candidateName[100];
|
||||
int i;
|
||||
for (i=path.size() - 2; i && path[i] != '\\'; i--);
|
||||
strcpy(candidateName, &path[i + 1]);
|
||||
candidateName[strlen(candidateName) - 1] = '\0';
|
||||
for (i=0; i<candidates.size(); i++) {
|
||||
if (scumm_stricmp(candidateName, candidates[i].name) == 0) {
|
||||
idx = i;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if (idx < 0)
|
||||
return;
|
||||
|
||||
// FIXME : factor that
|
||||
result = candidates[idx];
|
||||
|
||||
// The auto detector or the user made a choice.
|
||||
// Pick a domain name which does not yet exist (after all, we
|
||||
// are *adding* a game to the config, not replacing).
|
||||
String domain(result.name);
|
||||
if (ConfMan.hasGameDomain(domain)) {
|
||||
char suffix = 'a';
|
||||
domain += suffix;
|
||||
while (ConfMan.hasGameDomain(domain)) {
|
||||
assert(suffix < 'z');
|
||||
domain.deleteLastChar();
|
||||
suffix++;
|
||||
domain += suffix;
|
||||
}
|
||||
ConfMan.set("gameid", result.name, domain);
|
||||
ConfMan.set("description", result.description, domain);
|
||||
}
|
||||
ConfMan.set("path", path, domain);
|
||||
|
||||
// Set language if specified
|
||||
if (result.language != Common::UNK_LANG)
|
||||
ConfMan.set("language", Common::getLanguageCode(result.language), domain);
|
||||
|
||||
// Set platform if specified
|
||||
if (result.platform != Common::kPlatformUnknown)
|
||||
ConfMan.set("platform", Common::getPlatformCode(result.platform), domain);
|
||||
}
|
||||
|
||||
void CELauncherDialog::automaticScanDirectory(const FilesystemNode *node) {
|
||||
// First check if we have a recognized game in the current directory
|
||||
FSList *files = node->listDir(FilesystemNode::kListFilesOnly);
|
||||
DetectedGameList candidates(PluginManager::instance().detectGames(*files));
|
||||
addCandidate(node->path(), candidates);
|
||||
// Then recurse on the subdirectories
|
||||
FSList *dirs = node->listDir(FilesystemNode::kListDirectoriesOnly);
|
||||
for (FSList::ConstIterator currentDir = dirs->begin(); currentDir != dirs->end(); ++currentDir)
|
||||
automaticScanDirectory(&(*currentDir));
|
||||
|
||||
}
|
||||
|
||||
void CELauncherDialog::addGame() {
|
||||
MessageDialog alert("Do you want to perform an automatic scan ?", "Yes", "No");
|
||||
if (alert.runModal() == 1 && _browser->runModal()) {
|
||||
// Clear existing domains
|
||||
ConfigManager::DomainMap &domains = (ConfigManager::DomainMap&)ConfMan.getGameDomains();
|
||||
domains.clear();
|
||||
ConfMan.flushToDisk();
|
||||
automaticScanDirectory(_browser->getResult());
|
||||
ConfMan.flushToDisk();
|
||||
updateListing();
|
||||
draw();
|
||||
}
|
||||
else
|
||||
GUILauncherDialog::addGame();
|
||||
}
|
43
backends/wince/CELauncherDialog.h
Normal file
43
backends/wince/CELauncherDialog.h
Normal file
@ -0,0 +1,43 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CELAUNCHERDIALOG
|
||||
#define CELAUNCHERDIALOG
|
||||
|
||||
#include "backends/fs/fs.h"
|
||||
|
||||
#include "base/gameDetector.h"
|
||||
#include "base/plugins.h"
|
||||
|
||||
#include "gui/launcher.h"
|
||||
|
||||
class CELauncherDialog : public GUI::LauncherDialog {
|
||||
public:
|
||||
CELauncherDialog(GameDetector &detector);
|
||||
protected:
|
||||
void addGame();
|
||||
void addCandidate(String &path, DetectedGameList &candidates);
|
||||
void automaticScanDirectory(const FilesystemNode *node);
|
||||
};
|
||||
|
||||
typedef GUI::LauncherDialog GUILauncherDialog;
|
||||
|
||||
#endif
|
76
backends/wince/CEScaler.cpp
Normal file
76
backends/wince/CEScaler.cpp
Normal file
@ -0,0 +1,76 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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 "stdafx.h"
|
||||
#include "CEScaler.h"
|
||||
|
||||
void PocketPCPortrait(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
|
||||
int width, int height) {
|
||||
uint8 *work;
|
||||
int i;
|
||||
|
||||
while (height--) {
|
||||
i = 0;
|
||||
work = dstPtr;
|
||||
|
||||
for (int i=0; i<width; i+=4) {
|
||||
// Work with 4 pixels
|
||||
uint16 color1 = *(((const uint16 *)srcPtr) + i);
|
||||
uint16 color2 = *(((const uint16 *)srcPtr) + (i + 1));
|
||||
uint16 color3 = *(((const uint16 *)srcPtr) + (i + 2));
|
||||
uint16 color4 = *(((const uint16 *)srcPtr) + (i + 3));
|
||||
|
||||
*(((uint16 *)work) + 0) = interpolate16_2<565, 3, 1>(color1, color2);
|
||||
*(((uint16 *)work) + 1) = interpolate16_2<565, 1, 1>(color2, color3);
|
||||
*(((uint16 *)work) + 2) = interpolate16_2<565, 1, 3>(color3, color4);
|
||||
|
||||
work += 3 * sizeof(uint16);
|
||||
}
|
||||
srcPtr += srcPitch;
|
||||
dstPtr += dstPitch;
|
||||
}
|
||||
}
|
||||
|
||||
void PocketPCHalf(const uint8 *srcPtr, uint32 srcPitch, uint8 *dstPtr, uint32 dstPitch,
|
||||
int width, int height) {
|
||||
uint8 *work;
|
||||
int i;
|
||||
uint16 srcPitch16 = (uint16)(srcPitch / sizeof(uint16));
|
||||
|
||||
while (height--) {
|
||||
i = 0;
|
||||
work = dstPtr;
|
||||
|
||||
for (int i=0; i<width; i+=2) {
|
||||
// Work with 2 pixels on a row and one below
|
||||
uint16 color1 = *(((const uint16 *)srcPtr) + i);
|
||||
uint16 color2 = *(((const uint16 *)srcPtr) + (i + 1));
|
||||
uint16 color3 = *(((const uint16 *)srcPtr) + (i + srcPitch16));
|
||||
|
||||
*(((uint16 *)work) + 0) = interpolate16_3<565, 2, 1, 1>(color1, color2, color3);
|
||||
|
||||
work += 2 * sizeof(uint16);
|
||||
}
|
||||
srcPtr += 2 * srcPitch;
|
||||
dstPtr += dstPitch;
|
||||
}
|
||||
}
|
||||
|
34
backends/wince/CEScaler.h
Normal file
34
backends/wince/CEScaler.h
Normal file
@ -0,0 +1,34 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef CESCALER
|
||||
#define CESCALER
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
#include "common/scaler.h"
|
||||
#include "common/scaler/intern.h"
|
||||
|
||||
DECLARE_SCALER(PocketPCPortrait);
|
||||
DECLARE_SCALER(PocketPCHalf);
|
||||
|
||||
#endif
|
1146
backends/wince/wince-sdl.cpp
Normal file
1146
backends/wince/wince-sdl.cpp
Normal file
File diff suppressed because it is too large
Load Diff
125
backends/wince/wince-sdl.h
Normal file
125
backends/wince/wince-sdl.h
Normal file
@ -0,0 +1,125 @@
|
||||
/* ScummVM - Scumm Interpreter
|
||||
* Copyright (C) 2001-2004 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$
|
||||
*
|
||||
*/
|
||||
|
||||
#ifndef WINCE_SDL_H
|
||||
#define WINCE_SDL_H
|
||||
|
||||
#include "common/stdafx.h"
|
||||
#include "common/scummsys.h"
|
||||
#include "common/system.h"
|
||||
#include "common/scaler.h"
|
||||
#include "backends/intern.h"
|
||||
#include "backends/sdl/sdl-common.h"
|
||||
|
||||
#include "CEgui.h"
|
||||
#include "CEkeys.h"
|
||||
#include "CEDevice.h"
|
||||
#include "CEScaler.h"
|
||||
|
||||
#include <SDL.h>
|
||||
|
||||
class OSystem_WINCE3 : public OSystem_SDL_Common {
|
||||
public:
|
||||
OSystem_WINCE3();
|
||||
|
||||
// Update the dirty areas of the screen
|
||||
void update_screen();
|
||||
|
||||
// Set a parameter
|
||||
uint32 property(int param, Property *value);
|
||||
|
||||
void init_size(uint w, uint h);
|
||||
|
||||
// Overloaded from SDL_Common (toolbar handling)
|
||||
bool poll_event(Event *event);
|
||||
// Overloaded from SDL_Common (toolbar handling)
|
||||
void draw_mouse();
|
||||
// Overloaded from SDL_Common (mouse and new scaler handling)
|
||||
void fillMouseEvent(Event &event, int x, int y);
|
||||
// Overloaded from SDL_Common (new scaler handling)
|
||||
void add_dirty_rect(int x, int y, int w, int h);
|
||||
// Overloaded from SDL_Common (new scaler handling)
|
||||
void warp_mouse(int x, int y);
|
||||
// Overloaded from SDL_Commmon
|
||||
void quit();
|
||||
// Overloaded from SDL_Commmon (master volume and sample rate subtleties)
|
||||
bool set_sound_proc(SoundProc proc, void *param, SoundFormat format);
|
||||
|
||||
// GUI and action stuff
|
||||
void swap_panel_visibility();
|
||||
void swap_panel();
|
||||
void swap_sound_master();
|
||||
void add_right_click();
|
||||
void swap_mouse_visibility();
|
||||
void swap_freeLook();
|
||||
|
||||
protected:
|
||||
SDL_Surface *_hwscreen; // hardware screen
|
||||
|
||||
ScalerProc *_scaler_proc;
|
||||
|
||||
virtual void load_gfx_mode();
|
||||
virtual void unload_gfx_mode();
|
||||
virtual bool save_screenshot(const char *filename);
|
||||
void hotswap_gfx_mode();
|
||||
|
||||
|
||||
private:
|
||||
|
||||
static void private_sound_proc(void *param, byte *buf, int len);
|
||||
static SoundProc _originalSoundProc;
|
||||
|
||||
void create_toolbar();
|
||||
void update_game_settings();
|
||||
void update_keyboard();
|
||||
|
||||
CEKEYS::KeysBuffer *_keysBuffer;
|
||||
CEGUI::ToolbarHandler _toolbarHandler;
|
||||
|
||||
bool _freeLook; // freeLook mode (do not send mouse button events)
|
||||
|
||||
bool _forceHideMouse; // force invisible mouse cursor
|
||||
|
||||
bool _addRightClickDown; // add a right click event (button pushed)
|
||||
bool _addRightClickUp; // add a right click event (button released)
|
||||
|
||||
bool _forcePanelInvisible; // force panel visibility for some cases
|
||||
bool _panelVisible; // panel visibility
|
||||
bool _panelStateForced; // panel visibility forced by external call
|
||||
|
||||
bool _panelInitialized; // only initialize the toolbar once
|
||||
|
||||
bool _monkeyKeyboard; // forced keyboard for Monkey Island copy protection
|
||||
static bool _soundMaster; // turn off sound after all calculations
|
||||
// static since needed by the SDL callback
|
||||
bool _orientationLandscape; // current orientation
|
||||
bool _newOrientation; // new orientation
|
||||
|
||||
bool _saveToolbarState; // save visibility when forced
|
||||
String _saveActiveToolbar; // save active toolbar when forced
|
||||
|
||||
int _scaleFactorXm;
|
||||
int _scaleFactorXd;
|
||||
int _scaleFactorYm;
|
||||
int _scaleFactorYd;
|
||||
};
|
||||
|
||||
#endif
|
Loading…
x
Reference in New Issue
Block a user