WIP: Zeropad fork. This is intended more as a backup copy so I have a good copy to work from then as a release. As such, while it works, the gui is glitchy, the Windows port is non-existant, and a lot of things are subject to change...

git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1457 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
arcum42 2009-07-03 11:45:47 +00:00
parent 25aa15a0a2
commit d82c3653ce
31 changed files with 6914 additions and 0 deletions

View File

@ -0,0 +1,131 @@
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
void
OnAbout_Ok (GtkDialog *dialog,
gint response_id,
gpointer user_data)
{
}
void
OnConf_Pad1 (GtkButton *button,
gpointer user_data)
{
}
void
OnConf_Pad2 (GtkButton *button,
gpointer user_data)
{
}
void
OnConf_Pad3 (GtkButton *button,
gpointer user_data)
{
}
void
OnConf_Pad4 (GtkButton *button,
gpointer user_data)
{
}
void
on_joydevicescombo_changed (GtkComboBox *combobox,
gpointer user_data)
{
}
void
OnConf_Key (GtkButton *button,
gpointer user_data)
{
}
void
on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
on_forcefeedback_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
on_checkbutton_reversely_toggled (GtkToggleButton *togglebutton,
gpointer user_data)
{
}
void
OnConf_Ok (GtkButton *button,
gpointer user_data)
{
}
void
OnConf_Cancel (GtkButton *button,
gpointer user_data)
{
}
void
on_Remove (GtkButton *button,
gpointer user_data)
{
}

View File

@ -0,0 +1,63 @@
#include <gtk/gtk.h>
void
OnAbout_Ok (GtkDialog *dialog,
gint response_id,
gpointer user_data);
void
OnConf_Pad1 (GtkButton *button,
gpointer user_data);
void
OnConf_Pad2 (GtkButton *button,
gpointer user_data);
void
OnConf_Pad3 (GtkButton *button,
gpointer user_data);
void
OnConf_Pad4 (GtkButton *button,
gpointer user_data);
void
on_joydevicescombo_changed (GtkComboBox *combobox,
gpointer user_data);
void
OnConf_Key (GtkButton *button,
gpointer user_data);
void
on_checkbutton_reversery_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
on_checkbutton_reverserx_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
on_forcefeedback_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
on_checkbutton_reverselx_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
on_checkbutton_reversely_toggled (GtkToggleButton *togglebutton,
gpointer user_data);
void
OnConf_Ok (GtkButton *button,
gpointer user_data);
void
OnConf_Cancel (GtkButton *button,
gpointer user_data);
void
on_Remove (GtkButton *button,
gpointer user_data);

View File

@ -0,0 +1,442 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#include <string.h>
#include <gtk/gtk.h>
#include <pthread.h>
#include "joystick.h"
#include "onepad.h"
#include "linux.h"
extern "C"
{
#include "interface.h"
#include "support.h"
#include "callbacks.h"
}
extern string s_strIniPath;
GtkWidget *Conf, *About, *MsgDlg;
GtkWidget *s_devicecombo;
GtkTreeStore *treestore;
GtkTreeModel *model;
bool has_columns = false;
extern string KeyName(int pad, int key);
extern const char* s_pGuiKeyMap[];
extern void UpdateConf(int pad);
enum
{
COL_PAD = 0,
COL_BUTTON,
COL_KEY,
COL_VALUE,
NUM_COLS
};
void populate_tree_view()
{
GtkTreeIter toplevel;
gtk_tree_store_clear(treestore);
for (int pad = 0; pad < 2 * PADSUBKEYS; pad++)
{
for (int key = 0; key < PADKEYS; key++)
{
if (get_key(pad, key) != 0)
{
gtk_tree_store_append(treestore, &toplevel, NULL);
gtk_tree_store_set(treestore, &toplevel,
COL_PAD, pad,
COL_BUTTON, s_pGuiKeyMap[key],
COL_KEY, KeyName(pad, key).c_str(),
COL_VALUE, key,
-1);
}
}
}
}
void create_a_column(GtkWidget *view, const char *name, int num, bool visible)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *col;
col = gtk_tree_view_column_new();
gtk_tree_view_column_set_title(col, name);
/* pack tree view column into tree view */
gtk_tree_view_append_column(GTK_TREE_VIEW(view), col);
renderer = gtk_cell_renderer_text_new();
/* pack cell renderer into tree view column */
gtk_tree_view_column_pack_start(col, renderer, TRUE);
/* connect 'text' property of the cell renderer to
* model column that contains the first name */
gtk_tree_view_column_add_attribute(col, renderer, "text", num);
gtk_tree_view_column_set_visible(col, visible);
}
void create_columns(GtkWidget *view)
{
GtkCellRenderer *renderer;
GtkTreeViewColumn *col;
if (!has_columns)
{
create_a_column(view, "Pad #", COL_PAD, true);
create_a_column(view, "Pad Button", COL_BUTTON, true);
create_a_column(view, "Key Value", COL_KEY, true);
create_a_column(view, "Internal", COL_VALUE, false);
has_columns = true;
}
}
void init_tree_view()
{
GtkWidget *view;
view = lookup_widget(Conf,"padtreeview");
treestore = gtk_tree_store_new(NUM_COLS,
G_TYPE_UINT,
G_TYPE_STRING,
G_TYPE_STRING,
G_TYPE_UINT);
populate_tree_view();
create_columns(view);
model = GTK_TREE_MODEL(treestore);
gtk_tree_view_set_model(GTK_TREE_VIEW(view), model);
g_object_unref(model); /* destroy model automatically with view */
gtk_tree_selection_set_mode(gtk_tree_view_get_selection(GTK_TREE_VIEW(view)),
GTK_SELECTION_SINGLE);
}
void destroy_tree_view()
{
has_columns = false;
//g_object_unref(treestore);
}
/*void add_tree_row(int pad, int key)
{
GtkTreeIter toplevel;
gtk_tree_store_append(treestore, &toplevel, NULL);
gtk_tree_store_set(treestore, &toplevel,
COL_PAD, pad,
COL_BUTTON, s_pGuiKeyMap[key],
COL_KEY, KeyName(pad, key).c_str(),
COL_VALUE, key,
-1);
}
void delete_tree_row()
{
}*/
void SaveConfig()
{
FILE *f;
char cfg[255];
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg, "w");
if (f == NULL)
{
printf("ZeroPAD: failed to save ini %s\n", s_strIniPath.c_str());
return;
}
for (int pad = 0; pad < 2 * PADSUBKEYS; pad++)
{
for (int key = 0; key < PADKEYS; key++)
{
fprintf(f, "[%d][%d] = 0x%lx\n", pad, key, get_key(pad,key));
}
}
fprintf(f, "log = %d\n", conf.log);
fprintf(f, "options = %d\n", conf.options);
fclose(f);
}
void LoadConfig()
{
FILE *f;
char str[256];
char cfg[255];
memset(&conf, 0, sizeof(conf));
set_key(0, PAD_L2, XK_a);
set_key(0, PAD_R2, XK_semicolon);
set_key(0, PAD_L1, XK_w);
set_key(0, PAD_R1, XK_p);
set_key(0, PAD_TRIANGLE, XK_i);
set_key(0, PAD_CIRCLE, XK_l);
set_key(0, PAD_CROSS, XK_k);
set_key(0, PAD_SQUARE, XK_j);
set_key(0, PAD_SELECT, XK_v);
set_key(0, PAD_START, XK_n);
set_key(0, PAD_UP, XK_e);
set_key(0, PAD_RIGHT, XK_f);
set_key(0, PAD_DOWN, XK_d);
set_key(0, PAD_LEFT, XK_s);
conf.log = 0;
strcpy(cfg, s_strIniPath.c_str());
f = fopen(cfg, "r");
if (f == NULL)
{
printf("OnePAD: failed to load ini %s\n", s_strIniPath.c_str());
SaveConfig(); //save and return
return;
}
for (int pad = 0; pad < 2 * PADSUBKEYS; pad++)
{
for (int key = 0; key < PADKEYS; key++)
{
sprintf(str, "[%d][%d] = 0x%%x\n", pad, key);
u32 temp;
if (fscanf(f, str, &temp) == 0) temp = 0;
set_key(pad, key, temp);
}
}
fscanf(f, "log = %d\n", &conf.log);
fscanf(f, "options = %d\n", &conf.options);
fclose(f);
}
void OnMsg_Ok()
{
gtk_widget_destroy(MsgDlg);
gtk_main_quit();
}
// GUI event handlers
void on_joydevicescombo_changed(GtkComboBox *combobox, gpointer user_data)
{
int joyid = gtk_combo_box_get_active(combobox);
// unassign every joystick with this pad
for (int i = 0; i < (int)s_vjoysticks.size(); ++i)
{
if (s_vjoysticks[i]->GetPAD() == s_selectedpad) s_vjoysticks[i]->Assign(-1);
}
if (joyid >= 0 && joyid < (int)s_vjoysticks.size()) s_vjoysticks[joyid]->Assign(s_selectedpad);
}
void on_checkbutton_reverselx_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTLX << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
conf.options |= mask;
else
conf.options &= ~mask;
}
void on_checkbutton_reversely_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTLY << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
conf.options |= mask;
else
conf.options &= ~mask;
}
void on_checkbutton_reverserx_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTRX << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
conf.options |= mask;
else
conf.options &= ~mask;
}
void on_checkbutton_reversery_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTRY << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
conf.options |= mask;
else
conf.options &= ~mask;
}
void on_forcefeedback_toggled(GtkToggleButton *togglebutton, gpointer user_data)
{
int mask = PADOPTION_REVERTLX << (16 * s_selectedpad);
if (gtk_toggle_button_get_active(togglebutton))
{
conf.options |= mask;
int joyid = gtk_combo_box_get_active(GTK_COMBO_BOX(s_devicecombo));
if (joyid >= 0 && joyid < (int)s_vjoysticks.size()) s_vjoysticks[joyid]->TestForce();
}
else
{
conf.options &= ~mask;
}
}
void SysMessage(char *fmt, ...)
{
GtkWidget *Ok, *Txt;
GtkWidget *Box, *Box1;
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
if (msg[strlen(msg)-1] == '\n') msg[strlen(msg)-1] = 0;
MsgDlg = gtk_window_new(GTK_WINDOW_TOPLEVEL);
gtk_window_set_position(GTK_WINDOW(MsgDlg), GTK_WIN_POS_CENTER);
gtk_window_set_title(GTK_WINDOW(MsgDlg), "ZeroPad");
gtk_container_set_border_width(GTK_CONTAINER(MsgDlg), 5);
Box = gtk_vbox_new(5, 0);
gtk_container_add(GTK_CONTAINER(MsgDlg), Box);
gtk_widget_show(Box);
Txt = gtk_label_new(msg);
gtk_box_pack_start(GTK_BOX(Box), Txt, FALSE, FALSE, 5);
gtk_widget_show(Txt);
Box1 = gtk_hbutton_box_new();
gtk_box_pack_start(GTK_BOX(Box), Box1, FALSE, FALSE, 0);
gtk_widget_show(Box1);
Ok = gtk_button_new_with_label("Ok");
gtk_signal_connect(GTK_OBJECT(Ok), "clicked", GTK_SIGNAL_FUNC(OnMsg_Ok), NULL);
gtk_container_add(GTK_CONTAINER(Box1), Ok);
GTK_WIDGET_SET_FLAGS(Ok, GTK_CAN_DEFAULT);
gtk_widget_show(Ok);
gtk_widget_show(MsgDlg);
gtk_main();
}
void on_Remove(GtkButton *button, gpointer user_data)
{
GtkTreeSelection *selection;
GtkTreeIter iter;
GtkWidget *view;
view = lookup_widget(Conf,"padtreeview");
selection = gtk_tree_view_get_selection(GTK_TREE_VIEW(view));
if (gtk_tree_selection_get_selected(selection, &model, &iter))
{
int pad;
int key;
gtk_tree_model_get(model, &iter, COL_PAD, &pad, COL_VALUE, &key,-1);
set_key(pad, key, 0);
init_tree_view();
}
else
{
// Not selected.
}
}
void OnConf_Pad1(GtkButton *button, gpointer user_data)
{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) UpdateConf(0);
}
void OnConf_Pad2(GtkButton *button, gpointer user_data)
{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) UpdateConf(1);
}
void OnConf_Pad3(GtkButton *button, gpointer user_data)
{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) UpdateConf(2);
}
void OnConf_Pad4(GtkButton *button, gpointer user_data)
{
if (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(button))) UpdateConf(3);
}
void OnConf_Ok(GtkButton *button, gpointer user_data)
{
// conf.analog = gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(Analog));
SaveConfig();
destroy_tree_view();
gtk_widget_destroy(Conf);
gtk_main_quit();
}
void OnConf_Cancel(GtkButton *button, gpointer user_data)
{
gtk_widget_destroy(Conf);
gtk_main_quit();
LoadConfig(); // load previous config
}
void OnAbout_Ok(GtkDialog *About, gint response_id, gpointer user_data)
{
gtk_widget_destroy(GTK_WIDGET(About));
gtk_main_quit();
}
EXPORT_C_(void) PADabout()
{
About = create_About();
gtk_widget_show_all(About);
gtk_main();
}
EXPORT_C_(s32) PADtest()
{
return 0;
}

View File

