File: GamePad.cpp

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 (57 lines) | stat: -rw-r--r-- 1,140 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
#include "GamePad.h"
#ifdef  SDL_BUILD
#include "SDL/joystick.h"
#endif

vector<GamePad*> s_vgamePad;
bool GamePadIdWithinBounds(int GamePadId)
{
	return ((GamePadId >= 0) && (GamePadId < (int)s_vgamePad.size()));
}

/**
 * Following static methods are just forwarders to their backend
 * This is where link between agnostic and specific code is done
 **/

/**
 * Find every interesting devices and create right structure for them(depend on backend)
 **/
void GamePad::EnumerateGamePads(vector<GamePad*>& vgamePad)
{
#ifdef  SDL_BUILD
	JoystickInfo::EnumerateJoysticks(vgamePad);
#endif
}

void GamePad::UpdateReleaseState()
{
#ifdef  SDL_BUILD
	JoystickInfo::UpdateReleaseState();
#endif
}

/**
 * Safely dispatch to the Rumble method above
 **/
void GamePad::DoRumble(int type, int pad)
{
	u32 id = conf->get_joyid(pad);
	if (GamePadIdWithinBounds(id)) {
		GamePad* gamePad = s_vgamePad[id];
		if (gamePad)
			gamePad->Rumble(type, pad);
	}
}

/**
 * Update state of every attached devices
 **/
void GamePad::UpdateGamePadState()
{
#ifdef  SDL_BUILD
	SDL_JoystickUpdate(); // No need to make yet another function call for that
#endif
}