Skip to content

Commit

Permalink
WINCE: Some cleanup (public vs. private scopes), fix freelook
Browse files Browse the repository at this point in the history
  • Loading branch information
CeRiAl committed Jun 11, 2011
1 parent 42f8f39 commit 60bc0c8
Show file tree
Hide file tree
Showing 9 changed files with 59 additions and 74 deletions.
11 changes: 4 additions & 7 deletions backends/events/wincesdl/wincesdl-events.cpp
Expand Up @@ -38,7 +38,7 @@

WINCESdlEventSource::WINCESdlEventSource()
: _tapTime(0), _closeClick(false), _rbutton(false),
_freeLook(false), _graphicsMan(0) {
_graphicsMan(0) {
}

void WINCESdlEventSource::init(WINCESdlGraphicsManager *graphicsMan) {
Expand Down Expand Up @@ -67,6 +67,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
ev.type = SDL_NOEVENT;
DWORD currentTime;
bool keyEvent = false;
bool freeLookActive = _graphicsMan->getFreeLookState();
int deltaX, deltaY;

memset(&event, 0, sizeof(Common::Event));
Expand Down Expand Up @@ -202,7 +203,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {
}
}

if (_freeLook && !_closeClick) {
if (freeLookActive && !_closeClick) {
_rbutton = false;
_tapTime = 0;
_tapX = event.mouse.x;
Expand Down Expand Up @@ -244,7 +245,7 @@ bool WINCESdlEventSource::pollEvent(Common::Event &event) {

fillMouseEvent(event, ev.button.x, ev.button.y);

if (_freeLook && !_closeClick) {
if (freeLookActive && !_closeClick) {
_tapX = event.mouse.x;
_tapY = event.mouse.y;
event.type = Common::EVENT_MOUSEMOVE;
Expand Down Expand Up @@ -325,8 +326,4 @@ int WINCESdlEventSource::mapKeyCE(SDLKey key, SDLMod mod, Uint16 unicode, bool u
return key;
}

void WINCESdlEventSource::swap_freeLook() {
_freeLook = !_freeLook;
}

#endif /* _WIN32_WCE */
4 changes: 0 additions & 4 deletions backends/events/wincesdl/wincesdl-events.h
Expand Up @@ -48,8 +48,6 @@ class WINCESdlEventSource : public SdlEventSource {
// Overloaded from SDL backend (mouse and new scaler handling)
void fillMouseEvent(Common::Event &event, int x, int y);

void swap_freeLook();

protected:

private:
Expand All @@ -64,8 +62,6 @@ class WINCESdlEventSource : public SdlEventSource {

bool _closeClick; // flag when taps are spatially close together
bool _rbutton; // double tap -> right button simulation
bool _freeLook; // freeLook mode (do not send mouse button events)

};

#endif
Expand Down
13 changes: 10 additions & 3 deletions backends/graphics/wincesdl/wincesdl-graphics.cpp
Expand Up @@ -52,8 +52,8 @@ WINCESdlGraphicsManager::WINCESdlGraphicsManager(SdlEventSource *sdlEventSource)
_panelVisible(true), _saveActiveToolbar(NAME_MAIN_PANEL), _panelStateForced(false),
_canBeAspectScaled(false), _scalersChanged(false), _saveToolbarState(false),
_mouseBackupOld(NULL), _mouseBackupDim(0), _mouseBackupToolbar(NULL),
_usesEmulatedMouse(false), _forceHideMouse(false), _hasfocus(true),
_zoomUp(false), _zoomDown(false) {
_usesEmulatedMouse(false), _forceHideMouse(false), _freeLook(false),
_hasfocus(true), _zoomUp(false), _zoomDown(false) {
memset(&_mouseCurState, 0, sizeof(_mouseCurState));
if (_isSmartphone) {
_mouseCurState.x = 20;
Expand Down Expand Up @@ -447,7 +447,6 @@ void WINCESdlGraphicsManager::update_game_settings() {
// Skip
panel->add(NAME_ITEM_SKIP, new CEGUI::ItemAction(ITEM_SKIP, POCKET_ACTION_SKIP));
// sound
//__XXX__ panel->add(NAME_ITEM_SOUND, new CEGUI::ItemSwitch(ITEM_SOUND_OFF, ITEM_SOUND_ON, &_soundMaster));
panel->add(NAME_ITEM_SOUND, new CEGUI::ItemSwitch(ITEM_SOUND_OFF, ITEM_SOUND_ON, &OSystem_WINCE3::_soundMaster));

// bind keys
Expand Down Expand Up @@ -1630,6 +1629,14 @@ void WINCESdlGraphicsManager::create_toolbar() {
_toolbarHandler.setVisible(false);
}

void WINCESdlGraphicsManager::swap_freeLook() {
_freeLook = !_freeLook;
}

bool WINCESdlGraphicsManager::getFreeLookState() {
return _freeLook;
}

WINCESdlGraphicsManager::zoneDesc WINCESdlGraphicsManager::_zones[TOTAL_ZONES] = {
{ 0, 0, 320, 145 },
{ 0, 145, 150, 55 },
Expand Down
19 changes: 11 additions & 8 deletions backends/graphics/wincesdl/wincesdl-graphics.h
Expand Up @@ -59,6 +59,8 @@ class WINCESdlGraphicsManager : public SdlGraphicsManager {
void unloadGFXMode();
bool hotswapGFXMode();

void update_game_settings();

// Overloaded from SDL backend (toolbar handling)
void drawMouse();
// Overloaded from SDL backend (new scaler handling)
Expand Down Expand Up @@ -91,15 +93,15 @@ class WINCESdlGraphicsManager : public SdlGraphicsManager {
void swap_zoom_up();
void swap_zoom_down();
void swap_mouse_visibility();

void swap_freeLook();
bool getFreeLookState();

//#ifdef WIN32_PLATFORM_WFSP
void move_cursor_up();
void move_cursor_down();
void move_cursor_left();
void move_cursor_right();

void retrieve_mouse_location(int &x, int &y);
void switch_zone();

void add_right_click(bool pushed);
Expand All @@ -109,6 +111,11 @@ class WINCESdlGraphicsManager : public SdlGraphicsManager {
void smartphone_rotate_display();
//#endif

bool hasPocketPCResolution();
bool hasDesktopResolution();
bool hasSquareQVGAResolution();
bool hasWideResolution() const;

bool _panelInitialized; // only initialize the toolbar once
bool _noDoubleTapRMB; // disable double tap -> rmb click

Expand All @@ -125,11 +132,6 @@ class WINCESdlGraphicsManager : public SdlGraphicsManager {

bool _hasfocus; // scummvm has the top window

bool hasPocketPCResolution();
bool hasDesktopResolution();
bool hasSquareQVGAResolution();
bool hasWideResolution() const;

MousePos _mouseCurState;

bool _zoomUp; // zooming up mode
Expand Down Expand Up @@ -161,8 +163,8 @@ class WINCESdlGraphicsManager : public SdlGraphicsManager {

private:
bool update_scalers();
void update_game_settings();
void drawToolbarMouse(SDL_Surface *surf, bool draw);
void retrieve_mouse_location(int &x, int &y);

void create_toolbar();
bool _panelVisible; // panel visibility
Expand All @@ -189,6 +191,7 @@ class WINCESdlGraphicsManager : public SdlGraphicsManager {
uint16 _mouseBackupDim;

bool _forceHideMouse; // force invisible mouse cursor
bool _freeLook; // freeLook mode (do not send mouse button events)

// Smartphone specific variables
void loadDeviceConfigurationElement(Common::String element, int &value, int defaultValue);
Expand Down
45 changes: 16 additions & 29 deletions backends/platform/wince/CEActionsPocket.cpp
Expand Up @@ -236,23 +236,22 @@ CEActionsPocket::~CEActionsPocket() {
bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) {
static bool keydialogrunning = false, quitdialog = false;

_graphicsMan = ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager());

if (!pushed) {
switch (action) {
case POCKET_ACTION_RIGHTCLICK:
//_CESystem->add_right_click(false);
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(false);
_graphicsMan->add_right_click(false);
return true;
case POCKET_ACTION_LEFTCLICK:
//_CESystem->add_left_click(false);
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(false);
_graphicsMan->add_left_click(false);
return true;
case POCKET_ACTION_PAUSE:
case POCKET_ACTION_SAVE:
case POCKET_ACTION_SKIP:
case POCKET_ACTION_MULTI:
EventsBuffer::simulateKey(&_key_action[action], false);
return true;

}
return false;
}
Expand All @@ -274,55 +273,43 @@ bool CEActionsPocket::perform(GUI::ActionType action, bool pushed) {
EventsBuffer::simulateKey(&_key_action[action], true);
return true;
case POCKET_ACTION_KEYBOARD:
//_CESystem->swap_panel();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_panel();
_graphicsMan->swap_panel();
return true;
case POCKET_ACTION_HIDE:
//_CESystem->swap_panel_visibility();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_panel_visibility();
_graphicsMan->swap_panel_visibility();
return true;
case POCKET_ACTION_SOUND:
_CESystem->swap_sound_master();
return true;
case POCKET_ACTION_RIGHTCLICK:
//_CESystem->add_right_click(true);
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(true);
_graphicsMan->add_right_click(true);
return true;
case POCKET_ACTION_CURSOR:
//_CESystem->swap_mouse_visibility();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_mouse_visibility();
_graphicsMan->swap_mouse_visibility();
return true;
case POCKET_ACTION_FREELOOK:
//_CESystem->swap_freeLook();
((WINCESdlEventSource *)((OSystem_SDL *)g_system)->getEventManager())->swap_freeLook();
_graphicsMan->swap_freeLook();
return true;
case POCKET_ACTION_ZOOM_UP:
//_CESystem->swap_zoom_up();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_zoom_up();
_graphicsMan->swap_zoom_up();
return true;
case POCKET_ACTION_ZOOM_DOWN:
//_CESystem->swap_zoom_down();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_zoom_down();
_graphicsMan->swap_zoom_down();
return true;
case POCKET_ACTION_LEFTCLICK:
//_CESystem->add_left_click(true);
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(true);
_graphicsMan->add_left_click(true);
return true;
case POCKET_ACTION_UP:
//_CESystem->move_cursor_up();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_up();
_graphicsMan->move_cursor_up();
return true;
case POCKET_ACTION_DOWN:
//_CESystem->move_cursor_down();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_down();
_graphicsMan->move_cursor_down();
return true;
case POCKET_ACTION_LEFT:
//_CESystem->move_cursor_left();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_left();
_graphicsMan->move_cursor_left();
return true;
case POCKET_ACTION_RIGHT:
//_CESystem->move_cursor_right();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_right();
_graphicsMan->move_cursor_right();
return true;
case POCKET_ACTION_QUIT:
if (!quitdialog) {
Expand Down
2 changes: 2 additions & 0 deletions backends/platform/wince/CEActionsPocket.h
Expand Up @@ -31,6 +31,7 @@
#include "common/str.h"
#include "gui/Key.h"
#include "gui/Actions.h"
#include "backends/graphics/wincesdl/wincesdl-graphics.h"

#define POCKET_ACTION_VERSION 5

Expand Down Expand Up @@ -83,6 +84,7 @@ class CEActionsPocket : public GUI::Actions {
~CEActionsPocket();
private:
CEActionsPocket(const Common::String &gameid);
WINCESdlGraphicsManager *_graphicsMan;
bool _right_click_needed;
bool _hide_toolbar_needed;
bool _zoom_needed;
Expand Down
35 changes: 13 additions & 22 deletions backends/platform/wince/CEActionsSmartphone.cpp
Expand Up @@ -202,15 +202,15 @@ CEActionsSmartphone::~CEActionsSmartphone() {
bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) {
static bool keydialogrunning = false, quitdialog = false;

_graphicsMan = ((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager());

if (!pushed) {
switch (action) {
case SMARTPHONE_ACTION_RIGHTCLICK:
//_CESystem->add_right_click(false);
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(false);
_graphicsMan->add_right_click(false);
return true;
case SMARTPHONE_ACTION_LEFTCLICK:
//_CESystem->add_left_click(false);
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(false);
_graphicsMan->add_left_click(false);
return true;
case SMARTPHONE_ACTION_SAVE:
case SMARTPHONE_ACTION_SKIP:
Expand All @@ -237,32 +237,25 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) {
EventsBuffer::simulateKey(&_key_action[action], true);
return true;
case SMARTPHONE_ACTION_RIGHTCLICK:
//_CESystem->add_right_click(true);
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_right_click(true);
_graphicsMan->add_right_click(true);
return true;
case SMARTPHONE_ACTION_LEFTCLICK:
//_CESystem->add_left_click(true);
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->add_left_click(true);
_graphicsMan->add_left_click(true);
return true;
case SMARTPHONE_ACTION_UP:
//_CESystem->move_cursor_up();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_up();
_graphicsMan->move_cursor_up();
return true;
case SMARTPHONE_ACTION_DOWN:
//_CESystem->move_cursor_down();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_down();
_graphicsMan->move_cursor_down();
return true;
case SMARTPHONE_ACTION_LEFT:
//_CESystem->move_cursor_left();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_left();
_graphicsMan->move_cursor_left();
return true;
case SMARTPHONE_ACTION_RIGHT:
//_CESystem->move_cursor_right();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->move_cursor_right();
_graphicsMan->move_cursor_right();
return true;
case SMARTPHONE_ACTION_ZONE:
//_CESystem->switch_zone();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->switch_zone();
_graphicsMan->switch_zone();
return true;
case SMARTPHONE_ACTION_BINDKEYS:
if (!keydialogrunning) {
Expand All @@ -274,12 +267,10 @@ bool CEActionsSmartphone::perform(GUI::ActionType action, bool pushed) {
}
return true;
case SMARTPHONE_ACTION_KEYBOARD:
//_CESystem->swap_smartphone_keyboard();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->swap_smartphone_keyboard();
_graphicsMan->swap_smartphone_keyboard();
return true;
case SMARTPHONE_ACTION_ROTATE:
//_CESystem->smartphone_rotate_display();
((WINCESdlGraphicsManager *)((OSystem_SDL *)g_system)->getGraphicsManager())->smartphone_rotate_display();
_graphicsMan->smartphone_rotate_display();
return true;
case SMARTPHONE_ACTION_QUIT:
if (!quitdialog) {
Expand Down
2 changes: 2 additions & 0 deletions backends/platform/wince/CEActionsSmartphone.h
Expand Up @@ -31,6 +31,7 @@
#include "common/str.h"
#include "gui/Key.h"
#include "gui/Actions.h"
#include "backends/graphics/wincesdl/wincesdl-graphics.h"

#define SMARTPHONE_ACTION_VERSION 5

Expand Down Expand Up @@ -71,6 +72,7 @@ class CEActionsSmartphone : public GUI::Actions {
~CEActionsSmartphone();
private:
CEActionsSmartphone();
WINCESdlGraphicsManager *_graphicsMan;
bool _right_click_needed;
OSystem_WINCE3 *_CESystem;
};
Expand Down
2 changes: 1 addition & 1 deletion backends/platform/wince/wince-sdl.cpp
Expand Up @@ -466,7 +466,7 @@ void OSystem_WINCE3::swap_sound_master() {
void OSystem_WINCE3::engineInit() {
check_mappings(); // called here to initialize virtual keys handling

//update_game_settings();
((WINCESdlGraphicsManager *)_graphicsManager)->update_game_settings();
// finalize mixer init
_mixerManager->init();
}
Expand Down

0 comments on commit 60bc0c8

Please sign in to comment.