1
0
Fork 0
mirror of https://github.com/suchmememanyskill/TegraExplorer.git synced 2024-11-22 11:56:42 +00:00

controller can be NULL

This commit is contained in:
suchmememanyskill 2021-01-12 00:37:31 +01:00
parent 8709e3aa2e
commit 7862a15e1d

View file

@ -21,20 +21,30 @@ extern hekate_config h_cfg;
Input_t *hidRead(){ Input_t *hidRead(){
jc_gamepad_rpt_t *controller = joycon_poll(); jc_gamepad_rpt_t *controller = joycon_poll();
if (controller->home) inputs.buttons = 0;
RebootToPayloadOrRcm(); u8 left_connected = 0;
u8 right_connected = 0;
if (controller->cap) if (controller != NULL){
TakeScreenshot(); if (controller->home)
RebootToPayloadOrRcm();
if (controller->cap)
TakeScreenshot();
inputs.buttons = controller->buttons;
left_connected = controller->conn_l;
right_connected = controller->conn_r;
}
inputs.buttons = controller->buttons;
u8 btn = btn_read(); u8 btn = btn_read();
inputs.volp = (btn & BTN_VOL_UP) ? 1 : 0; inputs.volp = (btn & BTN_VOL_UP) ? 1 : 0;
inputs.volm = (btn & BTN_VOL_DOWN) ? 1 : 0; inputs.volm = (btn & BTN_VOL_DOWN) ? 1 : 0;
inputs.power = (btn & BTN_POWER) ? 1 : 0; inputs.power = (btn & BTN_POWER) ? 1 : 0;
if (controller->conn_l){ if (left_connected){
if ((LbaseX == 0 || LbaseY == 0) || controller->l3){ if ((LbaseX == 0 || LbaseY == 0) || controller->l3){
LbaseX = controller->lstick_x; LbaseX = controller->lstick_x;
LbaseY = controller->lstick_y; LbaseY = controller->lstick_y;
@ -50,7 +60,7 @@ Input_t *hidRead(){
inputs.down = inputs.volm; inputs.down = inputs.volm;
} }
if (controller->conn_r){ if (right_connected){
if ((RbaseX == 0 || RbaseY == 0) || controller->r3){ if ((RbaseX == 0 || RbaseY == 0) || controller->r3){
RbaseX = controller->rstick_x; RbaseX = controller->rstick_x;
RbaseY = controller->rstick_y; RbaseY = controller->rstick_y;