Zeropad: Continuing to do some cleanup.

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1162 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-05-09 20:06:57 +00:00
parent 6ea395be4b
commit 0b23b77051
8 changed files with 114 additions and 161 deletions

View File

@ -108,7 +108,6 @@ bool JoystickInfo::Init(int id, bool bStartThread)
numaxes = SDL_JoystickNumAxes(joy);
numbuttons = SDL_JoystickNumButtons(joy);
numpov = SDL_JoystickNumHats(joy);
numhats = SDL_JoystickNumHats(joy);
devname = SDL_JoystickName(id);
vbutstate.resize(numbuttons);
vaxisstate.resize(numbuttons);
@ -144,9 +143,8 @@ void JoystickInfo::SaveState()
vbutstate[i] = SDL_JoystickGetButton(joy, i);
for (int i = 0; i < numaxes; ++i)
vaxisstate[i] = SDL_JoystickGetAxis(joy, i);
//for (int i = 0; i < numhats; ++i)
// vhatstate[i] = SDL_JoystickGetHat(joy, i);
/*for (int i = 0; i < numpov; ++i)
vpovstate[i] = SDL_JoystickGetHat(joy, i);*/
}
void JoystickInfo::TestForce()

View File

@ -42,60 +42,71 @@ class JoystickInfo
{
return devname;
}
int GetNumButtons()
{
return numbuttons;
}
int GetNumAxes()
{
return numaxes;
}
int GetNumPOV()
{
return numpov;
}
/*int GetNumHats()
{
return numhats;
}*/
int GetId()
{
return _id;
}
int GetPAD()
{
return pad;
}
int GetDeadzone(int axis)
{
return deadzone;
}
void SaveState();
int GetButtonState(int i)
{
return vbutstate[i];
}
int GetAxisState(int i)
{
return vaxisstate[i];
}
/*int GetHatState(int i)
int GetPOVState(int i)
{
return vhatstate[i];
}*/
//printf("Getting POV State of %d.\n", i);
return vpovstate[i];
}
void SetButtonState(int i, int state)
{
vbutstate[i] = state;
}
void SetAxisState(int i, int value)
{
vaxisstate[i] = value;
}
/*void SetHatState(int i, int value)
void SetPOVState(int i, int value)
{
vhatstate[i] = value;
}*/
//printf("We should set %d to %d.\n", i, value);
vpovstate[i] = value;
}
SDL_Joystick* GetJoy()
{
return joy;
@ -105,11 +116,11 @@ class JoystickInfo
string devname; // pretty device name
int _id;
int numbuttons, numaxes, numpov, numhats;
int numbuttons, numaxes, numpov;
int axisrange, deadzone;
int pad;
vector<int> vbutstate, vaxisstate;
vector<int> vbutstate, vaxisstate, vpovstate;
SDL_Joystick* joy;
};
@ -117,10 +128,3 @@ class JoystickInfo
extern int s_selectedpad;
extern vector<JoystickInfo*> s_vjoysticks;
//extern void JoystickInfo::EnumerateJoysticks(vector<JoystickInfo*>& vjoysticks);
/*extern JoystickInfo::JoystickInfo();
extern void JoystickInfo::Destroy();
extern bool JoystickInfo::Init(int id, bool bStartThread);
extern void JoystickInfo::Assign(int newpad);
extern void JoystickInfo::SaveState();
extern void JoystickInfo::TestForce();*/

View File

