mirror of
https://github.com/libretro/pcsx2.git
synced 2025-01-11 03:56:13 +00:00
Zeropad: Add analog.cpp & analog.h.
git-svn-id: http://pcsx2.googlecode.com/svn/trunk@1163 96395faa-99c1-11dd-bbfe-3dabce05a288
This commit is contained in:
parent
0b23b77051
commit
05867d69cb
153
plugins/zeropad/analog.cpp
Normal file
153
plugins/zeropad/analog.cpp
Normal file
@ -0,0 +1,153 @@
|
||||
/* 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);
|
||||
break;
|
||||
|
||||
case PAD_RX:
|
||||
return (conf.options & PADOPTION_REVERTRX);
|
||||
break;
|
||||
|
||||
case PAD_LY:
|
||||
return (conf.options & PADOPTION_REVERTLY);
|
||||
break;
|
||||
|
||||
case PAD_RY:
|
||||
return (conf.options & PADOPTION_REVERTRY);
|
||||
break;
|
||||
|
||||
default:
|
||||
return false;
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
void ConfigurePad(int padvalue, u8 i, int value)
|
||||
{
|
||||
SetPad(padvalue, i, value / 256);
|
||||
if (RevertPad(padvalue)) InvertPad(padvalue, i);
|
||||
SetPad(padvalue, i, Pad(padvalue, i) + 0x80);
|
||||
}
|
||||
|
||||
#ifdef ANALOG_CONTROLS_HACK
|
||||
int KeypadToPad(u8 keypress)
|
||||
{
|
||||
switch (keypress)
|
||||
{
|
||||
case KEY_PAD_LX_LEFT:
|
||||
case KEY_PAD_LX_RIGHT:
|
||||
return PAD_LX;
|
||||
break;
|
||||
case KEY_PAD_LY_UP:
|
||||
case KEY_PAD_LY_DOWN:
|
||||
return PAD_LY;
|
||||
break;
|
||||
case KEY_PAD_RX_LEFT:
|
||||
case KEY_PAD_RX_RIGHT:
|
||||
return PAD_RX;
|
||||
break;
|
||||
case KEY_PAD_RY_UP:
|
||||
case KEY_PAD_RY_DOWN:
|
||||
return PAD_RY;
|
||||
break;
|
||||
}
|
||||
}
|
||||
#endif
|
||||
}
|
32
plugins/zeropad/analog.h
Normal file
32
plugins/zeropad/analog.h
Normal file
@ -0,0 +1,32 @@
|
||||
/* 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 "zeropad.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);
|
||||
}
|
Loading…
x
Reference in New Issue
Block a user