2009-07-03 11:45:47 +00:00
|
|
|
/* 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
|
2010-07-04 22:49:00 +00:00
|
|
|
* Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301, USA
|
2009-07-03 11:45:47 +00:00
|
|
|
*/
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2015-10-14 13:05:02 +00:00
|
|
|
#pragma once
|
2009-12-22 03:17:35 +00:00
|
|
|
|
2014-12-07 20:06:21 +00:00
|
|
|
#include <SDL.h>
|
|
|
|
#if SDL_MAJOR_VERSION >= 2
|
|
|
|
#include <SDL_haptic.h>
|
2009-07-03 11:45:47 +00:00
|
|
|
#endif
|
|
|
|
|
2015-10-14 13:05:02 +00:00
|
|
|
#include "GamePad.h"
|
2009-07-03 11:45:47 +00:00
|
|
|
#include "onepad.h"
|
2009-07-10 06:07:32 +00:00
|
|
|
#include "controller.h"
|
2015-10-14 14:06:31 +00:00
|
|
|
#define NB_EFFECT 2 // Don't use more than two, ps2 only has one for big motor and one for small(like most systems)
|
2009-07-03 11:45:47 +00:00
|
|
|
// holds all joystick info
|
2015-10-14 13:05:02 +00:00
|
|
|
class JoystickInfo : GamePad
|
2009-07-03 11:45:47 +00:00
|
|
|
{
|
|
|
|
public:
|
2016-08-12 20:37:37 +00:00
|
|
|
JoystickInfo() : GamePad(), joy(NULL) {
|
2013-11-01 21:05:59 +00:00
|
|
|
#if SDL_MAJOR_VERSION >= 2
|
2015-10-14 14:06:31 +00:00
|
|
|
haptic = NULL;
|
|
|
|
first = true;
|
2011-06-12 14:48:36 +00:00
|
|
|
#endif
|
|
|
|
}
|
|
|
|
|
2009-07-03 11:45:47 +00:00
|
|
|
~JoystickInfo()
|
|
|
|
{
|
|
|
|
Destroy();
|
|
|
|
}
|
|
|
|
|
2011-04-10 00:09:17 +00:00
|
|
|
JoystickInfo(const JoystickInfo&); // copy constructor
|
|
|
|
JoystickInfo& operator=(const JoystickInfo&); // assignment
|
2015-10-17 16:57:28 +00:00
|
|
|
|
2009-07-03 11:45:47 +00:00
|
|
|
void Destroy();
|
|
|
|
// opens handles to all possible joysticks
|
2015-10-14 13:05:02 +00:00
|
|
|
static void EnumerateJoysticks(vector<GamePad*>& vjoysticks);
|
2009-07-03 11:45:47 +00:00
|
|
|
|
2015-10-14 14:06:31 +00:00
|
|
|
void Rumble(int type,int pad);
|
2011-06-12 14:48:36 +00:00
|
|
|
|
2011-04-10 00:09:17 +00:00
|
|
|
bool Init(int id); // opens a handle and gets information
|
2009-07-03 11:45:47 +00:00
|
|
|
|
2015-10-17 16:57:28 +00:00
|
|
|
bool TestForce(float);
|
2009-07-03 11:45:47 +00:00
|
|
|
|
2011-06-12 14:48:36 +00:00
|
|
|
bool PollButtons(u32 &pkey);
|
|
|
|
bool PollAxes(u32 &pkey);
|
|
|
|
bool PollHats(u32 &pkey);
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2015-10-14 13:05:02 +00:00
|
|
|
int GetHat(int key_to_axis);
|
|
|
|
|
|
|
|
int GetButton(int key_to_button);
|
|
|
|
|
2009-07-03 11:45:47 +00:00
|
|
|
|
|
|
|
void SaveState();
|
2010-04-25 00:31:27 +00:00
|
|
|
|
2010-06-05 11:03:12 +00:00
|
|
|
int GetAxisFromKey(int pad, int index);
|
2011-06-19 16:13:41 +00:00
|
|
|
|
2013-11-01 21:05:59 +00:00
|
|
|
static void UpdateReleaseState();
|
|
|
|
|
2009-07-03 11:45:47 +00:00
|
|
|
private:
|
2015-10-14 13:05:02 +00:00
|
|
|
SDL_Joystick* GetJoy()
|
|
|
|
{
|
|
|
|
return joy;
|
|
|
|
}
|
2015-10-14 14:06:31 +00:00
|
|
|
void GenerateDefaultEffect();
|
2009-07-03 11:45:47 +00:00
|
|
|
|
2011-06-12 14:48:36 +00:00
|
|
|
SDL_Joystick* joy;
|
2013-11-01 21:05:59 +00:00
|
|
|
#if SDL_MAJOR_VERSION >= 2
|
2011-06-12 14:48:36 +00:00
|
|
|
SDL_Haptic* haptic;
|
2015-10-14 14:06:31 +00:00
|
|
|
bool first;
|
|
|
|
SDL_HapticEffect effects[NB_EFFECT];
|
|
|
|
int effects_id[NB_EFFECT];
|
2011-06-12 14:48:36 +00:00
|
|
|
#endif
|
2009-07-03 11:45:47 +00:00
|
|
|
};
|