@ -0,0 +1,710 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gdk/gdkkeysyms.h>
#include <gtk/gtk.h>
#include "callbacks.h"
#include "interface.h"
#include "support.h"
#define GLADE_HOOKUP_OBJECT(component,widget,name) \
g_object_set_data_full (G_OBJECT (component), name, \
gtk_widget_ref (widget), (GDestroyNotify) gtk_widget_unref)
#define GLADE_HOOKUP_OBJECT_NO_REF(component,widget,name) \
g_object_set_data (G_OBJECT (component), name, widget)
GtkWidget*
create_About (void)
{
GtkWidget *About;
const gchar *authors[] = {
"Author: arcum42(@gmail.com)",
"Forked from ZeroPad, by:",
"zerofrog(@gmail.com)",
"Thanks to:",
" linuzappz <linuzappz@hotmail.com>",
"florin sasu <florinsasu@hotmail.com>",
"and SSSPSXPad, TwinPad authors",
NULL
};
/* TRANSLATORS: Replace this string with your names, one name per line. */
gchar *translators = _("translator-credits");
About = gtk_about_dialog_new ();
gtk_widget_set_name (About, "About");
gtk_container_set_border_width (GTK_CONTAINER (About), 5);
gtk_window_set_destroy_with_parent (GTK_WINDOW (About), TRUE);
gtk_about_dialog_set_version (GTK_ABOUT_DIALOG (About), VERSION);
gtk_about_dialog_set_name (GTK_ABOUT_DIALOG (About), _("OnePAD"));
gtk_about_dialog_set_authors (GTK_ABOUT_DIALOG (About), authors);
gtk_about_dialog_set_translator_credits (GTK_ABOUT_DIALOG (About), translators);
g_signal_connect ((gpointer) About, "response",
G_CALLBACK (OnAbout_Ok),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (About, About, "About");
return About;
}
GtkWidget*
create_Conf (void)
{
GtkWidget *Conf;
GtkWidget *dialog_vbox1;
GtkWidget *vbox1;
GtkWidget *frame1;
GtkWidget *alignment1;
GtkWidget *hbox1;
GtkWidget *PAD1;
GSList *PAD1_group = NULL;
GtkWidget *PAD2;
GtkWidget *PAD3;
GtkWidget *PAD4;
GtkWidget *label2;
GtkWidget *vbox2;
GtkWidget *label5;
GtkWidget *joydevicescombo;
GtkWidget *fixed1;
GtkWidget *vbox3;
GtkWidget *hbox3;
GtkWidget *fixed2;
GtkWidget *fixed3;
GtkWidget *Left;
GtkWidget *Up;
GtkWidget *Right;
GtkWidget *Down;
GtkWidget *L2;
GtkWidget *L1;
GtkWidget *Select;
GtkWidget *Start;
GtkWidget *L3;
GtkWidget *R3;
GtkWidget *Analog;
GtkWidget *Square;
GtkWidget *Triangle;
GtkWidget *Circle;
GtkWidget *Cross;
GtkWidget *R2;
GtkWidget *R1;
GtkWidget *label3;
GtkWidget *label6;
GtkWidget *L_Up;
GtkWidget *L_Left;
GtkWidget *Lx;
GtkWidget *Ly;
GtkWidget *L_Down;
GtkWidget *L_Right;
GtkWidget *checkbutton_reverselx;
GtkWidget *checkbutton_reversely;
GtkWidget *R_Up;
GtkWidget *R_Left;
GtkWidget *Rx;
GtkWidget *Ry;
GtkWidget *R_Right;
GtkWidget *R_Down;
GtkWidget *forcefeedback;
GtkWidget *checkbutton_reverserx;
GtkWidget *checkbutton_reversery;
GtkWidget *frame2;
GtkWidget *alignment2;
GtkWidget *scrolledwindow2;
GtkWidget *padtreeview;
GtkWidget *label7;
GtkWidget *remove_button;
GtkWidget *dialog_action_area1;
GtkWidget *okbutton1;
GtkWidget *cancelbutton1;
Conf = gtk_dialog_new ();
gtk_widget_set_name (Conf, "Conf");
gtk_window_set_title (GTK_WINDOW (Conf), _("OnePAD Configuration Dialog"));
gtk_window_set_type_hint (GTK_WINDOW (Conf), GDK_WINDOW_TYPE_HINT_DIALOG);
dialog_vbox1 = GTK_DIALOG (Conf)->vbox;
gtk_widget_set_name (dialog_vbox1, "dialog_vbox1");
gtk_widget_show (dialog_vbox1);
vbox1 = gtk_vbox_new (FALSE, 0);
gtk_widget_set_name (vbox1, "vbox1");
gtk_widget_show (vbox1);
gtk_box_pack_start (GTK_BOX (dialog_vbox1), vbox1, TRUE, TRUE, 0);
frame1 = gtk_frame_new (NULL);
gtk_widget_set_name (frame1, "frame1");
gtk_widget_show (frame1);
gtk_box_pack_start (GTK_BOX (vbox1), frame1, FALSE, FALSE, 0);
alignment1 = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_set_name (alignment1, "alignment1");
gtk_widget_show (alignment1);
gtk_container_add (GTK_CONTAINER (frame1), alignment1);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment1), 0, 0, 12, 0);
hbox1 = gtk_hbox_new (FALSE, 0);
gtk_widget_set_name (hbox1, "hbox1");
gtk_widget_show (hbox1);
gtk_container_add (GTK_CONTAINER (alignment1), hbox1);
PAD1 = gtk_radio_button_new_with_mnemonic (NULL, _("PAD1"));
gtk_widget_set_name (PAD1, "PAD1");
gtk_widget_show (PAD1);
gtk_box_pack_start (GTK_BOX (hbox1), PAD1, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (PAD1), PAD1_group);
PAD1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (PAD1));
gtk_toggle_button_set_active (GTK_TOGGLE_BUTTON (PAD1), TRUE);
PAD2 = gtk_radio_button_new_with_mnemonic (NULL, _("PAD2"));
gtk_widget_set_name (PAD2, "PAD2");
gtk_widget_show (PAD2);
gtk_box_pack_start (GTK_BOX (hbox1), PAD2, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (PAD2), PAD1_group);
PAD1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (PAD2));
PAD3 = gtk_radio_button_new_with_mnemonic (NULL, _("PAD1 alt."));
gtk_widget_set_name (PAD3, "PAD3");
gtk_widget_show (PAD3);
gtk_box_pack_start (GTK_BOX (hbox1), PAD3, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (PAD3), PAD1_group);
PAD1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (PAD3));
PAD4 = gtk_radio_button_new_with_mnemonic (NULL, _("PAD2 alt."));
gtk_widget_set_name (PAD4, "PAD4");
gtk_widget_show (PAD4);
gtk_box_pack_start (GTK_BOX (hbox1), PAD4, FALSE, FALSE, 0);
gtk_radio_button_set_group (GTK_RADIO_BUTTON (PAD4), PAD1_group);
PAD1_group = gtk_radio_button_get_group (GTK_RADIO_BUTTON (PAD4));
label2 = gtk_label_new (_("<b>Choose PAD to modify</b>"));
gtk_widget_set_name (label2, "label2");
gtk_widget_show (label2);
gtk_frame_set_label_widget (GTK_FRAME (frame1), label2);
gtk_label_set_use_markup (GTK_LABEL (label2), TRUE);
vbox2 = gtk_vbox_new (FALSE, 0);
gtk_widget_set_name (vbox2, "vbox2");
gtk_widget_show (vbox2);
gtk_box_pack_start (GTK_BOX (vbox1), vbox2, FALSE, TRUE, 0);
label5 = gtk_label_new (_("Joystick to use for this PAD"));
gtk_widget_set_name (label5, "label5");
gtk_widget_show (label5);
gtk_box_pack_start (GTK_BOX (vbox2), label5, FALSE, FALSE, 0);
joydevicescombo = gtk_combo_box_entry_new_text ();
gtk_widget_set_name (joydevicescombo, "joydevicescombo");
gtk_widget_show (joydevicescombo);
gtk_box_pack_start (GTK_BOX (vbox2), joydevicescombo, FALSE, TRUE, 0);
fixed1 = gtk_fixed_new ();
gtk_widget_set_name (fixed1, "fixed1");
gtk_widget_show (fixed1);
gtk_box_pack_start (GTK_BOX (vbox1), fixed1, TRUE, TRUE, 0);
vbox3 = gtk_vbox_new (FALSE, 0);
gtk_widget_set_name (vbox3, "vbox3");
gtk_widget_show (vbox3);
gtk_fixed_put (GTK_FIXED (fixed1), vbox3, 0, 0);
gtk_widget_set_size_request (vbox3, 0, 0);
hbox3 = gtk_hbox_new (FALSE, 0);
gtk_widget_set_name (hbox3, "hbox3");
gtk_widget_show (hbox3);
gtk_box_pack_start (GTK_BOX (vbox3), hbox3, FALSE, FALSE, 0);
fixed2 = gtk_fixed_new ();
gtk_widget_set_name (fixed2, "fixed2");
gtk_widget_show (fixed2);
gtk_box_pack_start (GTK_BOX (hbox3), fixed2, FALSE, FALSE, 0);
fixed3 = gtk_fixed_new ();
gtk_widget_set_name (fixed3, "fixed3");
gtk_widget_show (fixed3);
gtk_box_pack_start (GTK_BOX (hbox3), fixed3, FALSE, FALSE, 0);
Left = gtk_button_new_with_mnemonic (_("Left"));
gtk_widget_set_name (Left, "Left");
gtk_widget_show (Left);
gtk_fixed_put (GTK_FIXED (fixed1), Left, 320, 104);
gtk_widget_set_size_request (Left, 64, 24);
Up = gtk_button_new_with_mnemonic (_("Up"));
gtk_widget_set_name (Up, "Up");
gtk_widget_show (Up);
gtk_fixed_put (GTK_FIXED (fixed1), Up, 384, 80);
gtk_widget_set_size_request (Up, 64, 24);
Right = gtk_button_new_with_mnemonic (_("Right"));
gtk_widget_set_name (Right, "Right");
gtk_widget_show (Right);
gtk_fixed_put (GTK_FIXED (fixed1), Right, 448, 104);
gtk_widget_set_size_request (Right, 64, 24);
Down = gtk_button_new_with_mnemonic (_("Down"));
gtk_widget_set_name (Down, "Down");
gtk_widget_show (Down);
gtk_fixed_put (GTK_FIXED (fixed1), Down, 384, 128);
gtk_widget_set_size_request (Down, 64, 24);
L2 = gtk_button_new_with_mnemonic (_("L2"));
gtk_widget_set_name (L2, "L2");
gtk_widget_show (L2);
gtk_fixed_put (GTK_FIXED (fixed1), L2, 384, 8);
gtk_widget_set_size_request (L2, 64, 24);
L1 = gtk_button_new_with_mnemonic (_("L1"));
gtk_widget_set_name (L1, "L1");
gtk_widget_show (L1);
gtk_fixed_put (GTK_FIXED (fixed1), L1, 384, 32);
gtk_widget_set_size_request (L1, 64, 24);
Select = gtk_button_new_with_mnemonic (_("Select"));
gtk_widget_set_name (Select, "Select");
gtk_widget_show (Select);
gtk_fixed_put (GTK_FIXED (fixed1), Select, 520, 48);
gtk_widget_set_size_request (Select, 64, 24);
Start = gtk_button_new_with_mnemonic (_("Start"));
gtk_widget_set_name (Start, "Start");
gtk_widget_show (Start);
gtk_fixed_put (GTK_FIXED (fixed1), Start, 592, 48);
gtk_widget_set_size_request (Start, 64, 24);
L3 = gtk_button_new_with_mnemonic (_("L3"));
gtk_widget_set_name (L3, "L3");
gtk_widget_show (L3);
gtk_fixed_put (GTK_FIXED (fixed1), L3, 520, 8);
gtk_widget_set_size_request (L3, 64, 24);
R3 = gtk_button_new_with_mnemonic (_("R3"));
gtk_widget_set_name (R3, "R3");
gtk_widget_show (R3);
gtk_fixed_put (GTK_FIXED (fixed1), R3, 592, 8);
gtk_widget_set_size_request (R3, 64, 24);
Analog = gtk_button_new_with_mnemonic (_("Analog"));
gtk_widget_set_name (Analog, "Analog");
gtk_widget_show (Analog);
gtk_fixed_put (GTK_FIXED (fixed1), Analog, 552, 104);
gtk_widget_set_size_request (Analog, 64, 24);
Square = gtk_button_new_with_mnemonic (_("Square"));
gtk_widget_set_name (Square, "Square");
gtk_widget_show (Square);
gtk_fixed_put (GTK_FIXED (fixed1), Square, 648, 104);
gtk_widget_set_size_request (Square, 64, 24);
Triangle = gtk_button_new_with_mnemonic (_("Triangle"));
gtk_widget_set_name (Triangle, "Triangle");
gtk_widget_show (Triangle);
gtk_fixed_put (GTK_FIXED (fixed1), Triangle, 712, 80);
gtk_widget_set_size_request (Triangle, 64, 24);
Circle = gtk_button_new_with_mnemonic (_("Circle"));
gtk_widget_set_name (Circle, "Circle");
gtk_widget_show (Circle);
gtk_fixed_put (GTK_FIXED (fixed1), Circle, 776, 104);
gtk_widget_set_size_request (Circle, 64, 24);
Cross = gtk_button_new_with_mnemonic (_("Cross"));
gtk_widget_set_name (Cross, "Cross");
gtk_widget_show (Cross);
gtk_fixed_put (GTK_FIXED (fixed1), Cross, 712, 128);
gtk_widget_set_size_request (Cross, 64, 24);
R2 = gtk_button_new_with_mnemonic (_("R2"));
gtk_widget_set_name (R2, "R2");
gtk_widget_show (R2);
gtk_fixed_put (GTK_FIXED (fixed1), R2, 712, 8);
gtk_widget_set_size_request (R2, 64, 24);
R1 = gtk_button_new_with_mnemonic (_("R1"));
gtk_widget_set_name (R1, "R1");
gtk_widget_show (R1);
gtk_fixed_put (GTK_FIXED (fixed1), R1, 712, 32);
gtk_widget_set_size_request (R1, 64, 24);
label3 = gtk_label_new (_("Analog Controls (move mouse or analog joystick to select)"));
gtk_widget_set_name (label3, "label3");
gtk_widget_show (label3);
gtk_fixed_put (GTK_FIXED (fixed1), label3, 384, 168);
gtk_widget_set_size_request (label3, 400, 24);
gtk_label_set_line_wrap (GTK_LABEL (label3), TRUE);
gtk_label_set_single_line_mode (GTK_LABEL (label3), TRUE);
label6 = gtk_label_new (_("(Note: The analog key controls and joystick controls do not work well together currently, and should not be mixed. )"));
gtk_widget_set_name (label6, "label6");
gtk_widget_show (label6);
gtk_fixed_put (GTK_FIXED (fixed1), label6, 352, 192);
gtk_widget_set_size_request (label6, 448, 40);
gtk_label_set_justify (GTK_LABEL (label6), GTK_JUSTIFY_CENTER);
gtk_label_set_line_wrap (GTK_LABEL (label6), TRUE);
L_Up = gtk_button_new_with_mnemonic (_("Up"));
gtk_widget_set_name (L_Up, "L_Up");
gtk_widget_show (L_Up);
gtk_fixed_put (GTK_FIXED (fixed1), L_Up, 384, 240);
gtk_widget_set_size_request (L_Up, 64, 24);
L_Left = gtk_button_new_with_mnemonic (_("Left"));
gtk_widget_set_name (L_Left, "L_Left");
gtk_widget_show (L_Left);
gtk_fixed_put (GTK_FIXED (fixed1), L_Left, 320, 272);
gtk_widget_set_size_request (L_Left, 64, 24);
Lx = gtk_button_new_with_mnemonic (_("Lx"));
gtk_widget_set_name (Lx, "Lx");
gtk_widget_show (Lx);
gtk_fixed_put (GTK_FIXED (fixed1), Lx, 384, 264);
gtk_widget_set_size_request (Lx, 64, 24);
Ly = gtk_button_new_with_mnemonic (_("Ly"));
gtk_widget_set_name (Ly, "Ly");
gtk_widget_show (Ly);
gtk_fixed_put (GTK_FIXED (fixed1), Ly, 384, 288);
gtk_widget_set_size_request (Ly, 64, 24);
L_Down = gtk_button_new_with_mnemonic (_("Down"));
gtk_widget_set_name (L_Down, "L_Down");
gtk_widget_show (L_Down);
gtk_fixed_put (GTK_FIXED (fixed1), L_Down, 384, 312);
gtk_widget_set_size_request (L_Down, 64, 24);
L_Right = gtk_button_new_with_mnemonic (_("Right"));
gtk_widget_set_name (L_Right, "L_Right");
gtk_widget_show (L_Right);
gtk_fixed_put (GTK_FIXED (fixed1), L_Right, 448, 272);
gtk_widget_set_size_request (L_Right, 64, 24);
checkbutton_reverselx = gtk_check_button_new_with_mnemonic (_("Reverse LX"));
gtk_widget_set_name (checkbutton_reverselx, "checkbutton_reverselx");
gtk_widget_show (checkbutton_reverselx);
gtk_fixed_put (GTK_FIXED (fixed1), checkbutton_reverselx, 360, 344);
gtk_widget_set_size_request (checkbutton_reverselx, 111, 22);
checkbutton_reversely = gtk_check_button_new_with_mnemonic (_("Reverse LY"));
gtk_widget_set_name (checkbutton_reversely, "checkbutton_reversely");
gtk_widget_show (checkbutton_reversely);
gtk_fixed_put (GTK_FIXED (fixed1), checkbutton_reversely, 360, 368);
gtk_widget_set_size_request (checkbutton_reversely, 111, 22);
R_Up = gtk_button_new_with_mnemonic (_("Up"));
gtk_widget_set_name (R_Up, "R_Up");
gtk_widget_show (R_Up);
gtk_fixed_put (GTK_FIXED (fixed1), R_Up, 712, 240);
gtk_widget_set_size_request (R_Up, 64, 24);
R_Left = gtk_button_new_with_mnemonic (_("Left"));
gtk_widget_set_name (R_Left, "R_Left");
gtk_widget_show (R_Left);
gtk_fixed_put (GTK_FIXED (fixed1), R_Left, 648, 272);
gtk_widget_set_size_request (R_Left, 64, 24);
Rx = gtk_button_new_with_mnemonic (_("Rx"));
gtk_widget_set_name (Rx, "Rx");
gtk_widget_show (Rx);
gtk_fixed_put (GTK_FIXED (fixed1), Rx, 712, 264);
gtk_widget_set_size_request (Rx, 64, 24);
Ry = gtk_button_new_with_mnemonic (_("Ry"));
gtk_widget_set_name (Ry, "Ry");
gtk_widget_show (Ry);
gtk_fixed_put (GTK_FIXED (fixed1), Ry, 712, 288);
gtk_widget_set_size_request (Ry, 64, 24);
R_Right = gtk_button_new_with_mnemonic (_("Right"));
gtk_widget_set_name (R_Right, "R_Right");
gtk_widget_show (R_Right);
gtk_fixed_put (GTK_FIXED (fixed1), R_Right, 776, 272);
gtk_widget_set_size_request (R_Right, 64, 24);
R_Down = gtk_button_new_with_mnemonic (_("Down"));
gtk_widget_set_name (R_Down, "R_Down");
gtk_widget_show (R_Down);
gtk_fixed_put (GTK_FIXED (fixed1), R_Down, 712, 312);
gtk_widget_set_size_request (R_Down, 64, 24);
forcefeedback = gtk_check_button_new_with_mnemonic (_("Enable Force\nFeedback"));
gtk_widget_set_name (forcefeedback, "forcefeedback");
gtk_widget_show (forcefeedback);
gtk_fixed_put (GTK_FIXED (fixed1), forcefeedback, 528, 344);
gtk_widget_set_size_request (forcefeedback, 112, 48);
checkbutton_reverserx = gtk_check_button_new_with_mnemonic (_("Reverse RX"));
gtk_widget_set_name (checkbutton_reverserx, "checkbutton_reverserx");
gtk_widget_show (checkbutton_reverserx);
gtk_fixed_put (GTK_FIXED (fixed1), checkbutton_reverserx, 688, 344);
gtk_widget_set_size_request (checkbutton_reverserx, 111, 22);
checkbutton_reversery = gtk_check_button_new_with_mnemonic (_("Reverse RY"));
gtk_widget_set_name (checkbutton_reversery, "checkbutton_reversery");
gtk_widget_show (checkbutton_reversery);
gtk_fixed_put (GTK_FIXED (fixed1), checkbutton_reversery, 688, 368);
gtk_widget_set_size_request (checkbutton_reversery, 111, 22);
frame2 = gtk_frame_new (NULL);
gtk_widget_set_name (frame2, "frame2");
gtk_widget_show (frame2);
gtk_fixed_put (GTK_FIXED (fixed1), frame2, 0, 8);
gtk_widget_set_size_request (frame2, 312, 336);
alignment2 = gtk_alignment_new (0.5, 0.5, 1, 1);
gtk_widget_set_name (alignment2, "alignment2");
gtk_widget_show (alignment2);
gtk_container_add (GTK_CONTAINER (frame2), alignment2);
gtk_alignment_set_padding (GTK_ALIGNMENT (alignment2), 0, 0, 12, 0);
scrolledwindow2 = gtk_scrolled_window_new (NULL, NULL);
gtk_widget_set_name (scrolledwindow2, "scrolledwindow2");
gtk_widget_show (scrolledwindow2);
gtk_container_add (GTK_CONTAINER (alignment2), scrolledwindow2);
gtk_scrolled_window_set_shadow_type (GTK_SCROLLED_WINDOW (scrolledwindow2), GTK_SHADOW_IN);
padtreeview = gtk_tree_view_new ();
gtk_widget_set_name (padtreeview, "padtreeview");
gtk_widget_show (padtreeview);
gtk_container_add (GTK_CONTAINER (scrolledwindow2), padtreeview);
gtk_widget_set_extension_events (padtreeview, GDK_EXTENSION_EVENTS_ALL);
gtk_tree_view_set_rules_hint (GTK_TREE_VIEW (padtreeview), TRUE);
gtk_tree_view_set_enable_search (GTK_TREE_VIEW (padtreeview), FALSE);
gtk_tree_view_set_hover_expand (GTK_TREE_VIEW (padtreeview), TRUE);
label7 = gtk_label_new (_("Key Settings"));
gtk_widget_set_name (label7, "label7");
gtk_widget_show (label7);
gtk_frame_set_label_widget (GTK_FRAME (frame2), label7);
remove_button = gtk_button_new_with_mnemonic (_("Remove"));
gtk_widget_set_name (remove_button, "remove_button");
gtk_widget_show (remove_button);
gtk_fixed_put (GTK_FIXED (fixed1), remove_button, 248, 352);
gtk_widget_set_size_request (remove_button, 0, 0);
dialog_action_area1 = GTK_DIALOG (Conf)->action_area;
gtk_widget_set_name (dialog_action_area1, "dialog_action_area1");
gtk_widget_show (dialog_action_area1);
gtk_button_box_set_layout (GTK_BUTTON_BOX (dialog_action_area1), GTK_BUTTONBOX_END);
okbutton1 = gtk_button_new_from_stock ("gtk-ok");
gtk_widget_set_name (okbutton1, "okbutton1");
gtk_widget_show (okbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (Conf), okbutton1, GTK_RESPONSE_OK);
GTK_WIDGET_SET_FLAGS (okbutton1, GTK_CAN_DEFAULT);
cancelbutton1 = gtk_button_new_from_stock ("gtk-cancel");
gtk_widget_set_name (cancelbutton1, "cancelbutton1");
gtk_widget_show (cancelbutton1);
gtk_dialog_add_action_widget (GTK_DIALOG (Conf), cancelbutton1, GTK_RESPONSE_CANCEL);
GTK_WIDGET_SET_FLAGS (cancelbutton1, GTK_CAN_DEFAULT);
g_signal_connect ((gpointer) PAD1, "clicked",
G_CALLBACK (OnConf_Pad1),
NULL);
g_signal_connect ((gpointer) PAD2, "clicked",
G_CALLBACK (OnConf_Pad2),
NULL);
g_signal_connect ((gpointer) PAD3, "clicked",
G_CALLBACK (OnConf_Pad3),
NULL);
g_signal_connect ((gpointer) PAD4, "clicked",
G_CALLBACK (OnConf_Pad4),
NULL);
g_signal_connect ((gpointer) joydevicescombo, "changed",
G_CALLBACK (on_joydevicescombo_changed),
NULL);
g_signal_connect ((gpointer) Left, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Up, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Right, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Down, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) L2, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) L1, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Select, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Start, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) L3, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) R3, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Analog, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Square, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Triangle, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Circle, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Cross, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) R2, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) R1, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) L_Up, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) L_Left, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Lx, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Ly, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) L_Down, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) L_Right, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) checkbutton_reverselx, "toggled",
G_CALLBACK (on_checkbutton_reverselx_toggled),
NULL);
g_signal_connect ((gpointer) checkbutton_reversely, "toggled",
G_CALLBACK (on_checkbutton_reversely_toggled),
NULL);
g_signal_connect ((gpointer) R_Up, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) R_Left, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Rx, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) Ry, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) R_Right, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) R_Down, "clicked",
G_CALLBACK (OnConf_Key),
NULL);
g_signal_connect ((gpointer) forcefeedback, "toggled",
G_CALLBACK (on_forcefeedback_toggled),
NULL);
g_signal_connect ((gpointer) checkbutton_reverserx, "toggled",
G_CALLBACK (on_checkbutton_reverserx_toggled),
NULL);
g_signal_connect ((gpointer) checkbutton_reversery, "toggled",
G_CALLBACK (on_checkbutton_reversery_toggled),
NULL);
g_signal_connect ((gpointer) remove_button, "clicked",
G_CALLBACK (on_Remove),
NULL);
g_signal_connect ((gpointer) okbutton1, "clicked",
G_CALLBACK (OnConf_Ok),
NULL);
g_signal_connect ((gpointer) cancelbutton1, "clicked",
G_CALLBACK (OnConf_Cancel),
NULL);
/* Store pointers to all widgets, for use by lookup_widget(). */
GLADE_HOOKUP_OBJECT_NO_REF (Conf, Conf, "Conf");
GLADE_HOOKUP_OBJECT_NO_REF (Conf, dialog_vbox1, "dialog_vbox1");
GLADE_HOOKUP_OBJECT (Conf, vbox1, "vbox1");
GLADE_HOOKUP_OBJECT (Conf, frame1, "frame1");
GLADE_HOOKUP_OBJECT (Conf, alignment1, "alignment1");
GLADE_HOOKUP_OBJECT (Conf, hbox1, "hbox1");
GLADE_HOOKUP_OBJECT (Conf, PAD1, "PAD1");
GLADE_HOOKUP_OBJECT (Conf, PAD2, "PAD2");
GLADE_HOOKUP_OBJECT (Conf, PAD3, "PAD3");
GLADE_HOOKUP_OBJECT (Conf, PAD4, "PAD4");
GLADE_HOOKUP_OBJECT (Conf, label2, "label2");
GLADE_HOOKUP_OBJECT (Conf, vbox2, "vbox2");
GLADE_HOOKUP_OBJECT (Conf, label5, "label5");
GLADE_HOOKUP_OBJECT (Conf, joydevicescombo, "joydevicescombo");
GLADE_HOOKUP_OBJECT (Conf, fixed1, "fixed1");
GLADE_HOOKUP_OBJECT (Conf, vbox3, "vbox3");
GLADE_HOOKUP_OBJECT (Conf, hbox3, "hbox3");
GLADE_HOOKUP_OBJECT (Conf, fixed2, "fixed2");
GLADE_HOOKUP_OBJECT (Conf, fixed3, "fixed3");
GLADE_HOOKUP_OBJECT (Conf, Left, "Left");
GLADE_HOOKUP_OBJECT (Conf, Up, "Up");
GLADE_HOOKUP_OBJECT (Conf, Right, "Right");
GLADE_HOOKUP_OBJECT (Conf, Down, "Down");
GLADE_HOOKUP_OBJECT (Conf, L2, "L2");
GLADE_HOOKUP_OBJECT (Conf, L1, "L1");
GLADE_HOOKUP_OBJECT (Conf, Select, "Select");
GLADE_HOOKUP_OBJECT (Conf, Start, "Start");
GLADE_HOOKUP_OBJECT (Conf, L3, "L3");
GLADE_HOOKUP_OBJECT (Conf, R3, "R3");
GLADE_HOOKUP_OBJECT (Conf, Analog, "Analog");
GLADE_HOOKUP_OBJECT (Conf, Square, "Square");
GLADE_HOOKUP_OBJECT (Conf, Triangle, "Triangle");
GLADE_HOOKUP_OBJECT (Conf, Circle, "Circle");
GLADE_HOOKUP_OBJECT (Conf, Cross, "Cross");
GLADE_HOOKUP_OBJECT (Conf, R2, "R2");
GLADE_HOOKUP_OBJECT (Conf, R1, "R1");
GLADE_HOOKUP_OBJECT (Conf, label3, "label3");
GLADE_HOOKUP_OBJECT (Conf, label6, "label6");
GLADE_HOOKUP_OBJECT (Conf, L_Up, "L_Up");
GLADE_HOOKUP_OBJECT (Conf, L_Left, "L_Left");
GLADE_HOOKUP_OBJECT (Conf, Lx, "Lx");
GLADE_HOOKUP_OBJECT (Conf, Ly, "Ly");
GLADE_HOOKUP_OBJECT (Conf, L_Down, "L_Down");
GLADE_HOOKUP_OBJECT (Conf, L_Right, "L_Right");
GLADE_HOOKUP_OBJECT (Conf, checkbutton_reverselx, "checkbutton_reverselx");
GLADE_HOOKUP_OBJECT (Conf, checkbutton_reversely, "checkbutton_reversely");
GLADE_HOOKUP_OBJECT (Conf, R_Up, "R_Up");
GLADE_HOOKUP_OBJECT (Conf, R_Left, "R_Left");
GLADE_HOOKUP_OBJECT (Conf, Rx, "Rx");
GLADE_HOOKUP_OBJECT (Conf, Ry, "Ry");
GLADE_HOOKUP_OBJECT (Conf, R_Right, "R_Right");
GLADE_HOOKUP_OBJECT (Conf, R_Down, "R_Down");
GLADE_HOOKUP_OBJECT (Conf, forcefeedback, "forcefeedback");
GLADE_HOOKUP_OBJECT (Conf, checkbutton_reverserx, "checkbutton_reverserx");
GLADE_HOOKUP_OBJECT (Conf, checkbutton_reversery, "checkbutton_reversery");
GLADE_HOOKUP_OBJECT (Conf, frame2, "frame2");
GLADE_HOOKUP_OBJECT (Conf, alignment2, "alignment2");
GLADE_HOOKUP_OBJECT (Conf, scrolledwindow2, "scrolledwindow2");
GLADE_HOOKUP_OBJECT (Conf, padtreeview, "padtreeview");
GLADE_HOOKUP_OBJECT (Conf, label7, "label7");
GLADE_HOOKUP_OBJECT (Conf, remove_button, "remove_button");
GLADE_HOOKUP_OBJECT_NO_REF (Conf, dialog_action_area1, "dialog_action_area1");
GLADE_HOOKUP_OBJECT (Conf, okbutton1, "okbutton1");
GLADE_HOOKUP_OBJECT (Conf, cancelbutton1, "cancelbutton1");
return Conf;
}

