2009-02-09 21:15:56 +00:00
|
|
|
/* ZeroPAD - author: zerofrog(@gmail.com)
|
2009-05-03 12:19:58 +00:00
|
|
|
* Copyright (C) 2006-2007
|
2009-02-09 21:15:56 +00:00
|
|
|
*
|
|
|
|
* This program is free software; you can redistribute it and/or modify
|
|
|
|
* it under the terms of the GNU General Public License as published by
|
|
|
|
* the Free Software Foundation; either version 2 of the License, or
|
|
|
|
* (at your option) any later version.
|
|
|
|
*
|
|
|
|
* This program is distributed in the hope that it will be useful,
|
|
|
|
* but WITHOUT ANY WARRANTY; without even the implied warranty of
|
|
|
|
* MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
|
|
|
|
* GNU General Public License for more details.
|
|
|
|
*
|
|
|
|
* You should have received a copy of the GNU General Public License
|
|
|
|
* along with this program; if not, write to the Free Software
|
|
|
|
* Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA 02111-1307 USA
|
|
|
|
*/
|
|
|
|
|
2009-05-10 05:57:57 +00:00
|
|
|
#include "linux.h"
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
Display *GSdsp;
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
static const char* s_pGuiKeyMap[] =
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
"L2", "R2", "L1", "R1",
|
|
|
|
"Triangle", "Circle", "Cross", "Square",
|
|
|
|
"Select", "L3", "R3", "Start",
|
|
|
|
"Up", "Right", "Down", "Left",
|
2009-05-10 05:57:57 +00:00
|
|
|
"Lx", "Rx", "Ly", "Ry",
|
|
|
|
"L_Up", "L_Right", "L_Down", "L_Left",
|
|
|
|
"R_Up", "R_Right", "R_Down", "R_Left"
|
2009-05-03 12:19:58 +00:00
|
|
|
};
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
string GetLabelFromButton(const char* buttonname)
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
string label = "e";
|
|
|
|
label += buttonname;
|
|
|
|
return label;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
s32 _PADopen(void *pDsp)
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
GSdsp = *(Display**)pDsp;
|
2009-05-29 06:33:56 +00:00
|
|
|
SetAutoRepeat(false);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
|
|
|
|
void _PADclose()
|
|
|
|
{
|
2009-05-29 06:33:56 +00:00
|
|
|
SetAutoRepeat(true);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-07 23:37:57 +00:00
|
|
|
vector<JoystickInfo*>::iterator it = s_vjoysticks.begin();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-07 23:37:57 +00:00
|
|
|
// Delete everything in the vector vjoysticks.
|
2009-05-07 23:49:12 +00:00
|
|
|
while (it != s_vjoysticks.end())
|
2009-05-07 23:37:57 +00:00
|
|
|
{
|
|
|
|
delete *it;
|
|
|
|
it ++;
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
s_vjoysticks.clear();
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
int _GetJoystickIdFromPAD(int pad)
|
|
|
|
{
|
2009-05-03 11:09:15 +00:00
|
|
|
// select the right joystick id
|
|
|
|
int joyid = -1;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
for (int p = 0; p < PADSUBKEYS; p++)
|
|
|
|
{
|
|
|
|
for (int i = 0; i < PADKEYS; ++i)
|
|
|
|
{
|
2009-05-10 05:57:57 +00:00
|
|
|
u32 temp = conf.keys[(PadEnum[pad][p])][i];
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-10 05:57:57 +00:00
|
|
|
if (IS_JOYSTICK( temp) || IS_JOYBUTTONS(temp))
|
2009-05-03 12:19:58 +00:00
|
|
|
{
|
2009-05-10 05:57:57 +00:00
|
|
|
joyid = PAD_GETJOYID(temp);
|
2009-05-03 11:09:15 +00:00
|
|
|
return joyid;
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
2009-05-03 11:09:15 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-30 12:11:21 +00:00
|
|
|
if (!JoystickIdWithinBounds(joyid))
|
2009-05-25 01:59:17 +00:00
|
|
|
{
|
|
|
|
// get first unused joystick
|
|
|
|
for (joyid = 0; joyid < s_vjoysticks.size(); ++joyid)
|
|
|
|
{
|
|
|
|
if (s_vjoysticks[joyid]->GetPAD() < 0) break;
|
|
|
|
}
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-03 19:30:38 +00:00
|
|
|
return joyid;
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CALLBACK PADupdate(int pad)
|
|
|
|
{
|
2009-05-29 06:33:56 +00:00
|
|
|
// Poll keyboard.
|
|
|
|
PollForKeyboardInput(pad);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
// joystick info
|
2009-05-03 11:09:15 +00:00
|
|
|
SDL_JoystickUpdate();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
for (int i = 0; i < PADKEYS; i++)
|
|
|
|
{
|
|
|
|
int key = conf.keys[PadEnum[pad][0]][i];
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-29 06:33:56 +00:00
|
|
|
if (JoystickIdWithinBounds(PAD_GETJOYID(key)))
|
2010-04-25 00:31:27 +00:00
|
|
|
{
|
2009-05-29 06:33:56 +00:00
|
|
|
JoystickInfo* pjoy = s_vjoysticks[PAD_GETJOYID(key)];
|
|
|
|
int pad = (pjoy)->GetPAD();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-29 06:33:56 +00:00
|
|
|
if (IS_JOYBUTTONS(key))
|
2009-05-03 12:19:58 +00:00
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
int value = SDL_JoystickGetButton((pjoy)->GetJoy(), PAD_GETJOYBUTTON(key));
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
if (value)
|
2009-05-29 06:33:56 +00:00
|
|
|
clear_bit(status[pad], i); // released
|
2009-05-03 12:19:58 +00:00
|
|
|
else
|
2009-05-25 01:59:17 +00:00
|
|
|
set_bit(status[pad], i); // pressed
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
2009-05-29 06:33:56 +00:00
|
|
|
else if (IS_JOYSTICK(key))
|
2009-05-03 12:19:58 +00:00
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key));
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
switch (i)
|
|
|
|
{
|
|
|
|
case PAD_LX:
|
|
|
|
case PAD_LY:
|
|
|
|
case PAD_RX:
|
|
|
|
case PAD_RY:
|
|
|
|
if (abs(value) > (pjoy)->GetDeadzone(value))
|
2009-05-09 20:06:57 +00:00
|
|
|
Analog::ConfigurePad(i, pad, value);
|
2010-04-25 00:31:27 +00:00
|
|
|
else
|
2009-05-09 20:06:57 +00:00
|
|
|
Analog::ResetPad(i, pad);
|
2009-05-03 12:19:58 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-29 06:33:56 +00:00
|
|
|
#ifdef EXPERIMENTAL_POV_CODE
|
|
|
|
else if (IS_HAT(key))
|
2009-05-10 05:57:57 +00:00
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
int value = SDL_JoystickGetHat((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key));
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-15 00:42:05 +00:00
|
|
|
//PAD_LOG("Hat = %d for key %d\n", PAD_GETPOVDIR(key), key);
|
2009-05-23 23:07:53 +00:00
|
|
|
if ((value != SDL_HAT_CENTERED) && (PAD_GETHATDIR(key) == value))
|
2009-05-15 00:42:05 +00:00
|
|
|
{
|
2009-05-23 23:07:53 +00:00
|
|
|
if ((value == SDL_HAT_UP) || (value == SDL_HAT_RIGHT) || (value == SDL_HAT_DOWN) ||(value == SDL_HAT_LEFT))
|
|
|
|
{
|
2009-05-15 00:42:05 +00:00
|
|
|
set_bit(status[pad], i);
|
2009-05-25 01:59:17 +00:00
|
|
|
PAD_LOG("Registered %s. Set (%d)\n", HatName(value), i);
|
2009-05-23 23:07:53 +00:00
|
|
|
}
|
2009-05-23 11:57:28 +00:00
|
|
|
else
|
2009-05-23 23:07:53 +00:00
|
|
|
{
|
2009-05-23 11:57:28 +00:00
|
|
|
clear_bit(status[pad], i);
|
2009-05-23 23:07:53 +00:00
|
|
|
}
|
2009-05-15 00:42:05 +00:00
|
|
|
}
|
2009-05-23 23:07:53 +00:00
|
|
|
else
|
2009-05-15 00:42:05 +00:00
|
|
|
{
|
2009-05-23 11:57:28 +00:00
|
|
|
clear_bit(status[pad], i);
|
2009-05-23 23:07:53 +00:00
|
|
|
}
|
2009-05-03 11:09:15 +00:00
|
|
|
}
|
2009-05-29 06:33:56 +00:00
|
|
|
#endif
|
|
|
|
else if (IS_POV(key))
|
2009-05-25 01:59:17 +00:00
|
|
|
{
|
|
|
|
int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), PAD_GETJOYSTICK_AXIS(key));
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
if (PAD_GETPOVSIGN(key) && (value < -2048))
|
|
|
|
clear_bit(status[pad], i);
|
|
|
|
else if (!PAD_GETPOVSIGN(key) && (value > 2048))
|
|
|
|
clear_bit(status[pad], i);
|
|
|
|
else
|
|
|
|
set_bit(status[pad], i);
|
|
|
|
}
|
|
|
|
}
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void UpdateConf(int pad)
|
|
|
|
{
|
2009-05-09 22:44:06 +00:00
|
|
|
initLogging();
|
2009-05-03 11:09:15 +00:00
|
|
|
s_selectedpad = pad;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
int i;
|
2009-05-03 11:09:15 +00:00
|
|
|
GtkWidget *Btn;
|
2009-05-03 12:19:58 +00:00
|
|
|
for (i = 0; i < ArraySize(s_pGuiKeyMap); i++)
|
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
string tmp;
|
2009-05-03 12:19:58 +00:00
|
|
|
|
2009-05-10 05:57:57 +00:00
|
|
|
if (s_pGuiKeyMap[i] == NULL) continue;
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
Btn = lookup_widget(Conf, GetLabelFromButton(s_pGuiKeyMap[i]).c_str());
|
2009-05-03 12:19:58 +00:00
|
|
|
if (Btn == NULL)
|
|
|
|
{
|
2009-05-09 22:44:06 +00:00
|
|
|
PAD_LOG("ZeroPAD: cannot find key %s\n", s_pGuiKeyMap[i]);
|
2009-05-03 12:19:58 +00:00
|
|
|
continue;
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
if (IS_KEYBOARD(conf.keys[pad][i]))
|
|
|
|
{
|
2009-05-29 06:33:56 +00:00
|
|
|
char* pstr = KeysymToChar(PAD_GETKEY(conf.keys[pad][i]));
|
2009-05-03 12:19:58 +00:00
|
|
|
if (pstr != NULL) tmp = pstr;
|
|
|
|
}
|
|
|
|
else if (IS_JOYBUTTONS(conf.keys[pad][i]))
|
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
int button = PAD_GETJOYBUTTON(conf.keys[pad][i]);
|
2009-05-10 05:57:57 +00:00
|
|
|
tmp.resize(28);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
sprintf(&tmp[0], "JBut %d", button);
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
|
|
|
else if (IS_JOYSTICK(conf.keys[pad][i]))
|
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
int axis = PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]);
|
2009-05-10 05:57:57 +00:00
|
|
|
tmp.resize(28);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
sprintf(&tmp[0], "JAxis %d", axis);
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
2009-05-23 11:57:28 +00:00
|
|
|
#ifdef EXPERIMENTAL_POV_CODE
|
2009-05-23 23:07:53 +00:00
|
|
|
else if (IS_HAT(conf.keys[pad][i]))
|
2009-05-03 12:19:58 +00:00
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
int axis = PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]);
|
2009-05-10 05:57:57 +00:00
|
|
|
tmp.resize(28);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-23 22:20:16 +00:00
|
|
|
switch(PAD_GETHATDIR(conf.keys[pad][i]))
|
2009-05-10 05:57:57 +00:00
|
|
|
{
|
|
|
|
case SDL_HAT_UP:
|
2009-05-25 01:59:17 +00:00
|
|
|
sprintf(&tmp[0], "JPOVU-%d", axis);
|
2009-05-10 05:57:57 +00:00
|
|
|
break;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-10 05:57:57 +00:00
|
|
|
case SDL_HAT_RIGHT:
|
2009-05-25 01:59:17 +00:00
|
|
|
sprintf(&tmp[0], "JPOVR-%d", axis);
|
2009-05-10 05:57:57 +00:00
|
|
|
break;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-10 05:57:57 +00:00
|
|
|
case SDL_HAT_DOWN:
|
2009-05-25 01:59:17 +00:00
|
|
|
sprintf(&tmp[0], "JPOVD-%d", axis);
|
2009-05-10 05:57:57 +00:00
|
|
|
break;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-10 05:57:57 +00:00
|
|
|
case SDL_HAT_LEFT:
|
2009-05-25 01:59:17 +00:00
|
|
|
sprintf(&tmp[0], "JPOVL-%d", axis);
|
2009-05-10 05:57:57 +00:00
|
|
|
break;
|
|
|
|
}
|
|
|
|
}
|
2009-05-25 01:59:17 +00:00
|
|
|
#endif
|
2009-05-23 23:07:53 +00:00
|
|
|
else if (IS_POV(conf.keys[pad][i]))
|
2009-05-10 05:57:57 +00:00
|
|
|
{
|
|
|
|
tmp.resize(28);
|
2009-05-03 12:19:58 +00:00
|
|
|
sprintf(&tmp[0], "JPOV %d%s", PAD_GETJOYSTICK_AXIS(conf.keys[pad][i]), PAD_GETPOVSIGN(conf.keys[pad][i]) ? "-" : "+");
|
|
|
|
}
|
|
|
|
|
|
|
|
if (tmp.size() > 0)
|
|
|
|
{
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(Btn), tmp.c_str());
|
|
|
|
}
|
2009-02-09 21:15:56 +00:00
|
|
|
else
|
|
|
|
gtk_entry_set_text(GTK_ENTRY(Btn), "Unknown");
|
|
|
|
|
2009-05-10 05:57:57 +00:00
|
|
|
gtk_object_set_user_data(GTK_OBJECT(Btn), (void*)(PADKEYS * pad + i));
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
// check bounds
|
|
|
|
int joyid = _GetJoystickIdFromPAD(pad);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-29 06:33:56 +00:00
|
|
|
if (JoystickIdWithinBounds(joyid))
|
2009-05-03 12:19:58 +00:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(s_devicecombo), joyid); // select the combo
|
2010-04-25 00:31:27 +00:00
|
|
|
else
|
2009-05-03 12:19:58 +00:00
|
|
|
gtk_combo_box_set_active(GTK_COMBO_BOX(s_devicecombo), s_vjoysticks.size()); // no gamepad
|
|
|
|
|
|
|
|
int padopts = conf.options >> (16 * pad);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-10 05:57:57 +00:00
|
|
|
set_checked(Conf, "checkbutton_reverselx", padopts & PADOPTION_REVERTLX);
|
|
|
|
set_checked(Conf, "checkbutton_reversely", padopts & PADOPTION_REVERTLY);
|
|
|
|
set_checked(Conf, "checkbutton_reverserx", padopts & PADOPTION_REVERTRX);
|
|
|
|
set_checked(Conf, "checkbutton_reversery", padopts & PADOPTION_REVERTRY);
|
|
|
|
set_checked(Conf, "forcefeedback", padopts & PADOPTION_FORCEFEEDBACK);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
2009-05-23 11:57:28 +00:00
|
|
|
GtkWidget* GetLabelWidget(GtkButton *button)
|
2009-02-09 21:15:56 +00:00
|
|
|
{
|
2009-05-23 11:57:28 +00:00
|
|
|
const char* buttonname = gtk_widget_get_name(GTK_WIDGET(button));
|
2009-05-10 05:57:57 +00:00
|
|
|
const char* labelname = GetLabelFromButton(buttonname).c_str();
|
2009-05-23 11:57:28 +00:00
|
|
|
return lookup_widget(Conf, labelname);
|
|
|
|
}
|
|
|
|
|
|
|
|
int GetLabelId(GtkWidget *label)
|
|
|
|
{
|
2009-05-03 12:19:58 +00:00
|
|
|
if (label == NULL)
|
|
|
|
{
|
2009-05-09 22:44:06 +00:00
|
|
|
PAD_LOG("couldn't find correct label\n");
|
2009-05-23 11:57:28 +00:00
|
|
|
return -1;
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
|
|
|
|
2010-04-25 00:31:27 +00:00
|
|
|
return (int)(uptr)gtk_object_get_user_data(GTK_OBJECT(label));
|
2009-05-23 11:57:28 +00:00
|
|
|
}
|
2009-05-03 12:19:58 +00:00
|
|
|
|
2009-05-23 11:57:28 +00:00
|
|
|
void OnConf_Key(GtkButton *button, gpointer user_data)
|
|
|
|
{
|
|
|
|
GtkWidget* label = GetLabelWidget(button);
|
2009-05-25 01:59:17 +00:00
|
|
|
bool captured = false;
|
|
|
|
char str[32];
|
2009-05-23 11:57:28 +00:00
|
|
|
int id = GetLabelId(label);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-23 11:57:28 +00:00
|
|
|
if (id == -1) return;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-23 11:57:28 +00:00
|
|
|
int pad = id / PADKEYS;
|
|
|
|
int key = id % PADKEYS;
|
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
// save the joystick states
|
|
|
|
UpdateJoysticks();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
while (!captured)
|
2009-05-23 11:57:28 +00:00
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
vector<JoystickInfo*>::iterator itjoy;
|
2009-05-23 11:57:28 +00:00
|
|
|
char *tmp;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
|
|
|
if (PollX11Keyboard(tmp, conf.keys[pad][key]))
|
2009-05-23 11:57:28 +00:00
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
strcpy(str, tmp);
|
|
|
|
captured = true;
|
|
|
|
break;
|
2009-05-23 11:57:28 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
SDL_JoystickUpdate();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
itjoy = s_vjoysticks.begin();
|
|
|
|
while ((itjoy != s_vjoysticks.end()) && (!captured))
|
2009-05-03 12:19:58 +00:00
|
|
|
{
|
2009-05-23 11:57:28 +00:00
|
|
|
int jbutton, direction;
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
if ((*itjoy)->PollButtons(jbutton, conf.keys[pad][key]))
|
2009-05-03 12:19:58 +00:00
|
|
|
{
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-23 11:57:28 +00:00
|
|
|
sprintf(str, "JBut %d", jbutton);
|
2009-05-25 01:59:17 +00:00
|
|
|
captured = true;
|
|
|
|
break;
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
bool negative = false;
|
|
|
|
bool pov = (!((key == PAD_RY) || (key == PAD_LY) || (key == PAD_RX) || (key == PAD_LX)));
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
if ((*itjoy)->PollAxes(pov, jbutton, negative, conf.keys[pad][key]))
|
2009-05-03 12:19:58 +00:00
|
|
|
{
|
2009-05-23 11:57:28 +00:00
|
|
|
if (pov)
|
|
|
|
sprintf(str, "JPOV %d%s", jbutton, (negative) ? "-" : "+");
|
|
|
|
else
|
|
|
|
sprintf(str, "JAxis %d", jbutton);
|
2009-05-25 01:59:17 +00:00
|
|
|
captured = true;
|
|
|
|
break;
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-23 11:57:28 +00:00
|
|
|
#ifdef EXPERIMENTAL_POV_CODE
|
2009-05-25 01:59:17 +00:00
|
|
|
if ((*itjoy)->PollHats(jbutton, direction, conf.keys[pad][key]))
|
2009-05-07 23:37:57 +00:00
|
|
|
{
|
2009-05-23 11:57:28 +00:00
|
|
|
switch (direction)
|
2009-05-07 23:37:57 +00:00
|
|
|
{
|
2009-05-23 11:57:28 +00:00
|
|
|
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;
|
2010-04-25 00:31:27 +00:00
|
|
|
case SDL_HAT_LEFT: sprintf(str, "JPOVL-%d", jbutton); break;
|
2009-05-07 23:37:57 +00:00
|
|
|
}
|
2009-05-25 01:59:17 +00:00
|
|
|
captured = true;
|
|
|
|
break;
|
2009-05-09 22:44:06 +00:00
|
|
|
}
|
|
|
|
#endif
|
2009-05-07 23:37:57 +00:00
|
|
|
itjoy++;
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-25 01:59:17 +00:00
|
|
|
gtk_entry_set_text(GTK_ENTRY(label), str);
|
2009-02-09 21:15:56 +00:00
|
|
|
}
|
|
|
|
|
|
|
|
void CALLBACK PADconfigure()
|
|
|
|
{
|
2009-02-22 12:08:05 +00:00
|
|
|
char strcurdir[256];
|
|
|
|
getcwd(strcurdir, 256);
|
|
|
|
s_strIniPath = strcurdir;
|
|
|
|
s_strIniPath += "/inis/zeropad.ini";
|
2009-05-03 12:19:58 +00:00
|
|
|
|
2009-02-09 21:15:56 +00:00
|
|
|
LoadConfig();
|
|
|
|
|
|
|
|
Conf = create_Conf();
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
// recreate
|
|
|
|
JoystickInfo::EnumerateJoysticks(s_vjoysticks);
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-07 23:37:57 +00:00
|
|
|
s_devicecombo = lookup_widget(Conf, "joydevicescombo");
|
2009-02-09 21:15:56 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
// fill the combo
|
|
|
|
char str[255];
|
2009-05-07 23:37:57 +00:00
|
|
|
vector<JoystickInfo*>::iterator it = s_vjoysticks.begin();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-07 23:37:57 +00:00
|
|
|
// Delete everything in the vector vjoysticks.
|
2009-05-07 23:49:12 +00:00
|
|
|
while (it != s_vjoysticks.end())
|
2009-05-03 12:19:58 +00:00
|
|
|
{
|
2009-05-25 01:59:17 +00:00
|
|
|
sprintf(str, "%d: %s - but: %d, axes: %d, hats: %d", (*it)->GetId(), (*it)->GetName().c_str(),
|
|
|
|
(*it)->GetNumButtons(), (*it)->GetNumAxes(), (*it)->GetNumHats());
|
2009-05-03 12:19:58 +00:00
|
|
|
gtk_combo_box_append_text(GTK_COMBO_BOX(s_devicecombo), str);
|
2009-05-07 23:37:57 +00:00
|
|
|
it++;
|
2009-05-03 12:19:58 +00:00
|
|
|
}
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
gtk_combo_box_append_text(GTK_COMBO_BOX(s_devicecombo), "No Gamepad");
|
2009-02-09 21:15:56 +00:00
|
|
|
|
|
|
|
UpdateConf(0);
|
|
|
|
|
2009-05-03 12:19:58 +00:00
|
|
|
gtk_widget_show_all(Conf);
|
2009-02-09 21:15:56 +00:00
|
|
|
gtk_main();
|
|
|
|
}
|