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
|
|
|
*/
|
|
|
|
|
|
|
|
#ifndef __CONTROLLER_H__
|
|
|
|
#define __CONTROLLER_H__
|
|
|
|
|
|
|
|
#ifdef __LINUX__
|
2011-06-12 14:48:36 +00:00
|
|
|
#define MAX_KEYS 24
|
2009-07-03 11:45:47 +00:00
|
|
|
#else
|
2009-07-10 06:07:32 +00:00
|
|
|
#define MAX_KEYS 20
|
2009-07-03 11:45:47 +00:00
|
|
|
#endif
|
|
|
|
|
|
|
|
enum KeyType
|
|
|
|
{
|
2011-06-12 14:48:36 +00:00
|
|
|
PAD_JOYBUTTONS = 0,
|
|
|
|
PAD_AXIS,
|
2009-07-03 11:45:47 +00:00
|
|
|
PAD_HAT,
|
|
|
|
PAD_NULL = -1
|
|
|
|
};
|
|
|
|
|
2011-06-12 14:48:36 +00:00
|
|
|
extern void set_keyboad_key(int pad, int keysym, int index);
|
|
|
|
extern int get_keyboard_key(int pad, int keysym);
|
2009-11-14 09:02:10 +00:00
|
|
|
extern void set_key(int pad, int index, int value);
|
2009-07-03 11:45:47 +00:00
|
|
|
extern int get_key(int pad, int index);
|
2011-06-12 14:48:36 +00:00
|
|
|
extern bool IsAnalogKey(int index);
|
2009-07-03 11:45:47 +00:00
|
|
|
|
2011-06-12 14:48:36 +00:00
|
|
|
extern KeyType type_of_joykey(int pad, int index);
|
2009-07-10 00:05:05 +00:00
|
|
|
extern int key_to_button(int pad, int index);
|
|
|
|
extern int key_to_axis(int pad, int index);
|
2011-06-12 14:48:36 +00:00
|
|
|
extern bool key_to_axis_sign(int pad, int index);
|
|
|
|
extern bool key_to_axis_type(int pad, int index);
|
2009-07-10 00:05:05 +00:00
|
|
|
extern int key_to_hat_dir(int pad, int index);
|
|
|
|
|
2011-06-12 14:48:36 +00:00
|
|
|
extern int button_to_key(int button_id);
|
|
|
|
extern int axis_to_key(int full_axis, int sign, int axis_id);
|
|
|
|
extern int hat_to_key(int dir, int axis_id);
|
2009-07-03 11:45:47 +00:00
|
|
|
|
|
|
|
extern int PadEnum[2][2];
|
|
|
|
|
2011-06-12 14:48:36 +00:00
|
|
|
struct PADconf
|
2009-07-10 06:07:32 +00:00
|
|
|
{
|
2011-06-12 14:48:36 +00:00
|
|
|
public:
|
|
|
|
u32 keys[2][MAX_KEYS];
|
2009-07-03 11:45:47 +00:00
|
|
|
u32 log;
|
|
|
|
u32 options; // upper 16 bits are for pad2
|
2011-06-12 14:48:36 +00:00
|
|
|
u32 sensibility;
|
|
|
|
u32 joyid_map;
|
2011-08-20 12:17:47 +00:00
|
|
|
u32 ff_intensity;
|
2011-06-12 14:48:36 +00:00
|
|
|
map<u32,u32> keysym_map[2];
|
|
|
|
|
|
|
|
PADconf() { init(); }
|
|
|
|
|
|
|
|
void init() {
|
|
|
|
memset(&keys, 0, sizeof(keys));
|
|
|
|
log = options = joyid_map = 0;
|
2011-08-20 12:17:47 +00:00
|
|
|
ff_intensity = 100;
|
2011-06-12 14:48:36 +00:00
|
|
|
sensibility = 500;
|
|
|
|
for (int pad = 0; pad < 2 ; pad++)
|
|
|
|
keysym_map[pad].clear();
|
|
|
|
}
|
|
|
|
|
|
|
|
void set_joyid(u32 pad, u32 joy_id) {
|
|
|
|
int shift = 8 * pad;
|
|
|
|
joyid_map &= ~(0xFF << shift); // clear
|
|
|
|
joyid_map |= (joy_id & 0xFF) << shift; // set
|
|
|
|
}
|
|
|
|
|
|
|
|
u32 get_joyid(u32 pad) {
|
|
|
|
int shift = 8 * pad;
|
|
|
|
return ((joyid_map >> shift) & 0xFF);
|
|
|
|
}
|
|
|
|
};
|
|
|
|
extern PADconf *conf;
|
2009-11-14 09:02:10 +00:00
|
|
|
#endif
|