View File

@ -0,0 +1,6 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
GtkWidget* create_About (void);
GtkWidget* create_Conf (void);

View File

@ -0,0 +1,406 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#include "linux.h"
Display *GSdsp;
const char* s_pGuiKeyMap[] =
{
"L2", "R2", "L1", "R1",
"Triangle", "Circle", "Cross", "Square",
"Select", "L3", "R3", "Start",
"Up", "Right", "Down", "Left",
"Lx", "Rx", "Ly", "Ry",
"L_Up", "L_Right", "L_Down", "L_Left",
"R_Up", "R_Right", "R_Down", "R_Left"
};
s32 _PADopen(void *pDsp)
{
GSdsp = *(Display**)pDsp;
SetAutoRepeat(false);
return 0;
}
void _PADclose()
{
SetAutoRepeat(true);
vector<JoystickInfo*>::iterator it = s_vjoysticks.begin();
// Delete everything in the vector vjoysticks.
while (it != s_vjoysticks.end())
{
delete *it;
it ++;
}
s_vjoysticks.clear();
}
int _GetJoystickIdFromPAD(int pad)
{
// select the right joystick id
int joyid = -1;
for (int p = 0; p < PADSUBKEYS; p++)
{
for (int i = 0; i < PADKEYS; ++i)
{
u32 temp = get_key(PadEnum[pad][p],i);
KeyType k = type_of_key(temp);
if (k == PAD_JOYSTICK || k == PAD_JOYBUTTONS)
{
joyid = key_to_joystick_id(temp);
return joyid;
}
}
}
if (!JoystickIdWithinBounds(joyid))
{
// get first unused joystick
for (joyid = 0; joyid < s_vjoysticks.size(); ++joyid)
{
if (s_vjoysticks[joyid]->GetPAD() < 0) break;
}
}
return joyid;
}
EXPORT_C_(void) PADupdate(int pad)
{
// Poll keyboard.
PollForKeyboardInput(pad);
// joystick info
SDL_JoystickUpdate();
for (int i = 0; i < PADKEYS; i++)
{
int key = get_key(PadEnum[pad][0], i);
if (JoystickIdWithinBounds(key_to_joystick_id(key)))
{
JoystickInfo* pjoy = s_vjoysticks[key_to_joystick_id(key)];
int pad = (pjoy)->GetPAD();
KeyType k = type_of_key(key);
switch (k)
{
case PAD_JOYBUTTONS:
{
int value = SDL_JoystickGetButton((pjoy)->GetJoy(), key_to_button(key));
if (value)
clear_bit(status[pad], i); // released
else
set_bit(status[pad], i); // pressed
break;
}
case PAD_JOYSTICK:
{
int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), key_to_axis(key));
switch (i)
{
case PAD_LX:
case PAD_LY:
case PAD_RX:
case PAD_RY:
if (abs(value) > (pjoy)->GetDeadzone(value))
Analog::ConfigurePad(i, pad, value);
else
Analog::ResetPad(i, pad);
break;
}
break;
}
#ifdef EXPERIMENTAL_POV_CODE
case PAD_HAT:
{
int value = SDL_JoystickGetHat((pjoy)->GetJoy(), key_to_axis(key));
//PAD_LOG("Hat = %d for key %d\n", key_to_hat_dir(key), key);
if ((value != SDL_HAT_CENTERED) && (key_to_hat_dir(key) == value))
{
if ((value == SDL_HAT_UP) || (value == SDL_HAT_RIGHT) || (value == SDL_HAT_DOWN) ||(value == SDL_HAT_LEFT))
{
set_bit(status[pad], i);
PAD_LOG("Registered %s. Set (%d)\n", HatName(value), i);
}
else
{
clear_bit(status[pad], i);
}
}
else
{
clear_bit(status[pad], i);
}
break;
}
#endif
case PAD_POV:
{
int value = SDL_JoystickGetAxis((pjoy)->GetJoy(), key_to_axis(key));
if (key_to_pov_sign(key) && (value < -2048))
clear_bit(status[pad], i);
else if (!key_to_pov_sign(key) && (value > 2048))
clear_bit(status[pad], i);
else
set_bit(status[pad], i);
break;
}
default: break;
}
}
}
}
string KeyName(int pad, int key)
{
string tmp;
KeyType k = type_of_key(get_key(pad, key));
switch (k)
{
case PAD_KEYBOARD:
{
char* pstr = KeysymToChar(pad_to_key(get_key(pad, key)));
if (pstr != NULL) tmp = pstr;
break;
}
case PAD_JOYBUTTONS:
{
int button = key_to_button(get_key(pad, key));
tmp.resize(28);
sprintf(&tmp[0], "JBut %d", button);
break;
}
case PAD_JOYSTICK:
{
int axis = key_to_axis(get_key(pad, key));
tmp.resize(28);
sprintf(&tmp[0], "JAxis %d", axis);
break;
}
#ifdef EXPERIMENTAL_POV_CODE
case PAD_HAT:
{
int axis = key_to_axis(get_key(pad, key));
tmp.resize(28);
switch(key_to_hat_dir(get_key(pad, key)))
{
case SDL_HAT_UP:
sprintf(&tmp[0], "JPOVU-%d", axis);
break;
case SDL_HAT_RIGHT:
sprintf(&tmp[0], "JPOVR-%d", axis);
break;
case SDL_HAT_DOWN:
sprintf(&tmp[0], "JPOVD-%d", axis);
break;
case SDL_HAT_LEFT:
sprintf(&tmp[0], "JPOVL-%d", axis);
break;
}
break;
}
#endif
case PAD_POV:
{
tmp.resize(28);
sprintf(&tmp[0], "JPOV %d%s", key_to_axis(get_key(pad, key)), key_to_pov_sign(get_key(pad, key)) ? "-" : "+");
break;
}
default: break;
}
return tmp;
}
void UpdateConf(int pad)
{
initLogging();
s_selectedpad = pad;
init_tree_view();
int i;
GtkWidget *Btn;
for (i = 0; i < ArraySize(s_pGuiKeyMap); i++)
{
if (s_pGuiKeyMap[i] == NULL) continue;
Btn = lookup_widget(Conf, s_pGuiKeyMap[i]);
if (Btn == NULL)
{
PAD_LOG("OnePAD: cannot find key %s\n", s_pGuiKeyMap[i]);
continue;
}
gtk_object_set_user_data(GTK_OBJECT(Btn), (void*)(PADKEYS * pad + i));
}
// check bounds
int joyid = _GetJoystickIdFromPAD(pad);
if (JoystickIdWithinBounds(joyid))
gtk_combo_box_set_active(GTK_COMBO_BOX(s_devicecombo), joyid); // select the combo
else
gtk_combo_box_set_active(GTK_COMBO_BOX(s_devicecombo), s_vjoysticks.size()); // no gamepad
int padopts = conf.options >> (16 * pad);
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);
}
int GetLabelId(GtkWidget *label)
{
if (label == NULL)
{
PAD_LOG("couldn't find correct label\n");
return -1;
}
return (int)(uptr)gtk_object_get_user_data(GTK_OBJECT(label));
}
void OnConf_Key(GtkButton *button, gpointer user_data)
{
bool captured = false;
const char* buttonname = gtk_widget_get_name(GTK_WIDGET(button));
GtkWidget* label = lookup_widget(Conf, buttonname);
int id = GetLabelId(label);
if (id == -1) return;
int pad = id / PADKEYS;
int key = id % PADKEYS;
// save the joystick states
UpdateJoysticks();
while (!captured)
{
vector<JoystickInfo*>::iterator itjoy;
char *tmp;
u32 pkey = get_key(pad, key);
if (PollX11Keyboard(tmp, pkey))
{
set_key(pad, key, pkey);
captured = true;
break;
}
SDL_JoystickUpdate();
itjoy = s_vjoysticks.begin();
while ((itjoy != s_vjoysticks.end()) && (!captured))
{
int jbutton, direction;
pkey = get_key(pad, key);
if ((*itjoy)->PollButtons(jbutton, pkey))
{
set_key(pad, key, pkey);
captured = true;
break;
}
bool negative = false;
bool pov = (!((key == PAD_RY) || (key == PAD_LY) || (key == PAD_RX) || (key == PAD_LX)));
if ((*itjoy)->PollAxes(pov, jbutton, negative, pkey))
{
set_key(pad, key, pkey);
captured = true;
break;
}
#ifdef EXPERIMENTAL_POV_CODE
if ((*itjoy)->PollHats(jbutton, direction, pkey))
{
set_key(pad, key, pkey);
captured = true;
break;
}
#endif
itjoy++;
}
}
init_tree_view();
}
EXPORT_C_(void) PADconfigure()
{
char strcurdir[256];
getcwd(strcurdir, 256);
s_strIniPath = strcurdir;
s_strIniPath += "/inis/OnePAD.ini";
LoadConfig();
Conf = create_Conf();
// recreate
JoystickInfo::EnumerateJoysticks(s_vjoysticks);
s_devicecombo = lookup_widget(Conf, "joydevicescombo");
// fill the combo
char str[255];
vector<JoystickInfo*>::iterator it = s_vjoysticks.begin();
// Delete everything in the vector vjoysticks.
while (it != s_vjoysticks.end())
{
sprintf(str, "%d: %s - but: %d, axes: %d, hats: %d", (*it)->GetId(), (*it)->GetName().c_str(),
(*it)->GetNumButtons(), (*it)->GetNumAxes(), (*it)->GetNumHats());
gtk_combo_box_append_text(GTK_COMBO_BOX(s_devicecombo), str);
it++;
}
gtk_combo_box_append_text(GTK_COMBO_BOX(s_devicecombo), "No Gamepad");
UpdateConf(0);
gtk_widget_show_all(Conf);
gtk_main();
}

View File

@ -0,0 +1,45 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#include "joystick.h"
#include "keyboard.h"
#include "onepad.h"
#include <string.h>
#include <gtk/gtk.h>
#include <gdk/gdkkeysyms.h>
#include <pthread.h>
extern "C"
{
#include "interface.h"
#include "support.h"
#include "callbacks.h"
}
extern GtkWidget *Conf, *s_devicecombo;
extern string s_strIniPath;
extern void init_tree_view();
extern void destroy_tree_view();
#define is_checked(main_widget, widget_name) (gtk_toggle_button_get_active(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name))))
#define set_checked(main_widget,widget_name, state) gtk_toggle_button_set_state(GTK_TOGGLE_BUTTON(lookup_widget(main_widget, widget_name)), state)

File diff suppressed because it is too large Load Diff

View File

@ -0,0 +1,12 @@
<?xml version="1.0" standalone="no"?> <!--*- mode: xml -*-->
<!DOCTYPE glade-project SYSTEM "http://glade.gnome.org/glade-project-2.0.dtd">
<glade-project>
<name>Linux</name>
<program_name>linux</program_name>
<gnome_support>FALSE</gnome_support>
<use_widget_names>TRUE</use_widget_names>
<output_main_file>FALSE</output_main_file>
<output_build_files>FALSE</output_build_files>
<backup_source_files>FALSE</backup_source_files>
</glade-project>

View File

@ -0,0 +1,144 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <sys/types.h>
#include <sys/stat.h>
#include <unistd.h>
#include <string.h>
#include <stdio.h>
#include <gtk/gtk.h>
#include "support.h"
GtkWidget*
lookup_widget (GtkWidget *widget,
const gchar *widget_name)
{
GtkWidget *parent, *found_widget;
for (;;)
{
if (GTK_IS_MENU (widget))
parent = gtk_menu_get_attach_widget (GTK_MENU (widget));
else
parent = widget->parent;
if (!parent)
parent = (GtkWidget*) g_object_get_data (G_OBJECT (widget), "GladeParentKey");
if (parent == NULL)
break;
widget = parent;
}
found_widget = (GtkWidget*) g_object_get_data (G_OBJECT (widget),
widget_name);
if (!found_widget)
g_warning ("Widget not found: %s", widget_name);
return found_widget;
}
static GList *pixmaps_directories = NULL;
/* Use this function to set the directory containing installed pixmaps. */
void
add_pixmap_directory (const gchar *directory)
{
pixmaps_directories = g_list_prepend (pixmaps_directories,
g_strdup (directory));
}
/* This is an internally used function to find pixmap files. */
static gchar*
find_pixmap_file (const gchar *filename)
{
GList *elem;
/* We step through each of the pixmaps directory to find it. */
elem = pixmaps_directories;
while (elem)
{
gchar *pathname = g_strdup_printf ("%s%s%s", (gchar*)elem->data,
G_DIR_SEPARATOR_S, filename);
if (g_file_test (pathname, G_FILE_TEST_EXISTS))
return pathname;
g_free (pathname);
elem = elem->next;
}
return NULL;
}
/* This is an internally used function to create pixmaps. */
GtkWidget*
create_pixmap (GtkWidget *widget,
const gchar *filename)
{
gchar *pathname = NULL;
GtkWidget *pixmap;
if (!filename || !filename[0])
return gtk_image_new ();
pathname = find_pixmap_file (filename);
if (!pathname)
{
g_warning (_("Couldn't find pixmap file: %s"), filename);
return gtk_image_new ();
}
pixmap = gtk_image_new_from_file (pathname);
g_free (pathname);
return pixmap;
}
/* This is an internally used function to create pixmaps. */
GdkPixbuf*
create_pixbuf (const gchar *filename)
{
gchar *pathname = NULL;
GdkPixbuf *pixbuf;
GError *error = NULL;
if (!filename || !filename[0])
return NULL;
pathname = find_pixmap_file (filename);
if (!pathname)
{
g_warning (_("Couldn't find pixmap file: %s"), filename);
return NULL;
}
pixbuf = gdk_pixbuf_new_from_file (pathname, &error);
if (!pixbuf)
{
fprintf (stderr, "Failed to load pixbuf file: %s: %s\n",
pathname, error->message);
g_error_free (error);
}
g_free (pathname);
return pixbuf;
}
/* This is used to set ATK action descriptions. */
void
glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description)
{
gint n_actions, i;
n_actions = atk_action_get_n_actions (action);
for (i = 0; i < n_actions; i++)
{
if (!strcmp (atk_action_get_name (action, i), action_name))
atk_action_set_description (action, i, description);
}
}

View File

@ -0,0 +1,69 @@
/*
* DO NOT EDIT THIS FILE - it is generated by Glade.
*/
#ifdef HAVE_CONFIG_H
# include <config.h>
#endif
#include <gtk/gtk.h>
/*
* Standard gettext macros.
*/
#ifdef ENABLE_NLS
# include <libintl.h>
# undef _
# define _(String) dgettext (PACKAGE, String)
# define Q_(String) g_strip_context ((String), gettext (String))
# ifdef gettext_noop
# define N_(String) gettext_noop (String)
# else
# define N_(String) (String)
# endif
#else
# define textdomain(String) (String)
# define gettext(String) (String)
# define dgettext(Domain,Message) (Message)
# define dcgettext(Domain,Message,Type) (Message)
# define bindtextdomain(Domain,Directory) (Domain)
# define _(String) (String)
# define Q_(String) g_strip_context ((String), (String))
# define N_(String) (String)
#endif
/*
* Public Functions.
*/
/*
* This function returns a widget in a component created by Glade.
* Call it with the toplevel widget in the component (i.e. a window/dialog),
* or alternatively any widget in the component, and the name of the widget
* you want returned.
*/
GtkWidget* lookup_widget (GtkWidget *widget,
const gchar *widget_name);
/* Use this function to set the directory containing installed pixmaps. */
void add_pixmap_directory (const gchar *directory);
/*
* Private Functions.
*/
/* This is used to create the pixmaps used in the interface. */
GtkWidget* create_pixmap (GtkWidget *widget,
const gchar *filename);
/* This is used to create the pixbufs used in the interface. */
GdkPixbuf* create_pixbuf (const gchar *filename);
/* This is used to set ATK action descriptions. */
void glade_set_atk_action_description (AtkAction *action,
const gchar *action_name,
const gchar *description);