@ -138,50 +138,23 @@ void CALLBACK PADupdate(int pad)
switch (key)
{
case KEY_PAD_LX_LEFT:
g_lanalog[pad].x = DEF_VALUE / 256;
if (conf.options&PADOPTION_REVERTLX) g_lanalog[pad].x = -g_lanalog[pad].x;
g_lanalog[pad].x += 0x80;
case KEY_PAD_LY_UP:
case KEY_PAD_RX_LEFT:
case KEY_PAD_RY_UP:
Analog::ConfigurePad(KeypadToPad(key), pad, DEF_VALUE);
break;
case KEY_PAD_LX_RIGHT:
g_lanalog[pad].x = -DEF_VALUE / 256;
if (conf.options&PADOPTION_REVERTLX) g_lanalog[pad].x = -g_lanalog[pad].x;
g_lanalog[pad].x += 0x80;
break;
case KEY_PAD_LY_UP:
g_lanalog[pad].y = DEF_VALUE / 256;
if (conf.options&PADOPTION_REVERTLY) g_lanalog[pad].y = -g_lanalog[pad].y;
g_lanalog[pad].y += 0x80;
break;
case KEY_PAD_LY_DOWN:
g_lanalog[pad].y = -DEF_VALUE / 256;
if (conf.options&PADOPTION_REVERTLY) g_lanalog[pad].y = -g_lanalog[pad].y;
g_lanalog[pad].y += 0x80;
break;
case KEY_PAD_RX_LEFT:
g_ranalog[pad].x = DEF_VALUE / 256;
if (conf.options&PADOPTION_REVERTRX) g_ranalog[pad].x = -g_ranalog[pad].x;
g_ranalog[pad].x += 0x80;
break;
case KEY_PAD_RX_RIGHT:
g_ranalog[pad].x = -DEF_VALUE / 256;
if (conf.options&PADOPTION_REVERTRX) g_ranalog[pad].x = -g_ranalog[pad].x;
g_ranalog[pad].x += 0x80;
break;
case KEY_PAD_RY_UP:
g_ranalog[pad].y = DEF_VALUE / 256;
if (conf.options&PADOPTION_REVERTRY) g_ranalog[pad].y = -g_ranalog[pad].y;
g_ranalog[pad].y += 0x80;
break;
case KEY_PAD_RY_DOWN:
g_ranalog[pad].y = -DEF_VALUE / 256;
if (conf.options&PADOPTION_REVERTRY) g_ranalog[pad].y = -g_ranalog[pad].y;
g_ranalog[pad].y += 0x80;
Analog::ConfigurePad(KeypadToPad(key), pad, -DEF_VALUE);
break;
}
#endif
i = FindKey(key, pad);
if (i != -1) {
if (i != -1)
{
keyPress |= (1 << i);
keyRelease &= ~(1 << i);
}
@ -196,34 +169,21 @@ void CALLBACK PADupdate(int pad)
switch (key)
{
case KEY_PAD_LX_LEFT:
g_lanalog[pad].x = 0x80;
break;
case KEY_PAD_LY_UP:
g_lanalog[pad].y = 0x80;
break;
case KEY_PAD_RX_LEFT:
g_ranalog[pad].x = 0x80;
break;
case KEY_PAD_RY_UP:
g_ranalog[pad].y = 0x80;
break;
case KEY_PAD_LX_RIGHT:
g_lanalog[pad].x = 0x80;
break;
case KEY_PAD_LY_UP:
case KEY_PAD_LY_DOWN:
g_lanalog[pad].y = 0x80;
break;
case KEY_PAD_RX_LEFT:
case KEY_PAD_RX_RIGHT:
g_ranalog[pad].x = 0x80;
break;
case KEY_PAD_RY_UP:
case KEY_PAD_RY_DOWN:
g_ranalog[pad].y = 0x80;
Analog::ResetPad(KeypadToPad(key));
break;
}
#endif
i = FindKey(key, pad);
if (i != -1) {
if (i != -1)
{
keyPress &= ~(1 << i);
keyRelease |= (1 << i);
}
@ -277,52 +237,13 @@ void CALLBACK PADupdate(int pad)
switch (i)
{
case PAD_LX:
if (abs(value) > (pjoy)->GetDeadzone(value))
{
g_lanalog[pad].x = value / 256;
if (conf.options & PADOPTION_REVERTLX) g_lanalog[pad].x = -g_lanalog[pad].x;
g_lanalog[pad].x += 0x80;
}
else
{
g_lanalog[pad].x = 0x80;
}
break;
case PAD_LY:
if (abs(value) > (pjoy)->GetDeadzone(value))
{
g_lanalog[pad].y = value / 256;
if (conf.options & PADOPTION_REVERTLY) g_lanalog[pad].y = -g_lanalog[pad].y;
g_lanalog[pad].y += 0x80;
}
else
{
g_lanalog[pad].y = 0x80;
}
break;
case PAD_RX:
if (abs(value) > (pjoy)->GetDeadzone(value))
{
g_ranalog[pad].x = value / 256;
if (conf.options & PADOPTION_REVERTRX) g_ranalog[pad].x = -g_ranalog[pad].x;
g_ranalog[pad].x += 0x80;
}
else
{
g_ranalog[pad].x = 0x80;
}
break;
case PAD_RY:
if (abs(value) > (pjoy)->GetDeadzone(value))
{
g_ranalog[pad].y = value / 256;
if (conf.options&PADOPTION_REVERTRY) g_ranalog[pad].y = -g_ranalog[pad].y;
g_ranalog[pad].y += 0x80;
}
Analog::ConfigurePad(i, pad, value);
else
{
g_ranalog[pad].y = 0x80;
}
Analog::ResetPad(i, pad);
break;
}
}
@ -516,6 +437,7 @@ void OnConf_Key(GtkButton *button, gpointer user_data)
if (abs(value) <= (*itjoy)->GetAxisState(i)) // we don't want this
{
// released, we don't really want this
// SetButtonState? Shouldn't this be SetAxisState?
(*itjoy)->SetButtonState(i, value);
break;
}
@ -543,21 +465,33 @@ void OnConf_Key(GtkButton *button, gpointer user_data)
}
}
/*for (int i = 0; i < (*itjoy)->GetNumHats(); ++i)
/*for (int i = 0; i < (*itjoy)->GetNumPOV(); ++i)
{
int value = SDL_JoystickGetHat((*itjoy)->GetJoy(), i);
if (value != (*itjoy)->GetAxisState(i))
if (value != (*itjoy)->GetPOVState(i))
{
*pkey = PAD_HAT((*itjoy)->GetId(), i);
char str[32];
sprintf(str, "JHat %d", i);
gtk_entry_set_text(GTK_ENTRY(label), str);
return;
if (abs(value) > 0x3fff)
{
if (key < 16) // POV
{
*pkey = PAD_POV((*itjoy)->GetId(), value < 0, i);
char str[32];
sprintf(str, "JPOV %d%s", i, value < 0 ? "-" : "+");
gtk_entry_set_text(GTK_ENTRY(label), str);
return;
}
else // axis
{
*pkey = PAD_JOYSTICK((*itjoy)->GetId(), i);
char str[32];
sprintf(str, "JAxis %d", i);
gtk_entry_set_text(GTK_ENTRY(label), str);
return;
}
}
}
}*/
itjoy++;
}
#endif
@ -590,7 +524,7 @@ void CALLBACK PADconfigure()
while (it != s_vjoysticks.end())
{
sprintf(str, "%d: %s - but: %d, axes: %d, pov: %d", (*it)->GetId(), (*it)->GetName().c_str(),
(*it)->GetNumButtons(), (*it)->GetNumAxes(), (*it)->GetNumPOV()/*, (*it)->GetNumHats()*/); // ,hats: %d
(*it)->GetNumButtons(), (*it)->GetNumAxes(), (*it)->GetNumPOV());
gtk_combo_box_append_text(GTK_COMBO_BOX(s_devicecombo), str);
it++;
}

