mirror of
https://github.com/Ryuzaki-MrL/savemii.git
synced 2026-03-21 17:54:06 -05:00
Merge pull request #5 from jakobkg/padscore
Add support for additional controllers to SaveMii's menus
This commit is contained in:
commit
1e9bda828c
336
src/controllers.c
Normal file
336
src/controllers.c
Normal file
|
|
@ -0,0 +1,336 @@
|
|||
//Based on code from lib_easy, current stickPos() is straight borrowed from there
|
||||
|
||||
#include "controllers.h"
|
||||
|
||||
int vpadError = -1;
|
||||
VPADData vpad;
|
||||
|
||||
s32 padErrors[4];
|
||||
u32 padTypes[4];
|
||||
KPADData pads[4];
|
||||
|
||||
void pingControllers() {
|
||||
for (int i = 0; i < 4; i++) {
|
||||
padErrors[i] = WPADProbe(i, &padTypes[i]);
|
||||
}
|
||||
}
|
||||
|
||||
void updateButtons() {
|
||||
VPADRead(0, &vpad, 1, &vpadError);
|
||||
buttons_pressed[0] = vpad.btns_d;
|
||||
buttons_hold[0] = vpad.btns_h;
|
||||
buttons_released[0] = vpad.btns_r;
|
||||
|
||||
pingControllers();
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (padErrors[i] == 0) {
|
||||
KPADRead(i, &pads[i], 1);
|
||||
if (isWiimote(&pads[i])) {
|
||||
buttons_pressed[i + 1] = pads[i].btns_d;
|
||||
buttons_hold[i + 1] = pads[i].btns_h;
|
||||
buttons_released[i + 1] = pads[i].btns_r;
|
||||
}
|
||||
else if (isClassicController(&pads[i])) {
|
||||
buttons_pressed[i + 1] = pads[i].classic.btns_d;
|
||||
buttons_hold[i + 1] = pads[i].classic.btns_h;
|
||||
buttons_released[i + 1] = pads[i].classic.btns_r;
|
||||
}
|
||||
else if (isProController(&pads[i])) {
|
||||
buttons_pressed[i + 1] = pads[i].pro.btns_d;
|
||||
buttons_hold[i + 1] = pads[i].pro.btns_h;
|
||||
buttons_released[i + 1] = pads[i].pro.btns_r;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
bool stickPos(u8 stick, f32 value) {
|
||||
switch(stick) {
|
||||
case 0 :
|
||||
return (value > 0) ? (vpad.lstick.x > value): (vpad.lstick.x < value);
|
||||
case 1 :
|
||||
return (value > 0) ? (vpad.lstick.y > value): (vpad.lstick.y < value);
|
||||
case 2 :
|
||||
return (value > 0) ? (vpad.rstick.x > value): (vpad.rstick.x < value);
|
||||
case 3 :
|
||||
return (value > 0) ? (vpad.rstick.y > value): (vpad.rstick.y < value);
|
||||
case 4 :
|
||||
return ((vpad.lstick.x > value) || (vpad.lstick.x < -value)) || \
|
||||
((vpad.lstick.y > value) || (vpad.lstick.y < -value)) || \
|
||||
((vpad.rstick.x > value) || (vpad.rstick.x < -value)) || \
|
||||
((vpad.rstick.y > value) || (vpad.rstick.y < -value));
|
||||
|
||||
default :
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
|
||||
bool isWiimote(KPADData *padData){
|
||||
return padData->device_type == 0 || padData->device_type == 1 || padData->device_type == 5 || padData->device_type == 6;
|
||||
}
|
||||
|
||||
bool isClassicController(KPADData *padData){
|
||||
return padData->device_type == 2 || padData->device_type == 7;
|
||||
}
|
||||
|
||||
bool isProController(KPADData *padData){
|
||||
return padData->device_type == 31;
|
||||
}
|
||||
|
||||
int checkButton(int button, int state) {
|
||||
uint32_t *stateArray;
|
||||
|
||||
switch(state) {
|
||||
case PRESS:
|
||||
stateArray = &buttons_pressed;
|
||||
break;
|
||||
|
||||
case HOLD:
|
||||
stateArray = &buttons_hold;
|
||||
break;
|
||||
|
||||
case RELEASE:
|
||||
stateArray = &buttons_released;
|
||||
break;
|
||||
|
||||
default:
|
||||
return 0;
|
||||
}
|
||||
|
||||
//Check for any button at all
|
||||
if (button == PAD_BUTTON_ANY) {
|
||||
for (int i = 0; i < 5; i++) {
|
||||
if (stateArray[i] > 0) return 1;
|
||||
}
|
||||
}
|
||||
|
||||
//VPad buttons
|
||||
switch (button) {
|
||||
case PAD_BUTTON_A:
|
||||
if (stateArray[0] & VPAD_BUTTON_A) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_B:
|
||||
if (stateArray[0] & VPAD_BUTTON_B) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_X:
|
||||
if (stateArray[0] & VPAD_BUTTON_X) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_Y:
|
||||
if (stateArray[0] & VPAD_BUTTON_Y) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_UP:
|
||||
if (stateArray[0] & VPAD_BUTTON_UP) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_DOWN:
|
||||
if (stateArray[0] & VPAD_BUTTON_DOWN) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_LEFT:
|
||||
if (stateArray[0] & VPAD_BUTTON_LEFT) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_RIGHT:
|
||||
if (stateArray[0] & VPAD_BUTTON_RIGHT) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_L:
|
||||
if (stateArray[0] & VPAD_BUTTON_L) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_R:
|
||||
if (stateArray[0] & VPAD_BUTTON_R) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_ZL:
|
||||
if (stateArray[0] & VPAD_BUTTON_ZL) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_ZR:
|
||||
if (stateArray[0] & VPAD_BUTTON_ZR) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_PLUS:
|
||||
if (stateArray[0] & VPAD_BUTTON_PLUS) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_MINUS:
|
||||
if (stateArray[0] & VPAD_BUTTON_MINUS) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_HOME:
|
||||
if (stateArray[0] & VPAD_BUTTON_HOME) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_SYNC:
|
||||
if (stateArray[0] & VPAD_BUTTON_SYNC) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_STICK_L:
|
||||
if (stateArray[0] & VPAD_BUTTON_L) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_STICK_R:
|
||||
if (stateArray[0] & VPAD_BUTTON_STICK_R) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_TV:
|
||||
if (stateArray[0] & VPAD_BUTTON_TV) return 1;
|
||||
break;
|
||||
|
||||
default:
|
||||
break;
|
||||
}
|
||||
|
||||
//Buttons handled by the padscore library
|
||||
for (int i = 0; i < 4; i++) {
|
||||
if (padErrors[i] == 0) {
|
||||
if (isWiimote(&pads[i])) {
|
||||
switch (button) {
|
||||
case PAD_BUTTON_UP:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_UP) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_DOWN:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_DOWN) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_LEFT:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_LEFT) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_RIGHT:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_RIGHT) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_A:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_A) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_B:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_B) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_L:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_1) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_R:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_2) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_1:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_1) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_2:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_2) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_Z:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_Z) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_C:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_C) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_PLUS:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_PLUS) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_MINUS:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_MINUS) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_HOME:
|
||||
if (stateArray[i + 1] & WPAD_BUTTON_HOME) return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
//Turns out the Pro Controller and Classic Controller have almost the exact same mapping
|
||||
//Except for the Pro Controller having clicky sticks
|
||||
else if (isClassicController(&pads[i]) || isProController(&pads[i])) {
|
||||
switch (button) {
|
||||
case PAD_BUTTON_UP:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_UP) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_DOWN:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_DOWN) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_LEFT:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_LEFT) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_RIGHT:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_RIGHT) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_A:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_A) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_B:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_B) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_X:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_X) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_Y:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_Y) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_L:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_L) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_R:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_R) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_ZL:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_ZL) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_ZR:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_ZR) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_PLUS:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_PLUS) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_MINUS:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_MINUS) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_HOME:
|
||||
if (stateArray[i + 1] & WPAD_CLASSIC_BUTTON_HOME) return 1;
|
||||
break;
|
||||
}
|
||||
//Here, we handle the aforementioned clicky sticks
|
||||
if (isProController(&pads[i])) {
|
||||
switch (button) {
|
||||
case PAD_BUTTON_STICK_L:
|
||||
if (stateArray[i + 1] & WPAD_PRO_BUTTON_STICK_L) return 1;
|
||||
break;
|
||||
|
||||
case PAD_BUTTON_STICK_R:
|
||||
if (stateArray[i + 1] & WPAD_PRO_BUTTON_STICK_R) return 1;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return 0;
|
||||
}
|
||||
55
src/controllers.h
Normal file
55
src/controllers.h
Normal file
|
|
@ -0,0 +1,55 @@
|
|||
#ifndef CONTROLLERS_H
|
||||
#define CONTROLLERS_H
|
||||
|
||||
#include "dynamic_libs/padscore_functions.h"
|
||||
#include "dynamic_libs/vpad_functions.h"
|
||||
|
||||
enum buttons {
|
||||
PAD_BUTTON_A,
|
||||
PAD_BUTTON_B,
|
||||
PAD_BUTTON_X,
|
||||
PAD_BUTTON_Y,
|
||||
PAD_BUTTON_UP,
|
||||
PAD_BUTTON_DOWN,
|
||||
PAD_BUTTON_LEFT,
|
||||
PAD_BUTTON_RIGHT,
|
||||
PAD_BUTTON_L,
|
||||
PAD_BUTTON_R,
|
||||
PAD_BUTTON_ZL,
|
||||
PAD_BUTTON_ZR,
|
||||
PAD_BUTTON_PLUS,
|
||||
PAD_BUTTON_MINUS,
|
||||
PAD_BUTTON_Z,
|
||||
PAD_BUTTON_C,
|
||||
PAD_BUTTON_STICK_L,
|
||||
PAD_BUTTON_STICK_R,
|
||||
PAD_BUTTON_HOME,
|
||||
PAD_BUTTON_SYNC,
|
||||
PAD_BUTTON_TV,
|
||||
PAD_BUTTON_1,
|
||||
PAD_BUTTON_2,
|
||||
PAD_BUTTON_ANY
|
||||
};
|
||||
|
||||
enum buttonStates {
|
||||
PRESS,
|
||||
HOLD,
|
||||
RELEASE
|
||||
};
|
||||
|
||||
uint32_t buttons_hold[5]; //Held buttons
|
||||
uint32_t buttons_pressed[5]; //Pressed buttons
|
||||
uint32_t buttons_released[5]; //Released buttons
|
||||
|
||||
void pingControllers();
|
||||
void updateButtons();
|
||||
bool stickPos(u8 stick, f32 value);
|
||||
bool isWiimote(KPADData *padData);
|
||||
bool isClassicController(KPADData *padData);
|
||||
bool isProController(KPADData *padData);
|
||||
int checkButton(int button, int state);
|
||||
// int isPressed(int button);
|
||||
// int isHeld(int button);
|
||||
// int isReleased(int button);
|
||||
|
||||
#endif //CONTROLLERS_H
|
||||
32
src/draw.c
32
src/draw.c
|
|
@ -345,21 +345,21 @@ void draw_bitmap(FT_Bitmap* bitmap, FT_Int x, FT_Int y) {
|
|||
}
|
||||
}
|
||||
break;
|
||||
case FT_PIXEL_MODE_BGRA:
|
||||
x_max = x + bitmap->width/2;
|
||||
for (i = x, p = 0; i < x_max; i++, p++) {
|
||||
for (j = y, q = 0; j < y_max; j++, q++) {
|
||||
if (i < 0 || j < 0 || i >= 854 || j >= 480) continue;
|
||||
u8 cb = bitmap->buffer[q * bitmap->pitch + p * 4];
|
||||
u8 cg = bitmap->buffer[q * bitmap->pitch + p * 4 + 1];
|
||||
u8 cr = bitmap->buffer[q * bitmap->pitch + p * 4 + 2];
|
||||
u8 ca = bitmap->buffer[q * bitmap->pitch + p * 4 + 3];
|
||||
|
||||
if ((cr | cg | cb) == 0) continue;
|
||||
drawPixel(i, j, cr, cg, cb, ca);
|
||||
}
|
||||
}
|
||||
break;
|
||||
// case FT_PIXEL_MODE_BGRA:
|
||||
// x_max = x + bitmap->width/2;
|
||||
// for (i = x, p = 0; i < x_max; i++, p++) {
|
||||
// for (j = y, q = 0; j < y_max; j++, q++) {
|
||||
// if (i < 0 || j < 0 || i >= 854 || j >= 480) continue;
|
||||
// u8 cb = bitmap->buffer[q * bitmap->pitch + p * 4];
|
||||
// u8 cg = bitmap->buffer[q * bitmap->pitch + p * 4 + 1];
|
||||
// u8 cr = bitmap->buffer[q * bitmap->pitch + p * 4 + 2];
|
||||
// u8 ca = bitmap->buffer[q * bitmap->pitch + p * 4 + 3];
|
||||
//
|
||||
// if ((cr | cg | cb) == 0) continue;
|
||||
// drawPixel(i, j, cr, cg, cb, ca);
|
||||
// }
|
||||
// }
|
||||
// break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
@ -507,7 +507,7 @@ int ttfStringWidth(char *string, s8 part) {
|
|||
continue;
|
||||
}
|
||||
|
||||
error = FT_Load_Glyph(face, glyph_index, FT_LOAD_BITMAP_METRICS_ONLY);
|
||||
error = FT_Load_Glyph(face, glyph_index, 1/*FT_LOAD_BITMAP_METRICS_ONLY*/);
|
||||
if (error)
|
||||
continue;
|
||||
|
||||
|
|
|
|||
|
|
@ -1,7 +1,7 @@
|
|||
#include "lib_easy.h"
|
||||
|
||||
int vpadError = -1;
|
||||
VPADData vpad;
|
||||
// int vpadError = -1;
|
||||
// VPADData vpad;
|
||||
|
||||
int screen_buf0_size = 0;
|
||||
int screen_buf1_size = 0;
|
||||
|
|
@ -20,53 +20,53 @@ void ScreenInit() {
|
|||
initDraw(screenBuffer, screen_buf0_size, screen_buf1_size);
|
||||
}
|
||||
|
||||
void updatePressedButtons() {
|
||||
VPADRead(0, &vpad, 1, &vpadError);
|
||||
buttons_pressed = vpad.btns_d;
|
||||
}
|
||||
// void updatePressedButtons() {
|
||||
// VPADRead(0, &vpad, 1, &vpadError);
|
||||
// buttons_pressed = vpad.btns_d;
|
||||
// }
|
||||
|
||||
void updateHeldButtons() {
|
||||
VPADRead(0, &vpad, 1, &vpadError);
|
||||
buttons_hold = vpad.btns_h;
|
||||
}
|
||||
// void updateHeldButtons() {
|
||||
// VPADRead(0, &vpad, 1, &vpadError);
|
||||
// buttons_hold = vpad.btns_h;
|
||||
// }
|
||||
|
||||
void updateReleasedButtons() {
|
||||
VPADRead(0, &vpad, 1, &vpadError);
|
||||
buttons_released = vpad.btns_r;
|
||||
}
|
||||
// void updateReleasedButtons() {
|
||||
// VPADRead(0, &vpad, 1, &vpadError);
|
||||
// buttons_released = vpad.btns_r;
|
||||
// }
|
||||
|
||||
bool stickPos(u8 stick, f32 value) {
|
||||
switch(stick) {
|
||||
case 0 :
|
||||
return (value > 0) ? (vpad.lstick.x > value): (vpad.lstick.x < value);
|
||||
case 1 :
|
||||
return (value > 0) ? (vpad.lstick.y > value): (vpad.lstick.y < value);
|
||||
case 2 :
|
||||
return (value > 0) ? (vpad.rstick.x > value): (vpad.rstick.x < value);
|
||||
case 3 :
|
||||
return (value > 0) ? (vpad.rstick.y > value): (vpad.rstick.y < value);
|
||||
case 4 :
|
||||
return ((vpad.lstick.x > value) || (vpad.lstick.x < -value)) || \
|
||||
((vpad.lstick.y > value) || (vpad.lstick.y < -value)) || \
|
||||
((vpad.rstick.x > value) || (vpad.rstick.x < -value)) || \
|
||||
((vpad.rstick.y > value) || (vpad.rstick.y < -value));
|
||||
// bool stickPos(u8 stick, f32 value) {
|
||||
// switch(stick) {
|
||||
// case 0 :
|
||||
// return (value > 0) ? (vpad.lstick.x > value): (vpad.lstick.x < value);
|
||||
// case 1 :
|
||||
// return (value > 0) ? (vpad.lstick.y > value): (vpad.lstick.y < value);
|
||||
// case 2 :
|
||||
// return (value > 0) ? (vpad.rstick.x > value): (vpad.rstick.x < value);
|
||||
// case 3 :
|
||||
// return (value > 0) ? (vpad.rstick.y > value): (vpad.rstick.y < value);
|
||||
// case 4 :
|
||||
// return ((vpad.lstick.x > value) || (vpad.lstick.x < -value)) || \
|
||||
// ((vpad.lstick.y > value) || (vpad.lstick.y < -value)) || \
|
||||
// ((vpad.rstick.x > value) || (vpad.rstick.x < -value)) || \
|
||||
// ((vpad.rstick.y > value) || (vpad.rstick.y < -value));
|
||||
//
|
||||
// default :
|
||||
// return 0;
|
||||
// }
|
||||
// }
|
||||
|
||||
default :
|
||||
return 0;
|
||||
}
|
||||
}
|
||||
// int isPressed(int button) {
|
||||
// return (buttons_pressed&button);
|
||||
// }
|
||||
|
||||
int isPressed(int button) {
|
||||
return (buttons_pressed&button);
|
||||
}
|
||||
// int isHeld(int button) {
|
||||
// return (buttons_hold&button);
|
||||
// }
|
||||
|
||||
int isHeld(int button) {
|
||||
return (buttons_hold&button);
|
||||
}
|
||||
|
||||
int isReleased(int button) {
|
||||
return (buttons_released&button);
|
||||
}
|
||||
// int isReleased(int button) {
|
||||
// return (buttons_released&button);
|
||||
// }
|
||||
|
||||
void uInit() {
|
||||
//--Initialize every function pointer-- (byebye FindExport :D)
|
||||
|
|
@ -85,6 +85,8 @@ void uInit() {
|
|||
|
||||
memoryInitialize(); //You probably shouldn't care about this for now :P
|
||||
VPADInit(); //Init GamePad input library (needed for getting gamepad input)
|
||||
KPADInit(); //Init controller input library for other wireless inputs
|
||||
WPADInit();
|
||||
ScreenInit(); //Init OSScreen (all the complex stuff is in easyfunctions.h :P )
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -39,18 +39,18 @@
|
|||
#include "common/common.h"
|
||||
|
||||
unsigned char *screenBuffer;
|
||||
uint32_t buttons_hold; //Held buttons
|
||||
uint32_t buttons_pressed; //Pressed buttons
|
||||
uint32_t buttons_released; //Released buttons
|
||||
//uint32_t buttons_hold; //Held buttons
|
||||
//uint32_t buttons_pressed; //Pressed buttons
|
||||
//uint32_t buttons_released; //Released buttons
|
||||
|
||||
void ScreenInit();
|
||||
void updatePressedButtons();
|
||||
void updateHeldButtons();
|
||||
void updateReleasedButtons();
|
||||
bool stickPos(u8 stick, f32 value);
|
||||
int isPressed(int button);
|
||||
int isHeld(int button);
|
||||
int isReleased(int button);
|
||||
// void updatePressedButtons();
|
||||
// void updateHeldButtons();
|
||||
// void updateReleasedButtons();
|
||||
// bool stickPos(u8 stick, f32 value);
|
||||
// int isPressed(int button);
|
||||
// int isHeld(int button);
|
||||
// int isReleased(int button);
|
||||
void uInit();
|
||||
void uDeInit();
|
||||
|
||||
|
|
|
|||
26
src/main.c
26
src/main.c
|
|
@ -677,20 +677,18 @@ int Menu_Main(void) {
|
|||
|
||||
flipBuffers();
|
||||
while(1) {
|
||||
updatePressedButtons();
|
||||
updateHeldButtons();
|
||||
if (isPressed(0xFFFF) || isHeld(0xFFFF) || stickPos(4, 0.7)) break;
|
||||
updateButtons();
|
||||
if (checkButton(PAD_BUTTON_ANY, PRESS) || checkButton(PAD_BUTTON_ANY, HOLD) || stickPos(4, 0.7)) break;
|
||||
}
|
||||
updatePressedButtons();
|
||||
updateHeldButtons();
|
||||
updateButtons();
|
||||
|
||||
if (isPressed(VPAD_BUTTON_DOWN) || isHeld(VPAD_BUTTON_DOWN) || stickPos(1, -0.7) || stickPos(3, -0.7)) {
|
||||
if (checkButton(PAD_BUTTON_DOWN, PRESS) || checkButton(PAD_BUTTON_DOWN, HOLD) || stickPos(1, -0.7) || stickPos(3, -0.7)) {
|
||||
if (entrycount <= 14) cursor = (cursor + 1) % entrycount;
|
||||
else if (cursor < 6) cursor++;
|
||||
else if ((cursor + scroll + 1) % entrycount) scroll++;
|
||||
else cursor = scroll = 0;
|
||||
os_usleep(100000);
|
||||
} else if (isPressed(VPAD_BUTTON_UP) || isHeld(VPAD_BUTTON_UP) || stickPos(1, 0.7) || stickPos(3, 0.7)) {
|
||||
} else if (checkButton(PAD_BUTTON_UP, PRESS) || checkButton(PAD_BUTTON_UP, HOLD) || stickPos(1, 0.7) || stickPos(3, 0.7)) {
|
||||
if (scroll > 0) cursor -= (cursor>6) ? 1 : 0 * (scroll--);
|
||||
else if (cursor > 0) cursor--;
|
||||
else if (entrycount > 14) scroll = entrycount - (cursor = 6) - 1;
|
||||
|
|
@ -698,7 +696,7 @@ int Menu_Main(void) {
|
|||
os_usleep(100000);
|
||||
}
|
||||
|
||||
if (isPressed(VPAD_BUTTON_LEFT) || isHeld(VPAD_BUTTON_LEFT) || stickPos(0, -0.7) || stickPos(2, -0.7)) {
|
||||
if (checkButton(PAD_BUTTON_LEFT, PRESS) || checkButton(PAD_BUTTON_LEFT, HOLD) || stickPos(0, -0.7) || stickPos(2, -0.7)) {
|
||||
if (menu==3) {
|
||||
if (task == 5) {
|
||||
switch(cursor) {
|
||||
|
|
@ -746,7 +744,7 @@ int Menu_Main(void) {
|
|||
}
|
||||
}
|
||||
os_usleep(100000);
|
||||
} else if (isPressed(VPAD_BUTTON_RIGHT) || isHeld(VPAD_BUTTON_RIGHT) || stickPos(0, 0.7) || stickPos(2, 0.7)) {
|
||||
} else if (checkButton(PAD_BUTTON_RIGHT, PRESS) || checkButton(PAD_BUTTON_RIGHT, HOLD) || stickPos(0, 0.7) || stickPos(2, 0.7)) {
|
||||
if (menu == 3) {
|
||||
if (task == 5) {
|
||||
switch(cursor) {
|
||||
|
|
@ -796,7 +794,7 @@ int Menu_Main(void) {
|
|||
os_usleep(100000);
|
||||
}
|
||||
|
||||
if (isPressed(VPAD_BUTTON_R)) {
|
||||
if (checkButton(PAD_BUTTON_R, PRESS)) {
|
||||
if (menu == 1) {
|
||||
tsort = (tsort + 1) % 4;
|
||||
qsort(titles, count, sizeof(Title), titleSort);
|
||||
|
|
@ -806,7 +804,7 @@ int Menu_Main(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isPressed(VPAD_BUTTON_L)) {
|
||||
if (checkButton(PAD_BUTTON_L, PRESS)) {
|
||||
if ((menu==1) && (tsort > 0)) {
|
||||
sorta *= -1;
|
||||
qsort(titles, count, sizeof(Title), titleSort);
|
||||
|
|
@ -816,7 +814,7 @@ int Menu_Main(void) {
|
|||
}
|
||||
}
|
||||
|
||||
if (isPressed(VPAD_BUTTON_A)) {
|
||||
if (checkButton(PAD_BUTTON_A, PRESS)) {
|
||||
clearBuffers();
|
||||
if (menu < 3) {
|
||||
if (menu == 0) {
|
||||
|
|
@ -928,7 +926,7 @@ int Menu_Main(void) {
|
|||
} break;
|
||||
}
|
||||
}
|
||||
} else if (isPressed(VPAD_BUTTON_B) && menu > 0) {
|
||||
} else if (checkButton(PAD_BUTTON_B, PRESS) && menu > 0) {
|
||||
clearBuffers();
|
||||
menu--;
|
||||
cursor = scroll = 0;
|
||||
|
|
@ -938,7 +936,7 @@ int Menu_Main(void) {
|
|||
}
|
||||
if (menu == 2) cursor = cursort;
|
||||
}
|
||||
if (isPressed(VPAD_BUTTON_HOME)) break;
|
||||
if (checkButton(PAD_BUTTON_HOME, PRESS)) break;
|
||||
}
|
||||
|
||||
if (tgaBufDRC) free(tgaBufDRC);
|
||||
|
|
|
|||
|
|
@ -299,9 +299,9 @@ bool promptConfirm(Style st, const char* question) {
|
|||
|
||||
int ret = 0;
|
||||
while(1) {
|
||||
updatePressedButtons();
|
||||
if (isPressed(VPAD_BUTTON_A | VPAD_BUTTON_B | VPAD_BUTTON_HOME)) {
|
||||
ret = isPressed(VPAD_BUTTON_A);
|
||||
updateButtons();
|
||||
if (checkButton(PAD_BUTTON_ANY, PRESS)) {
|
||||
ret = checkButton(PAD_BUTTON_A, PRESS);
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
|
@ -329,8 +329,8 @@ void promptError(const char* message, ...) {
|
|||
flipBuffers();
|
||||
va_end(va);
|
||||
while(1) {
|
||||
updatePressedButtons();
|
||||
if (isPressed(0xFFFF)) break;
|
||||
updateButtons();
|
||||
if (checkButton(PAD_BUTTON_ANY, PRESS)) break;
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -10,6 +10,7 @@
|
|||
|
||||
#include "lib_easy.h"
|
||||
#include "draw.h"
|
||||
#include "controllers.h"
|
||||
|
||||
#define PATH_SIZE 0x400
|
||||
|
||||
|
|
|
|||
Loading…
Reference in New Issue
Block a user