View File

@ -0,0 +1,26 @@
# Create a shared library libOnePAD
AUTOMAKE_OPTIONS = foreign
noinst_LIBRARIES = libOnePAD.a
INCLUDES = -I@srcdir@/../../common/include
libOnePAD_a_CXXFLAGS = $(shell pkg-config --cflags gtk+-2.0)
libOnePAD_a_CFLAGS = $(shell pkg-config --cflags gtk+-2.0)
# Create a shared object by faking an exe (thanks to ODE makefiles)
traplibdir=$(prefix)
if DEBUGBUILD
preext=d
endif
EXEEXT=$(preext)@so_ext@
traplib_PROGRAMS=libOnePAD
libOnePAD_SOURCES=
libOnePAD_DEPENDENCIES = libOnePAD.a
libOnePAD_LDFLAGS= @SHARED_LDFLAGS@
libOnePAD_LDFLAGS+=-Wl,-soname,@ZEROPAD_SONAME@
libOnePAD_LDADD=$(libOnePAD_a_OBJECTS)
libOnePAD_a_SOURCES = joystick.cpp analog.cpp analog.h onepad.cpp onepad.h controller.cpp controller.h \
Linux/gui.cpp Linux/linux.cpp Linux/support.c Linux/interface.c keyboard.cpp keyboard.h

View File

973
plugins/onepad/aclocal.m4 vendored Normal file
View File

