Commit | Line | Data |
---|---|---|
ef79bbde P |
1 | /* |
2 | * Copyright (c) 2010, Wei Mingzhi <whistler@openoffice.org>. | |
3 | * All Rights Reserved. | |
4 | * | |
5 | * This program is free software; you can redistribute it and/or modify | |
6 | * it under the terms of the GNU General Public License as published by | |
7 | * the Free Software Foundation; either version 2 of the License, or | |
8 | * (at your option) any later version. | |
9 | * | |
10 | * This program is distributed in the hope that it will be useful, | |
11 | * but WITHOUT ANY WARRANTY; without even the implied warranty of | |
12 | * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the | |
13 | * GNU General Public License for more details. | |
14 | * | |
15 | * You should have received a copy of the GNU General Public License | |
16 | * along with this program; if not, see <http://www.gnu.org/licenses>. | |
17 | */ | |
18 | ||
19 | #include "pad.h" | |
20 | ||
21 | void InitKeyboard() { | |
22 | g.PadState[0].KeyStatus = 0xFFFF; | |
23 | g.PadState[1].KeyStatus = 0xFFFF; | |
24 | } | |
25 | ||
26 | void DestroyKeyboard() { | |
27 | } | |
28 | ||
29 | void CheckKeyboard() { | |
30 | int i, j, k; | |
31 | uint16_t key; | |
32 | ||
33 | union { | |
34 | KeyMap km; | |
35 | KeyMapByteArray k; | |
36 | } keyState; | |
37 | ||
38 | g.PadState[0].KeyStatus = 0xFFFF; | |
39 | g.PadState[1].KeyStatus = 0xFFFF; | |
40 | ||
41 | GetKeys(keyState.km); | |
42 | ||
43 | #define KeyDown(X) \ | |
44 | (keyState.k[((X) - 1) >> 3] & (1 << (((X) - 1) & 7))) | |
45 | ||
46 | for (i = 0; i < 2; i++) { | |
47 | for (j = 0; j < DKEY_TOTAL; j++) { | |
48 | key = g.cfg.PadDef[i].KeyDef[j].Key; | |
49 | if (key == 0) continue; | |
50 | ||
51 | if (KeyDown(key)) g.PadState[i].KeyStatus &= ~(1 << j); | |
52 | } | |
53 | ||
54 | if (g.cfg.PadDef[i].Type != PSE_PAD_TYPE_ANALOGPAD) continue; | |
55 | ||
56 | for (j = 0; j < ANALOG_TOTAL; j++) { | |
57 | for (k = 0; k < 4; k++) { | |
58 | key = g.cfg.PadDef[i].AnalogDef[j][k].Key; | |
59 | if (key == 0) continue; | |
60 | ||
61 | g.PadState[i].AnalogKeyStatus[j][k] = (KeyDown(key) ? 1 : 0); | |
62 | } | |
63 | } | |
64 | } | |
65 | } |