View File

@ -27,4 +27,5 @@ libZeroPAD_LDFLAGS= @SHARED_LDFLAGS@
libZeroPAD_LDFLAGS+=-Wl,-soname,@ZEROPAD_SONAME@
libZeroPAD_LDADD=$(libZeroPAD_a_OBJECTS)
libZeroPAD_a_SOURCES = zeropad.cpp Linux/gui.cpp Linux/linux.cpp Linux/joystick.cpp Linux/support.c Linux/interface.c
libZeroPAD_a_SOURCES = analog.cpp analog.h zeropad.cpp zeropad.h \
Linux/gui.cpp Linux/linux.cpp Linux/joystick.cpp Linux/support.c Linux/interface.c

View File

@ -250,6 +250,10 @@
RelativePath="..\zeropad.cpp"
>
</File>
<File
RelativePath="..\analog.cpp"
>
</File>
</Filter>
<Filter
Name="Header Files"
@ -272,6 +276,10 @@
RelativePath="..\zeropad.h"
>
</File>
<File
RelativePath="..\analog.h"
>
</File>
</Filter>
<Filter
Name="Resource Files"

View File

@ -1,6 +1,6 @@
AC_INIT(ZeroPAD,0.2,zerofrog@gmail.com)
AC_INIT(ZeroPAD,0.3,zerofrog@gmail.com)
AM_INIT_AUTOMAKE(ZeroPAD,0.2)
AM_INIT_AUTOMAKE(ZeroPAD,0.3)
AC_PROG_CC([gcc g++ cl KCC CC cxx cc++ xlC aCC c++])
AC_PROG_CXX([gcc g++ cl KCC CC cxx cc++ xlC aCC c++])
@ -13,9 +13,9 @@ dnl necessary for compiling assembly
AM_PROG_AS
AC_SUBST(ZEROPAD_CURRENT, 0)
AC_SUBST(ZEROPAD_REVISION, 2)
AC_SUBST(ZEROPAD_REVISION, 3)
AC_SUBST(ZEROPAD_AGE, 0)
AC_SUBST(ZEROPAD_RELEASE, libZeroPAD.so.[$ZEROPAD_CURRENT].[$ZEROPAD_REVISION].[$ZEROPAD_AGE])
AC_SUBST(ZEROPAD_RELEASE, [$ZEROPAD_CURRENT].[$ZEROPAD_REVISION].[$ZEROPAD_AGE])
AC_SUBST(ZEROPAD_SONAME, libZeroPAD.so.[$ZEROPAD_CURRENT].[$ZEROPAD_REVISION].[$ZEROPAD_AGE])
CFLAGS=