@ -0,0 +1,973 @@
# generated automatically by aclocal 1.11 -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2007, 2008, 2009 Free Software Foundation, Inc.
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# This program is distributed in the hope that it will be useful,
# but WITHOUT ANY WARRANTY, to the extent permitted by law; without
# even the implied warranty of MERCHANTABILITY or FITNESS FOR A
# PARTICULAR PURPOSE.
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
m4_if(m4_defn([AC_AUTOCONF_VERSION]), [2.63],,
[m4_warning([this file was generated for autoconf 2.63.
You have another version of autoconf. It may work, but is not guaranteed to.
If you have problems, you may need to regenerate the build system entirely.
To do so, use the procedure documented by the package, typically `autoreconf'.])])
# Copyright (C) 2002, 2003, 2005, 2006, 2007, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_AUTOMAKE_VERSION(VERSION)
# ----------------------------
# Automake X.Y traces this macro to ensure aclocal.m4 has been
# generated from the m4 files accompanying Automake X.Y.
# (This private macro should not be called outside this file.)
AC_DEFUN([AM_AUTOMAKE_VERSION],
[am__api_version='1.11'
dnl Some users find AM_AUTOMAKE_VERSION and mistake it for a way to
dnl require some minimum version. Point them to the right macro.
m4_if([$1], [1.11], [],
[AC_FATAL([Do not call $0, use AM_INIT_AUTOMAKE([$1]).])])dnl
])
# _AM_AUTOCONF_VERSION(VERSION)
# -----------------------------
# aclocal traces this macro to find the Autoconf version.
# This is a private macro too. Using m4_define simplifies
# the logic in aclocal, which can simply ignore this definition.
m4_define([_AM_AUTOCONF_VERSION], [])
# AM_SET_CURRENT_AUTOMAKE_VERSION
# -------------------------------
# Call AM_AUTOMAKE_VERSION and AM_AUTOMAKE_VERSION so they can be traced.
# This function is AC_REQUIREd by AM_INIT_AUTOMAKE.
AC_DEFUN([AM_SET_CURRENT_AUTOMAKE_VERSION],
[AM_AUTOMAKE_VERSION([1.11])dnl
m4_ifndef([AC_AUTOCONF_VERSION],
[m4_copy([m4_PACKAGE_VERSION], [AC_AUTOCONF_VERSION])])dnl
_AM_AUTOCONF_VERSION(m4_defn([AC_AUTOCONF_VERSION]))])
# Figure out how to run the assembler. -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 5
# AM_PROG_AS
# ----------
AC_DEFUN([AM_PROG_AS],
[# By default we simply use the C compiler to build assembly code.
AC_REQUIRE([AC_PROG_CC])
test "${CCAS+set}" = set || CCAS=$CC
test "${CCASFLAGS+set}" = set || CCASFLAGS=$CFLAGS
AC_ARG_VAR([CCAS], [assembler compiler command (defaults to CC)])
AC_ARG_VAR([CCASFLAGS], [assembler compiler flags (defaults to CFLAGS)])
_AM_IF_OPTION([no-dependencies],, [_AM_DEPENDENCIES([CCAS])])dnl
])
# AM_AUX_DIR_EXPAND -*- Autoconf -*-
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# For projects using AC_CONFIG_AUX_DIR([foo]), Autoconf sets
# $ac_aux_dir to `$srcdir/foo'. In other projects, it is set to
# `$srcdir', `$srcdir/..', or `$srcdir/../..'.
#
# Of course, Automake must honor this variable whenever it calls a
# tool from the auxiliary directory. The problem is that $srcdir (and
# therefore $ac_aux_dir as well) can be either absolute or relative,
# depending on how configure is run. This is pretty annoying, since
# it makes $ac_aux_dir quite unusable in subdirectories: in the top
# source directory, any form will work fine, but in subdirectories a
# relative path needs to be adjusted first.
#
# $ac_aux_dir/missing
# fails when called from a subdirectory if $ac_aux_dir is relative
# $top_srcdir/$ac_aux_dir/missing
# fails if $ac_aux_dir is absolute,
# fails when called from a subdirectory in a VPATH build with
# a relative $ac_aux_dir
#
# The reason of the latter failure is that $top_srcdir and $ac_aux_dir
# are both prefixed by $srcdir. In an in-source build this is usually
# harmless because $srcdir is `.', but things will broke when you
# start a VPATH build or use an absolute $srcdir.
#
# So we could use something similar to $top_srcdir/$ac_aux_dir/missing,
# iff we strip the leading $srcdir from $ac_aux_dir. That would be:
# am_aux_dir='\$(top_srcdir)/'`expr "$ac_aux_dir" : "$srcdir//*\(.*\)"`
# and then we would define $MISSING as
# MISSING="\${SHELL} $am_aux_dir/missing"
# This will work as long as MISSING is not called from configure, because
# unfortunately $(top_srcdir) has no meaning in configure.
# However there are other variables, like CC, which are often used in
# configure, and could therefore not use this "fixed" $ac_aux_dir.
#
# Another solution, used here, is to always expand $ac_aux_dir to an
# absolute PATH. The drawback is that using absolute paths prevent a
# configured tree to be moved without reconfiguration.
AC_DEFUN([AM_AUX_DIR_EXPAND],
[dnl Rely on autoconf to set up CDPATH properly.
AC_PREREQ([2.50])dnl
# expand $ac_aux_dir to an absolute path
am_aux_dir=`cd $ac_aux_dir && pwd`
])
# AM_CONDITIONAL -*- Autoconf -*-
# Copyright (C) 1997, 2000, 2001, 2003, 2004, 2005, 2006, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 9
# AM_CONDITIONAL(NAME, SHELL-CONDITION)
# -------------------------------------
# Define a conditional.
AC_DEFUN([AM_CONDITIONAL],
[AC_PREREQ(2.52)dnl
ifelse([$1], [TRUE], [AC_FATAL([$0: invalid condition: $1])],
[$1], [FALSE], [AC_FATAL([$0: invalid condition: $1])])dnl
AC_SUBST([$1_TRUE])dnl
AC_SUBST([$1_FALSE])dnl
_AM_SUBST_NOTMAKE([$1_TRUE])dnl
_AM_SUBST_NOTMAKE([$1_FALSE])dnl
m4_define([_AM_COND_VALUE_$1], [$2])dnl
if $2; then
$1_TRUE=
$1_FALSE='#'
else
$1_TRUE='#'
$1_FALSE=
fi
AC_CONFIG_COMMANDS_PRE(
[if test -z "${$1_TRUE}" && test -z "${$1_FALSE}"; then
AC_MSG_ERROR([[conditional "$1" was never defined.
Usually this means the macro was only invoked conditionally.]])
fi])])
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2006, 2009
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 10
# There are a few dirty hacks below to avoid letting `AC_PROG_CC' be
# written in clear, in which case automake, when reading aclocal.m4,
# will think it sees a *use*, and therefore will trigger all it's
# C support machinery. Also note that it means that autoscan, seeing
# CC etc. in the Makefile, will ask for an AC_PROG_CC use...
# _AM_DEPENDENCIES(NAME)
# ----------------------
# See how the compiler implements dependency checking.
# NAME is "CC", "CXX", "GCJ", or "OBJC".
# We try a few techniques and use that to set a single cache variable.
#
# We don't AC_REQUIRE the corresponding AC_PROG_CC since the latter was
# modified to invoke _AM_DEPENDENCIES(CC); we would have a circular
# dependency, and given that the user is not expected to run this macro,
# just rely on AC_PROG_CC.
AC_DEFUN([_AM_DEPENDENCIES],
[AC_REQUIRE([AM_SET_DEPDIR])dnl
AC_REQUIRE([AM_OUTPUT_DEPENDENCY_COMMANDS])dnl
AC_REQUIRE([AM_MAKE_INCLUDE])dnl
AC_REQUIRE([AM_DEP_TRACK])dnl
ifelse([$1], CC, [depcc="$CC" am_compiler_list=],
[$1], CXX, [depcc="$CXX" am_compiler_list=],
[$1], OBJC, [depcc="$OBJC" am_compiler_list='gcc3 gcc'],
[$1], UPC, [depcc="$UPC" am_compiler_list=],
[$1], GCJ, [depcc="$GCJ" am_compiler_list='gcc3 gcc'],
[depcc="$$1" am_compiler_list=])
AC_CACHE_CHECK([dependency style of $depcc],
[am_cv_$1_dependencies_compiler_type],
[if test -z "$AMDEP_TRUE" && test -f "$am_depcomp"; then
# We make a subdir and do the tests there. Otherwise we can end up
# making bogus files that we don't know about and never remove. For
# instance it was reported that on HP-UX the gcc test will end up
# making a dummy file named `D' -- because `-MD' means `put the output
# in D'.
mkdir conftest.dir
# Copy depcomp to subdir because otherwise we won't find it if we're
# using a relative directory.
cp "$am_depcomp" conftest.dir
cd conftest.dir
# We will build objects and dependencies in a subdirectory because
# it helps to detect inapplicable dependency modes. For instance
# both Tru64's cc and ICC support -MD to output dependencies as a
# side effect of compilation, but ICC will put the dependencies in
# the current directory while Tru64 will put them in the object
# directory.
mkdir sub
am_cv_$1_dependencies_compiler_type=none
if test "$am_compiler_list" = ""; then
am_compiler_list=`sed -n ['s/^#*\([a-zA-Z0-9]*\))$/\1/p'] < ./depcomp`
fi
am__universal=false
m4_case([$1], [CC],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac],
[CXX],
[case " $depcc " in #(
*\ -arch\ *\ -arch\ *) am__universal=true ;;
esac])
for depmode in $am_compiler_list; do
# Setup a source with many dependencies, because some compilers
# like to wrap large dependency lists on column 80 (with \), and
# we should not choose a depcomp mode which is confused by this.
#
# We need to recreate these files for each test, as the compiler may
# overwrite some of them when testing with obscure command lines.
# This happens at least with the AIX C compiler.
: > sub/conftest.c
for i in 1 2 3 4 5 6; do
echo '#include "conftst'$i'.h"' >> sub/conftest.c
# Using `: > sub/conftst$i.h' creates only sub/conftst1.h with
# Solaris 8's {/usr,}/bin/sh.
touch sub/conftst$i.h
done
echo "${am__include} ${am__quote}sub/conftest.Po${am__quote}" > confmf
# We check with `-c' and `-o' for the sake of the "dashmstdout"
# mode. It turns out that the SunPro C++ compiler does not properly
# handle `-M -o', and we need to detect this. Also, some Intel
# versions had trouble with output in subdirs
am__obj=sub/conftest.${OBJEXT-o}
am__minus_obj="-o $am__obj"
case $depmode in
gcc)
# This depmode causes a compiler race in universal mode.
test "$am__universal" = false || continue
;;
nosideeffect)
# after this tag, mechanisms are not by side-effect, so they'll
# only be used when explicitly requested
if test "x$enable_dependency_tracking" = xyes; then
continue
else
break
fi
;;
msvisualcpp | msvcmsys)
# This compiler won't grok `-c -o', but also, the minuso test has
# not run yet. These depmodes are late enough in the game, and
# so weak that their functioning should not be impacted.
am__obj=conftest.${OBJEXT-o}
am__minus_obj=
;;
none) break ;;
esac
if depmode=$depmode \
source=sub/conftest.c object=$am__obj \
depfile=sub/conftest.Po tmpdepfile=sub/conftest.TPo \
$SHELL ./depcomp $depcc -c $am__minus_obj sub/conftest.c \
>/dev/null 2>conftest.err &&
grep sub/conftst1.h sub/conftest.Po > /dev/null 2>&1 &&
grep sub/conftst6.h sub/conftest.Po > /dev/null 2>&1 &&
grep $am__obj sub/conftest.Po > /dev/null 2>&1 &&
${MAKE-make} -s -f confmf > /dev/null 2>&1; then
# icc doesn't choke on unknown options, it will just issue warnings
# or remarks (even with -Werror). So we grep stderr for any message
# that says an option was ignored or not supported.
# When given -MP, icc 7.0 and 7.1 complain thusly:
# icc: Command line warning: ignoring option '-M'; no argument required
# The diagnosis changed in icc 8.0:
# icc: Command line remark: option '-MP' not supported
if (grep 'ignoring option' conftest.err ||
grep 'not supported' conftest.err) >/dev/null 2>&1; then :; else
am_cv_$1_dependencies_compiler_type=$depmode
break
fi
fi
done
cd ..
rm -rf conftest.dir
else
am_cv_$1_dependencies_compiler_type=none
fi
])
AC_SUBST([$1DEPMODE], [depmode=$am_cv_$1_dependencies_compiler_type])
AM_CONDITIONAL([am__fastdep$1], [
test "x$enable_dependency_tracking" != xno \
&& test "$am_cv_$1_dependencies_compiler_type" = gcc3])
])
# AM_SET_DEPDIR
# -------------
# Choose a directory name for dependency files.
# This macro is AC_REQUIREd in _AM_DEPENDENCIES
AC_DEFUN([AM_SET_DEPDIR],
[AC_REQUIRE([AM_SET_LEADING_DOT])dnl
AC_SUBST([DEPDIR], ["${am__leading_dot}deps"])dnl
])
# AM_DEP_TRACK
# ------------
AC_DEFUN([AM_DEP_TRACK],
[AC_ARG_ENABLE(dependency-tracking,
[ --disable-dependency-tracking speeds up one-time build
--enable-dependency-tracking do not reject slow dependency extractors])
if test "x$enable_dependency_tracking" != xno; then
am_depcomp="$ac_aux_dir/depcomp"
AMDEPBACKSLASH='\'
fi
AM_CONDITIONAL([AMDEP], [test "x$enable_dependency_tracking" != xno])
AC_SUBST([AMDEPBACKSLASH])dnl
_AM_SUBST_NOTMAKE([AMDEPBACKSLASH])dnl
])
# Generate code to set up dependency tracking. -*- Autoconf -*-
# Copyright (C) 1999, 2000, 2001, 2002, 2003, 2004, 2005, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
#serial 5
# _AM_OUTPUT_DEPENDENCY_COMMANDS
# ------------------------------
AC_DEFUN([_AM_OUTPUT_DEPENDENCY_COMMANDS],
[{
# Autoconf 2.62 quotes --file arguments for eval, but not when files
# are listed without --file. Let's play safe and only enable the eval
# if we detect the quoting.
case $CONFIG_FILES in
*\'*) eval set x "$CONFIG_FILES" ;;
*) set x $CONFIG_FILES ;;
esac
shift
for mf
do
# Strip MF so we end up with the name of the file.
mf=`echo "$mf" | sed -e 's/:.*$//'`
# Check whether this is an Automake generated Makefile or not.
# We used to match only the files named `Makefile.in', but
# some people rename them; so instead we look at the file content.
# Grep'ing the first line is not enough: some people post-process
# each Makefile.in and add a new line on top of each file to say so.
# Grep'ing the whole file is not good either: AIX grep has a line
# limit of 2048, but all sed's we know have understand at least 4000.
if sed -n 's,^#.*generated by automake.*,X,p' "$mf" | grep X >/dev/null 2>&1; then
dirpart=`AS_DIRNAME("$mf")`
else
continue
fi
# Extract the definition of DEPDIR, am__include, and am__quote
# from the Makefile without running `make'.
DEPDIR=`sed -n 's/^DEPDIR = //p' < "$mf"`
test -z "$DEPDIR" && continue
am__include=`sed -n 's/^am__include = //p' < "$mf"`
test -z "am__include" && continue
am__quote=`sed -n 's/^am__quote = //p' < "$mf"`
# When using ansi2knr, U may be empty or an underscore; expand it
U=`sed -n 's/^U = //p' < "$mf"`
# Find all dependency output files, they are included files with
# $(DEPDIR) in their names. We invoke sed twice because it is the
# simplest approach to changing $(DEPDIR) to its actual value in the
# expansion.
for file in `sed -n "
s/^$am__include $am__quote\(.*(DEPDIR).*\)$am__quote"'$/\1/p' <"$mf" | \
sed -e 's/\$(DEPDIR)/'"$DEPDIR"'/g' -e 's/\$U/'"$U"'/g'`; do
# Make sure the directory exists.
test -f "$dirpart/$file" && continue
fdir=`AS_DIRNAME(["$file"])`
AS_MKDIR_P([$dirpart/$fdir])
# echo "creating $dirpart/$file"
echo '# dummy' > "$dirpart/$file"
done
done
}
])# _AM_OUTPUT_DEPENDENCY_COMMANDS
# AM_OUTPUT_DEPENDENCY_COMMANDS
# -----------------------------
# This macro should only be invoked once -- use via AC_REQUIRE.
#
# This code is only required when automatic dependency tracking
# is enabled. FIXME. This creates each `.P' file that we will
# need in order to bootstrap the dependency handling code.
AC_DEFUN([AM_OUTPUT_DEPENDENCY_COMMANDS],
[AC_CONFIG_COMMANDS([depfiles],
[test x"$AMDEP_TRUE" != x"" || _AM_OUTPUT_DEPENDENCY_COMMANDS],
[AMDEP_TRUE="$AMDEP_TRUE" ac_aux_dir="$ac_aux_dir"])
])
# Do all the work for Automake. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 1998, 1999, 2000, 2001, 2002, 2003, 2004,
# 2005, 2006, 2008, 2009 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 16
# This macro actually does too much. Some checks are only needed if
# your package does certain things. But this isn't really a big deal.
# AM_INIT_AUTOMAKE(PACKAGE, VERSION, [NO-DEFINE])
# AM_INIT_AUTOMAKE([OPTIONS])
# -----------------------------------------------
# The call with PACKAGE and VERSION arguments is the old style
# call (pre autoconf-2.50), which is being phased out. PACKAGE
# and VERSION should now be passed to AC_INIT and removed from
# the call to AM_INIT_AUTOMAKE.
# We support both call styles for the transition. After
# the next Automake release, Autoconf can make the AC_INIT
# arguments mandatory, and then we can depend on a new Autoconf
# release and drop the old call support.
AC_DEFUN([AM_INIT_AUTOMAKE],
[AC_PREREQ([2.62])dnl
dnl Autoconf wants to disallow AM_ names. We explicitly allow
dnl the ones we care about.
m4_pattern_allow([^AM_[A-Z]+FLAGS$])dnl
AC_REQUIRE([AM_SET_CURRENT_AUTOMAKE_VERSION])dnl
AC_REQUIRE([AC_PROG_INSTALL])dnl
if test "`cd $srcdir && pwd`" != "`pwd`"; then
# Use -I$(srcdir) only when $(srcdir) != ., so that make's output
# is not polluted with repeated "-I."
AC_SUBST([am__isrc], [' -I$(srcdir)'])_AM_SUBST_NOTMAKE([am__isrc])dnl
# test to see if srcdir already configured
if test -f $srcdir/config.status; then
AC_MSG_ERROR([source directory already configured; run "make distclean" there first])
fi
fi
# test whether we have cygpath
if test -z "$CYGPATH_W"; then
if (cygpath --version) >/dev/null 2>/dev/null; then
CYGPATH_W='cygpath -w'
else
CYGPATH_W=echo
fi
fi
AC_SUBST([CYGPATH_W])
# Define the identity of the package.
dnl Distinguish between old-style and new-style calls.
m4_ifval([$2],
[m4_ifval([$3], [_AM_SET_OPTION([no-define])])dnl
AC_SUBST([PACKAGE], [$1])dnl
AC_SUBST([VERSION], [$2])],
[_AM_SET_OPTIONS([$1])dnl
dnl Diagnose old-style AC_INIT with new-style AM_AUTOMAKE_INIT.
m4_if(m4_ifdef([AC_PACKAGE_NAME], 1)m4_ifdef([AC_PACKAGE_VERSION], 1), 11,,
[m4_fatal([AC_INIT should be called with package and version arguments])])dnl
AC_SUBST([PACKAGE], ['AC_PACKAGE_TARNAME'])dnl
AC_SUBST([VERSION], ['AC_PACKAGE_VERSION'])])dnl
_AM_IF_OPTION([no-define],,
[AC_DEFINE_UNQUOTED(PACKAGE, "$PACKAGE", [Name of package])
AC_DEFINE_UNQUOTED(VERSION, "$VERSION", [Version number of package])])dnl
# Some tools Automake needs.
AC_REQUIRE([AM_SANITY_CHECK])dnl
AC_REQUIRE([AC_ARG_PROGRAM])dnl
AM_MISSING_PROG(ACLOCAL, aclocal-${am__api_version})
AM_MISSING_PROG(AUTOCONF, autoconf)
AM_MISSING_PROG(AUTOMAKE, automake-${am__api_version})
AM_MISSING_PROG(AUTOHEADER, autoheader)
AM_MISSING_PROG(MAKEINFO, makeinfo)
AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
AC_REQUIRE([AM_PROG_INSTALL_STRIP])dnl
AC_REQUIRE([AM_PROG_MKDIR_P])dnl
# We need awk for the "check" target. The system "awk" is bad on
# some platforms.
AC_REQUIRE([AC_PROG_AWK])dnl
AC_REQUIRE([AC_PROG_MAKE_SET])dnl
AC_REQUIRE([AM_SET_LEADING_DOT])dnl
_AM_IF_OPTION([tar-ustar], [_AM_PROG_TAR([ustar])],
[_AM_IF_OPTION([tar-pax], [_AM_PROG_TAR([pax])],
[_AM_PROG_TAR([v7])])])
_AM_IF_OPTION([no-dependencies],,
[AC_PROVIDE_IFELSE([AC_PROG_CC],
[_AM_DEPENDENCIES(CC)],
[define([AC_PROG_CC],
defn([AC_PROG_CC])[_AM_DEPENDENCIES(CC)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_CXX],
[_AM_DEPENDENCIES(CXX)],
[define([AC_PROG_CXX],
defn([AC_PROG_CXX])[_AM_DEPENDENCIES(CXX)])])dnl
AC_PROVIDE_IFELSE([AC_PROG_OBJC],
[_AM_DEPENDENCIES(OBJC)],
[define([AC_PROG_OBJC],
defn([AC_PROG_OBJC])[_AM_DEPENDENCIES(OBJC)])])dnl
])
_AM_IF_OPTION([silent-rules], [AC_REQUIRE([AM_SILENT_RULES])])dnl
dnl The `parallel-tests' driver may need to know about EXEEXT, so add the
dnl `am__EXEEXT' conditional if _AM_COMPILER_EXEEXT was seen. This macro
dnl is hooked onto _AC_COMPILER_EXEEXT early, see below.
AC_CONFIG_COMMANDS_PRE(dnl
[m4_provide_if([_AM_COMPILER_EXEEXT],
[AM_CONDITIONAL([am__EXEEXT], [test -n "$EXEEXT"])])])dnl
])
dnl Hook into `_AC_COMPILER_EXEEXT' early to learn its expansion. Do not
dnl add the conditional right here, as _AC_COMPILER_EXEEXT may be further
dnl mangled by Autoconf and run in a shell conditional statement.
m4_define([_AC_COMPILER_EXEEXT],
m4_defn([_AC_COMPILER_EXEEXT])[m4_provide([_AM_COMPILER_EXEEXT])])
# When config.status generates a header, we must update the stamp-h file.
# This file resides in the same directory as the config header
# that is generated. The stamp files are numbered to have different names.
# Autoconf calls _AC_AM_CONFIG_HEADER_HOOK (when defined) in the
# loop where config.status creates the headers, so we can generate
# our stamp files there.
AC_DEFUN([_AC_AM_CONFIG_HEADER_HOOK],
[# Compute $1's index in $config_headers.
_am_arg=$1
_am_stamp_count=1
for _am_header in $config_headers :; do
case $_am_header in
$_am_arg | $_am_arg:* )
break ;;
* )
_am_stamp_count=`expr $_am_stamp_count + 1` ;;
esac
done
echo "timestamp for $_am_arg" >`AS_DIRNAME(["$_am_arg"])`/stamp-h[]$_am_stamp_count])
# Copyright (C) 2001, 2003, 2005, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_SH
# ------------------
# Define $install_sh.
AC_DEFUN([AM_PROG_INSTALL_SH],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
if test x"${install_sh}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
install_sh="\${SHELL} '$am_aux_dir/install-sh'" ;;
*)
install_sh="\${SHELL} $am_aux_dir/install-sh"
esac
fi
AC_SUBST(install_sh)])
# Copyright (C) 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# Check whether the underlying file-system supports filenames
# with a leading dot. For instance MS-DOS doesn't.
AC_DEFUN([AM_SET_LEADING_DOT],
[rm -rf .tst 2>/dev/null
mkdir .tst 2>/dev/null
if test -d .tst; then
am__leading_dot=.
else
am__leading_dot=_
fi
rmdir .tst 2>/dev/null
AC_SUBST([am__leading_dot])])
# Check to see how 'make' treats includes. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005, 2009 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# AM_MAKE_INCLUDE()
# -----------------
# Check to see how make treats includes.
AC_DEFUN([AM_MAKE_INCLUDE],
[am_make=${MAKE-make}
cat > confinc << 'END'
am__doit:
@echo this is the am__doit target
.PHONY: am__doit
END
# If we don't find an include directive, just comment out the code.
AC_MSG_CHECKING([for style of include used by $am_make])
am__include="#"
am__quote=
_am_result=none
# First try GNU make style include.
echo "include confinc" > confmf
# Ignore all kinds of additional output from `make'.
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=include
am__quote=
_am_result=GNU
;;
esac
# Now try BSD make style include.
if test "$am__include" = "#"; then
echo '.include "confinc"' > confmf
case `$am_make -s -f confmf 2> /dev/null` in #(
*the\ am__doit\ target*)
am__include=.include
am__quote="\""
_am_result=BSD
;;
esac
fi
AC_SUBST([am__include])
AC_SUBST([am__quote])
AC_MSG_RESULT([$_am_result])
rm -f confinc confmf
])
# Fake the existence of programs that GNU maintainers use. -*- Autoconf -*-
# Copyright (C) 1997, 1999, 2000, 2001, 2003, 2004, 2005, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 6
# AM_MISSING_PROG(NAME, PROGRAM)
# ------------------------------
AC_DEFUN([AM_MISSING_PROG],
[AC_REQUIRE([AM_MISSING_HAS_RUN])
$1=${$1-"${am_missing_run}$2"}
AC_SUBST($1)])
# AM_MISSING_HAS_RUN
# ------------------
# Define MISSING if not defined so far and test if it supports --run.
# If it does, set am_missing_run to use it, otherwise, to nothing.
AC_DEFUN([AM_MISSING_HAS_RUN],
[AC_REQUIRE([AM_AUX_DIR_EXPAND])dnl
AC_REQUIRE_AUX_FILE([missing])dnl
if test x"${MISSING+set}" != xset; then
case $am_aux_dir in
*\ * | *\ *)
MISSING="\${SHELL} \"$am_aux_dir/missing\"" ;;
*)
MISSING="\${SHELL} $am_aux_dir/missing" ;;
esac
fi
# Use eval to expand $SHELL
if eval "$MISSING --run true"; then
am_missing_run="$MISSING --run "
else
am_missing_run=
AC_MSG_WARN([`missing' script is too old or missing])
fi
])
# Copyright (C) 2003, 2004, 2005, 2006 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_MKDIR_P
# ---------------
# Check for `mkdir -p'.
AC_DEFUN([AM_PROG_MKDIR_P],
[AC_PREREQ([2.60])dnl
AC_REQUIRE([AC_PROG_MKDIR_P])dnl
dnl Automake 1.8 to 1.9.6 used to define mkdir_p. We now use MKDIR_P,
dnl while keeping a definition of mkdir_p for backward compatibility.
dnl @MKDIR_P@ is magic: AC_OUTPUT adjusts its value for each Makefile.
dnl However we cannot define mkdir_p as $(MKDIR_P) for the sake of
dnl Makefile.ins that do not define MKDIR_P, so we do our own
dnl adjustment using top_builddir (which is defined more often than
dnl MKDIR_P).
AC_SUBST([mkdir_p], ["$MKDIR_P"])dnl
case $mkdir_p in
[[\\/$]]* | ?:[[\\/]]*) ;;
*/*) mkdir_p="\$(top_builddir)/$mkdir_p" ;;
esac
])
# Helper functions for option handling. -*- Autoconf -*-
# Copyright (C) 2001, 2002, 2003, 2005, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 4
# _AM_MANGLE_OPTION(NAME)
# -----------------------
AC_DEFUN([_AM_MANGLE_OPTION],
[[_AM_OPTION_]m4_bpatsubst($1, [[^a-zA-Z0-9_]], [_])])
# _AM_SET_OPTION(NAME)
# ------------------------------
# Set option NAME. Presently that only means defining a flag for this option.
AC_DEFUN([_AM_SET_OPTION],
[m4_define(_AM_MANGLE_OPTION([$1]), 1)])
# _AM_SET_OPTIONS(OPTIONS)
# ----------------------------------
# OPTIONS is a space-separated list of Automake options.
AC_DEFUN([_AM_SET_OPTIONS],
[m4_foreach_w([_AM_Option], [$1], [_AM_SET_OPTION(_AM_Option)])])
# _AM_IF_OPTION(OPTION, IF-SET, [IF-NOT-SET])
# -------------------------------------------
# Execute IF-SET if OPTION is set, IF-NOT-SET otherwise.
AC_DEFUN([_AM_IF_OPTION],
[m4_ifset(_AM_MANGLE_OPTION([$1]), [$2], [$3])])
# Check to make sure that the build environment is sane. -*- Autoconf -*-
# Copyright (C) 1996, 1997, 2000, 2001, 2003, 2005, 2008
# Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 5
# AM_SANITY_CHECK
# ---------------
AC_DEFUN([AM_SANITY_CHECK],
[AC_MSG_CHECKING([whether build environment is sane])
# Just in case
sleep 1
echo timestamp > conftest.file
# Reject unsafe characters in $srcdir or the absolute working directory
# name. Accept space and tab only in the latter.
am_lf='
'
case `pwd` in
*[[\\\"\#\$\&\'\`$am_lf]]*)
AC_MSG_ERROR([unsafe absolute working directory name]);;
esac
case $srcdir in
*[[\\\"\#\$\&\'\`$am_lf\ \ ]]*)
AC_MSG_ERROR([unsafe srcdir value: `$srcdir']);;
esac
# Do `set' in a subshell so we don't clobber the current shell's
# arguments. Must try -L first in case configure is actually a
# symlink; some systems play weird games with the mod time of symlinks
# (eg FreeBSD returns the mod time of the symlink's containing
# directory).
if (
set X `ls -Lt "$srcdir/configure" conftest.file 2> /dev/null`
if test "$[*]" = "X"; then
# -L didn't work.
set X `ls -t "$srcdir/configure" conftest.file`
fi
rm -f conftest.file
if test "$[*]" != "X $srcdir/configure conftest.file" \
&& test "$[*]" != "X conftest.file $srcdir/configure"; then
# If neither matched, then we have a broken ls. This can happen
# if, for instance, CONFIG_SHELL is bash and it inherits a
# broken ls alias from the environment. This has actually
# happened. Such a system could not be considered "sane".
AC_MSG_ERROR([ls -t appears to fail. Make sure there is not a broken
alias in your environment])
fi
test "$[2]" = conftest.file
)
then
# Ok.
:
else
AC_MSG_ERROR([newly created file is older than distributed files!
Check your system clock])
fi
AC_MSG_RESULT(yes)])
# Copyright (C) 2001, 2003, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# AM_PROG_INSTALL_STRIP
# ---------------------
# One issue with vendor `install' (even GNU) is that you can't
# specify the program used to strip binaries. This is especially
# annoying in cross-compiling environments, where the build's strip
# is unlikely to handle the host's binaries.
# Fortunately install-sh will honor a STRIPPROG variable, so we
# always use install-sh in `make install-strip', and initialize
# STRIPPROG with the value of the STRIP variable (set by the user).
AC_DEFUN([AM_PROG_INSTALL_STRIP],
[AC_REQUIRE([AM_PROG_INSTALL_SH])dnl
# Installed binaries are usually stripped using `strip' when the user
# run `make install-strip'. However `strip' might not be the right
# tool to use in cross-compilation environments, therefore Automake
# will honor the `STRIP' environment variable to overrule this program.
dnl Don't test for $cross_compiling = yes, because it might be `maybe'.
if test "$cross_compiling" != no; then
AC_CHECK_TOOL([STRIP], [strip], :)
fi
INSTALL_STRIP_PROGRAM="\$(install_sh) -c -s"
AC_SUBST([INSTALL_STRIP_PROGRAM])])
# Copyright (C) 2006, 2008 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Prevent Automake from outputting VARIABLE = @VARIABLE@ in Makefile.in.
# This macro is traced by Automake.
AC_DEFUN([_AM_SUBST_NOTMAKE])
# AM_SUBST_NOTMAKE(VARIABLE)
# ---------------------------
# Public sister of _AM_SUBST_NOTMAKE.
AC_DEFUN([AM_SUBST_NOTMAKE], [_AM_SUBST_NOTMAKE($@)])
# Check how to create a tarball. -*- Autoconf -*-
# Copyright (C) 2004, 2005 Free Software Foundation, Inc.
#
# This file is free software; the Free Software Foundation
# gives unlimited permission to copy and/or distribute it,
# with or without modifications, as long as this notice is preserved.
# serial 2
# _AM_PROG_TAR(FORMAT)
# --------------------
# Check how to create a tarball in format FORMAT.
# FORMAT should be one of `v7', `ustar', or `pax'.
#
# Substitute a variable $(am__tar) that is a command
# writing to stdout a FORMAT-tarball containing the directory
# $tardir.
# tardir=directory && $(am__tar) > result.tar
#
# Substitute a variable $(am__untar) that extract such
# a tarball read from stdin.
# $(am__untar) < result.tar
AC_DEFUN([_AM_PROG_TAR],
[# Always define AMTAR for backward compatibility.
AM_MISSING_PROG([AMTAR], [tar])
m4_if([$1], [v7],
[am__tar='${AMTAR} chof - "$$tardir"'; am__untar='${AMTAR} xf -'],
[m4_case([$1], [ustar],, [pax],,
[m4_fatal([Unknown tar format])])
AC_MSG_CHECKING([how to create a $1 tar archive])
# Loop over all known methods to create a tar archive until one works.
_am_tools='gnutar m4_if([$1], [ustar], [plaintar]) pax cpio none'
_am_tools=${am_cv_prog_tar_$1-$_am_tools}
# Do not fold the above two line into one, because Tru64 sh and
# Solaris sh will not grok spaces in the rhs of `-'.
for _am_tool in $_am_tools
do
case $_am_tool in
gnutar)
for _am_tar in tar gnutar gtar;
do
AM_RUN_LOG([$_am_tar --version]) && break
done
am__tar="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$$tardir"'
am__tar_="$_am_tar --format=m4_if([$1], [pax], [posix], [$1]) -chf - "'"$tardir"'
am__untar="$_am_tar -xf -"
;;
plaintar)
# Must skip GNU tar: if it does not support --format= it doesn't create
# ustar tarball either.
(tar --version) >/dev/null 2>&1 && continue
am__tar='tar chf - "$$tardir"'
am__tar_='tar chf - "$tardir"'
am__untar='tar xf -'
;;
pax)
am__tar='pax -L -x $1 -w "$$tardir"'
am__tar_='pax -L -x $1 -w "$tardir"'
am__untar='pax -r'
;;
cpio)
am__tar='find "$$tardir" -print | cpio -o -H $1 -L'
am__tar_='find "$tardir" -print | cpio -o -H $1 -L'
am__untar='cpio -i -H $1 -d'
;;
none)
am__tar=false
am__tar_=false
am__untar=false
;;
esac
# If the value was cached, stop now. We just wanted to have am__tar
# and am__untar set.
test -n "${am_cv_prog_tar_$1}" && break
# tar/untar a dummy directory, and stop if the command works
rm -rf conftest.dir
mkdir conftest.dir
echo GrepMe > conftest.dir/file
AM_RUN_LOG([tardir=conftest.dir && eval $am__tar_ >conftest.tar])
rm -rf conftest.dir
if test -s conftest.tar; then
AM_RUN_LOG([$am__untar <conftest.tar])
grep GrepMe conftest.dir/file >/dev/null 2>&1 && break
fi
done
rm -rf conftest.dir
AC_CACHE_VAL([am_cv_prog_tar_$1], [am_cv_prog_tar_$1=$_am_tool])
AC_MSG_RESULT([$am_cv_prog_tar_$1])])
AC_SUBST([am__tar])
AC_SUBST([am__untar])
]) # _AM_PROG_TAR

165
plugins/onepad/analog.cpp Normal file
View File

@ -0,0 +1,165 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#include "analog.h"
PADAnalog g_lanalog[NUM_OF_PADS], g_ranalog[NUM_OF_PADS];
namespace Analog
{
u8 Pad(int padvalue, u8 i)
{
switch (padvalue)
{
case PAD_LX:
return g_lanalog[i].x;
break;
case PAD_RX:
return g_ranalog[i].x;
break;
case PAD_LY:
return g_lanalog[i].y;
break;
case PAD_RY:
return g_ranalog[i].y;
break;
default:
return 0;
break;
}
}
void SetPad(int padvalue, u8 i, u8 value)
{
switch (padvalue)
{
case PAD_LX:
g_lanalog[i].x = value;
break;
case PAD_RX:
g_ranalog[i].x = value;
break;
case PAD_LY:
g_lanalog[i].y = value;
break;
case PAD_RY:
g_ranalog[i].y = value;
break;
default:
break;
}
}
void InvertPad(int padvalue, u8 i)
{
SetPad(padvalue, i, -Pad(padvalue, i));
}
void ResetPad(int padvalue, u8 i)
{
SetPad(padvalue, i, 0x80);
}
void Init()
{
for (int i = 0; i < 2; ++i)
{
ResetPad(PAD_LX, i);
ResetPad(PAD_LY, i);
ResetPad(PAD_RX, i);
ResetPad(PAD_RY, i);
}
}
bool RevertPad(u8 padvalue)
{
switch (padvalue)
{
case PAD_LX:
return ((conf.options & PADOPTION_REVERTLX) != 0);
break;
case PAD_RX:
return ((conf.options & PADOPTION_REVERTRX) != 0);
break;
case PAD_LY:
return ((conf.options & PADOPTION_REVERTLY) != 0);
break;
case PAD_RY:
return ((conf.options & PADOPTION_REVERTRY) != 0);
break;
default:
return false;
break;
}
}
void ConfigurePad(int padvalue, u8 i, int value)
{
int temp = Pad(padvalue, i);
SetPad(padvalue, i, value / 256);
if (RevertPad(padvalue)) InvertPad(padvalue, i);
SetPad(padvalue, i, Pad(padvalue, i) + 0x80);
//PAD_LOG("Setting pad[%d]@%d to %d from %d\n", padvalue, i, value, temp);
}
int AnalogToPad(int padvalue)
{
switch (padvalue)
{
case PAD_R_LEFT:
return PAD_RX;
break;
case PAD_R_UP:
return PAD_RY;
break;
case PAD_L_LEFT:
return PAD_LX;
break;
case PAD_L_UP:
return PAD_LY;
break;
case PAD_R_DOWN:
return PAD_RY;
break;
case PAD_R_RIGHT:
return PAD_RX;
break;
case PAD_L_DOWN:
return PAD_LY;
break;
case PAD_L_RIGHT:
return PAD_LX;
break;
}
return 0;
}
}

36
plugins/onepad/analog.h Normal file
View File

@ -0,0 +1,36 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#define NUM_OF_PADS 2
#include "onepad.h"
namespace Analog
{
extern void Init();
extern u8 Pad(int padvalue, u8 i);
extern void SetPad(int padvalue, u8 i, u8 value);
extern void InvertPad(int padvalue, u8 i);
extern bool RevertPad(u8 padvalue);
extern void ResetPad(int padvalue, u8 i);
extern void ConfigurePad(int padvalue, u8 i, int value);
extern int KeypadToPad(u8 keypress);
extern int AnalogToPad(int padvalue);
}

44
plugins/onepad/bitwise.h Normal file
View File

@ -0,0 +1,44 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
template <class T>
static void __forceinline set_bit(T &value, int bit)
{
value |= (1 << bit);
}
template <class T>
static void __forceinline clear_bit(T &value, int bit)
{
value &= ~(1 << bit);
}
template <class T>
static void __forceinline toggle_bit(T &value, int bit)
{
value ^= (1 << bit);
}
template <class T>
static bool __forceinline test_bit(T &value, int bit)
{
return (value & (1 << bit));
}

29
plugins/onepad/build.sh Executable file
View File

@ -0,0 +1,29 @@
#!/bin/sh
curdir=`pwd`
echo ----------------
echo Building OnePAD
echo ----------------
if [ $# -gt 0 ] && [ $1 = "all" ]
then
#if possible
aclocal
automake -a
autoconf
chmod +x configure
./configure --prefix=${PCSX2PLUGINS}
make clean
make install
else
make $@
fi
if [ $? -ne 0 ]
then
exit 1
fi

View File

@ -0,0 +1,73 @@
AC_INIT(OnePAD,0.1,arcum42@gmail.com)
AM_INIT_AUTOMAKE(OnePAD,0.1)
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++])
AC_PROG_CPP([gcc g++ cl KCC CC cxx cc++ xlC aCC c++])
AC_PROG_INSTALL
AC_PROG_RANLIB
dnl necessary for compiling assembly
AM_PROG_AS
AC_SUBST(ONEPAD_CURRENT, 0)
AC_SUBST(ONEPAD_REVISION, 1)
AC_SUBST(ONEPAD_AGE, 0)
AC_SUBST(ONEPAD_RELEASE, [$ONEPAD_CURRENT].[$ONEPAD_REVISION].[$ONEPAD_AGE])
AC_SUBST(ONEPAD_SONAME, libOnePAD.so.[$ONEPAD_CURRENT].[$ONEPAD_REVISION].[$ONEPAD_AGE])
CFLAGS=
CXXFLAGS=
CCASFLAGS=
dnl Check for debug build
AC_MSG_CHECKING(debug build)
AC_ARG_ENABLE(debug, AC_HELP_STRING([--enable-debug], [debug build]),
debug=$enableval,debug=no)
if test "x$debug" == xyes
then
AC_DEFINE(PCSX2_DEBUG,1,[PCSX2_DEBUG])
CFLAGS+="-g -m32 -fpic "
CXXFLAGS+="-g -m32 -fpic "
CCASFLAGS+=" -m32 -fpic "
else
AC_DEFINE(NDEBUG,1,[NDEBUG])
CFLAGS+="-O2 -fomit-frame-pointer -m32 -fpic "
CXXFLAGS+="-O2 -fomit-frame-pointer -m32 -fpic "
CCASFLAGS+=" -m32 -fpic "
fi
AM_CONDITIONAL(DEBUGBUILD, test x$debug = xyes)
AC_MSG_RESULT($debug)
AC_CHECK_FUNCS([ _aligned_malloc _aligned_free ], AC_DEFINE(HAVE_ALIGNED_MALLOC))
AC_CHECK_LIB(SDL,SDL_Init,[])
dnl gtk
AC_MSG_CHECKING(gtk2+)
AC_CHECK_PROG(GTK_CONFIG, pkg-config, pkg-config)
LIBS+=$(pkg-config --libs gtk+-2.0 sdl)
CFLAGS+="$(pkg-config --cflags gtk+-2.0 sdl) "
CXXFLAGS+="$(pkg-config --cflags gtk+-2.0 sdl) "
dnl AC_CHECK_HEADER([SDL/SDL.h], [AC_DEFINE(JOYSTICK_SUPPORT,1)])
dnl assuming linux environment
so_ext=".so.$ONEPAD_RELEASE"
SHARED_LDFLAGS="-shared"
AC_SUBST(so_ext)
AC_SUBST(SHARED_LDFLAGS)
AC_CHECK_LIB(stdc++,main,[LIBS="$LIBS -lstdc++"])
AC_CHECK_LIB(dl,main,[LIBS="$LIBS -ldl"])
AC_OUTPUT([
Makefile
])
echo "Configuration:"
echo " Debug build? $debug"

View File

@ -0,0 +1,93 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#include "onepad.h"
#include "controller.h"
__forceinline int set_key(int pad, int index, int value)
{
conf.keys[pad][index] = value;
}
__forceinline int get_key(int pad, int index)
{
return conf.keys[pad][index];
}
__forceinline KeyType type_of_key(int key)
{
if (key < 0x10000) return PAD_KEYBOARD;
else if (key >= 0x10000 && key < 0x20000) return PAD_JOYBUTTONS;
else if (key >= 0x20000 && key < 0x30000) return PAD_JOYSTICK;
else if (key >= 0x30000 && key < 0x40000) return PAD_POV;
else if (key >= 0x40000 && key < 0x50000) return PAD_HAT;
else return PAD_NULL;
}
__forceinline int pad_to_key(int key)
{
return ((key) & 0xffff);
}
__forceinline int key_to_joystick_id(int key)
{
return (((key) & 0xf000) >> 12);
}
__forceinline int key_to_button(int key)
{
return ((key) & 0xff);
}
__forceinline int key_to_axis(int key)
{
return ((key) & 0xff);
}
__forceinline int button_to_key(int joy_id, int button_id)
{
return (0x10000 | ((joy_id) << 12) | (button_id));
}
__forceinline int joystick_to_key(int joy_id, int axis_id)
{
return (0x20000 | ((joy_id) << 12) | (axis_id));
}
__forceinline int pov_to_key(int joy_id, int sign, int axis_id)
{
return (0x30000 | ((joy_id) << 12) | ((sign) << 8) | (axis_id));
}
__forceinline int hat_to_key(int joy_id, int dir, int axis_id)
{
return (0x40000 | ((joy_id) << 12) | ((dir) << 8) | (axis_id));
}
__forceinline int key_to_pov_sign(int key)
{
return (((key) & 0x100) >> 8);
}
__forceinline int key_to_hat_dir(int key)
{
return (((key) & ~ 0x40000) >> 8);
}

View File

@ -0,0 +1,82 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#ifndef __CONTROLLER_H__
#define __CONTROLLER_H__
#ifdef __LINUX__
#define PADKEYS 28
#else
#define PADKEYS 20
#endif
#ifdef _WIN32
#define PADSUBKEYS 1
#else
#define PADSUBKEYS 2
#endif
enum KeyType
{
PAD_KEYBOARD = 0,
PAD_JOYBUTTONS,
PAD_JOYSTICK,
PAD_POV,
PAD_HAT,
PAD_NULL = -1
};
extern int set_key(int pad, int index, int value);
extern int get_key(int pad, int index);
extern KeyType type_of_key(int key);
extern int pad_to_key(int key);
extern int key_to_joystick_id(int key);
extern int key_to_button(int key);
extern int key_to_axis(int key);
extern int button_to_key(int joy_id, int button_id);
extern int joystick_to_key(int joy_id, int axis_id);
extern int pov_to_key(int joy_id, int sign, int axis_id);
extern int hat_to_key(int joy_id, int dir, int axis_id);
extern int key_to_pov_sign(int key);
extern int key_to_hat_dir(int key);
//#define EXPERIMENTAL_POV_CODE
extern int PadEnum[2][2];
typedef struct
{
u32 keys[2 * PADSUBKEYS][PADKEYS];
u32 log;
u32 options; // upper 16 bits are for pad2
} PADconf;
typedef struct
{
u8 x, y;
} PADAnalog;
extern PADconf conf;
extern PADAnalog g_lanalog[2], g_ranalog[2];
#endif

529
plugins/onepad/depcomp Normal file
View File

@ -0,0 +1,529 @@
#! /bin/sh
# depcomp - compile a program generating dependencies as side-effects
scriptversion=2005-05-14.22
# Copyright (C) 1999, 2000, 2003, 2004, 2005 Free Software Foundation, Inc.
# 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, 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., 51 Franklin Street, Fifth Floor, Boston, MA
# 02110-1301, USA.
# As a special exception to the GNU General Public License, if you
# distribute this file as part of a program that contains a
# configuration script generated by Autoconf, you may include it under
# the same distribution terms that you use for the rest of that program.
# Originally written by Alexandre Oliva <oliva@dcc.unicamp.br>.
case $1 in
'')
echo "$0: No command. Try \`$0 --help' for more information." 1>&2
exit 1;
;;
-h | --h*)
cat <<\EOF
Usage: depcomp [--help] [--version] PROGRAM [ARGS]
Run PROGRAMS ARGS to compile a file, generating dependencies
as side-effects.
Environment variables:
depmode Dependency tracking mode.
source Source file read by `PROGRAMS ARGS'.
object Object file output by `PROGRAMS ARGS'.
DEPDIR directory where to store dependencies.
depfile Dependency file to output.
tmpdepfile Temporary file to use when outputing dependencies.
libtool Whether libtool is used (yes/no).
Report bugs to <bug-automake@gnu.org>.
EOF
exit $?
;;
-v | --v*)
echo "depcomp $scriptversion"
exit $?
;;
esac
if test -z "$depmode" || test -z "$source" || test -z "$object"; then
echo "depcomp: Variables source, object and depmode must be set" 1>&2
exit 1
fi
# Dependencies for sub/bar.o or sub/bar.obj go into sub/.deps/bar.Po.
depfile=${depfile-`echo "$object" |
sed 's|[^\\/]*$|'${DEPDIR-.deps}'/&|;s|\.\([^.]*\)$|.P\1|;s|Pobj$|Po|'`}
tmpdepfile=${tmpdepfile-`echo "$depfile" | sed 's/\.\([^.]*\)$/.T\1/'`}
rm -f "$tmpdepfile"
# Some modes work just like other modes, but use different flags. We
# parameterize here, but still list the modes in the big case below,
# to make depend.m4 easier to write. Note that we *cannot* use a case
# here, because this file can only contain one case statement.
if test "$depmode" = hp; then
# HP compiler uses -M and no extra arg.
gccflag=-M
depmode=gcc
fi
if test "$depmode" = dashXmstdout; then
# This is just like dashmstdout with a different argument.
dashmflag=-xM
depmode=dashmstdout
fi
case "$depmode" in
gcc3)
## gcc 3 implements dependency tracking that does exactly what
## we want. Yay! Note: for some reason libtool 1.4 doesn't like
## it if -MD -MP comes after the -MF stuff. Hmm.
"$@" -MT "$object" -MD -MP -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
mv "$tmpdepfile" "$depfile"
;;
gcc)
## There are various ways to get dependency output from gcc. Here's
## why we pick this rather obscure method:
## - Don't want to use -MD because we'd like the dependencies to end
## up in a subdir. Having to rename by hand is ugly.
## (We might end up doing this anyway to support other compilers.)
## - The DEPENDENCIES_OUTPUT environment variable makes gcc act like
## -MM, not -M (despite what the docs say).
## - Using -M directly means running the compiler twice (even worse
## than renaming).
if test -z "$gccflag"; then
gccflag=-MD,
fi
"$@" -Wp,"$gccflag$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
echo "$object : \\" > "$depfile"
alpha=ABCDEFGHIJKLMNOPQRSTUVWXYZabcdefghijklmnopqrstuvwxyz
## The second -e expression handles DOS-style file names with drive letters.
sed -e 's/^[^:]*: / /' \
-e 's/^['$alpha']:\/[^:]*: / /' < "$tmpdepfile" >> "$depfile"
## This next piece of magic avoids the `deleted header file' problem.
## The problem is that when a header file which appears in a .P file
## is deleted, the dependency causes make to die (because there is
## typically no way to rebuild the header). We avoid this by adding
## dummy dependencies for each header file. Too bad gcc doesn't do
## this for us directly.
tr ' ' '
' < "$tmpdepfile" |
## Some versions of gcc put a space before the `:'. On the theory
## that the space means something, we add a space to the output as
## well.
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
hp)
# This case exists only to let depend.m4 do its work. It works by
# looking at the text of this script. This case will never be run,
# since it is checked for above.
exit 1
;;
sgi)
if test "$libtool" = yes; then
"$@" "-Wp,-MDupdate,$tmpdepfile"
else
"$@" -MDupdate "$tmpdepfile"
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
if test -f "$tmpdepfile"; then # yes, the sourcefile depend on other files
echo "$object : \\" > "$depfile"
# Clip off the initial element (the dependent). Don't try to be
# clever and replace this with sed code, as IRIX sed won't handle
# lines with more than a fixed number of characters (4096 in
# IRIX 6.2 sed, 8192 in IRIX 6.5). We also remove comment lines;
# the IRIX cc adds comments like `#:fec' to the end of the
# dependency line.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' | \
tr '
' ' ' >> $depfile
echo >> $depfile
# The second pass generates a dummy entry for each header file.
tr ' ' '
' < "$tmpdepfile" \
| sed -e 's/^.*\.o://' -e 's/#.*$//' -e '/^$/ d' -e 's/$/:/' \
>> $depfile
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
aix)
# The C for AIX Compiler uses -M and outputs the dependencies
# in a .u file. In older versions, this file always lives in the
# current directory. Also, the AIX compiler puts `$object:' at the
# start of each line; $object doesn't have directory information.
# Version 6 uses the directory in both cases.
stripped=`echo "$object" | sed 's/\(.*\)\..*$/\1/'`
tmpdepfile="$stripped.u"
if test "$libtool" = yes; then
"$@" -Wc,-M
else
"$@" -M
fi
stat=$?
if test -f "$tmpdepfile"; then :
else
stripped=`echo "$stripped" | sed 's,^.*/,,'`
tmpdepfile="$stripped.u"
fi
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
if test -f "$tmpdepfile"; then
outname="$stripped.o"
# Each line is of the form `foo.o: dependent.h'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed -e "s,^$outname:,$object :," < "$tmpdepfile" > "$depfile"
sed -e "s,^$outname: \(.*\)$,\1:," < "$tmpdepfile" >> "$depfile"
else
# The sourcefile does not contain any dependencies, so just
# store a dummy comment line, to avoid errors with the Makefile
# "include basename.Plo" scheme.
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
icc)
# Intel's C compiler understands `-MD -MF file'. However on
# icc -MD -MF foo.d -c -o sub/foo.o sub/foo.c
# ICC 7.0 will fill foo.d with something like
# foo.o: sub/foo.c
# foo.o: sub/foo.h
# which is wrong. We want:
# sub/foo.o: sub/foo.c
# sub/foo.o: sub/foo.h
# sub/foo.c:
# sub/foo.h:
# ICC 7.1 will output
# foo.o: sub/foo.c sub/foo.h
# and will wrap long lines using \ :
# foo.o: sub/foo.c ... \
# sub/foo.h ... \
# ...
"$@" -MD -MF "$tmpdepfile"
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile"
exit $stat
fi
rm -f "$depfile"
# Each line is of the form `foo.o: dependent.h',
# or `foo.o: dep1.h dep2.h \', or ` dep3.h dep4.h \'.
# Do two passes, one to just change these to
# `$object: dependent.h' and one to simply `dependent.h:'.
sed "s,^[^:]*:,$object :," < "$tmpdepfile" > "$depfile"
# Some versions of the HPUX 10.20 sed can't process this invocation
# correctly. Breaking it into two sed invocations is a workaround.
sed 's,^[^:]*: \(.*\)$,\1,;s/^\\$//;/^$/d;/:$/d' < "$tmpdepfile" |
sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
tru64)
# The Tru64 compiler uses -MD to generate dependencies as a side
# effect. `cc -MD -o foo.o ...' puts the dependencies into `foo.o.d'.
# At least on Alpha/Redhat 6.1, Compaq CCC V6.2-504 seems to put
# dependencies in `foo.d' instead, so we check for that too.
# Subdirectories are respected.
dir=`echo "$object" | sed -e 's|/[^/]*$|/|'`
test "x$dir" = "x$object" && dir=
base=`echo "$object" | sed -e 's|^.*/||' -e 's/\.o$//' -e 's/\.lo$//'`
if test "$libtool" = yes; then
# With Tru64 cc, shared objects can also be used to make a
# static library. This mecanism is used in libtool 1.4 series to
# handle both shared and static libraries in a single compilation.
# With libtool 1.4, dependencies were output in $dir.libs/$base.lo.d.
#
# With libtool 1.5 this exception was removed, and libtool now
# generates 2 separate objects for the 2 libraries. These two
# compilations output dependencies in in $dir.libs/$base.o.d and
# in $dir$base.o.d. We have to check for both files, because
# one of the two compilations can be disabled. We should prefer
# $dir$base.o.d over $dir.libs/$base.o.d because the latter is
# automatically cleaned when .libs/ is deleted, while ignoring
# the former would cause a distcleancheck panic.
tmpdepfile1=$dir.libs/$base.lo.d # libtool 1.4
tmpdepfile2=$dir$base.o.d # libtool 1.5
tmpdepfile3=$dir.libs/$base.o.d # libtool 1.5
tmpdepfile4=$dir.libs/$base.d # Compaq CCC V6.2-504
"$@" -Wc,-MD
else
tmpdepfile1=$dir$base.o.d
tmpdepfile2=$dir$base.d
tmpdepfile3=$dir$base.d
tmpdepfile4=$dir$base.d
"$@" -MD
fi
stat=$?
if test $stat -eq 0; then :
else
rm -f "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
exit $stat
fi
for tmpdepfile in "$tmpdepfile1" "$tmpdepfile2" "$tmpdepfile3" "$tmpdepfile4"
do
test -f "$tmpdepfile" && break
done
if test -f "$tmpdepfile"; then
sed -e "s,^.*\.[a-z]*:,$object:," < "$tmpdepfile" > "$depfile"
# That's a tab and a space in the [].
sed -e 's,^.*\.[a-z]*:[ ]*,,' -e 's,$,:,' < "$tmpdepfile" >> "$depfile"
else
echo "#dummy" > "$depfile"
fi
rm -f "$tmpdepfile"
;;
#nosideeffect)
# This comment above is used by automake to tell side-effect
# dependency tracking mechanisms from slower ones.
dashmstdout)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
test -z "$dashmflag" && dashmflag=-M
# Require at least two characters before searching for `:'
# in the target name. This is to cope with DOS-style filenames:
# a dependency such as `c:/foo/bar' could be seen as target `c' otherwise.
"$@" $dashmflag |
sed 's:^[ ]*[^: ][^:][^:]*\:[ ]*:'"$object"'\: :' > "$tmpdepfile"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
tr ' ' '
' < "$tmpdepfile" | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
dashXmstdout)
# This case only exists to satisfy depend.m4. It is never actually
# run, as this mode is specially recognized in the preamble.
exit 1
;;
makedepend)
"$@" || exit $?
# Remove any Libtool call
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# X makedepend
shift
cleared=no
for arg in "$@"; do
case $cleared in
no)
set ""; shift
cleared=yes ;;
esac
case "$arg" in
-D*|-I*)
set fnord "$@" "$arg"; shift ;;
# Strip any option that makedepend may not understand. Remove
# the object too, otherwise makedepend will parse it as a source file.
-*|$object)
;;
*)
set fnord "$@" "$arg"; shift ;;
esac
done
obj_suffix="`echo $object | sed 's/^.*\././'`"
touch "$tmpdepfile"
${MAKEDEPEND-makedepend} -o"$obj_suffix" -f"$tmpdepfile" "$@"
rm -f "$depfile"
cat < "$tmpdepfile" > "$depfile"
sed '1,2d' "$tmpdepfile" | tr ' ' '
' | \
## Some versions of the HPUX 10.20 sed can't process this invocation
## correctly. Breaking it into two sed invocations is a workaround.
sed -e 's/^\\$//' -e '/^$/d' -e '/:$/d' | sed -e 's/$/ :/' >> "$depfile"
rm -f "$tmpdepfile" "$tmpdepfile".bak
;;
cpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout.
"$@" || exit $?
# Remove the call to Libtool.
if test "$libtool" = yes; then
while test $1 != '--mode=compile'; do
shift
done
shift
fi
# Remove `-o $object'.
IFS=" "
for arg
do
case $arg in
-o)
shift
;;
$object)
shift
;;
*)
set fnord "$@" "$arg"
shift # fnord
shift # $arg
;;
esac
done
"$@" -E |
sed -n '/^# [0-9][0-9]* "\([^"]*\)".*/ s:: \1 \\:p' |
sed '$ s: \\$::' > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
cat < "$tmpdepfile" >> "$depfile"
sed < "$tmpdepfile" '/^$/d;s/^ //;s/ \\$//;s/$/ :/' >> "$depfile"
rm -f "$tmpdepfile"
;;
msvisualcpp)
# Important note: in order to support this mode, a compiler *must*
# always write the preprocessed file to stdout, regardless of -o,
# because we must use -o when running libtool.
"$@" || exit $?
IFS=" "
for arg
do
case "$arg" in
"-Gm"|"/Gm"|"-Gi"|"/Gi"|"-ZI"|"/ZI")
set fnord "$@"
shift
shift
;;
*)
set fnord "$@" "$arg"
shift
shift
;;
esac
done
"$@" -E |
sed -n '/^#line [0-9][0-9]* "\([^"]*\)"/ s::echo "`cygpath -u \\"\1\\"`":p' | sort | uniq > "$tmpdepfile"
rm -f "$depfile"
echo "$object : \\" > "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s:: \1 \\:p' >> "$depfile"
echo " " >> "$depfile"
. "$tmpdepfile" | sed 's% %\\ %g' | sed -n '/^\(.*\)$/ s::\1\::p' >> "$depfile"
rm -f "$tmpdepfile"
;;
none)
exec "$@"
;;
*)
echo "Unknown depmode $depmode" 1>&2
exit 1
;;
esac
exit 0
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

