Skip to content

Commit 7862a15

Browse files
controller can be NULL
1 parent 8709e3a commit 7862a15

1 file changed

Lines changed: 17 additions & 7 deletions

File tree

source/hid/hid.c

Lines changed: 17 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -21,20 +21,30 @@ extern hekate_config h_cfg;
2121
Input_t *hidRead(){
2222
jc_gamepad_rpt_t *controller = joycon_poll();
2323

24-
if (controller->home)
25-
RebootToPayloadOrRcm();
24+
inputs.buttons = 0;
25+
u8 left_connected = 0;
26+
u8 right_connected = 0;
2627

27-
if (controller->cap)
28-
TakeScreenshot();
28+
if (controller != NULL){
29+
if (controller->home)
30+
RebootToPayloadOrRcm();
31+
32+
if (controller->cap)
33+
TakeScreenshot();
34+
35+
inputs.buttons = controller->buttons;
36+
37+
left_connected = controller->conn_l;
38+
right_connected = controller->conn_r;
39+
}
2940

30-
inputs.buttons = controller->buttons;
3141

3242
u8 btn = btn_read();
3343
inputs.volp = (btn & BTN_VOL_UP) ? 1 : 0;
3444
inputs.volm = (btn & BTN_VOL_DOWN) ? 1 : 0;
3545
inputs.power = (btn & BTN_POWER) ? 1 : 0;
3646

37-
if (controller->conn_l){
47+
if (left_connected){
3848
if ((LbaseX == 0 || LbaseY == 0) || controller->l3){
3949
LbaseX = controller->lstick_x;
4050
LbaseY = controller->lstick_y;
@@ -50,7 +60,7 @@ Input_t *hidRead(){
5060
inputs.down = inputs.volm;
5161
}
5262

53-
if (controller->conn_r){
63+
if (right_connected){
5464
if ((RbaseX == 0 || RbaseY == 0) || controller->r3){
5565
RbaseX = controller->rstick_x;
5666
RbaseY = controller->rstick_y;

0 commit comments

Comments
 (0)