winport: add autohold for stylus

This commit is contained in:
gocha 2009-09-08 02:39:58 +00:00
parent d9534edf36
commit 158852cea2
3 changed files with 35 additions and 6 deletions

View File

@ -43,6 +43,9 @@ extern LRESULT OpenFile(); //adelikat: Made this an extern here instead of main.
SCustomKeys CustomKeys; SCustomKeys CustomKeys;
bool AutoHoldPressed=false; bool AutoHoldPressed=false;
bool StylusAutoHoldPressed=false;
POINT winLastTouch = { 128, 96 };
bool userTouchesScreen = false;
bool IsLastCustomKey (const SCustomKey *key) bool IsLastCustomKey (const SCustomKey *key)
{ {
@ -185,9 +188,20 @@ void HK_StateQuickLoadSlot(int)
void HK_MicrophoneKeyDown(int) { NDS_setMic(1); } void HK_MicrophoneKeyDown(int) { NDS_setMic(1); }
void HK_MicrophoneKeyUp(int) { NDS_setMic(0); } void HK_MicrophoneKeyUp(int) { NDS_setMic(0); }
void HK_AutoHoldKeyDown(int) {AutoHoldPressed = true;}
void HK_AutoHoldKeyUp(int) {AutoHoldPressed = false;}
void HK_StylusAutoHoldKeyDown(int) {
StylusAutoHoldPressed = !StylusAutoHoldPressed;
if (StylusAutoHoldPressed)
NDS_setTouchPos(winLastTouch.x, winLastTouch.y);
else if (!userTouchesScreen)
NDS_releaseTouch();
}
void HK_AutoHoldClearKeyDown(int) { void HK_AutoHoldClearKeyDown(int) {
ClearAutoHold(); ClearAutoHold();
StylusAutoHoldPressed = false;
} }
void HK_Reset(int) {ResetGame();} void HK_Reset(int) {ResetGame();}
@ -257,9 +271,6 @@ void HK_MostRecentLuaScriptDown(int)
SendMessage(MainWindow->getHWnd(), WM_COMMAND, IDD_LUARECENT_RESERVE_START, 0); SendMessage(MainWindow->getHWnd(), WM_COMMAND, IDD_LUARECENT_RESERVE_START, 0);
} }
void HK_AutoHoldKeyDown(int) {AutoHoldPressed = true;}
void HK_AutoHoldKeyUp(int) {AutoHoldPressed = false;}
void HK_TurboRightKeyDown(int) { Turbo.R = true; } void HK_TurboRightKeyDown(int) { Turbo.R = true; }
void HK_TurboRightKeyUp(int) { Turbo.R = false; } void HK_TurboRightKeyUp(int) { Turbo.R = false; }
@ -419,6 +430,12 @@ void InitCustomKeys (SCustomKeys *keys)
keys->AutoHold.page = HOTKEY_PAGE_MAIN; keys->AutoHold.page = HOTKEY_PAGE_MAIN;
keys->AutoHold.key = NULL; keys->AutoHold.key = NULL;
keys->StylusAutoHold.handleKeyDown = HK_StylusAutoHoldKeyDown;
keys->StylusAutoHold.code = "StylusAutoHold";
keys->StylusAutoHold.name = L"Stylus Auto-Hold";
keys->StylusAutoHold.page = HOTKEY_PAGE_MOVIE; // TODO: set more appropriate category?
keys->StylusAutoHold.key = NULL;
keys->AutoHoldClear.handleKeyDown = HK_AutoHoldClearKeyDown; keys->AutoHoldClear.handleKeyDown = HK_AutoHoldClearKeyDown;
keys->AutoHoldClear.code = "AutoHoldClear"; keys->AutoHoldClear.code = "AutoHoldClear";
keys->AutoHoldClear.name = L"Auto-Hold Clear"; keys->AutoHoldClear.name = L"Auto-Hold Clear";

View File

@ -89,6 +89,7 @@ struct SCustomKeys
SCustomKey ToggleInput; SCustomKey ToggleInput;
SCustomKey ToggleLag; SCustomKey ToggleLag;
SCustomKey ResetLagCounter; SCustomKey ResetLagCounter;
SCustomKey StylusAutoHold;
SCustomKey LastItem; // dummy, must be last SCustomKey LastItem; // dummy, must be last
//--methods-- //--methods--

View File

@ -258,6 +258,10 @@ float DefaultHeight;
float widthTradeOff; float widthTradeOff;
float heightTradeOff; float heightTradeOff;
extern bool StylusAutoHoldPressed;
extern POINT winLastTouch;
extern bool userTouchesScreen;
/*__declspec(thread)*/ bool inFrameBoundary = false; /*__declspec(thread)*/ bool inFrameBoundary = false;
//static char IniName[MAX_PATH]; //static char IniName[MAX_PATH];
@ -3459,17 +3463,24 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
if(x<0) x = 0; else if(x>255) x = 255; if(x<0) x = 0; else if(x>255) x = 255;
if(y<0) y = 0; else if(y>192) y = 192; if(y<0) y = 0; else if(y>192) y = 192;
NDS_setTouchPos(x, y); NDS_setTouchPos(x, y);
winLastTouch.x = x;
winLastTouch.y = y;
userTouchesScreen = true;
return 0; return 0;
} }
} }
NDS_releaseTouch(); if (!StylusAutoHoldPressed)
NDS_releaseTouch();
userTouchesScreen = false;
return 0; return 0;
case WM_LBUTTONUP: case WM_LBUTTONUP:
ReleaseCapture(); ReleaseCapture();
NDS_releaseTouch();
HudClickRelease(&Hud); HudClickRelease(&Hud);
if (!StylusAutoHoldPressed)
NDS_releaseTouch();
userTouchesScreen = false;
return 0; return 0;
#if 0 #if 0