Book a Demo!
CoCalc Logo Icon
StoreFeaturesDocsShareSupportNewsAboutPoliciesSign UpSign In
alexbevi
GitHub Repository: alexbevi/BizHawk
Path: blob/master/yabause/src/dreamcast/perdc.c
2 views
1
/* Copyright 2005-2008 Lawrence Sebald
2
3
This file is part of Yabause.
4
5
Yabause 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
Yabause 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 Yabause; if not, write to the Free Software
17
Foundation, Inc., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA
18
*/
19
20
#include "perdc.h"
21
#include "../yabause.h"
22
#include "../yui.h"
23
#include "../vdp2.h"
24
25
#include <dc/maple.h>
26
#include <dc/maple/controller.h>
27
28
int PERDCInit(void);
29
void PERDCDeInit(void);
30
int PERDCHandleEvents(void);
31
void PERDCNothing(void);
32
u32 PERDCScan(void);
33
34
static PerPad_struct *pad1;
35
36
PerInterface_struct PERDC = {
37
PERCORE_DC,
38
"Dreamcast Input Interface",
39
PERDCInit,
40
PERDCDeInit,
41
PERDCHandleEvents,
42
PERDCNothing,
43
PERDCScan,
44
0,
45
PERDCNothing
46
};
47
48
int PERDCInit(void) {
49
PerPortReset();
50
pad1 = PerPadAdd(&PORTDATA1);
51
return 0;
52
}
53
54
void PERDCDeInit(void) {
55
}
56
57
int PERDCHandleEvents(void) {
58
maple_device_t *dev;
59
60
dev = maple_enum_type(0, MAPLE_FUNC_CONTROLLER);
61
if(dev != NULL) {
62
cont_state_t *state = (cont_state_t *) maple_dev_status(dev);
63
64
if(state != NULL) {
65
if(state->buttons & CONT_DPAD_UP)
66
*pad1->padbits &= 0xEF;
67
else
68
*pad1->padbits |= 0x10;
69
70
if(state->buttons & CONT_DPAD_DOWN)
71
*pad1->padbits &= 0xDF;
72
else
73
*pad1->padbits |= 0x20;
74
75
if(state->buttons & CONT_DPAD_RIGHT)
76
*pad1->padbits &= 0x7F;
77
else
78
*pad1->padbits |= 0x80;
79
80
if(state->buttons & CONT_DPAD_LEFT)
81
*pad1->padbits &= 0xBF;
82
else
83
*pad1->padbits |= 0x40;
84
85
if(state->buttons & CONT_START)
86
*pad1->padbits &= 0xF7;
87
else
88
*pad1->padbits |= 0x08;
89
90
if(state->buttons & CONT_A)
91
*pad1->padbits &= 0xFB;
92
else
93
*pad1->padbits |= 0x04;
94
95
if(state->buttons & CONT_B)
96
*pad1->padbits &= 0xFE;
97
else
98
*pad1->padbits |= 0x01;
99
100
if(state->buttons & CONT_X)
101
*(pad1->padbits + 1) &= 0xBF;
102
else
103
*(pad1->padbits + 1) |= 0x40;
104
105
if(state->buttons & CONT_Y)
106
*(pad1->padbits + 1) &= 0xDF;
107
else
108
*(pad1->padbits + 1) |= 0x20;
109
110
if(state->rtrig > 20)
111
*(pad1->padbits + 1) &= 0x7F;
112
else
113
*(pad1->padbits + 1) |= 0x80;
114
115
if(state->ltrig > 20)
116
*(pad1->padbits + 1) &= 0xF7;
117
else
118
*(pad1->padbits + 1) |= 0x08;
119
120
if(state->joyx > 20)
121
*pad1->padbits &= 0xFD;
122
else
123
*pad1->padbits |= 0x02;
124
125
if(state->joyy > 20)
126
*(pad1->padbits + 1) &= 0xEF;
127
else
128
*(pad1->padbits + 1) |= 0x10;
129
130
}
131
}
132
133
YabauseExec();
134
135
return 0;
136
}
137
138
void PERDCNothing(void) {
139
/* Nothing */
140
}
141
142
u32 PERDCScan(void) {
143
/* Nothing */
144
return 0;
145
}
146
147