some random fixes.
This commit is contained in:
@ -1,16 +1,33 @@
|
||||
#include <gamepad.h>
|
||||
#include <string.h>
|
||||
#include <interrupts.h>
|
||||
|
||||
typedef struct {
|
||||
bool button_sel;
|
||||
bool dir_sel;
|
||||
gamepad_state controller;
|
||||
gamepad_state prev;
|
||||
} gamepad_context;
|
||||
|
||||
static gamepad_context ctx = {0};
|
||||
|
||||
void gamepad_init();
|
||||
|
||||
void gamepad_int_update(){
|
||||
if(ctx.button_sel) {
|
||||
if((ctx.prev.a == 1 && ctx.controller.a == 0) || (ctx.prev.b == 1 && ctx.controller.b == 0) || (ctx.prev.select == 1 && ctx.controller.select == 0) || (ctx.prev.start == 1 && ctx.controller.start == 0)) {
|
||||
cpu_request_interrupt(IT_JOYPAD);
|
||||
return;
|
||||
}
|
||||
}
|
||||
if(ctx.dir_sel) {
|
||||
if((ctx.prev.up == 1 && ctx.controller.up == 0) || (ctx.prev.down == 1 && ctx.controller.down == 0) || (ctx.prev.left == 1 && ctx.controller.left == 0) || (ctx.prev.right == 1 && ctx.controller.right == 0)) {
|
||||
cpu_request_interrupt(IT_JOYPAD);
|
||||
}
|
||||
}
|
||||
|
||||
}
|
||||
|
||||
bool gamepad_button_sel(){
|
||||
return ctx.button_sel;
|
||||
}
|
||||
|
Reference in New Issue
Block a user