mirror of https://github.com/PCSX2/pcsx2.git
onepad: slim down a little more the KeyStatus API
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@4781 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
9cb19121e0
commit
89c48d526e
|
@ -33,10 +33,10 @@ void KeyStatus::Init()
|
||||||
m_internal_button_pressure[pad][index] = 0xFF;
|
m_internal_button_pressure[pad][index] = 0xFF;
|
||||||
}
|
}
|
||||||
|
|
||||||
analog[pad].lx = 0x80;
|
m_analog[pad].lx = 0x80;
|
||||||
analog[pad].ly = 0x80;
|
m_analog[pad].ly = 0x80;
|
||||||
analog[pad].rx = 0x80;
|
m_analog[pad].rx = 0x80;
|
||||||
analog[pad].ry = 0x80;
|
m_analog[pad].ry = 0x80;
|
||||||
m_internal_analog_kbd[pad].lx = 0x80;
|
m_internal_analog_kbd[pad].lx = 0x80;
|
||||||
m_internal_analog_kbd[pad].ly = 0x80;
|
m_internal_analog_kbd[pad].ly = 0x80;
|
||||||
m_internal_analog_kbd[pad].rx = 0x80;
|
m_internal_analog_kbd[pad].rx = 0x80;
|
||||||
|
@ -51,6 +51,7 @@ void KeyStatus::Init()
|
||||||
void KeyStatus::press(u32 pad, u32 index, s32 value)
|
void KeyStatus::press(u32 pad, u32 index, s32 value)
|
||||||
{
|
{
|
||||||
if (!IsAnalogKey(index)) {
|
if (!IsAnalogKey(index)) {
|
||||||
|
m_internal_button_pressure[pad][index] = value;
|
||||||
if (m_state_acces[pad])
|
if (m_state_acces[pad])
|
||||||
clear_bit(m_internal_button_kbd[pad], index);
|
clear_bit(m_internal_button_kbd[pad], index);
|
||||||
else
|
else
|
||||||
|
@ -90,16 +91,6 @@ u16 KeyStatus::get(u32 pad)
|
||||||
return m_button[pad];
|
return m_button[pad];
|
||||||
}
|
}
|
||||||
|
|
||||||
void KeyStatus::set_pressure(u32 pad, u32 index, u32 value)
|
|
||||||
{
|
|
||||||
m_internal_button_pressure[pad][index] = value;
|
|
||||||
}
|
|
||||||
|
|
||||||
u8 KeyStatus::get_pressure(u32 pad, u32 index)
|
|
||||||
{
|
|
||||||
return m_button_pressure[pad][index];
|
|
||||||
}
|
|
||||||
|
|
||||||
void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
|
void KeyStatus::analog_set(u32 pad, u32 index, u8 value)
|
||||||
{
|
{
|
||||||
PADAnalog* m_internal_analog_ref;
|
PADAnalog* m_internal_analog_ref;
|
||||||
|
@ -150,23 +141,23 @@ bool KeyStatus::analog_is_reversed(u32 index)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
u8 KeyStatus::analog_get(u32 pad, u32 index)
|
u8 KeyStatus::get(u32 pad, u32 index)
|
||||||
{
|
{
|
||||||
switch (index)
|
switch (index)
|
||||||
{
|
{
|
||||||
case PAD_R_LEFT:
|
case PAD_R_LEFT:
|
||||||
case PAD_R_RIGHT: return analog[pad].rx;
|
case PAD_R_RIGHT: return m_analog[pad].rx;
|
||||||
|
|
||||||
case PAD_R_DOWN:
|
case PAD_R_DOWN:
|
||||||
case PAD_R_UP: return analog[pad].ry;
|
case PAD_R_UP: return m_analog[pad].ry;
|
||||||
|
|
||||||
case PAD_L_LEFT:
|
case PAD_L_LEFT:
|
||||||
case PAD_L_RIGHT: return analog[pad].lx;
|
case PAD_L_RIGHT: return m_analog[pad].lx;
|
||||||
|
|
||||||
case PAD_L_DOWN:
|
case PAD_L_DOWN:
|
||||||
case PAD_L_UP: return analog[pad].ly;
|
case PAD_L_UP: return m_analog[pad].ly;
|
||||||
|
|
||||||
default: return 0;
|
default: return m_button_pressure[pad][index];
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -185,8 +176,8 @@ void KeyStatus::commit_status(u32 pad)
|
||||||
for (int index = 0; index < MAX_KEYS; index++)
|
for (int index = 0; index < MAX_KEYS; index++)
|
||||||
m_button_pressure[pad][index] = m_internal_button_pressure[pad][index];
|
m_button_pressure[pad][index] = m_internal_button_pressure[pad][index];
|
||||||
|
|
||||||
analog[pad].lx = analog_merge(m_internal_analog_kbd[pad].lx, m_internal_analog_joy[pad].lx);
|
m_analog[pad].lx = analog_merge(m_internal_analog_kbd[pad].lx, m_internal_analog_joy[pad].lx);
|
||||||
analog[pad].ly = analog_merge(m_internal_analog_kbd[pad].ly, m_internal_analog_joy[pad].ly);
|
m_analog[pad].ly = analog_merge(m_internal_analog_kbd[pad].ly, m_internal_analog_joy[pad].ly);
|
||||||
analog[pad].rx = analog_merge(m_internal_analog_kbd[pad].rx, m_internal_analog_joy[pad].rx);
|
m_analog[pad].rx = analog_merge(m_internal_analog_kbd[pad].rx, m_internal_analog_joy[pad].rx);
|
||||||
analog[pad].ry = analog_merge(m_internal_analog_kbd[pad].ry, m_internal_analog_joy[pad].ry);
|
m_analog[pad].ry = analog_merge(m_internal_analog_kbd[pad].ry, m_internal_analog_joy[pad].ry);
|
||||||
}
|
}
|
||||||
|
|
|
@ -44,7 +44,7 @@ class KeyStatus
|
||||||
|
|
||||||
bool m_state_acces[2];
|
bool m_state_acces[2];
|
||||||
|
|
||||||
PADAnalog analog[2];
|
PADAnalog m_analog[2];
|
||||||
PADAnalog m_internal_analog_kbd[2];
|
PADAnalog m_internal_analog_kbd[2];
|
||||||
PADAnalog m_internal_analog_joy[2];
|
PADAnalog m_internal_analog_joy[2];
|
||||||
|
|
||||||
|
@ -59,14 +59,12 @@ class KeyStatus
|
||||||
void keyboard_state_acces(u32 pad) { m_state_acces[pad] = true; }
|
void keyboard_state_acces(u32 pad) { m_state_acces[pad] = true; }
|
||||||
void joystick_state_acces(u32 pad) { m_state_acces[pad] = false; }
|
void joystick_state_acces(u32 pad) { m_state_acces[pad] = false; }
|
||||||
|
|
||||||
void press(u32 pad, u32 index, s32 value = 0);
|
void press(u32 pad, u32 index, s32 value = 0xFF);
|
||||||
void release(u32 pad, u32 index);
|
void release(u32 pad, u32 index);
|
||||||
|
|
||||||
u16 get(u32 pad);
|
u16 get(u32 pad);
|
||||||
|
u8 get(u32 pad, u32 index);
|
||||||
|
|
||||||
void set_pressure(u32 pad, u32 index, u32 value);
|
|
||||||
u8 get_pressure(u32 pad, u32 index);
|
|
||||||
|
|
||||||
u8 analog_get(u32 pad, u32 index);
|
|
||||||
|
|
||||||
void commit_status(u32 pad);
|
void commit_status(u32 pad);
|
||||||
};
|
};
|
||||||
|
|
|
@ -139,23 +139,18 @@ void PollForJoystickInput(int cpad)
|
||||||
} else {
|
} else {
|
||||||
if (full_axis) {
|
if (full_axis) {
|
||||||
value += 0x8000;
|
value += 0x8000;
|
||||||
if (value > pjoy->GetDeadzone()) {
|
if (value > pjoy->GetDeadzone())
|
||||||
key_status->press(cpad, i);
|
key_status->press(cpad, i, min(value/256 , 0xFF));
|
||||||
key_status->set_pressure(cpad, i, min(value/256 , 0xFF));
|
else
|
||||||
} else {
|
|
||||||
key_status->release(cpad, i);
|
key_status->release(cpad, i);
|
||||||
}
|
|
||||||
|
|
||||||
} else {
|
} else {
|
||||||
if (sign && (-value > pjoy->GetDeadzone())) {
|
if (sign && (-value > pjoy->GetDeadzone()))
|
||||||
key_status->press(cpad, i);
|
key_status->press(cpad, i, min(-value /128, 0xFF));
|
||||||
key_status->set_pressure(cpad, i, min(-value /128, 0xFF));
|
else if (!sign && (value > pjoy->GetDeadzone()))
|
||||||
} else if (!sign && (value > pjoy->GetDeadzone())) {
|
key_status->press(cpad, i, min(value /128, 0xFF));
|
||||||
key_status->press(cpad, i);
|
else
|
||||||
key_status->set_pressure(cpad, i, min(value /128, 0xFF));
|
|
||||||
} else {
|
|
||||||
key_status->release(cpad, i);
|
key_status->release(cpad, i);
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
|
@ -389,10 +389,10 @@ u8 _PADpoll(u8 value)
|
||||||
|
|
||||||
stdpar[curPad][2] = key_status->get(curPad) >> 8;
|
stdpar[curPad][2] = key_status->get(curPad) >> 8;
|
||||||
stdpar[curPad][3] = key_status->get(curPad) & 0xff;
|
stdpar[curPad][3] = key_status->get(curPad) & 0xff;
|
||||||
stdpar[curPad][4] = key_status->analog_get(curPad, PAD_R_RIGHT);
|
stdpar[curPad][4] = key_status->get(curPad, PAD_R_RIGHT);
|
||||||
stdpar[curPad][5] = key_status->analog_get(curPad, PAD_R_UP);
|
stdpar[curPad][5] = key_status->get(curPad, PAD_R_UP);
|
||||||
stdpar[curPad][6] = key_status->analog_get(curPad, PAD_L_RIGHT);
|
stdpar[curPad][6] = key_status->get(curPad, PAD_L_RIGHT);
|
||||||
stdpar[curPad][7] = key_status->analog_get(curPad, PAD_L_UP);
|
stdpar[curPad][7] = key_status->get(curPad, PAD_L_UP);
|
||||||
|
|
||||||
if (padMode[curPad] == 1)
|
if (padMode[curPad] == 1)
|
||||||
cmdLen = 20;
|
cmdLen = 20;
|
||||||
|
@ -403,35 +403,35 @@ u8 _PADpoll(u8 value)
|
||||||
switch (stdpar[curPad][3])
|
switch (stdpar[curPad][3])
|
||||||
{
|
{
|
||||||
case 0xBF: // X
|
case 0xBF: // X
|
||||||
stdpar[curPad][14] = key_status->get_pressure(curPad, PAD_CROSS);
|
stdpar[curPad][14] = key_status->get(curPad, PAD_CROSS);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xDF: // Circle
|
case 0xDF: // Circle
|
||||||
stdpar[curPad][13] = key_status->get_pressure(curPad, PAD_CIRCLE);
|
stdpar[curPad][13] = key_status->get(curPad, PAD_CIRCLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xEF: // Triangle
|
case 0xEF: // Triangle
|
||||||
stdpar[curPad][12] = key_status->get_pressure(curPad, PAD_TRIANGLE);
|
stdpar[curPad][12] = key_status->get(curPad, PAD_TRIANGLE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x7F: // Square
|
case 0x7F: // Square
|
||||||
stdpar[curPad][15] = key_status->get_pressure(curPad, PAD_SQUARE);
|
stdpar[curPad][15] = key_status->get(curPad, PAD_SQUARE);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xFB: // L1
|
case 0xFB: // L1
|
||||||
stdpar[curPad][16] = key_status->get_pressure(curPad, PAD_L1);
|
stdpar[curPad][16] = key_status->get(curPad, PAD_L1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xF7: // R1
|
case 0xF7: // R1
|
||||||
stdpar[curPad][17] = key_status->get_pressure(curPad, PAD_R1);
|
stdpar[curPad][17] = key_status->get(curPad, PAD_R1);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xFE: // L2
|
case 0xFE: // L2
|
||||||
stdpar[curPad][18] = key_status->get_pressure(curPad, PAD_L2);
|
stdpar[curPad][18] = key_status->get(curPad, PAD_L2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xFD: // R2
|
case 0xFD: // R2
|
||||||
stdpar[curPad][19] = key_status->get_pressure(curPad, PAD_R2);
|
stdpar[curPad][19] = key_status->get(curPad, PAD_R2);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
@ -448,19 +448,19 @@ u8 _PADpoll(u8 value)
|
||||||
switch (button_check)
|
switch (button_check)
|
||||||
{
|
{
|
||||||
case 0xE: // UP
|
case 0xE: // UP
|
||||||
stdpar[curPad][10] = key_status->get_pressure(curPad, PAD_UP);
|
stdpar[curPad][10] = key_status->get(curPad, PAD_UP);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xB: // DOWN
|
case 0xB: // DOWN
|
||||||
stdpar[curPad][11] =key_status->get_pressure(curPad, PAD_DOWN);
|
stdpar[curPad][11] =key_status->get(curPad, PAD_DOWN);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0x7: // LEFT
|
case 0x7: // LEFT
|
||||||
stdpar[curPad][9] = key_status->get_pressure(curPad, PAD_LEFT);
|
stdpar[curPad][9] = key_status->get(curPad, PAD_LEFT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
case 0xD: // RIGHT
|
case 0xD: // RIGHT
|
||||||
stdpar[curPad][8] = key_status->get_pressure(curPad, PAD_RIGHT);
|
stdpar[curPad][8] = key_status->get(curPad, PAD_RIGHT);
|
||||||
break;
|
break;
|
||||||
|
|
||||||
default:
|
default:
|
||||||
|
|
Loading…
Reference in New Issue