added key rotation

git-svn-id: svn://svn.code.sf.net/p/stella/code/trunk@1304 8b62c5a3-ac7e-4cc8-8f21-d9a121418aba
This commit is contained in:
knakos 2007-01-23 09:44:55 +00:00
parent 36ab14c1d1
commit 07a76c1921
3 changed files with 63 additions and 44 deletions

View File

@ -14,7 +14,7 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// Windows CE Port by Kostas Nakos // 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 <queue> #include <queue>
@ -26,16 +26,15 @@
#include "FrameBufferWinCE.hxx" #include "FrameBufferWinCE.hxx"
extern void KeySetup(void); extern void KeySetup(void);
extern void KeySetMode(int);
extern queue <SDL_Event> eventqueue; extern queue <SDL_Event> eventqueue;
extern int EventHandlerState; extern SDLKey RotateKey(SDLKey);
bool RequestRefresh = false; bool RequestRefresh = false;
SDLKey VK_keymap[SDLK_LAST]; SDLKey VK_keymap[SDLK_LAST];
OSystemWinCE* theOSystem = (OSystemWinCE*) NULL; OSystemWinCE* theOSystem = (OSystemWinCE*) NULL;
HWND hWnd; HWND hWnd;
uInt16 rotkeystate = 0; bool rotkeystate = 0;
DWORD REG_bat, REG_ac, REG_disp, bat_timeout; 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 (wParam == VK_F3)
{ {
if (rotkeystate == 0 && theOSystem) if (rotkeystate == 0 && theOSystem)
if (theOSystem->eventHandler().state() == 1) if (theOSystem->eventHandler().state() == EventHandler::S_EMULATE)
KeySetMode( ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay() ); ((FrameBufferWinCE *) (&(theOSystem->frameBuffer())))->rotatedisplay();
rotkeystate = 1; rotkeystate = true;
return 0;
} }
else else
rotkeystate = 0; rotkeystate = false;
e.key.type = SDL_KEYDOWN; 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; e.key.keysym.mod = (SDLMod) 0;
eventqueue.push(e); eventqueue.push(e);
return 0; return 0;
case WM_KEYUP: case WM_KEYUP:
if (wParam == VK_F3 && rotkeystate)
{
rotkeystate = false;
return 0;
}
e.key.type = SDL_KEYUP; 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; e.key.keysym.mod = (SDLMod) 0;
eventqueue.push(e); eventqueue.push(e);
return 0; return 0;

View File

@ -14,7 +14,7 @@
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// Windows CE Port by Kostas Nakos // 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 <queue> #include <queue>
@ -25,7 +25,6 @@
#include "EventHandler.hxx" #include "EventHandler.hxx"
char *msg = NULL; char *msg = NULL;
int EventHandlerState;
extern OSystemWinCE *theOSystem; extern OSystemWinCE *theOSystem;
extern SDLKey VK_keymap[SDLK_LAST]; extern SDLKey VK_keymap[SDLK_LAST];
@ -51,37 +50,56 @@ char *getcwd(void)
return cwd; 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)
switch (mode) if (mode != 2)
dir = 1;
else
dir = 2;
else
dir = mode;
switch (dir)
{ {
case 0: case 0:
keycodes[i][K_UP].keycode = klist.vkUp; return key;
keycodes[i][K_DOWN].keycode = klist.vkDown;
keycodes[i][K_LEFT].keycode = klist.vkLeft; case 1:
keycodes[i][K_RIGHT].keycode = klist.vkRight; 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; break;
case 2: case 2:
keycodes[i][K_UP].keycode = klist.vkRight; switch (key)
keycodes[i][K_DOWN].keycode = klist.vkLeft; {
keycodes[i][K_LEFT].keycode = klist.vkUp; case SDLK_LEFT:
keycodes[i][K_RIGHT].keycode = klist.vkDown; return SDLK_DOWN;
break; case SDLK_DOWN:
return SDLK_RIGHT;
case 1: case SDLK_RIGHT:
keycodes[i][K_UP].keycode = klist.vkLeft; return SDLK_UP;
keycodes[i][K_DOWN].keycode = klist.vkRight; case SDLK_UP:
keycodes[i][K_LEFT].keycode = klist.vkDown; return SDLK_LEFT;
keycodes[i][K_RIGHT].keycode = klist.vkUp;
break;
} }
}*/ break;
}
return key;
} }
void KeySetup(void) void KeySetup(void)

View File

@ -8,12 +8,13 @@
// SS SS tt ee ll ll aa aa // SS SS tt ee ll ll aa aa
// SSSS ttt eeeee llll llll aaaaa // 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 // See the file "license" for information on usage and redistribution of
// this file, and for a DISCLAIMER OF ALL WARRANTIES. // this file, and for a DISCLAIMER OF ALL WARRANTIES.
// //
// Windows CE Port by Kostas Nakos // Windows CE Port by Kostas Nakos
// $Id: missing.h,v 1.6 2007-01-23 09:44:55 knakos Exp $
//============================================================================ //============================================================================
#ifndef _WCE_MISSING_H_ #ifndef _WCE_MISSING_H_
@ -40,9 +41,4 @@ typedef unsigned int uintptr_t;
int time(int dummy); int time(int dummy);
char *getcwd(void); 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 #endif