1
plugins/onepad/install-sh Symbolic link
View File

@ -0,0 +1 @@
/usr/share/automake-1.11/install-sh

288
plugins/onepad/joystick.cpp Normal file
View File

@ -0,0 +1,288 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#include "joystick.h"
//////////////////////////
// Joystick definitions //
//////////////////////////
int s_selectedpad = 0;
vector<JoystickInfo*> s_vjoysticks;
static u32 s_bSDLInit = false;
void UpdateJoysticks()
{
vector<JoystickInfo*>::iterator itjoy = s_vjoysticks.begin();
SDL_JoystickUpdate();
// Save everything in the vector s_vjoysticks.
while (itjoy != s_vjoysticks.end())
{
(*itjoy)->SaveState();
itjoy++;
}
}
const char *HatName(int value)
{
switch(value)
{
case SDL_HAT_CENTERED: return "SDL_HAT_CENTERED";
case SDL_HAT_UP: return "SDL_HAT_UP";
case SDL_HAT_RIGHT: return "SDL_HAT_RIGHT";
case SDL_HAT_DOWN: return "SDL_HAT_DOWN";
case SDL_HAT_LEFT: return "SDL_HAT_LEFT";
case SDL_HAT_RIGHTUP: return "SDL_HAT_RIGHTUP";
case SDL_HAT_RIGHTDOWN: return "SDL_HAT_RIGHTDOWN";
case SDL_HAT_LEFTUP: return "SDL_HAT_LEFTUP";
case SDL_HAT_LEFTDOWN: return "SDL_HAT_LEFTDOWN";
default: return "Unknown";
}
return "Unknown";
}
bool JoystickIdWithinBounds(int joyid)
{
return ((joyid >= 0) && (joyid < (int)s_vjoysticks.size()));
}
// opens handles to all possible joysticks
void JoystickInfo::EnumerateJoysticks(vector<JoystickInfo*>& vjoysticks)
{
if (!s_bSDLInit)
{
if (SDL_Init(SDL_INIT_JOYSTICK) < 0) return;
SDL_JoystickEventState(SDL_QUERY);
s_bSDLInit = true;
}
vector<JoystickInfo*>::iterator it = vjoysticks.begin();
// Delete everything in the vector vjoysticks.
while (it != vjoysticks.end())
{
delete *it;
it ++;
}
vjoysticks.resize(SDL_NumJoysticks());
for (int i = 0; i < (int)vjoysticks.size(); ++i)
{
vjoysticks[i] = new JoystickInfo();
vjoysticks[i]->Init(i, true);
}
// set the pads
for (int pad = 0; pad < 2; ++pad)
{
// select the right joystick id
int joyid = -1;
for (int i = 0; i < PADKEYS; ++i)
{
KeyType k = type_of_key(get_key(pad,i));
if (k == PAD_JOYSTICK || k == PAD_JOYBUTTONS)
{
joyid = key_to_joystick_id(get_key(pad,i));
break;
}
}
if ((joyid >= 0) && (joyid < (int)s_vjoysticks.size())) s_vjoysticks[joyid]->Assign(pad);
}
}
JoystickInfo::JoystickInfo()
{
joy = NULL;
_id = -1;
pad = -1;
axisrange = 0x7fff;
deadzone = 2000;
}
void JoystickInfo::Destroy()
{
if (joy != NULL)
{
if (SDL_JoystickOpened(_id)) SDL_JoystickClose(joy);
joy = NULL;
}
}
bool JoystickInfo::Init(int id, bool bStartThread)
{
Destroy();
_id = id;
joy = SDL_JoystickOpen(id);
if (joy == NULL)
{
PAD_LOG("failed to open joystick %d\n", id);
return false;
}
numaxes = SDL_JoystickNumAxes(joy);
numbuttons = SDL_JoystickNumButtons(joy);
numhats = SDL_JoystickNumHats(joy);
devname = SDL_JoystickName(id);
vaxisstate.resize(numaxes);
vbuttonstate.resize(numbuttons);
vhatstate.resize(numhats);
//PAD_LOG("There are %d buttons, %d axises, and %d hats.\n", numbuttons, numaxes, numhats);
return true;
}
// assigns a joystick to a pad
void JoystickInfo::Assign(int newpad)
{
if (pad == newpad) return;
pad = newpad;
if (pad >= 0)
{
for (int i = 0; i < PADKEYS; ++i)
{
KeyType k = type_of_key(get_key(pad,i));
if (k == PAD_JOYBUTTONS)
{
set_key(pad, i, button_to_key(_id, key_to_button(get_key(pad,i))));
}
else if (k == PAD_JOYSTICK)
{
set_key(pad, i, joystick_to_key(_id, key_to_button(get_key(pad,i))));
}
}
}
}
void JoystickInfo::SaveState()
{
for (int i = 0; i < numbuttons; ++i)
SetButtonState(i, SDL_JoystickGetButton(joy, i));
for (int i = 0; i < numaxes; ++i)
SetAxisState(i, SDL_JoystickGetAxis(joy, i));
for (int i = 0; i < numhats; ++i)
SetHatState(i, SDL_JoystickGetHat(joy, i));
}
void JoystickInfo::TestForce()
{
}
bool JoystickInfo::PollButtons(int &jbutton, u32 &pkey)
{
// MAKE sure to look for changes in the state!!
for (int i = 0; i < GetNumButtons(); ++i)
{
int but = SDL_JoystickGetButton(GetJoy(), i);
if (but != GetButtonState(i))
{
if (!but) // released, we don't really want this
{
SetButtonState(i, 0);
break;
}
pkey = button_to_key(GetId(), i);
jbutton = i;
return true;
}
}
return false;
}
bool JoystickInfo::PollAxes(bool pov, int &jbutton, bool &negative, u32 &pkey)
{
for (int i = 0; i < GetNumAxes(); ++i)
{
int value = SDL_JoystickGetAxis(GetJoy(), i);
if (value != GetAxisState(i))
{
PAD_LOG("Change in joystick %d: %d.\n", i, value);
if (abs(value) <= GetAxisState(i)) // we don't want this
{
// released, we don't really want this
SetAxisState(i, value);
break;
}
if (abs(value) > 0x3fff)
{
jbutton = i;
if (pov)
{
negative = (value < 0);
pkey = pov_to_key(GetId(), negative, i);
}
else // axis
{
pkey = joystick_to_key(GetId(), i);
}
return true;
}
}
}
return false;
}
bool JoystickInfo::PollHats(int &jbutton, int &dir, u32 &pkey)
{
#ifdef EXPERIMENTAL_POV_CODE
for (int i = 0; i < GetNumHats(); ++i)
{
int value = SDL_JoystickGetHat(GetJoy(), i);
if (value != SDL_HAT_CENTERED)
{
switch (value)
{
case SDL_HAT_UP:
case SDL_HAT_RIGHT:
case SDL_HAT_DOWN:
case SDL_HAT_LEFT:
pkey = hat_to_key(GetId(), value, i);
jbutton = i;
dir = value;
PAD_LOG("Hat Pressed!");
return true;
default:
break;
}
}
}
#endif
return false;
}

