pcsx2/plugins/onepad/Linux/linux.cpp

134 lines
3.2 KiB
C++
Raw Normal View History

/* 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
*/
#include "GamePad.h"
#include "onepad.h"
#include "keyboard.h"
#include "state_management.h"
#include <string.h>
#include <gtk/gtk.h>
#include "linux.h"
Display *GSdsp;
2016-09-04 12:10:02 +00:00
Window GSwin;
void SysMessage(const char *fmt, ...)
{
va_list list;
char msg[512];
va_start(list, fmt);
vsprintf(msg, fmt, list);
va_end(list);
2016-09-04 12:10:02 +00:00
if (msg[strlen(msg) - 1] == '\n')
msg[strlen(msg) - 1] = 0;
GtkWidget *dialog;
2016-09-04 12:10:02 +00:00
dialog = gtk_message_dialog_new(NULL,
GTK_DIALOG_DESTROY_WITH_PARENT,
GTK_MESSAGE_INFO,
GTK_BUTTONS_OK,
"%s", msg);
gtk_dialog_run(GTK_DIALOG(dialog));
gtk_widget_destroy(dialog);
}
2016-09-04 12:10:02 +00:00
EXPORT_C_(void)
PADabout()
{
2016-09-04 12:10:02 +00:00
SysMessage("OnePad is a rewrite of Zerofrog's ZeroPad, done by arcum42.");
}
2016-09-04 12:10:02 +00:00
EXPORT_C_(s32)
PADtest()
{
2016-09-04 12:10:02 +00:00
return 0;
}
2016-09-04 12:10:02 +00:00
s32 _PADopen(void *pDsp)
{
2016-09-04 12:10:02 +00:00
GSdsp = *(Display **)pDsp;
GSwin = (Window) * (((u32 *)pDsp) + 1);
SetAutoRepeat(false);
2016-09-04 12:10:02 +00:00
return 0;
}
void _PADclose()
{
2016-09-04 12:10:02 +00:00
SetAutoRepeat(true);
2016-09-04 12:10:02 +00:00
s_vgamePad.clear();
}
void PollForJoystickInput(int cpad)
{
2016-09-04 12:10:02 +00:00
int joyid = conf->get_joyid(cpad);
if (!GamePadIdWithinBounds(joyid))
return;
}
2016-09-04 12:10:02 +00:00
EXPORT_C_(void)
PADupdate(int pad)
{
2016-09-04 12:10:02 +00:00
// Gamepad inputs don't count as an activity. Therefore screensaver will
// be fired after a couple of minute.
// Emulate an user activity
static int count = 0;
count++;
if ((count & 0xFFF) == 0) {
// 1 call every 4096 Vsync is enough
XResetScreenSaver(GSdsp);
}
// Actually PADupdate is always call with pad == 0. So you need to update both
// pads -- Gregory
// Poll keyboard/mouse event. There is currently no way to separate pad0 from pad1 event.
// So we will populate both pad in the same time
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
key_status->keyboard_state_acces(cpad);
}
PollForX11KeyboardInput();
// Get joystick state + Commit
for (int cpad = 0; cpad < GAMEPAD_NUMBER; cpad++) {
key_status->joystick_state_acces(cpad);
PollForJoystickInput(cpad);
key_status->commit_status(cpad);
}
Pad::rumble_all();
}
2016-09-04 12:10:02 +00:00
EXPORT_C_(void)
PADconfigure()
{
2016-09-04 12:10:02 +00:00
LoadConfig();
2016-09-04 12:10:02 +00:00
DisplayDialog();
return;
}