-
Notifications
You must be signed in to change notification settings - Fork 0
/
keyselect.cpp
66 lines (49 loc) · 1.28 KB
/
keyselect.cpp
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
// keyselect.c
#include "stdafx.h"
#include "SDLU.h"
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <ctype.h>
#include "main.h"
#include "players.h"
#include "keyselect.h"
SDL_Keycode playerKeys[2][4] =
{
{ SDLK_a, SDLK_d, SDLK_x, SDLK_s },
{ SDLK_LEFT, SDLK_RIGHT, SDLK_DOWN, SDLK_UP }
};
const SDL_Keycode defaultPlayerKeys[2][4] =
{
{ SDLK_a, SDLK_d, SDLK_x, SDLK_s },
{ SDLK_LEFT, SDLK_RIGHT, SDLK_DOWN, SDLK_UP }
};
void CheckKeys()
{
int player;
int arraySize;
const Uint8* pressedKeys;
SDLU_PumpEvents();
pressedKeys = SDL_GetKeyboardState( &arraySize );
// Check for game keys
for( player = 0; player < 2; player++ )
{
if (pressedKeys[SDL_GetScancodeFromKey(playerKeys[player][0])])
hitKey[player].left++;
else
hitKey[player].left = 0;
if (pressedKeys[SDL_GetScancodeFromKey(playerKeys[player][1])])
hitKey[player].right++;
else
hitKey[player].right = 0;
if (pressedKeys[SDL_GetScancodeFromKey(playerKeys[player][2])])
hitKey[player].drop++;
else
hitKey[player].drop = 0;
if (pressedKeys[SDL_GetScancodeFromKey(playerKeys[player][3])])
hitKey[player].rotate++;
else
hitKey[player].rotate = 0;
}
pauseKey = pressedKeys[SDL_SCANCODE_ESCAPE];
}