parent
c9d6849502
commit
1d6983b51a
|
@ -37,9 +37,11 @@ char IniName[MAX_PATH];
|
|||
char vPath[MAX_PATH],*szPath,currDir[MAX_PATH];
|
||||
u32 keytab[12];
|
||||
|
||||
const char tabkeytext[48][8] = {"0","1","2","3","4","5","6","7","8","9","A","B","C",
|
||||
const char tabkeytext[52][14] = {"0","1","2","3","4","5","6","7","8","9","A","B","C",
|
||||
"D","E","F","G","H","I","J","K","L","M","N","O","P","Q","R","S","T","U","V","W","X",
|
||||
"Y","Z","SPACE","UP","DOWN","LEFT","RIGHT","TAB","SHIFT","DEL","INSERT","HOME","END","ENTER"};
|
||||
"Y","Z","SPACE","UP","DOWN","LEFT","RIGHT","TAB","SHIFT","DEL","INSERT","HOME","END","ENTER",
|
||||
"Joystick UP","Joystick DOWN","Joystick LEFT","Joystick RIGHT"};
|
||||
const char DI_tabkeytext[50][20];
|
||||
|
||||
DWORD dds_up=37;
|
||||
DWORD dds_down=38;
|
||||
|
@ -87,10 +89,11 @@ extern DWORD ds_start;
|
|||
#define KEY_DEBUG ds_debug
|
||||
|
||||
/* DirectInput stuff */
|
||||
int g_bDInput=0;
|
||||
char g_cDIBuf[256];
|
||||
char g_cDIBuf[512];
|
||||
LPDIRECTINPUT8 g_pDI;
|
||||
LPDIRECTINPUTDEVICE8 g_pKeyboard;
|
||||
LPDIRECTINPUTDEVICE8 g_pJoystick;
|
||||
DIDEVCAPS g_DIJoycap;
|
||||
|
||||
void GetINIPath(char *inipath,u16 bufferSize)
|
||||
{
|
||||
|
@ -240,7 +243,23 @@ BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lp
|
|||
{
|
||||
case WM_INITDIALOG:
|
||||
ReadConfig();
|
||||
for(i=0;i<48;i++)for(j=0;j<12;j++)SendDlgItemMessage(dialog,key_combos[j],CB_ADDSTRING,0,(LPARAM)&tabkeytext[i]);
|
||||
if (g_pKeyboard)
|
||||
for(i=0;i<48;i++)
|
||||
for(j=0;j<12;j++)
|
||||
SendDlgItemMessage(dialog,key_combos[j],CB_ADDSTRING,0,(LPARAM)&tabkeytext[i]);
|
||||
if (g_pJoystick)
|
||||
{
|
||||
for(i=0;i<4;i++)
|
||||
for(j=0;j<12;j++)
|
||||
SendDlgItemMessage(dialog,key_combos[j],CB_ADDSTRING,0,(LPARAM)&tabkeytext[i+48]);
|
||||
for(i=0;i<g_DIJoycap.dwButtons;i++)
|
||||
for(j=0;j<12;j++)
|
||||
{
|
||||
char buf[30];
|
||||
sprintf(buf,"Joystick B%i",i+1);
|
||||
SendDlgItemMessage(dialog,key_combos[j],CB_ADDSTRING,0,(LPARAM)&buf);
|
||||
}
|
||||
}
|
||||
SendDlgItemMessage(dialog,IDC_COMBO1,CB_SETCURSEL,KEY_UP,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO2,CB_SETCURSEL,KEY_LEFT,0);
|
||||
SendDlgItemMessage(dialog,IDC_COMBO3,CB_SETCURSEL,KEY_RIGHT,0);
|
||||
|
@ -305,47 +324,107 @@ BOOL CALLBACK ConfigView_Proc(HWND dialog,UINT komunikat,WPARAM wparam,LPARAM lp
|
|||
//================================================================================================
|
||||
//================================================================================================
|
||||
//================================================================================================
|
||||
BOOL CALLBACK JoyObjects(const DIDEVICEOBJECTINSTANCE* pdidoi,VOID* pContext)
|
||||
{
|
||||
if( pdidoi->dwType & DIDFT_AXIS )
|
||||
{
|
||||
DIPROPRANGE diprg;
|
||||
diprg.diph.dwSize = sizeof(DIPROPRANGE);
|
||||
diprg.diph.dwHeaderSize = sizeof(DIPROPHEADER);
|
||||
diprg.diph.dwHow = DIPH_BYID;
|
||||
diprg.diph.dwObj = pdidoi->dwType;
|
||||
diprg.lMin = -3;
|
||||
diprg.lMax = 3;
|
||||
|
||||
if( FAILED(IDirectInputDevice8_SetProperty(g_pJoystick,DIPROP_RANGE,&diprg.diph)))
|
||||
return DIENUM_STOP;
|
||||
}
|
||||
return DIENUM_CONTINUE;
|
||||
}
|
||||
HRESULT Input_Init(HWND hwnd)
|
||||
{
|
||||
HRESULT hr;
|
||||
int res;
|
||||
|
||||
ReadConfig();
|
||||
|
||||
hr=DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,&IID_IDirectInput8,(void**)&g_pDI,NULL);
|
||||
if(FAILED(hr)) return -1;
|
||||
hr=IDirectInput_CreateDevice(g_pDI,&GUID_SysKeyboard, &g_pKeyboard, NULL);
|
||||
if(FAILED(hr)) { Input_DeInit(); return (hr); }
|
||||
hr=IDirectInputDevice_SetDataFormat(g_pKeyboard,&c_dfDIKeyboard);
|
||||
if(FAILED(hr)) { Input_DeInit(); return (hr); }
|
||||
hr=IDirectInputDevice_SetCooperativeLevel(g_pKeyboard,hwnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE);
|
||||
if(FAILED(hr)) { Input_DeInit(); return (hr); }
|
||||
|
||||
//hr=IDirectInputDevice_Acquire(g_pKeyboard);
|
||||
//while(hr==DIERR_INPUTLOST) hr=IDirectInputDevice_Acquire(g_pKeyboard);
|
||||
//if(FAILED(hr)) { Input_DeInit(); return (hr); }
|
||||
//if(FAILED(hr)) { Input_DeInit(); return (hr); }
|
||||
//if(FAILED(hr)) { Input_DeInit(); return (hr); }
|
||||
g_pKeyboard=NULL; g_pJoystick=NULL;
|
||||
|
||||
return 0;
|
||||
if(!FAILED(DirectInput8Create(GetModuleHandle(NULL),DIRECTINPUT_VERSION,&IID_IDirectInput8,(void**)&g_pDI,NULL)))
|
||||
{
|
||||
//******************* Keyboard
|
||||
res=0;
|
||||
if (FAILED(IDirectInput8_CreateDevice(g_pDI,&GUID_SysKeyboard,&g_pKeyboard,NULL))) res=-1;
|
||||
else
|
||||
if (FAILED(IDirectInputDevice8_SetDataFormat(g_pKeyboard,&c_dfDIKeyboard))) res=-1;
|
||||
else
|
||||
if (FAILED(IDirectInputDevice8_SetCooperativeLevel(g_pKeyboard,hwnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE))) res=-1;
|
||||
if (res!=0)
|
||||
{
|
||||
if(g_pKeyboard) IDirectInputDevice8_Release(g_pKeyboard);
|
||||
g_pKeyboard=NULL;
|
||||
}
|
||||
|
||||
//******************** Joystick
|
||||
res=0;
|
||||
if(FAILED(IDirectInput8_CreateDevice(g_pDI,&GUID_Joystick,&g_pJoystick,NULL))) res=-1;
|
||||
else
|
||||
if(FAILED(IDirectInputDevice8_SetDataFormat(g_pJoystick,&c_dfDIJoystick2))) res=-1;
|
||||
else
|
||||
if(FAILED(IDirectInputDevice8_SetCooperativeLevel(g_pJoystick,hwnd,DISCL_FOREGROUND|DISCL_NONEXCLUSIVE))) res=-1;
|
||||
if (res!=0)
|
||||
{
|
||||
if(g_pJoystick) IDirectInputDevice8_Release(g_pJoystick);
|
||||
g_pJoystick=NULL;
|
||||
}
|
||||
else
|
||||
{
|
||||
IDirectInputDevice8_EnumObjects(g_pJoystick,JoyObjects,(VOID*)hwnd,DIDFT_ALL);
|
||||
memset(&g_DIJoycap,0,sizeof(DIDEVCAPS));
|
||||
g_DIJoycap.dwSize=sizeof(DIDEVCAPS);
|
||||
IDirectInputDevice8_GetCapabilities(g_pJoystick,&g_DIJoycap);
|
||||
}
|
||||
}
|
||||
else return E_FAIL;
|
||||
|
||||
if ((g_pKeyboard==NULL)&&(g_pJoystick==NULL))
|
||||
{
|
||||
Input_DeInit();
|
||||
return E_FAIL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
||||
HRESULT Input_DeInit (void)
|
||||
HRESULT Input_DeInit()
|
||||
{
|
||||
if (g_pDI)
|
||||
{
|
||||
HRESULT hr;
|
||||
if (g_pKeyboard)
|
||||
{
|
||||
hr=IDirectInputDevice_Unacquire(g_pKeyboard);
|
||||
hr=IDirectInputDevice8_Unacquire(g_pKeyboard);
|
||||
#ifdef DEBUG
|
||||
if (FAILED(hr)) LOG("DINPUT: error keyboard unacquire (0x%08X)\n",hr);
|
||||
#endif
|
||||
hr=IDirectInputDevice_Release(g_pKeyboard);
|
||||
hr=IDirectInputDevice8_Release(g_pKeyboard);
|
||||
#ifdef DEBUG
|
||||
if (FAILED(hr)) LOG("DINPUT: error keyboard release (0x%08X)\n",hr);
|
||||
#endif
|
||||
g_pKeyboard=NULL;
|
||||
}
|
||||
hr=IDirectInput_Release(g_pDI);
|
||||
if (g_pJoystick)
|
||||
{
|
||||
hr=IDirectInputDevice8_Unacquire(g_pJoystick);
|
||||
#ifdef DEBUG
|
||||
if (FAILED(hr)) LOG("DINPUT: error joystick unacquire (0x%08X)\n",hr);
|
||||
#endif
|
||||
hr=IDirectInputDevice8_Release(g_pJoystick);
|
||||
#ifdef DEBUG
|
||||
if (FAILED(hr)) LOG("DINPUT: error joystick release (0x%08X)\n",hr);
|
||||
#endif
|
||||
g_pJoystick=NULL;
|
||||
}
|
||||
IDirectInput8_Release(g_pDI);
|
||||
g_pDI=NULL;
|
||||
}
|
||||
return S_OK;
|
||||
}
|
||||
|
@ -353,12 +432,42 @@ HRESULT Input_DeInit (void)
|
|||
void Input_Process()
|
||||
{
|
||||
HRESULT hr;
|
||||
if(!g_pKeyboard) return;
|
||||
DIJOYSTATE2 JoyStatus;
|
||||
|
||||
long source,psource;
|
||||
|
||||
memset(g_cDIBuf,0,sizeof(g_cDIBuf));
|
||||
hr=IDirectInputDevice_GetDeviceState(g_pKeyboard,sizeof(g_cDIBuf),g_cDIBuf);
|
||||
if (FAILED(hr))
|
||||
if(g_pKeyboard)
|
||||
{
|
||||
hr=IDirectInputDevice_Acquire(g_pKeyboard);
|
||||
while(hr==DIERR_INPUTLOST) hr=IDirectInputDevice_Acquire(g_pKeyboard);
|
||||
hr=IDirectInputDevice8_GetDeviceState(g_pKeyboard,256,g_cDIBuf);
|
||||
if (FAILED(hr)) IDirectInputDevice8_Acquire(g_pKeyboard);
|
||||
}
|
||||
|
||||
if(g_pJoystick)
|
||||
{
|
||||
hr=IDirectInputDevice8_Poll(g_pJoystick);
|
||||
if (FAILED(hr)) IDirectInputDevice8_Acquire(g_pJoystick);
|
||||
else
|
||||
{
|
||||
hr=IDirectInputDevice8_GetDeviceState(g_pJoystick,sizeof(JoyStatus),&JoyStatus);
|
||||
if (FAILED(hr)) hr=IDirectInputDevice8_Acquire(g_pJoystick);
|
||||
else
|
||||
{
|
||||
if (JoyStatus.lX<-1) g_cDIBuf[258]=-128;
|
||||
if (JoyStatus.lX>1) g_cDIBuf[259]=-128;
|
||||
if (JoyStatus.lY<-1) g_cDIBuf[256]=-128;
|
||||
if (JoyStatus.lY>1) g_cDIBuf[257]=-128;
|
||||
|
||||
if (JoyStatus.rgdwPOV[0]==0) g_cDIBuf[256]=-128;
|
||||
if (JoyStatus.rgdwPOV[0]==4500) { g_cDIBuf[256]=-128; g_cDIBuf[259]=-128;}
|
||||
if (JoyStatus.rgdwPOV[0]==9000) g_cDIBuf[259]=-128;
|
||||
if (JoyStatus.rgdwPOV[0]==13500) { g_cDIBuf[259]=-128; g_cDIBuf[257]=-128;}
|
||||
if (JoyStatus.rgdwPOV[0]==18000) g_cDIBuf[257]=-128;
|
||||
if (JoyStatus.rgdwPOV[0]==22500) { g_cDIBuf[257]=-128; g_cDIBuf[258]=-128;}
|
||||
if (JoyStatus.rgdwPOV[0]==27000) g_cDIBuf[258]=-128;
|
||||
if (JoyStatus.rgdwPOV[0]==31500) { g_cDIBuf[258]=-128; g_cDIBuf[256]=-128;}
|
||||
memcpy(g_cDIBuf+260,JoyStatus.rgbButtons,sizeof(JoyStatus.rgbButtons));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
|
@ -40,10 +40,10 @@ extern DWORD ds_select;
|
|||
extern DWORD ds_start;
|
||||
extern DWORD ds_debug;
|
||||
|
||||
extern int g_bDInput;
|
||||
extern char g_cDIBuf[256];
|
||||
extern char g_cDIBuf[512];
|
||||
extern LPDIRECTINPUT8 g_pDI;
|
||||
extern LPDIRECTINPUTDEVICE8 g_pKeyboard;
|
||||
extern LPDIRECTINPUTDEVICE8 g_pJoystick;
|
||||
|
||||
void GetINIPath(char *initpath,u16 bufferSize);
|
||||
void ReadConfig (void);
|
||||
|
|
|
@ -92,7 +92,6 @@ float heightTradeOff;
|
|||
HMENU menu;
|
||||
HANDLE runthread=INVALID_HANDLE_VALUE;
|
||||
|
||||
const DWORD tabkey[48]={0x30,0x31,0x32,0x33,0x34,0x35,0x36,0x37,0x38,0x39,0x41,0x42,0x43,0x44,0x45,0x46,0x47,0x48,0x49,0x4a,0x4b,0x4c,0x4d,0x4e,0x4f,0x50,0x51,0x52,0x53,0x54,0x55,0x56,0x57,0x58,0x59,0x5a,VK_SPACE,VK_UP,VK_DOWN,VK_LEFT,VK_RIGHT,VK_TAB,VK_SHIFT,VK_DELETE,VK_INSERT,VK_HOME,VK_END,0x0d};
|
||||
const DWORD DI_tabkey[48] = {DIK_0,DIK_1,DIK_2,DIK_3,DIK_4,DIK_5,DIK_6,DIK_7,DIK_8,DIK_9,DIK_A,DIK_B,DIK_C,
|
||||
DIK_D,DIK_E,DIK_F,DIK_G,DIK_H,DIK_I,DIK_J,DIK_K,DIK_L,DIK_M,DIK_N,DIK_O,DIK_P,
|
||||
DIK_Q,DIK_R,DIK_S,DIK_T,DIK_U,DIK_V,DIK_W,DIK_X,DIK_Y,DIK_Z,DIK_SPACE,DIK_UP,
|
||||
|
@ -327,41 +326,45 @@ void translateXY(s32 *x, s32*y)
|
|||
|
||||
void Input_Post()
|
||||
{
|
||||
char txt[255];
|
||||
BOOL bPressed;
|
||||
HRESULT hr;
|
||||
WORD keys[13][4]={{ds_a,0xFFFE,0x01,0},{ds_b,0xFFFD,0x02,0},{ds_select,0xFFFB,0x04,0},{ds_start,0xFFF7,0x08,0},
|
||||
{ds_right,0xFFEF,0x10,0},{ds_left,0xFFDF,0x20,0},{ds_up,0xFFBF,0x40,0},{ds_down,0xFF7F,0x80,0},
|
||||
{ds_r,0xFEFF,0x100,0},{ds_l,0xFDFF,0x200,0},
|
||||
{ds_x,0xFFFE,0x01,6},{ds_y,0xFFFD,0x02,6},{ds_debug,0xFFFB,0x04,6}};
|
||||
WORD keys[13][3]={{ds_a,0xFFFE,0x01},{ds_b,0xFFFD,0x02},{ds_select,0xFFFB,0x04},{ds_start,0xFFF7,0x08},
|
||||
{ds_right,0xFFEF,0x10},{ds_left,0xFFDF,0x20},{ds_up,0xFFBF,0x40},{ds_down,0xFF7F,0x80},
|
||||
{ds_r,0xFEFF,0x100},{ds_l,0xFDFF,0x200},
|
||||
{ds_x,0xFFFE,0x01},{ds_y,0xFFFD,0x02},{ds_debug,0xFFFB,0x04}};
|
||||
int i;
|
||||
|
||||
for (i=0; i<13; i++)
|
||||
for (i=0; i<10; i++)
|
||||
{
|
||||
if (g_cDIBuf[DI_tabkey[keys[i][0]]]&0x80)
|
||||
bPressed=FALSE;
|
||||
if (keys[i][0]<48)
|
||||
if (g_cDIBuf[DI_tabkey[keys[i][0]]]&0x80) bPressed=TRUE;
|
||||
if (keys[i][0]>=48)
|
||||
if (g_cDIBuf[208+keys[i][0]]&0x80) bPressed=TRUE;
|
||||
if (bPressed)
|
||||
{
|
||||
if (keys[i][3]==0)
|
||||
{
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= keys[i][1];
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= keys[i][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1] &= keys[i][1];
|
||||
}
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1]&=keys[i][1];
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1]&=keys[i][1];
|
||||
}
|
||||
else
|
||||
{
|
||||
if (keys[i][3]==0)
|
||||
{
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= keys[i][2];
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= keys[i][2];
|
||||
}
|
||||
else
|
||||
{
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1] |= keys[i][2];
|
||||
}
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1]|=keys[i][2];
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1]|=keys[i][2];
|
||||
}
|
||||
}
|
||||
|
||||
for (i=10; i<13; i++)
|
||||
{
|
||||
bPressed=FALSE;
|
||||
if (keys[i][0]<48)
|
||||
if (g_cDIBuf[DI_tabkey[keys[i][0]]]&0x80) bPressed=TRUE;
|
||||
if (keys[i][0]>=48)
|
||||
if (g_cDIBuf[208+keys[i][0]]&0x80) bPressed=TRUE;
|
||||
if (bPressed)
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1]&=keys[i][1];
|
||||
else
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1]|=keys[i][2];
|
||||
}
|
||||
}
|
||||
|
||||
DWORD WINAPI run( LPVOID lpParameter)
|
||||
|
@ -426,11 +429,8 @@ DWORD WINAPI run( LPVOID lpParameter)
|
|||
{
|
||||
cycles = NDS_exec((560190<<1)-cycles,FALSE);
|
||||
SPU_Emulate();
|
||||
if (g_bDInput==1)
|
||||
{
|
||||
Input_Process();
|
||||
Input_Post();
|
||||
}
|
||||
Input_Process();
|
||||
Input_Post();
|
||||
|
||||
if (!skipnextframe)
|
||||
{
|
||||
|
@ -881,8 +881,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
case WM_CREATE:
|
||||
{
|
||||
RECT clientSize, fullSize;
|
||||
HRESULT hr=Input_Init(hwnd); //ReadConfig();
|
||||
if (!FAILED(hr)) g_bDInput=1;
|
||||
HRESULT hr=Input_Init(hwnd);
|
||||
#ifdef DEBUG
|
||||
if(FAILED(hr)) LOG("DirectInput init failed (0x%08x)\n",hr);
|
||||
else LOG("DirectInput init\n");
|
||||
|
@ -958,142 +957,7 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
}
|
||||
}
|
||||
return 0;
|
||||
case WM_KEYDOWN:
|
||||
{
|
||||
if (g_bDInput==0)
|
||||
{
|
||||
//if(wParam=='1'){PostMessage(hwnd, WM_DESTROY, 0, 0);return 0;}
|
||||
|
||||
if(wParam==tabkey[ds_a]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFFE;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFFE;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_b]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFFD;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFFD;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_select]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFFB;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFFB;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_start]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFF7;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFF7;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_right]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFEF;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFEF;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_left]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFDF;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFDF;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_up]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFFBF;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFFBF;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_down]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFF7F;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFF7F;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_r]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFEFF;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFEFF;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_l]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] &= 0xFDFF;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] &= 0xFDFF;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_x]){
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1] &= 0xFFFE;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_y]){
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1] &= 0xFFFD;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_debug]){
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1] &= 0xFFFB;
|
||||
return 0; }
|
||||
return 0;
|
||||
/*case 0x1E :
|
||||
MMU.ARM7_REG[0x136] &= 0xFE;
|
||||
break;
|
||||
case 0x1F :
|
||||
MMU.ARM7_REG[0x136] &= 0xFD;
|
||||
break;
|
||||
case 0x21 :
|
||||
NDS_ARM9.wIRQ = TRUE;
|
||||
break; */
|
||||
}
|
||||
else break;
|
||||
}
|
||||
case WM_KEYUP:
|
||||
{
|
||||
if (g_bDInput==0)
|
||||
{
|
||||
if(wParam==tabkey[ds_a]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x1;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x1;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_b]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x2;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x2;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_select]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x4;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x4;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_start]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x8;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x8;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_right]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x10;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x10;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_left]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x20;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x20;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_up]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x40;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x40;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_down]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x80;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x80;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_r]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x100;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x100;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_l]){
|
||||
((u16 *)ARM9Mem.ARM9_REG)[0x130>>1] |= 0x200;
|
||||
((u16 *)MMU.ARM7_REG)[0x130>>1] |= 0x200;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_x]){
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1] |= 0x1;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_y]){
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1] |= 0x2;
|
||||
return 0; }
|
||||
if(wParam==tabkey[ds_debug]){
|
||||
((u16 *)MMU.ARM7_REG)[0x136>>1] |= 0x4;
|
||||
return 0; }
|
||||
break;
|
||||
|
||||
/*case 0x1E :
|
||||
MMU.ARM7_REG[0x136] |= 1;
|
||||
break;
|
||||
case 0x1F :
|
||||
MMU.ARM7_REG[0x136] |= 2;
|
||||
break;*/
|
||||
/*case 0x21 :
|
||||
MMU.REG_IME[0] = 1;*/
|
||||
}
|
||||
else return 0;
|
||||
}
|
||||
case WM_MOUSEMOVE:
|
||||
{
|
||||
if (wParam & MK_LBUTTON)
|
||||
{
|
||||
RECT r ;
|
||||
|
@ -1124,49 +988,48 @@ LRESULT CALLBACK WindowProcedure (HWND hwnd, UINT message, WPARAM wParam, LPARAM
|
|||
NDS_setTouchPos(x, y);
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
NDS_releasTouch();
|
||||
NDS_releasTouch();
|
||||
return 0;
|
||||
case WM_LBUTTONDOWN:
|
||||
if(HIWORD(lParam)>=192)
|
||||
{
|
||||
RECT r ;
|
||||
s32 x = (s32)((s16)LOWORD(lParam));
|
||||
s32 y = (s32)((s16)HIWORD(lParam));
|
||||
GetClientRect(hwnd,&r) ;
|
||||
/* translate from scaling (screen reoltution to 256x384 or 512x192) */
|
||||
switch (GPU_rotation)
|
||||
{
|
||||
case 0:
|
||||
case 180:
|
||||
x = (x*256) / (r.right - r.left) ;
|
||||
y = (y*384) / (r.bottom - r.top) ;
|
||||
break ;
|
||||
case 90:
|
||||
case 270:
|
||||
x = (x*512) / (r.right - r.left) ;
|
||||
y = (y*192) / (r.bottom - r.top) ;
|
||||
break ;
|
||||
}
|
||||
/* translate for rotation */
|
||||
if (GPU_rotation != 0)
|
||||
translateXY(&x,&y);
|
||||
else
|
||||
y-=192;
|
||||
if(y>=0)
|
||||
{
|
||||
SetCapture(hwnd);
|
||||
if(x<0) x = 0; else if(x>255) x = 255;
|
||||
if(y<0) y = 0; else if(y>192) y = 192;
|
||||
NDS_setTouchPos(x, y);
|
||||
click = TRUE;
|
||||
}
|
||||
}
|
||||
if(HIWORD(lParam)>=192)
|
||||
{
|
||||
RECT r ;
|
||||
s32 x = (s32)((s16)LOWORD(lParam));
|
||||
s32 y = (s32)((s16)HIWORD(lParam));
|
||||
GetClientRect(hwnd,&r) ;
|
||||
/* translate from scaling (screen reoltution to 256x384 or 512x192) */
|
||||
switch (GPU_rotation)
|
||||
{
|
||||
case 0:
|
||||
case 180:
|
||||
x = (x*256) / (r.right - r.left) ;
|
||||
y = (y*384) / (r.bottom - r.top) ;
|
||||
break ;
|
||||
case 90:
|
||||
case 270:
|
||||
x = (x*512) / (r.right - r.left) ;
|
||||
y = (y*192) / (r.bottom - r.top) ;
|
||||
break ;
|
||||
}
|
||||
/* translate for rotation */
|
||||
if (GPU_rotation != 0)
|
||||
translateXY(&x,&y);
|
||||
else
|
||||
y-=192;
|
||||
if(y>=0)
|
||||
{
|
||||
SetCapture(hwnd);
|
||||
if(x<0) x = 0; else if(x>255) x = 255;
|
||||
if(y<0) y = 0; else if(y>192) y = 192;
|
||||
NDS_setTouchPos(x, y);
|
||||
click = TRUE;
|
||||
}
|
||||
}
|
||||
return 0;
|
||||
case WM_LBUTTONUP:
|
||||
if(click)
|
||||
ReleaseCapture();
|
||||
NDS_releasTouch();
|
||||
if(click)
|
||||
ReleaseCapture();
|
||||
NDS_releasTouch();
|
||||
return 0;
|
||||
case WM_COMMAND:
|
||||
switch(LOWORD(wParam))
|
||||
|
|
Loading…
Reference in New Issue