forked from vrmiguel/sm64-analog-camera
-
Notifications
You must be signed in to change notification settings - Fork 0
/
controller_entry_point.c
61 lines (49 loc) · 1.64 KB
/
controller_entry_point.c
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
#include "lib/src/libultra_internal.h"
#include "lib/src/osContInternal.h"
#include "controller_recorded_tas.h"
#include "controller_keyboard.h"
#include <stdio.h>
#include "controller_sdl.h"
int16_t rightx;
int16_t righty;
int c_rightx;
int c_righty;
// Analog camera movement by Pathétique (github.com/vrmiguel), y0shin and Mors
// Contribute or communicate bugs at github.com/vrmiguel/sm64-analog-camera
static struct ControllerAPI *controller_implementations[] = {
&controller_recorded_tas,
&controller_sdl,
&controller_keyboard,
};
s32 osContInit(OSMesgQueue *mq, u8 *controllerBits, OSContStatus *status) {
for (size_t i = 0; i < sizeof(controller_implementations) / sizeof(struct ControllerAPI *); i++) {
controller_implementations[i]->init();
}
*controllerBits = 1;
return 0;
}
s32 osContStartReadData(OSMesgQueue *mesg) {
return 0;
}
void osContGetReadData(OSContPad *pad) {
pad->button = 0;
pad->stick_x = 0;
pad->stick_y = 0;
pad->errnum = 0;
// sm64_analog_camera: saves the P1's right stick data in order to feed P2's left stick later on.
if (magnitude_sq > (uint32_t)(DEADZONE * DEADZONE)) {
c_rightx = rightx / 0x100;
int stick_y = -righty / 0x100;
c_righty = stick_y == 128 ? 127 : stick_y;
}
else {
c_rightx = 0;
c_righty = 0;
}
// End of new code
//if(rightx != 0 || righty !=0)
// printf("%d, %d\n", c_rightx, c_righty); // is righty broken?
for (size_t i = 0; i < sizeof(controller_implementations) / sizeof(struct ControllerAPI *); i++) {
controller_implementations[i]->read(pad);
}
}