From 07a76c1921f84f68b36822f448bb4b771b489cc6 Mon Sep 17 00:00:00 2001 From: knakos Date: Tue, 23 Jan 2007 09:44:55 +0000 Subject: [PATCH] added key rotation git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1304 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba --- stella/src/wince/PocketStella.cpp | 25 ++++++----- stella/src/wince/missing.cpp | 74 +++++++++++++++++++------------ stella/src/wince/missing.h | 8 +--- 3 files changed, 63 insertions(+), 44 deletions(-) diff --git a/stella/src/wince/PocketStella.cpp b/stella/src/wince/PocketStella.cpp index f8648855d..6be746128 100644 --- a/stella/src/wince/PocketStella.cpp +++ b/stella/src/wince/PocketStella.cpp @@ -14,7 +14,7 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. // // Windows CE Port by Kostas Nakos -// $Id: PocketStella.cpp,v 1.8 2007-01-21 20:10:50 knakos Exp $ +// $Id: PocketStella.cpp,v 1.9 2007-01-23 09:44:55 knakos Exp $ //============================================================================ #include @@ -26,16 +26,15 @@ #include "FrameBufferWinCE.hxx" extern void KeySetup(void); -extern void KeySetMode(int); extern queue eventqueue; -extern int EventHandlerState; +extern SDLKey RotateKey(SDLKey); bool RequestRefresh = false; SDLKey VK_keymap[SDLK_LAST]; OSystemWinCE* theOSystem = (OSystemWinCE*) NULL; HWND hWnd; -uInt16 rotkeystate = 0; +bool rotkeystate = 0; DWORD REG_bat, REG_ac, REG_disp, bat_timeout; @@ -51,21 +50,27 @@ LRESULT CALLBACK WindowProc(HWND hwnd, UINT uMsg, WPARAM wParam, LPARAM lParam ) if (wParam == VK_F3) { if (rotkeystate == 0 && theOSystem) - if (theOSystem->eventHandler().state() == 1) - KeySetMode( ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay() ); - rotkeystate = 1; + if (theOSystem->eventHandler().state() == EventHandler::S_EMULATE) + ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay(); + rotkeystate = true; + return 0; } else - rotkeystate = 0; + rotkeystate = false; e.key.type = SDL_KEYDOWN; - e.key.keysym.sym = VK_keymap[wParam]; + e.key.keysym.sym = RotateKey(VK_keymap[wParam]); e.key.keysym.mod = (SDLMod) 0; eventqueue.push(e); return 0; case WM_KEYUP: + if (wParam == VK_F3 && rotkeystate) + { + rotkeystate = false; + return 0; + } e.key.type = SDL_KEYUP; - e.key.keysym.sym = VK_keymap[wParam]; + e.key.keysym.sym = RotateKey(VK_keymap[wParam]); e.key.keysym.mod = (SDLMod) 0; eventqueue.push(e); return 0; diff --git a/stella/src/wince/missing.cpp b/stella/src/wince/missing.cpp index 08ff46d89..98150555b 100644 --- a/stella/src/wince/missing.cpp +++ b/stella/src/wince/missing.cpp @@ -14,7 +14,7 @@ // this file, and for a DISCLAIMER OF ALL WARRANTIES. // // Windows CE Port by Kostas Nakos -// $Id: missing.cpp,v 1.8 2007-01-21 20:10:50 knakos Exp $ +// $Id: missing.cpp,v 1.9 2007-01-23 09:44:55 knakos Exp $ //============================================================================ #include @@ -25,7 +25,6 @@ #include "EventHandler.hxx" char *msg = NULL; -int EventHandlerState; extern OSystemWinCE *theOSystem; extern SDLKey VK_keymap[SDLK_LAST]; @@ -51,37 +50,56 @@ char *getcwd(void) return cwd; } -void KeySetMode(int mode) +SDLKey RotateKey(SDLKey key) { -/* GXKeyList klist = GXGetDefaultKeys(GX_NORMALKEYS); + uInt8 dir = 0; + uInt8 mode = ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->getmode(); + uInt8 state = theOSystem->eventHandler().state(); + bool lscp = ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->IsLandscape(); - for (int i=0; i<2; i++) + if (!(lscp && mode == 0)) + if (state != EventHandler::S_EMULATE) + if (mode != 2) + dir = 1; + else + dir = 2; + else + dir = mode; + + switch (dir) { - switch (mode) + case 0: + return key; + + case 1: + switch (key) { - case 0: - keycodes[i][K_UP].keycode = klist.vkUp; - keycodes[i][K_DOWN].keycode = klist.vkDown; - keycodes[i][K_LEFT].keycode = klist.vkLeft; - keycodes[i][K_RIGHT].keycode = klist.vkRight; - break; - - case 2: - keycodes[i][K_UP].keycode = klist.vkRight; - keycodes[i][K_DOWN].keycode = klist.vkLeft; - keycodes[i][K_LEFT].keycode = klist.vkUp; - keycodes[i][K_RIGHT].keycode = klist.vkDown; - break; - - case 1: - keycodes[i][K_UP].keycode = klist.vkLeft; - keycodes[i][K_DOWN].keycode = klist.vkRight; - keycodes[i][K_LEFT].keycode = klist.vkDown; - keycodes[i][K_RIGHT].keycode = klist.vkUp; - break; - + 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) diff --git a/stella/src/wince/missing.h b/stella/src/wince/missing.h index d1a09d4ba..8287de40a 100644 --- a/stella/src/wince/missing.h +++ b/stella/src/wince/missing.h @@ -8,12 +8,13 @@ // SS SS tt ee ll ll aa aa // SSSS ttt eeeee llll llll aaaaa // -// Copyright (c) 1995-2006 by Bradford W. Mott and the Stella team +// 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.h,v 1.6 2007-01-23 09:44:55 knakos Exp $ //============================================================================ #ifndef _WCE_MISSING_H_ @@ -40,9 +41,4 @@ typedef unsigned int uintptr_t; int time(int dummy); char *getcwd(void); - -#define MAX_KEYS 8 -#define NUM_MOUSEKEYS 2 -enum key {K_UP = 0, K_DOWN, K_LEFT, K_RIGHT, K_FIRE, K_RESET, K_SELECT, K_QUIT, M_POS, M_BUT}; - #endif