git repos / blockattack-game

blame: source/code/joypad.h

normal view · raw

89c4a3a6 sago007 2008-08-29 14:32 1
/*
c53e6443 sago007 2012-04-17 11:04 2
===========================================================================
c53e6443 sago007 2012-04-17 11:04 3
blockattack - Block Attack - Rise of the Blocks
c53e6443 sago007 2012-04-17 11:04 4
Copyright (C) 2005-2012 Poul Sander
c53e6443 sago007 2012-04-17 11:04 5
c53e6443 sago007 2012-04-17 11:04 6
This program is free software: you can redistribute it and/or modify
c53e6443 sago007 2012-04-17 11:04 7
it under the terms of the GNU General Public License as published by
c53e6443 sago007 2012-04-17 11:04 8
the Free Software Foundation, either version 2 of the License, or
c53e6443 sago007 2012-04-17 11:04 9
(at your option) any later version.
c53e6443 sago007 2012-04-17 11:04 10
c53e6443 sago007 2012-04-17 11:04 11
This program is distributed in the hope that it will be useful,
c53e6443 sago007 2012-04-17 11:04 12
but WITHOUT ANY WARRANTY; without even the implied warranty of
c53e6443 sago007 2012-04-17 11:04 13
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
c53e6443 sago007 2012-04-17 11:04 14
GNU General Public License for more details.
c53e6443 sago007 2012-04-17 11:04 15
c53e6443 sago007 2012-04-17 11:04 16
You should have received a copy of the GNU General Public License
c53e6443 sago007 2012-04-17 11:04 17
along with this program.  If not, see http://www.gnu.org/licenses/
c53e6443 sago007 2012-04-17 11:04 18
c53e6443 sago007 2012-04-17 11:04 19
Source information and contacts persons can be found at
021de090 sago007 2015-12-30 18:56 20
http://blockattack.net
c53e6443 sago007 2012-04-17 11:04 21
===========================================================================
89c4a3a6 sago007 2008-08-29 14:32 22
*/
89c4a3a6 sago007 2008-08-29 14:32 23
89c4a3a6 sago007 2008-08-29 14:32 24
//headerfile joypad.h
89c4a3a6 sago007 2008-08-29 14:32 25
89c4a3a6 sago007 2008-08-29 14:32 26
#include <SDL.h>
89c4a3a6 sago007 2008-08-29 14:32 27
#include <stdlib.h>
89c4a3a6 sago007 2008-08-29 14:32 28
#include <iostream>
89c4a3a6 sago007 2008-08-29 14:32 29
89c4a3a6 sago007 2008-08-29 14:32 30
#define NRofPADS 4
89c4a3a6 sago007 2008-08-29 14:32 31
#define NRofBUTTONS 12
89c4a3a6 sago007 2008-08-29 14:32 32
c53e6443 sago007 2012-04-17 11:04 33
struct Joypad_status
c53e6443 sago007 2012-04-17 11:04 34
{
c53e6443 sago007 2012-04-17 11:04 35
	bool padLeft[NRofPADS];
c53e6443 sago007 2012-04-17 11:04 36
	bool padRight[NRofPADS];
c53e6443 sago007 2012-04-17 11:04 37
	bool padUp[NRofPADS];
c53e6443 sago007 2012-04-17 11:04 38
	bool padDown[NRofPADS];
c53e6443 sago007 2012-04-17 11:04 39
	bool button[NRofBUTTONS];
89c4a3a6 sago007 2008-08-29 14:32 40
};
89c4a3a6 sago007 2008-08-29 14:32 41
89c4a3a6 sago007 2008-08-29 14:32 42
//Contains the init code
89c4a3a6 sago007 2008-08-29 14:32 43
bool Joypad_init();
89c4a3a6 sago007 2008-08-29 14:32 44
89c4a3a6 sago007 2008-08-29 14:32 45
//How many joypads are availble?
89c4a3a6 sago007 2008-08-29 14:32 46
#define Joypad_number SDL_NumJoysticks()
89c4a3a6 sago007 2008-08-29 14:32 47
89c4a3a6 sago007 2008-08-29 14:32 48
//Open a joystick
89c4a3a6 sago007 2008-08-29 14:32 49
#define Joypad_open(X) SDL_JoystickOpen(X)
89c4a3a6 sago007 2008-08-29 14:32 50
89c4a3a6 sago007 2008-08-29 14:32 51
//Returns the status of the joypad
89c4a3a6 sago007 2008-08-29 14:32 52
Joypad_status Joypad_getStatus(SDL_Joystick);
89c4a3a6 sago007 2008-08-29 14:32 53
c53e6443 sago007 2012-04-17 11:04 54
class Joypad
c53e6443 sago007 2012-04-17 11:04 55
{
89c4a3a6 sago007 2008-08-29 14:32 56
private:
c53e6443 sago007 2012-04-17 11:04 57
	SDL_Joystick *joystick;
c53e6443 sago007 2012-04-17 11:04 58
	static int Joy_count;
89c4a3a6 sago007 2008-08-29 14:32 59
public:
c53e6443 sago007 2012-04-17 11:04 60
	bool up,down,left,right,but1,but2;
c53e6443 sago007 2012-04-17 11:04 61
	bool upREL,downREL,leftREL,rightREL,but1REL,but2REL;
c53e6443 sago007 2012-04-17 11:04 62
	bool working;
89c4a3a6 sago007 2008-08-29 14:32 63
c53e6443 sago007 2012-04-17 11:04 64
	Joypad();
c53e6443 sago007 2012-04-17 11:04 65
	~Joypad();
89c4a3a6 sago007 2008-08-29 14:32 66
c53e6443 sago007 2012-04-17 11:04 67
	void update();
89c4a3a6 sago007 2008-08-29 14:32 68
};
1970-01-01 00:00 69