File: KeyStatus.h

package info (click to toggle)
pcsx2 1.4.0%2Bdfsg-2
  • links: PTS, VCS
  • area: main
  • in suites: stretch
  • size: 22,172 kB
  • ctags: 40,348
  • sloc: cpp: 232,892; ansic: 22,912; asm: 2,273; lisp: 1,346; sh: 561; perl: 253; makefile: 113; xml: 69
file content (74 lines) | stat: -rw-r--r-- 1,904 bytes parent folder | download
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
/*  OnePAD - author: arcum42(@gmail.com)
 *  Copyright (C) 2011
 *
 *  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
 */

#ifndef __KEYSTATUS_H__
#define __KEYSTATUS_H__

#include "onepad.h"

typedef struct
{
	u8 lx, ly;
	u8 rx, ry;
} PADAnalog;

#define MAX_ANALOG_VALUE	  	32766

class KeyStatus
{
	private:
		u16 m_button[2];
		u16 m_internal_button_kbd[2];
		u16 m_internal_button_joy[2];

		u8 m_button_pressure[2][MAX_KEYS];
		u8 m_internal_button_pressure[2][MAX_KEYS];

		bool m_state_acces[2];

		PADAnalog m_analog[2];
		PADAnalog m_internal_analog_kbd[2];
		PADAnalog m_internal_analog_joy[2];

		void analog_set(u32 pad, u32 index, u8 value);
		bool analog_is_reversed(u32 pad, u32 index);
		u8   analog_merge(u8 kbd, u8 joy);

	public:
		KeyStatus() { Init(); }
		void Init();

		void keyboard_state_acces(u32 pad) { m_state_acces[pad] = true; }
		void joystick_state_acces(u32 pad) { m_state_acces[pad] = false; }

		void press(u32 pad, u32 index, s32 value = 0xFF);
		void release(u32 pad, u32 index);

		u16  get(u32 pad);
		u8   get(u32 pad, u32 index);


		void commit_status(u32 pad);
};

extern KeyStatus* key_status;

#endif