151
plugins/onepad/joystick.h Normal file
View File

@ -0,0 +1,151 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#ifndef __JOYSTICK_H__
#define __JOYSTICK_H__
#ifdef __LINUX__
#include <SDL/SDL.h>
#else
#include <SDL.h>
#endif
#include "onepad.h"
// holds all joystick info
class JoystickInfo
{
public:
JoystickInfo();
~JoystickInfo()
{
Destroy();
}
void Destroy();
// opens handles to all possible joysticks
static void EnumerateJoysticks(vector<JoystickInfo*>& vjoysticks);
bool Init(int id, bool bStartThread = true); // opens a handle and gets information
void Assign(int pad); // assigns a joystick to a pad
void TestForce();
bool PollButtons(int &jbutton, u32 &pkey);
bool PollAxes(bool pov, int &jbutton, bool &negative, u32 &pkey);
bool PollHats(int &jbutton, int &dir, u32 &pkey);
const string& GetName()
{
return devname;
}
int GetNumButtons()
{
return numbuttons;
}
int GetNumAxes()
{
return numaxes;
}
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 vbuttonstate[i];
}
int GetAxisState(int i)
{
return vaxisstate[i];
}
int GetHatState(int i)
{
//PAD_LOG("Getting POV State of %d.\n", i);
return vhatstate[i];
}
void SetButtonState(int i, int state)
{
vbuttonstate[i] = state;
}
void SetAxisState(int i, int value)
{
vaxisstate[i] = value;
}
void SetHatState(int i, int value)
{
//PAD_LOG("We should set %d to %d.\n", i, value);
vhatstate[i] = value;
}
SDL_Joystick* GetJoy()
{
return joy;
}
private:
string devname; // pretty device name
int _id;
int numbuttons, numaxes, numhats;
int axisrange, deadzone;
int pad;
vector<int> vbuttonstate, vaxisstate, vhatstate;
SDL_Joystick* joy;
};
extern int s_selectedpad;
extern vector<JoystickInfo*> s_vjoysticks;
extern void UpdateJoysticks();
extern const char *HatName(int value);
extern bool JoystickIdWithinBounds(int joyid);
#endif

284
plugins/onepad/keyboard.cpp Normal file
View File

@ -0,0 +1,284 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
/*
* Theoretically, this header is for anything to do with keyboard input.
* Pragmatically, event handing's going in here too.
*/
#include "keyboard.h"
__forceinline int FindKey(int key, int pad)
{
for (int p = 0; p < PADSUBKEYS; p++)
for (int i = 0; i < PADKEYS; i++)
if (key == get_key(PadEnum[pad][p], i)) return i;
return -1;
}
char* KeysymToChar(int keysym)
{
#ifdef __LINUX__
return XKeysymToString(keysym);
#else
LPWORD temp;
ToAscii((UINT) keysym, NULL, NULL, temp, NULL);
return (char*)temp;
#endif
}
void PollForKeyboardInput(int pad)
{
#ifdef __LINUX__
PollForX11KeyboardInput(pad);
#endif
}
void SetAutoRepeat(bool autorep)
{
#ifdef __LINUX__
if (autorep)
XAutoRepeatOn(GSdsp);
else
XAutoRepeatOff(GSdsp);
#endif
}
#ifdef __LINUX__
void PollForX11KeyboardInput(int pad)
{
XEvent E;
KeySym key;
int keyPress = 0, keyRelease = 0;
int i;
// keyboard input
while (XPending(GSdsp) > 0)
{
XNextEvent(GSdsp, &E);
switch (E.type)
{
case KeyPress:
key = XLookupKeysym((XKeyEvent *) & E, 0);
i = FindKey(key, pad);
// Analog controls.
if ((i > PAD_RY) && (i <= PAD_R_LEFT))
{
switch (i)
{
case PAD_R_LEFT:
case PAD_R_UP:
case PAD_L_LEFT:
case PAD_L_UP:
Analog::ConfigurePad(Analog::AnalogToPad(i), pad, DEF_VALUE);
break;
case PAD_R_RIGHT:
case PAD_R_DOWN:
case PAD_L_RIGHT:
case PAD_L_DOWN:
Analog::ConfigurePad(Analog::AnalogToPad(i), pad, -DEF_VALUE);
break;
}
i += 0xff00;
}
if (i != -1)
{
clear_bit(keyRelease, i);
set_bit(keyPress, i);
}
//PAD_LOG("Key pressed:%d\n", i);
event.evt = KEYPRESS;
event.key = key;
break;
case KeyRelease:
key = XLookupKeysym((XKeyEvent *) & E, 0);
i = FindKey(key, pad);
// Analog Controls.
if ((i > PAD_RY) && (i <= PAD_R_LEFT))
{
Analog::ResetPad(Analog::AnalogToPad(i), pad);
i += 0xff00;
}
if (i != -1)
{
clear_bit(keyPress, i);
set_bit(keyRelease, i);
}
event.evt = KEYRELEASE;
event.key = key;
break;
case FocusIn:
XAutoRepeatOff(GSdsp);
break;
case FocusOut:
XAutoRepeatOn(GSdsp);
break;
}
}
UpdateKeys(pad, keyPress, keyRelease);
}
bool PollX11Keyboard(char* &temp, u32 &pkey)
{
GdkEvent *ev = gdk_event_get();
if (ev != NULL)
{
if (ev->type == GDK_KEY_PRESS)
{
if (ev->key.keyval == GDK_Escape)
{
temp = "Unknown";
pkey = NULL;
}
else
{
temp = KeysymToChar(ev->key.keyval);
pkey = ev->key.keyval;
}
return true;
}
}
return false;
}
#else
LRESULT WINAPI PADwndProc(HWND hWnd, UINT msg, WPARAM wParam, LPARAM lParam)
{
int keyPress[2] = {0}, keyRelease[2] = {0};
static bool lbutton = false, rbutton = false;
switch (msg)
{
case WM_KEYDOWN:
if (lParam & 0x40000000) return TRUE;
for (int pad = 0; pad < 2; ++pad)
{
for (int i = 0; i < PADKEYS; i++)
{
if (wParam == get_key(pad, i))
{
set_bit(keyPress[pad], i);
clear_bit(keyRelease[pad], i);
break;
}
}
}
event.evt = KEYPRESS;
event.key = wParam;
break;
case WM_KEYUP:
for (int pad = 0; pad < 2; ++pad)
{
for (int i = 0; i < PADKEYS; i++)
{
if (wParam == get_key(pad,i))
{
set_bit(keyRelease[pad], i);
clear_bit(keyPress[pad], i);
break;
}
}
}
event.evt = KEYRELEASE;
event.key = wParam;
break;
/*case WM_LBUTTONDOWN:
lbutton = true;
break;
case WM_LBUTTONUP:
g_lanalog[0].x = 0x80;
g_lanalog[0].y = 0x80;
g_lanalog[1].x = 0x80;
g_lanalog[1].y = 0x80;
lbutton = false;
break;
case WM_RBUTTONDOWN:
rbutton = true;
break;
case WM_RBUTTONUP:
g_ranalog[0].x = 0x80;
g_ranalog[0].y = 0x80;
g_ranalog[1].x = 0x80;
g_ranalog[1].y = 0x80;
rbutton = false;
break;
case WM_MOUSEMOVE:
if (lbutton)
{
g_lanalog[0].x = LOWORD(lParam) & 254;
g_lanalog[0].y = HIWORD(lParam) & 254;
g_lanalog[1].x = LOWORD(lParam) & 254;
g_lanalog[1].y = HIWORD(lParam) & 254;
}
if (rbutton)
{
g_ranalog[0].x = LOWORD(lParam) & 254;
g_ranalog[0].y = HIWORD(lParam) & 254;
g_ranalog[1].x = LOWORD(lParam) & 254;
g_ranalog[1].y = HIWORD(lParam) & 254;
}
break;*/
case WM_DESTROY:
case WM_QUIT:
event.evt = KEYPRESS;
event.key = VK_ESCAPE;
return GSwndProc(hWnd, msg, wParam, lParam);
default:
return GSwndProc(hWnd, msg, wParam, lParam);
}
for (int pad = 0; pad < 2; ++pad)
{
UpdateKeys(pad, keyPress[pad], keyRelease[pad]);
}
return TRUE;
}
#endif

47
plugins/onepad/keyboard.h Normal file
View File

@ -0,0 +1,47 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#ifndef __KEYBOARD_H__
#define __KEYBOARD_H__
#include "onepad.h"
#ifdef __LINUX__
#include "Linux/linux.h"
extern Display *GSdsp;
extern void PollForX11KeyboardInput(int pad);
extern bool PollX11Keyboard(char* &temp, u32 &pkey);
#else
extern WNDPROC GSwndProc;
extern HWND GShwnd;
#endif
extern char* KeysymToChar(int keysym);
extern void PollForKeyboardInput(int pad);
extern void SetAutoRepeat(bool autorep);
extern __forceinline int FindKey(int key, int pad);
#endif

1
plugins/onepad/missing Symbolic link
View File

@ -0,0 +1 @@
/usr/share/automake-1.11/missing

View File

