mirror of https://github.com/PCSX2/pcsx2.git
ZeroPad: Refactor a bunch of code. Escape now sets the key value to 'Unknown' when configuring. Work some more on the hat code (still disabled).
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1245 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
fea158f392
commit
ecfed766cd
3
build.sh
3
build.sh
|
@ -29,6 +29,9 @@ export ZEROGSOPTIONS="--enable-sse2"
|
||||||
#ZeroSPU2 Debug mode (Don't enable right now)
|
#ZeroSPU2 Debug mode (Don't enable right now)
|
||||||
#export ZEROSPU2OPTIONS="--enable-debug --enable-devbuild"
|
#export ZEROSPU2OPTIONS="--enable-debug --enable-devbuild"
|
||||||
|
|
||||||
|
#GSnull debug options.
|
||||||
|
#export GSnullOPTIONS="--enable-debug"
|
||||||
|
|
||||||
option=$@
|
option=$@
|
||||||
export PCSX2PLUGINS="`pwd`/bin/plugins"
|
export PCSX2PLUGINS="`pwd`/bin/plugins"
|
||||||
curdir=`pwd`
|
curdir=`pwd`
|
||||||
|
|
|
@ -36,7 +36,8 @@ extern "C"
|
||||||
}
|
}
|
||||||
|
|
||||||
extern string s_strIniPath;
|
extern string s_strIniPath;
|
||||||
GtkWidget *Conf = NULL, *s_devicecombo = NULL;
|
GtkWidget *Conf = NULL, *About = NULL;
|
||||||
|
GtkWidget *s_devicecombo = NULL;
|
||||||
extern void UpdateConf(int pad);
|
extern void UpdateConf(int pad);
|
||||||
|
|
||||||
void SaveConfig()
|
void SaveConfig()
|
||||||
|
@ -268,9 +269,6 @@ void OnConf_Cancel(GtkButton *button, gpointer user_data)
|
||||||
LoadConfig(); // load previous config
|
LoadConfig(); // load previous config
|
||||||
}
|
}
|
||||||
|
|
||||||
GtkWidget *About = NULL;
|
|
||||||
|
|
||||||
//void OnAbout_Ok(GtkButton *button, gpointer user_data)
|
|
||||||
void OnAbout_Ok(GtkDialog *About, gint response_id, gpointer user_data)
|
void OnAbout_Ok(GtkDialog *About, gint response_id, gpointer user_data)
|
||||||
{
|
{
|
||||||
gtk_widget_destroy(GTK_WIDGET(About));
|
gtk_widget_destroy(GTK_WIDGET(About));
|
||||||
|
|
|
@ -143,8 +143,8 @@ void CALLBACK PADupdate(int pad)
|
||||||
#endif
|
#endif
|
||||||
if (i != -1)
|
if (i != -1)
|
||||||
{
|
{
|
||||||
keyPress |= (1 << i);
|
clear_bit(keyRelease, i);
|
||||||
keyRelease &= ~(1 << i);
|
set_bit(keyPress, i);
|
||||||
}
|
}
|
||||||
//PAD_LOG("Key pressed:%d\n", i);
|
//PAD_LOG("Key pressed:%d\n", i);
|
||||||
|
|
||||||
|
@ -232,7 +232,7 @@ void CALLBACK PADupdate(int pad)
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#ifdef EXPERAMENTAL_POV_CODE
|
#ifdef EXPERIMENTAL_POV_CODE
|
||||||
else if (IS_POV(key))
|
else if (IS_POV(key))
|
||||||
{
|
{
|
||||||
int joyid = PAD_GETJOYID(key);
|
int joyid = PAD_GETJOYID(key);
|
||||||
|
@ -245,12 +245,12 @@ void CALLBACK PADupdate(int pad)
|
||||||
int temp;
|
int temp;
|
||||||
|
|
||||||
//PAD_LOG("Hat = %d for key %d\n", PAD_GETPOVDIR(key), key);
|
//PAD_LOG("Hat = %d for key %d\n", PAD_GETPOVDIR(key), key);
|
||||||
if (value != 0)
|
if (value != SDL_HAT_CENTERED)
|
||||||
{
|
{
|
||||||
if (PAD_GETPOVDIR(key) == value)
|
if (PAD_GETPOVDIR(key) == value)
|
||||||
set_bit(status[pad], i);
|
set_bit(status[pad], i);
|
||||||
/*else
|
else
|
||||||
clear_bit(status[pad], i);*/
|
clear_bit(status[pad], i);
|
||||||
|
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
|
@ -269,19 +269,12 @@ void CALLBACK PADupdate(int pad)
|
||||||
case SDL_HAT_LEFT:
|
case SDL_HAT_LEFT:
|
||||||
PAD_LOG("Left!\n");
|
PAD_LOG("Left!\n");
|
||||||
break;
|
break;
|
||||||
case SDL_HAT_CENTER:
|
|
||||||
clear_bit(status[pad], i);
|
|
||||||
break;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
else
|
else
|
||||||
{
|
{
|
||||||
//clear_bit(status[pad], i);
|
clear_bit(status[pad], i);
|
||||||
}
|
}
|
||||||
/*if PAD_GETPOVSIGN(key)
|
|
||||||
set_bit(status[pad], i);
|
|
||||||
else
|
|
||||||
clear_bit(status[pad], i);*/
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#else
|
#else
|
||||||
|
@ -351,7 +344,7 @@ void UpdateConf(int pad)
|
||||||
sprintf(&tmp[0], "JAxis %d", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]));
|
sprintf(&tmp[0], "JAxis %d", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]));
|
||||||
}
|
}
|
||||||
else if (IS_POV(conf.keys[pad][i]))
|
else if (IS_POV(conf.keys[pad][i]))
|
||||||
#ifdef EXPERAMENTAL_POV_CODE
|
#ifdef EXPERIMENTAL_POV_CODE
|
||||||
{
|
{
|
||||||
tmp.resize(28);
|
tmp.resize(28);
|
||||||
switch(PAD_GETPOVDIR(conf.keys[pad][i]))
|
switch(PAD_GETPOVDIR(conf.keys[pad][i]))
|
||||||
|
@ -416,27 +409,27 @@ void UpdateConf(int pad)
|
||||||
set_checked(Conf, "forcefeedback", padopts & PADOPTION_FORCEFEEDBACK);
|
set_checked(Conf, "forcefeedback", padopts & PADOPTION_FORCEFEEDBACK);
|
||||||
}
|
}
|
||||||
|
|
||||||
void OnConf_Key(GtkButton *button, gpointer user_data)
|
GtkWidget* GetLabelWidget(GtkButton *button)
|
||||||
{
|
{
|
||||||
GdkEvent *ev;
|
const char* buttonname = gtk_widget_get_name(GTK_WIDGET(button));
|
||||||
const char* buttonname = gtk_widget_get_name(GTK_WIDGET(button));//gtk_button_get_label(button);
|
|
||||||
const char* labelname = GetLabelFromButton(buttonname).c_str();
|
const char* labelname = GetLabelFromButton(buttonname).c_str();
|
||||||
GtkWidget* label = lookup_widget(Conf, labelname);
|
return lookup_widget(Conf, labelname);
|
||||||
|
}
|
||||||
|
|
||||||
|
int GetLabelId(GtkWidget *label)
|
||||||
|
{
|
||||||
if (label == NULL)
|
if (label == NULL)
|
||||||
{
|
{
|
||||||
PAD_LOG("couldn't find correct label\n");
|
PAD_LOG("couldn't find correct label\n");
|
||||||
return;
|
return -1;
|
||||||
}
|
}
|
||||||
|
|
||||||
int id = (int)(uptr)gtk_object_get_user_data(GTK_OBJECT(label));
|
return (int)(uptr)gtk_object_get_user_data(GTK_OBJECT(label));
|
||||||
int pad = id / PADKEYS;
|
}
|
||||||
int key = id % PADKEYS;
|
|
||||||
PAD_LOG("Button = '%s', Label = '%s', id = %d, pad = %d, key = %d\n", buttonname, labelname, id, pad, key);
|
|
||||||
u32 *pkey = &conf.keys[pad][key];
|
|
||||||
|
|
||||||
// save the states
|
void UpdateJoysticks(vector<JoystickInfo*>::iterator itjoy)
|
||||||
#ifdef JOYSTICK_SUPPORT
|
{
|
||||||
vector<JoystickInfo*>::iterator itjoy = s_vjoysticks.begin();
|
itjoy = s_vjoysticks.begin();
|
||||||
|
|
||||||
SDL_JoystickUpdate();
|
SDL_JoystickUpdate();
|
||||||
|
|
||||||
|
@ -446,37 +439,37 @@ void OnConf_Key(GtkButton *button, gpointer user_data)
|
||||||
(*itjoy)->SaveState();
|
(*itjoy)->SaveState();
|
||||||
itjoy++;
|
itjoy++;
|
||||||
}
|
}
|
||||||
#endif
|
}
|
||||||
|
|
||||||
|
bool PollKeyboard(char* &temp, u32* &pkey)
|
||||||
|
{
|
||||||
|
GdkEvent *ev = gdk_event_get();
|
||||||
|
|
||||||
for (;;)
|
|
||||||
{
|
|
||||||
ev = gdk_event_get();
|
|
||||||
if (ev != NULL)
|
if (ev != NULL)
|
||||||
{
|
{
|
||||||
if (ev->type == GDK_KEY_PRESS)
|
if (ev->type == GDK_KEY_PRESS)
|
||||||
{
|
{
|
||||||
*pkey = ev->key.keyval;
|
*pkey = ev->key.keyval;
|
||||||
|
|
||||||
char* tmp = XKeysymToString(*pkey);
|
if (ev->key.keyval == GDK_Escape)
|
||||||
if (tmp != NULL)
|
temp = "Unknown";
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), tmp);
|
|
||||||
else
|
else
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), "Unknown");
|
temp = XKeysymToString(ev->key.keyval);
|
||||||
return;
|
|
||||||
|
return true;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
#ifdef JOYSTICK_SUPPORT
|
return false;
|
||||||
itjoy = s_vjoysticks.begin();
|
}
|
||||||
|
|
||||||
SDL_JoystickUpdate();
|
bool PollButtons(vector<JoystickInfo*>::iterator itjoy, int &jbutton, u32* &pkey)
|
||||||
|
{
|
||||||
while (itjoy != s_vjoysticks.end())
|
|
||||||
{
|
|
||||||
// MAKE sure to look for changes in the state!!
|
// MAKE sure to look for changes in the state!!
|
||||||
for (int i = 0; i < (*itjoy)->GetNumButtons(); ++i)
|
for (int i = 0; i < (*itjoy)->GetNumButtons(); ++i)
|
||||||
{
|
{
|
||||||
int but = SDL_JoystickGetButton((*itjoy)->GetJoy(), i);
|
int but = SDL_JoystickGetButton((*itjoy)->GetJoy(), i);
|
||||||
|
|
||||||
if (but != (*itjoy)->GetButtonState(i))
|
if (but != (*itjoy)->GetButtonState(i))
|
||||||
{
|
{
|
||||||
if (!but) // released, we don't really want this
|
if (!but) // released, we don't really want this
|
||||||
|
@ -486,13 +479,16 @@ void OnConf_Key(GtkButton *button, gpointer user_data)
|
||||||
}
|
}
|
||||||
|
|
||||||
*pkey = PAD_JOYBUTTON((*itjoy)->GetId(), i);
|
*pkey = PAD_JOYBUTTON((*itjoy)->GetId(), i);
|
||||||
char str[32];
|
jbutton = i;
|
||||||
sprintf(str, "JBut %d", i);
|
return true;
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), str);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool PollAxes(vector<JoystickInfo*>::iterator itjoy, bool pov, int &jbutton, bool &negative, u32* &pkey)
|
||||||
|
{
|
||||||
for (int i = 0; i < (*itjoy)->GetNumAxes(); ++i)
|
for (int i = 0; i < (*itjoy)->GetNumAxes(); ++i)
|
||||||
{
|
{
|
||||||
int value = SDL_JoystickGetAxis((*itjoy)->GetJoy(), i);
|
int value = SDL_JoystickGetAxis((*itjoy)->GetJoy(), i);
|
||||||
|
@ -510,64 +506,140 @@ void OnConf_Key(GtkButton *button, gpointer user_data)
|
||||||
|
|
||||||
if (abs(value) > 0x3fff)
|
if (abs(value) > 0x3fff)
|
||||||
{
|
{
|
||||||
if (key < 16) // POV
|
jbutton = i;
|
||||||
|
|
||||||
|
if (pov)
|
||||||
{
|
{
|
||||||
*pkey = PAD_POV((*itjoy)->GetId(), value < 0, i);
|
*pkey = PAD_POV((*itjoy)->GetId(), value < 0, i);
|
||||||
char str[32];
|
negative = (value < 0);
|
||||||
sprintf(str, "JPOV %d%s", i, value < 0 ? "-" : "+");
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), str);
|
|
||||||
return;
|
|
||||||
}
|
}
|
||||||
else // axis
|
else // axis
|
||||||
{
|
{
|
||||||
*pkey = PAD_JOYSTICK((*itjoy)->GetId(), i);
|
*pkey = PAD_JOYSTICK((*itjoy)->GetId(), i);
|
||||||
char str[32];
|
}
|
||||||
sprintf(str, "JAxis %d", i);
|
return true;
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), str);
|
|
||||||
return;
|
|
||||||
}
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
#ifdef EXPERAMENTAL_POV_CODE
|
/*SDL_HAT_CENTERED,
|
||||||
|
SDL_HAT_UP, SDL_HAT_RIGHT,
|
||||||
|
SDL_HAT_DOWN, SDL_HAT_LEFT,
|
||||||
|
SDL_HAT_RIGHTUP, SDL_HAT_RIGHTDOWN,
|
||||||
|
SDL_HAT_LEFTUP, SDL_HAT_LEFTDOWN*/
|
||||||
|
|
||||||
|
bool PollPOV(vector<JoystickInfo*>::iterator itjoy, int &jbutton, int &dir, u32* &pkey)
|
||||||
|
{
|
||||||
|
#ifdef EXPERIMENTAL_POV_CODE
|
||||||
for (int i = 0; i < (*itjoy)->GetNumPOV(); ++i)
|
for (int i = 0; i < (*itjoy)->GetNumPOV(); ++i)
|
||||||
{
|
{
|
||||||
int value = SDL_JoystickGetHat((*itjoy)->GetJoy(), i);
|
int value = SDL_JoystickGetHat((*itjoy)->GetJoy(), i);
|
||||||
|
|
||||||
if (value != (*itjoy)->GetPOVState(i))
|
if (value != SDL_HAT_CENTERED)
|
||||||
{
|
{
|
||||||
switch (value)
|
switch (value)
|
||||||
{
|
{
|
||||||
char str[32];
|
|
||||||
|
|
||||||
case SDL_HAT_UP:
|
case SDL_HAT_UP:
|
||||||
*pkey = PAD_POV((*itjoy)->GetId(), value, i);
|
|
||||||
sprintf(str, "JPOVU-%d", i);
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), str);
|
|
||||||
return;
|
|
||||||
case SDL_HAT_RIGHT:
|
case SDL_HAT_RIGHT:
|
||||||
*pkey = PAD_POV((*itjoy)->GetId(), value, i);
|
|
||||||
sprintf(str, "JPOVR-%d", i);
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), str);
|
|
||||||
return;
|
|
||||||
case SDL_HAT_DOWN:
|
case SDL_HAT_DOWN:
|
||||||
*pkey = PAD_POV((*itjoy)->GetId(), value, i);
|
|
||||||
sprintf(str, "JPOVD-%d", i);
|
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), str);
|
|
||||||
return;
|
|
||||||
case SDL_HAT_LEFT:
|
case SDL_HAT_LEFT:
|
||||||
*pkey = PAD_POV((*itjoy)->GetId(), value, i);
|
*pkey = PAD_POV((*itjoy)->GetId(), value, i);
|
||||||
sprintf(str, "JPOVL-%d", i);
|
jbutton = i;
|
||||||
gtk_entry_set_text(GTK_ENTRY(label), str);
|
dir = value;
|
||||||
return;
|
PAD_LOG("Hat Pressed!");
|
||||||
// Not handling SDL_HAT_RIGHTUP, SDL_HAT_RIGHTDOWN,
|
return true;
|
||||||
// SDL_HAT_LEFTUP, or SDL_HAT_LEFTDOWN here. They should be
|
default:
|
||||||
// handled in the PADUpdate code, though.
|
break;
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
void OnConf_Key(GtkButton *button, gpointer user_data)
|
||||||
|
{
|
||||||
|
u32 *pkey;
|
||||||
|
GtkWidget* label = GetLabelWidget(button);
|
||||||
|
int id = GetLabelId(label);
|
||||||
|
|
||||||
|
if (id == -1) return;
|
||||||
|
|
||||||
|
int pad = id / PADKEYS;
|
||||||
|
int key = id % PADKEYS;
|
||||||
|
pkey = &conf.keys[pad][key];
|
||||||
|
|
||||||
|
// save the states
|
||||||
|
#ifdef JOYSTICK_SUPPORT
|
||||||
|
vector<JoystickInfo*>::iterator itjoy;
|
||||||
|
|
||||||
|
UpdateJoysticks(itjoy);
|
||||||
|
#endif
|
||||||
|
|
||||||
|
for (;;)
|
||||||
|
{
|
||||||
|
char *tmp;
|
||||||
|
|
||||||
|
if (PollKeyboard(tmp, pkey))
|
||||||
|
{
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(label), tmp);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef JOYSTICK_SUPPORT
|
||||||
|
itjoy = s_vjoysticks.begin();
|
||||||
|
|
||||||
|
SDL_JoystickUpdate();
|
||||||
|
|
||||||
|
while (itjoy != s_vjoysticks.end())
|
||||||
|
{
|
||||||
|
int jbutton, direction;
|
||||||
|
|
||||||
|
if (PollButtons(itjoy, jbutton, pkey))
|
||||||
|
{
|
||||||
|
char str[32];
|
||||||
|
|
||||||
|
sprintf(str, "JBut %d", jbutton);
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(label), str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
bool negative = false, pov = (key < 16);
|
||||||
|
|
||||||
|
if (PollAxes(itjoy, pov, jbutton, negative, pkey))
|
||||||
|
{
|
||||||
|
char str[32];
|
||||||
|
|
||||||
|
if (pov)
|
||||||
|
sprintf(str, "JPOV %d%s", jbutton, (negative) ? "-" : "+");
|
||||||
|
else
|
||||||
|
sprintf(str, "JAxis %d", jbutton);
|
||||||
|
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(label), str);
|
||||||
|
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
|
||||||
|
#ifdef EXPERIMENTAL_POV_CODE
|
||||||
|
if (PollPOV(itjoy, jbutton, direction, pkey))
|
||||||
|
{
|
||||||
|
char str[32];
|
||||||
|
|
||||||
|
switch (direction)
|
||||||
|
{
|
||||||
|
case SDL_HAT_UP: sprintf(str, "JPOVU-%d", jbutton); break;
|
||||||
|
case SDL_HAT_RIGHT: sprintf(str, "JPOVR-%d", jbutton); break;
|
||||||
|
case SDL_HAT_DOWN: sprintf(str, "JPOVD-%d", jbutton); break;
|
||||||
|
case SDL_HAT_LEFT: sprintf(str, "JPOVL-%d", jbutton); break;
|
||||||
|
}
|
||||||
|
|
||||||
|
gtk_entry_set_text(GTK_ENTRY(label), str);
|
||||||
|
return;
|
||||||
|
}
|
||||||
|
#endif
|
||||||
|
|
||||||
itjoy++;
|
itjoy++;
|
||||||
}
|
}
|
||||||
#endif
|
#endif
|
||||||
|
|
|
@ -18,6 +18,7 @@
|
||||||
|
|
||||||
#include <string.h>
|
#include <string.h>
|
||||||
#include <gtk/gtk.h>
|
#include <gtk/gtk.h>
|
||||||
|
#include <gdk/gdkkeysyms.h>
|
||||||
#include <pthread.h>
|
#include <pthread.h>
|
||||||
|
|
||||||
#define JOYSTICK_SUPPORT
|
#define JOYSTICK_SUPPORT
|
||||||
|
|
|
@ -85,7 +85,7 @@ extern char libraryName[256];
|
||||||
#define PADSUBKEYS 2
|
#define PADSUBKEYS 2
|
||||||
#endif
|
#endif
|
||||||
|
|
||||||
//#define EXPERAMENTAL_POV_CODE
|
//#define EXPERIMENTAL_POV_CODE
|
||||||
extern int PadEnum[2][2];
|
extern int PadEnum[2][2];
|
||||||
|
|
||||||
typedef struct
|
typedef struct
|
||||||
|
@ -154,8 +154,7 @@ enum gamePadValues
|
||||||
PAD_L2 = 0
|
PAD_L2 = 0
|
||||||
};
|
};
|
||||||
|
|
||||||
// Put in the code for bolche's analog contols hack, ifdeffed out, so I don't forget to
|
// Activate bolche's analog contols hack
|
||||||
// add a gui some day and activate it.
|
|
||||||
#define ANALOG_CONTROLS_HACK
|
#define ANALOG_CONTROLS_HACK
|
||||||
// DEF_VALUE is the strength you press the control.
|
// DEF_VALUE is the strength you press the control.
|
||||||
// Code taken from http://forums.pcsx2.net/thread-4699.html
|
// Code taken from http://forums.pcsx2.net/thread-4699.html
|
||||||
|
|
Loading…
Reference in New Issue