mirror of https://github.com/PCSX2/pcsx2.git
onepad: replace key_status pointer by g_key_status object
This commit is contained in:
parent
b09a82fb94
commit
db4f28f4ca
|
@ -75,6 +75,6 @@ public:
|
|||
void commit_status(u32 pad);
|
||||
};
|
||||
|
||||
extern KeyStatus *key_status;
|
||||
extern KeyStatus g_key_status;
|
||||
|
||||
#endif
|
||||
|
|
|
@ -91,9 +91,9 @@ void PollForJoystickInput(int cpad)
|
|||
for (int i = 0; i < MAX_KEYS; i++) {
|
||||
s32 value = gamePad->GetInput((gamePadValues)i);
|
||||
if (value != 0)
|
||||
key_status->press(cpad, i, value);
|
||||
g_key_status.press(cpad, i, value);
|
||||
else
|
||||
key_status->release(cpad, i);
|
||||
g_key_status.release(cpad, i);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -116,17 +116,17 @@ PADupdate(int pad)
|
|||
// Poll keyboard/mouse event. There is currently no way to separate pad0 from pad1 event.
|
||||
// So we will populate both pad in the same time
|
||||
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
|
||||
key_status->keyboard_state_acces(cpad);
|
||||
g_key_status.keyboard_state_acces(cpad);
|
||||
}
|
||||
PollForX11KeyboardInput();
|
||||
|
||||
// Get joystick state + Commit
|
||||
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
|
||||
key_status->joystick_state_acces(cpad);
|
||||
g_key_status.joystick_state_acces(cpad);
|
||||
|
||||
PollForJoystickInput(cpad);
|
||||
|
||||
key_status->commit_status(cpad);
|
||||
g_key_status.commit_status(cpad);
|
||||
}
|
||||
|
||||
Pad::rumble_all();
|
||||
|
|
|
@ -86,17 +86,17 @@ static void AnalyzeKeyEvent(keyEvent &evt)
|
|||
case PAD_R_UP:
|
||||
case PAD_L_LEFT:
|
||||
case PAD_L_UP:
|
||||
key_status->press(pad, index, -MAX_ANALOG_VALUE);
|
||||
g_key_status.press(pad, index, -MAX_ANALOG_VALUE);
|
||||
break;
|
||||
case PAD_R_RIGHT:
|
||||
case PAD_R_DOWN:
|
||||
case PAD_L_RIGHT:
|
||||
case PAD_L_DOWN:
|
||||
key_status->press(pad, index, MAX_ANALOG_VALUE);
|
||||
g_key_status.press(pad, index, MAX_ANALOG_VALUE);
|
||||
break;
|
||||
}
|
||||
} else if (index != -1)
|
||||
key_status->press(pad, index);
|
||||
g_key_status.press(pad, index);
|
||||
|
||||
//PAD_LOG("Key pressed:%d\n", index);
|
||||
|
||||
|
@ -109,7 +109,7 @@ static void AnalyzeKeyEvent(keyEvent &evt)
|
|||
s_Shift = false;
|
||||
|
||||
if (index != -1)
|
||||
key_status->release(pad, index);
|
||||
g_key_status.release(pad, index);
|
||||
|
||||
event.evt = KEYRELEASE;
|
||||
event.key = key;
|
||||
|
@ -124,12 +124,12 @@ static void AnalyzeKeyEvent(keyEvent &evt)
|
|||
|
||||
case ButtonPress:
|
||||
if (index != -1)
|
||||
key_status->press(pad, index);
|
||||
g_key_status.press(pad, index);
|
||||
break;
|
||||
|
||||
case ButtonRelease:
|
||||
if (index != -1)
|
||||
key_status->release(pad, index);
|
||||
g_key_status.release(pad, index);
|
||||
break;
|
||||
|
||||
case MotionNotify:
|
||||
|
@ -154,15 +154,15 @@ static void AnalyzeKeyEvent(keyEvent &evt)
|
|||
value *= conf->get_sensibility();
|
||||
|
||||
if (x == 0)
|
||||
key_status->press(pad, pad_x, -MAX_ANALOG_VALUE);
|
||||
g_key_status.press(pad, pad_x, -MAX_ANALOG_VALUE);
|
||||
else if (x == 0xFFFF)
|
||||
key_status->press(pad, pad_x, MAX_ANALOG_VALUE);
|
||||
g_key_status.press(pad, pad_x, MAX_ANALOG_VALUE);
|
||||
else if (x < (s_previous_mouse_x - 2))
|
||||
key_status->press(pad, pad_x, -value);
|
||||
g_key_status.press(pad, pad_x, -value);
|
||||
else if (x > (s_previous_mouse_x + 2))
|
||||
key_status->press(pad, pad_x, value);
|
||||
g_key_status.press(pad, pad_x, value);
|
||||
else
|
||||
key_status->release(pad, pad_x);
|
||||
g_key_status.release(pad, pad_x);
|
||||
|
||||
|
||||
unsigned y = evt.key >> 16;
|
||||
|
@ -170,15 +170,15 @@ static void AnalyzeKeyEvent(keyEvent &evt)
|
|||
value *= conf->get_sensibility();
|
||||
|
||||
if (y == 0)
|
||||
key_status->press(pad, pad_y, -MAX_ANALOG_VALUE);
|
||||
g_key_status.press(pad, pad_y, -MAX_ANALOG_VALUE);
|
||||
else if (y == 0xFFFF)
|
||||
key_status->press(pad, pad_y, MAX_ANALOG_VALUE);
|
||||
g_key_status.press(pad, pad_y, MAX_ANALOG_VALUE);
|
||||
else if (y < (s_previous_mouse_y - 2))
|
||||
key_status->press(pad, pad_y, -value);
|
||||
g_key_status.press(pad, pad_y, -value);
|
||||
else if (y > (s_previous_mouse_y + 2))
|
||||
key_status->press(pad, pad_y, value);
|
||||
g_key_status.press(pad, pad_y, value);
|
||||
else
|
||||
key_status->release(pad, pad_y);
|
||||
g_key_status.release(pad, pad_y);
|
||||
|
||||
s_previous_mouse_x = x;
|
||||
s_previous_mouse_y = y;
|
||||
|
@ -240,7 +240,7 @@ bool PollX11KeyboardMouseEvent(u32 &pkey)
|
|||
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
||||
{
|
||||
static bool lbutton = false, rbutton = false;
|
||||
key_status->keyboard_state_acces(cpad);
|
||||
g_key_status.keyboard_state_acces(cpad);
|
||||
|
||||
switch (msg) {
|
||||
case WM_KEYDOWN:
|
||||
|
@ -252,7 +252,7 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
assert(0);
|
||||
#if 0
|
||||
if (wParam == get_key(pad, i)) {
|
||||
key_status->press(pad, i);
|
||||
g_key_status.press(pad, i);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -269,7 +269,7 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
assert(0);
|
||||
#if 0
|
||||
if (wParam == get_key(pad, i)) {
|
||||
key_status->release(pad, i);
|
||||
g_key_status.release(pad, i);
|
||||
break;
|
||||
}
|
||||
#endif
|
||||
|
@ -292,7 +292,7 @@ LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
|
|||
}
|
||||
|
||||
for (int pad = 0; pad < GAMEPAD_NUMBER; ++pad)
|
||||
key_status->commit_status(pad);
|
||||
g_key_status.commit_status(pad);
|
||||
|
||||
return TRUE;
|
||||
}
|
||||
|
|
|
@ -52,7 +52,7 @@ const u32 build = 0; // increase that with each version
|
|||
|
||||
FILE *padLog = NULL;
|
||||
|
||||
KeyStatus *key_status = NULL;
|
||||
KeyStatus g_key_status;
|
||||
|
||||
MtQueue<keyEvent> g_ev_fifo;
|
||||
|
||||
|
@ -159,8 +159,6 @@ PADinit(u32 flags)
|
|||
|
||||
LoadConfig();
|
||||
|
||||
key_status = new KeyStatus();
|
||||
|
||||
Pad::reset_all();
|
||||
|
||||
query.reset();
|
||||
|
@ -178,16 +176,13 @@ PADshutdown()
|
|||
|
||||
delete conf;
|
||||
conf = nullptr;
|
||||
|
||||
delete key_status;
|
||||
key_status = nullptr;
|
||||
}
|
||||
|
||||
EXPORT_C_(s32)
|
||||
PADopen(void *pDsp)
|
||||
{
|
||||
memset(&event, 0, sizeof(event));
|
||||
key_status->Init();
|
||||
g_key_status.Init();
|
||||
|
||||
g_ev_fifo.reset();
|
||||
|
||||
|
|
|
@ -239,7 +239,7 @@ u8 pad_poll(u8 value)
|
|||
b1=b1 & 0x1f;
|
||||
#endif
|
||||
|
||||
uint16_t buttons = key_status->get(query.port);
|
||||
uint16_t buttons = g_key_status.get(query.port);
|
||||
|
||||
query.numBytes = 5;
|
||||
|
||||
|
@ -249,27 +249,27 @@ u8 pad_poll(u8 value)
|
|||
if (pad->mode != MODE_DIGITAL) { // ANALOG || DS2 native
|
||||
query.numBytes = 9;
|
||||
|
||||
query.response[5] = key_status->get(query.port, PAD_R_RIGHT);
|
||||
query.response[6] = key_status->get(query.port, PAD_R_UP);
|
||||
query.response[7] = key_status->get(query.port, PAD_L_RIGHT);
|
||||
query.response[8] = key_status->get(query.port, PAD_L_UP);
|
||||
query.response[5] = g_key_status.get(query.port, PAD_R_RIGHT);
|
||||
query.response[6] = g_key_status.get(query.port, PAD_R_UP);
|
||||
query.response[7] = g_key_status.get(query.port, PAD_L_RIGHT);
|
||||
query.response[8] = g_key_status.get(query.port, PAD_L_UP);
|
||||
|
||||
if (pad->mode != MODE_ANALOG) { // DS2 native
|
||||
query.numBytes = 21;
|
||||
|
||||
query.response[9] = !test_bit(buttons, 13) ? key_status->get(query.port, PAD_RIGHT) : 0;
|
||||
query.response[10] = !test_bit(buttons, 15) ? key_status->get(query.port, PAD_LEFT) : 0;
|
||||
query.response[11] = !test_bit(buttons, 12) ? key_status->get(query.port, PAD_UP) : 0;
|
||||
query.response[12] = !test_bit(buttons, 14) ? key_status->get(query.port, PAD_DOWN) : 0;
|
||||
query.response[9] = !test_bit(buttons, 13) ? g_key_status.get(query.port, PAD_RIGHT) : 0;
|
||||
query.response[10] = !test_bit(buttons, 15) ? g_key_status.get(query.port, PAD_LEFT) : 0;
|
||||
query.response[11] = !test_bit(buttons, 12) ? g_key_status.get(query.port, PAD_UP) : 0;
|
||||
query.response[12] = !test_bit(buttons, 14) ? g_key_status.get(query.port, PAD_DOWN) : 0;
|
||||
|
||||
query.response[13] = !test_bit(buttons, 4) ? key_status->get(query.port, PAD_TRIANGLE) : 0;
|
||||
query.response[14] = !test_bit(buttons, 5) ? key_status->get(query.port, PAD_CIRCLE) : 0;
|
||||
query.response[15] = !test_bit(buttons, 6) ? key_status->get(query.port, PAD_CROSS) : 0;
|
||||
query.response[16] = !test_bit(buttons, 7) ? key_status->get(query.port, PAD_SQUARE) : 0;
|
||||
query.response[17] = !test_bit(buttons, 2) ? key_status->get(query.port, PAD_L1) : 0;
|
||||
query.response[18] = !test_bit(buttons, 3) ? key_status->get(query.port, PAD_R1) : 0;
|
||||
query.response[19] = !test_bit(buttons, 0) ? key_status->get(query.port, PAD_L2) : 0;
|
||||
query.response[20] = !test_bit(buttons, 1) ? key_status->get(query.port, PAD_R2) : 0;
|
||||
query.response[13] = !test_bit(buttons, 4) ? g_key_status.get(query.port, PAD_TRIANGLE) : 0;
|
||||
query.response[14] = !test_bit(buttons, 5) ? g_key_status.get(query.port, PAD_CIRCLE) : 0;
|
||||
query.response[15] = !test_bit(buttons, 6) ? g_key_status.get(query.port, PAD_CROSS) : 0;
|
||||
query.response[16] = !test_bit(buttons, 7) ? g_key_status.get(query.port, PAD_SQUARE) : 0;
|
||||
query.response[17] = !test_bit(buttons, 2) ? g_key_status.get(query.port, PAD_L1) : 0;
|
||||
query.response[18] = !test_bit(buttons, 3) ? g_key_status.get(query.port, PAD_R1) : 0;
|
||||
query.response[19] = !test_bit(buttons, 0) ? g_key_status.get(query.port, PAD_L2) : 0;
|
||||
query.response[20] = !test_bit(buttons, 1) ? g_key_status.get(query.port, PAD_R2) : 0;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
Loading…
Reference in New Issue