@ -0,0 +1,158 @@
#! /bin/sh
# mkinstalldirs --- make directory hierarchy
scriptversion=2005-06-29.22
# Original author: Noah Friedman <friedman@prep.ai.mit.edu>
# Created: 1993-05-16
# Public domain.
#
# This file is maintained in Automake, please report
# bugs to <bug-automake@gnu.org> or send patches to
# <automake-patches@gnu.org>.
errstatus=0
dirmode=
usage="\
Usage: mkinstalldirs [-h] [--help] [--version] [-m MODE] DIR ...
Create each directory DIR (with mode MODE, if specified), including all
leading file name components.
Report bugs to <bug-automake@gnu.org>."
# process command line arguments
while test $# -gt 0 ; do
case $1 in
-h | --help | --h*) # -h for help
echo "$usage"
exit $?
;;
-m) # -m PERM arg
shift
test $# -eq 0 && { echo "$usage" 1>&2; exit 1; }
dirmode=$1
shift
;;
--version)
echo "$0 $scriptversion"
exit $?
;;
--) # stop option processing
shift
break
;;
-*) # unknown option
echo "$usage" 1>&2
exit 1
;;
*) # first non-opt arg
break
;;
esac
done
for file
do
if test -d "$file"; then
shift
else
break
fi
done
case $# in
0) exit 0 ;;
esac
# Solaris 8's mkdir -p isn't thread-safe. If you mkdir -p a/b and
# mkdir -p a/c at the same time, both will detect that a is missing,
# one will create a, then the other will try to create a and die with
# a "File exists" error. This is a problem when calling mkinstalldirs
# from a parallel make. We use --version in the probe to restrict
# ourselves to GNU mkdir, which is thread-safe.
case $dirmode in
'')
if mkdir -p --version . >/dev/null 2>&1 && test ! -d ./--version; then
echo "mkdir -p -- $*"
exec mkdir -p -- "$@"
else
# On NextStep and OpenStep, the `mkdir' command does not
# recognize any option. It will interpret all options as
# directories to create, and then abort because `.' already
# exists.
test -d ./-p && rmdir ./-p
test -d ./--version && rmdir ./--version
fi
;;
*)
if mkdir -m "$dirmode" -p --version . >/dev/null 2>&1 &&
test ! -d ./--version; then
echo "mkdir -m $dirmode -p -- $*"
exec mkdir -m "$dirmode" -p -- "$@"
else
# Clean up after NextStep and OpenStep mkdir.
for d in ./-m ./-p ./--version "./$dirmode";
do
test -d $d && rmdir $d
done
fi
;;
esac
for file
do
case $file in
/*) pathcomp=/ ;;
*) pathcomp= ;;
esac
oIFS=$IFS
IFS=/
set fnord $file
shift
IFS=$oIFS
for d
do
test "x$d" = x && continue
pathcomp=$pathcomp$d
case $pathcomp in
-*) pathcomp=./$pathcomp ;;
esac
if test ! -d "$pathcomp"; then
echo "mkdir $pathcomp"
mkdir "$pathcomp" || lasterr=$?
if test ! -d "$pathcomp"; then
errstatus=$lasterr
else
if test ! -z "$dirmode"; then
echo "chmod $dirmode $pathcomp"
lasterr=
chmod "$dirmode" "$pathcomp" || lasterr=$?
if test ! -z "$lasterr"; then
errstatus=$lasterr
fi
fi
fi
fi
pathcomp=$pathcomp/
done
done
exit $errstatus
# Local Variables:
# mode: shell-script
# sh-indentation: 2
# eval: (add-hook 'write-file-hooks 'time-stamp)
# time-stamp-start: "scriptversion="
# time-stamp-format: "%:y-%02m-%02d.%02H"
# time-stamp-end: "$"
# End:

602
plugins/onepad/onepad.cpp Normal file
View File

@ -0,0 +1,602 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#include <sys/stat.h>
#include <sys/types.h>
#include <fcntl.h>
#include <string.h>
#include <stdarg.h>
#include "onepad.h"
#ifndef _WIN32
#include <unistd.h>
#else
#include "svnrev.h"
#endif
char libraryName[256];
PADconf conf;
keyEvent event;
u16 status[2];
int pressure;
static keyEvent s_event;
string s_strIniPath = "inis/OnePAD.ini";
const u32 version = PS2E_PAD_VERSION;
const u32 revision = 0;
const u32 build = 1; // increase that with each version
int PadEnum[2][2] = {{0, 2}, {1, 3}};
u32 pads = 0;
u8 stdpar[2][20] = {
{0xff, 0x5a, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00},
{0xff, 0x5a, 0xff, 0xff, 0x80, 0x80, 0x80, 0x80,
0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00,
0x00, 0x00, 0x00, 0x00}
};
u8 cmd40[2][8] = {
{0xff, 0x5a, 0x00, 0x00, 0x02, 0x00, 0x00, 0x5a},
{0xff, 0x5a, 0x00, 0x00, 0x02, 0x00, 0x00, 0x5a}
};
u8 cmd41[2][8] = {
{0xff, 0x5a, 0xff, 0xff, 0x03, 0x00, 0x00, 0x5a},
{0xff, 0x5a, 0xff, 0xff, 0x03, 0x00, 0x00, 0x5a}
};
u8 unk46[2][8] = {
{0xFF, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A},
{0xFF, 0x5A, 0x00, 0x00, 0x01, 0x02, 0x00, 0x0A}
};
u8 unk47[2][8] = {
{0xff, 0x5a, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00},
{0xff, 0x5a, 0x00, 0x00, 0x02, 0x00, 0x01, 0x00}
};
u8 unk4c[2][8] = {
{0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
};
u8 unk4d[2][8] = {
{0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff},
{0xff, 0x5a, 0xff, 0xff, 0xff, 0xff, 0xff, 0xff}
};
u8 cmd4f[2][8] = {
{0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a},
{0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x5a}
};
u8 stdcfg[2][8] = {
{0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
}; // 2 & 3 = 0
u8 stdmode[2][8] = {
{0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00},
{0xff, 0x5a, 0x00, 0x00, 0x00, 0x00, 0x00, 0x00}
};
u8 stdmodel[2][8] = {
{0xff,
0x5a,
0x03, // 03 - dualshock2, 01 - dualshock
0x02, // number of modes
0x01, // current mode: 01 - analog, 00 - digital
0x02,
0x01,
0x00},
{0xff,
0x5a,
0x03, // 03 - dualshock2, 01 - dualshock
0x02, // number of modes
0x01, // current mode: 01 - analog, 00 - digital
0x02,
0x01,
0x00}
};
u8 *buf;
int padID[2];
int padMode[2];
int curPad;
int curByte;
int curCmd;
int cmdLen;
int ds2mode = 0; // DS Mode at start
FILE *padLog = NULL;
pthread_spinlock_t s_mutexStatus;
u32 s_keyPress[2], s_keyRelease[2];
static void InitLibraryName()
{
#ifdef _WIN32
# ifdef PUBLIC
// Public Release!
// Output a simplified string that's just our name:
strcpy(libraryName, "OnePAD");
# elif defined( SVN_REV_UNKNOWN )
// Unknown revision.
// Output a name that includes devbuild status but not
// subversion revision tags:
strcpy(libraryName, "OnePAD"
# ifdef PCSX2_DEBUG
"-Debug"
# endif
);
# else
// Use TortoiseSVN's SubWCRev utility's output
// to label the specific revision:
sprintf_s(libraryName, "OnePAD r%d%s"
# ifdef PCSX2_DEBUG
"-Debug"
# else
"-Dev"
# endif
, SVN_REV,
SVN_MODS ? "m" : ""
);
# endif
#else
// I'll fix up SVN support later. --arcum42
strcpy(libraryName, "OnePAD"
# ifdef PCSX2_DEBUG
"-Debug"
# endif
);
#endif
}
EXPORT_C_(u32) PS2EgetLibType()
{
return PS2E_LT_PAD;
}
EXPORT_C_(char*) PS2EgetLibName()
{
InitLibraryName();
return libraryName;
}
EXPORT_C_(u32) PS2EgetLibVersion2(u32 type)
{
return (version << 16) | (revision << 8) | build;
}
void __Log(const char *fmt, ...)
{
va_list list;
//if (padLog == NULL || !conf.log) return;
if (padLog == NULL) return;
va_start(list, fmt);
vfprintf(padLog, fmt, list);
va_end(list);
}
void __LogToConsole(const char *fmt, ...)
{
va_list list;
va_start(list, fmt);
if (padLog != NULL) vfprintf(padLog, fmt, list);
printf("OnePAD: ");
vprintf(fmt, list);
va_end(list);
}
void initLogging()
{
#ifdef PAD_LOG
if (padLog == NULL)
{
padLog = fopen("logs/padLog.txt", "w");
if (padLog) setvbuf(padLog, NULL, _IONBF, 0);
}
PAD_LOG("PADinit\n");
#endif
}
EXPORT_C_(s32) PADinit(u32 flags)
{
initLogging();
pads |= flags;
status[0] = 0xffff;
status[1] = 0xffff;
#ifdef __LINUX__
char strcurdir[256];
getcwd(strcurdir, 256);
s_strIniPath = strcurdir;
s_strIniPath += "/inis/OnePAD.ini";
#endif
LoadConfig();
PADsetMode(0, 0);
PADsetMode(1, 0);
pressure = 100;
Analog::Init();
return 0;
}
EXPORT_C_(void) PADshutdown()
{
#ifdef PAD_LOG
if (padLog != NULL)
{
fclose(padLog);
padLog = NULL;
}
#endif
}
EXPORT_C_(s32) PADopen(void *pDsp)
{
memset(&event, 0, sizeof(event));
pthread_spin_init(&s_mutexStatus, PTHREAD_PROCESS_PRIVATE);
s_keyPress[0] = s_keyPress[1] = 0;
s_keyRelease[0] = s_keyRelease[1] = 0;
#ifdef __LINUX__
JoystickInfo::EnumerateJoysticks(s_vjoysticks);
#endif
return _PADopen(pDsp);
}
EXPORT_C_(void) PADclose()
{
pthread_spin_destroy(&s_mutexStatus);
_PADclose();
}
void _PADupdate(int pad)
{
pthread_spin_lock(&s_mutexStatus);
status[pad] |= s_keyRelease[pad];
status[pad] &= ~s_keyPress[pad];
s_keyRelease[pad] = 0;
s_keyPress[pad] = 0;
pthread_spin_unlock(&s_mutexStatus);
}
void UpdateKeys(int pad, int keyPress, int keyRelease)
{
pthread_spin_lock(&s_mutexStatus);
s_keyPress[pad] |= keyPress;
s_keyPress[pad] &= ~keyRelease;
s_keyRelease[pad] |= keyRelease;
s_keyRelease[pad] &= ~keyPress;
pthread_spin_unlock(&s_mutexStatus);
}
EXPORT_C_(u32) PADquery()
{
return 3; // both
}
void PADsetMode(int pad, int mode)
{
padMode[pad] = mode;
switch (ds2mode)
{
case 0: // dualshock
switch (mode)
{
case 0: // digital
padID[pad] = 0x41;
break;
case 1: // analog
padID[pad] = 0x73;
break;
}
break;
case 1: // dualshock2
switch (mode)
{
case 0: // digital
padID[pad] = 0x41;
break;
case 1: // analog
padID[pad] = 0x79;
break;
}
break;
}
}
EXPORT_C_(u8) PADstartPoll(int pad)
{
//PAD_LOG("PADstartPoll: %d\n", pad);
curPad = pad - 1;
curByte = 0;
return 0xff;
}
u8 _PADpoll(u8 value)
{
u8 button_check = 0, button_check2 = 0;
const int avg_pressure = (pressure * 255) / 100;
if (curByte == 0)
{
curByte++;
//PAD_LOG("PADpoll: cmd: %x\n", value);
curCmd = value;
switch (value)
{
case CMD_SET_VREF_PARAM: // DUALSHOCK2 ENABLER
cmdLen = 8;
buf = cmd40[curPad];
return 0xf3;
case CMD_QUERY_DS2_ANALOG_MODE: // QUERY_DS2_ANALOG_MODE
cmdLen = 8;
buf = cmd41[curPad];
return 0xf3;
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] = 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;
else
cmdLen = 4;
button_check2 = stdpar[curPad][2] >> 4;
switch (stdpar[curPad][3])
{
case 0xBF: // X
stdpar[curPad][14] = avg_pressure;
break;
case 0xDF: // Circle
stdpar[curPad][13] = avg_pressure;
break;
case 0xEF: // Triangle
stdpar[curPad][12] = avg_pressure;
break;
case 0x7F: // Square
stdpar[curPad][15] = avg_pressure;
break;
case 0xFB: // L1
stdpar[curPad][16] = avg_pressure;
break;
case 0xF7: // R1
stdpar[curPad][17] = avg_pressure;
break;
case 0xFE: // L2
stdpar[curPad][18] = avg_pressure;
break;
case 0xFD: // R2
stdpar[curPad][19] = avg_pressure;
break;
default:
stdpar[curPad][14] = 0x00; // Not pressed
stdpar[curPad][13] = 0x00; // Not pressed
stdpar[curPad][12] = 0x00; // Not pressed
stdpar[curPad][15] = 0x00; // Not pressed
stdpar[curPad][16] = 0x00; // Not pressed
stdpar[curPad][17] = 0x00; // Not pressed
stdpar[curPad][18] = 0x00; // Not pressed
stdpar[curPad][19] = 0x00; // Not pressed
break;
}
switch (button_check2)
{
case 0xE: // UP
stdpar[curPad][10] = avg_pressure;
break;
case 0xB: // DOWN
stdpar[curPad][11] = avg_pressure;
break;
case 0x7: // LEFT
stdpar[curPad][9] = avg_pressure;
break;
case 0xD: // RIGHT
stdpar[curPad][8] = avg_pressure;
break;
default:
stdpar[curPad][8] = 0x00; // Not pressed
stdpar[curPad][9] = 0x00; // Not pressed
stdpar[curPad][10] = 0x00; // Not pressed
stdpar[curPad][11] = 0x00; // Not pressed
break;
}
buf = stdpar[curPad];
return padID[curPad];
case CMD_CONFIG_MODE: // CONFIG_MODE
cmdLen = 8;
buf = stdcfg[curPad];
if (stdcfg[curPad][3] == 0xff)
return 0xf3;
else
return padID[curPad];
case CMD_SET_MODE_AND_LOCK: // SET_MODE_AND_LOCK
cmdLen = 8;
buf = stdmode[curPad];
return 0xf3;
case CMD_QUERY_MODEL_AND_MODE: // QUERY_MODEL_AND_MODE
cmdLen = 8;
buf = stdmodel[curPad];
buf[4] = padMode[curPad];
return 0xf3;
case CMD_QUERY_ACT: // ??
cmdLen = 8;
buf = unk46[curPad];
return 0xf3;
case CMD_QUERY_COMB: // ??
cmdLen = 8;
buf = unk47[curPad];
return 0xf3;
case CMD_QUERY_MODE: // QUERY_MODE ??
cmdLen = 8;
buf = unk4c[curPad];
return 0xf3;
case CMD_VIBRATION_TOGGLE:
cmdLen = 8;
buf = unk4d[curPad];
return 0xf3;
case CMD_SET_DS2_NATIVE_MODE: // SET_DS2_NATIVE_MODE
cmdLen = 8;
padID[curPad] = 0x79; // setting ds2 mode
ds2mode = 1; // Set DS2 Mode
buf = cmd4f[curPad];
return 0xf3;
default:
PAD_LOG("*PADpoll*: unknown cmd %x\n", value);
break;
}
}
switch (curCmd)
{
case CMD_CONFIG_MODE:
if (curByte == 2)
{
switch (value)
{
case 0:
buf[2] = 0;
buf[3] = 0;
break;
case 1:
buf[2] = 0xff;
buf[3] = 0xff;
break;
}
}
break;
case CMD_SET_MODE_AND_LOCK:
if (curByte == 2)
{
PADsetMode(curPad, value);
}
break;
case CMD_QUERY_ACT:
if (curByte == 2)
{
switch (value)
{
case 0: // default
buf[5] = 0x2;
buf[6] = 0x0;
buf[7] = 0xA;
break;
case 1: // Param std conf change
buf[5] = 0x1;
buf[6] = 0x1;
buf[7] = 0x14;
break;
}
}
break;
case CMD_QUERY_MODE:
if (curByte == 2)
{
switch (value)
{
case 0: // mode 0 - digital mode
buf[5] = 0x4;
break;
case 1: // mode 1 - analog mode
buf[5] = 0x7;
break;
}
}
break;
}
if (curByte >= cmdLen) return 0;
return buf[curByte++];
}
EXPORT_C_(u8) PADpoll(u8 value)
{
u8 ret;
ret = _PADpoll(value);
//PAD_LOG("PADpoll: %x (%d: %x)\n", value, curByte, ret);
return ret;
}
// PADkeyEvent is called every vsync (return NULL if no event)
keyEvent* CALLBACK PADkeyEvent()
{
s_event = event;
event.evt = 0;
return &s_event;
}

168
plugins/onepad/onepad.h Normal file
View File

@ -0,0 +1,168 @@
/* OnePAD - author: arcum42(@gmail.com)
* Copyright (C) 2009
*
* Based on ZeroPAD, author zerofrog@gmail.com
* Copyright (C) 2006-2007
*
* 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
*/
#ifndef __PAD_H__
#define __PAD_H__
#include <stdio.h>
#include <assert.h>
#ifdef _WIN32
#include <windows.h>
#include <windowsx.h>
#else
#include <X11/Xlib.h>
#include <X11/Xutil.h>
#include <X11/keysym.h>
#endif
#include <vector>
#include <map>
#include <string>
#include <pthread.h>
using namespace std;
#define PADdefs
#include "PS2Edefs.h"
#ifdef __LINUX__
#include "joystick.h"
#endif
#include "analog.h"
#include "bitwise.h"
#include "controller.h"
extern char libraryName[256];
enum PadOptions
{
PADOPTION_FORCEFEEDBACK = 0x1,
PADOPTION_REVERTLX = 0x2,
PADOPTION_REVERTLY = 0x4,
PADOPTION_REVERTRX = 0x8,
PADOPTION_REVERTRY = 0x10
};
extern FILE *padLog;
extern void initLogging();
#define PAD_LOG __Log
//#define PAD_LOG __LogToConsole
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_R_LEFT = 27,
PAD_R_DOWN = 26,
PAD_R_RIGHT = 25,
PAD_R_UP = 24,
PAD_L_LEFT = 23,
PAD_L_DOWN = 22,
PAD_L_RIGHT = 21,
PAD_L_UP = 20,
PAD_RY = 19,
PAD_LY = 18,
PAD_RX = 17,
PAD_LX = 16,
PAD_LEFT = 15,
PAD_DOWN = 14,
PAD_RIGHT = 13,
PAD_UP = 12,
PAD_START = 11,
PAD_R3 = 10,
PAD_L3 = 9,
PAD_SELECT = 8,
PAD_SQUARE = 7,
PAD_CROSS = 6,
PAD_CIRCLE = 5,
PAD_TRIANGLE = 4,
PAD_R1 = 3,
PAD_L1 = 2,
PAD_R2 = 1,
PAD_L2 = 0
};
// Activate bolche's analog controls hack
// DEF_VALUE is the strength you press the control.
// Code taken from http://forums.pcsx2.net/thread-4699.html
#define DEF_VALUE 32766
/* end of pad.h */
extern keyEvent event;
extern u16 status[2];
extern u32 pads;
int POV(u32 direction, u32 angle);
s32 _PADopen(void *pDsp);
void _PADclose();
void _KeyPress(int pad, u32 key);
void _KeyRelease(int pad, u32 key);
void PADsetMode(int pad, int mode);
void _PADupdate(int pad);
void __Log(const char *fmt, ...);
void __LogToConsole(const char *fmt, ...);
void LoadConfig();
void SaveConfig();
void SysMessage(char *fmt, ...);
void UpdateKeys(int pad, int keyPress, int keyRelease);
#ifdef __cplusplus
#ifdef _MSC_VER
#define EXPORT_C_(type) extern "C" __declspec(dllexport) type CALLBACK
#else
#define EXPORT_C_(type) extern "C" type
#endif
#else
#ifdef _MSC_VER
#define EXPORT_C_(type) __declspec(dllexport) type __stdcall
#else
#define EXPORT_C_(type) type
#endif
#endif
#endif