View File

@ -33,7 +33,6 @@
char libraryName[256];
PADAnalog g_lanalog[2], g_ranalog[2];
PADconf conf;
keyEvent event;
@ -44,7 +43,7 @@ string s_strIniPath = "inis/zeropad.ini";
const unsigned char version = PS2E_PAD_VERSION;
const unsigned char revision = 0;
const unsigned char build = 2; // increase that with each version
const unsigned char build = 3; // increase that with each version
int PadEnum[2][2] = {{0, 2}, {1, 3}};
@ -291,13 +290,7 @@ s32 CALLBACK PADinit(u32 flags)
PADsetMode(1, 0);
pressure = 100;
for (int i = 0; i < 2; ++i)
{
g_ranalog[i].x = 0x80;
g_ranalog[i].y = 0x80;
g_lanalog[i].x = 0x80;
g_lanalog[i].y = 0x80;
}
Analog::Init();
return 0;
}
@ -385,26 +378,26 @@ u8 _PADpoll(u8 value)
curCmd = value;
switch (value)
{
case 0x40: // DUALSHOCK2 ENABLER
case CMD_SET_VREF_PARAM: // DUALSHOCK2 ENABLER
cmdLen = 8;
buf = cmd40[curPad];
return 0xf3;
case 0x41: // QUERY_DS2_ANALOG_MODE
case CMD_QUERY_DS2_ANALOG_MODE: // QUERY_DS2_ANALOG_MODE
cmdLen = 8;
buf = cmd41[curPad];
return 0xf3;
case 0x42: // READ_DATA
case CMD_READ_DATA_AND_VIBRATE: // READ_DATA
_PADupdate(curPad);
stdpar[curPad][2] = status[curPad] >> 8;
stdpar[curPad][3] = status[curPad] & 0xff;
stdpar[curPad][4] = g_ranalog[curPad].x;
stdpar[curPad][5] = g_ranalog[curPad].y;
stdpar[curPad][6] = g_lanalog[curPad].x;
stdpar[curPad][7] = g_lanalog[curPad].y;
stdpar[curPad][4] = Analog::Pad(PAD_RX, curPad);
stdpar[curPad][5] = Analog::Pad(PAD_RY, curPad);
stdpar[curPad][6] = Analog::Pad(PAD_LX, curPad);
stdpar[curPad][7] = Analog::Pad(PAD_LY, curPad);
if (padMode[curPad] == 1)
cmdLen = 20;
@ -473,44 +466,44 @@ u8 _PADpoll(u8 value)
buf = stdpar[curPad];
return padID[curPad];
case 0x43: // CONFIG_MODE
case CMD_CONFIG_MODE: // CONFIG_MODE
cmdLen = 8;
buf = stdcfg[curPad];
if (stdcfg[curPad][3] == 0xff) return 0xf3;
else return padID[curPad];
case 0x44: // SET_MODE_AND_LOCK
case CMD_SET_MODE_AND_LOCK: // SET_MODE_AND_LOCK
cmdLen = 8;
buf = stdmode[curPad];
return 0xf3;
case 0x45: // QUERY_MODEL_AND_MODE
case CMD_QUERY_MODEL_AND_MODE: // QUERY_MODEL_AND_MODE
cmdLen = 8;
buf = stdmodel[curPad];
buf[4] = padMode[curPad];
return 0xf3;
case 0x46: // ??
case CMD_QUERY_ACT: // ??
cmdLen = 8;
buf = unk46[curPad];
return 0xf3;
case 0x47: // ??
case CMD_QUERY_COMB: // ??
cmdLen = 8;
buf = unk47[curPad];
return 0xf3;
case 0x4c: // QUERY_MODE ??
case CMD_QUERY_MODE: // QUERY_MODE ??
cmdLen = 8;
buf = unk4c[curPad];
return 0xf3;
case 0x4d:
case CMD_VIBRATION_TOGGLE:
cmdLen = 8;
buf = unk4d[curPad];
return 0xf3;
case 0x4f: // SET_DS2_NATIVE_MODE
case CMD_SET_DS2_NATIVE_MODE: // SET_DS2_NATIVE_MODE
cmdLen = 8;
padID[curPad] = 0x79; // setting ds2 mode
ds2mode = 1; // Set DS2 Mode
@ -527,7 +520,7 @@ u8 _PADpoll(u8 value)
switch (curCmd)
{
case 0x43:
case CMD_CONFIG_MODE:
if (curByte == 2)
{
switch (value)
@ -544,14 +537,14 @@ u8 _PADpoll(u8 value)
}
break;
case 0x44:
case CMD_SET_MODE_AND_LOCK:
if (curByte == 2)
{
PADsetMode(curPad, value);
}
break;
case 0x46:
case CMD_QUERY_ACT:
if (curByte == 2)
{
switch (value)
@ -570,7 +563,7 @@ u8 _PADpoll(u8 value)
}
break;
case 0x4c:
case CMD_QUERY_MODE:
if (curByte == 2)
{
switch (value)

View File

@ -44,6 +44,7 @@ extern "C"
{
#include "PS2Edefs.h"
}
#include "analog.h"
extern char libraryName[256];
@ -93,11 +94,25 @@ typedef struct
} PADAnalog;
extern PADconf conf;
extern PADAnalog g_lanalog[2], g_ranalog[2];
extern FILE *padLog;
#define PAD_LOG __Log
enum PadCommands
{
CMD_SET_VREF_PARAM = 0x40,
CMD_QUERY_DS2_ANALOG_MODE = 0x41,
CMD_READ_DATA_AND_VIBRATE = 0x42,
CMD_CONFIG_MODE = 0x43,
CMD_SET_MODE_AND_LOCK = 0x44,
CMD_QUERY_MODEL_AND_MODE = 0x45,
CMD_QUERY_ACT = 0x46, // ??
CMD_QUERY_COMB = 0x47, // ??
CMD_QUERY_MODE = 0x4C, // QUERY_MODE ??
CMD_VIBRATION_TOGGLE = 0x4D,
CMD_SET_DS2_NATIVE_MODE = 0x4F // SET_DS2_NATIVE_MODE
};
enum gamePadValues
{
PAD_RY = 19,