/*1* Ambient light sensor driver for Nintendo Switch's Rohm BH17302*3* Copyright (c) 2018 CTCaer4*5* This program is free software; you can redistribute it and/or modify it6* under the terms and conditions of the GNU General Public License,7* version 2, as published by the Free Software Foundation.8*9* This program is distributed in the hope it will be useful, but WITHOUT10* ANY WARRANTY; without even the implied warranty of MERCHANTABILITY or11* FITNESS FOR A PARTICULAR PURPOSE. See the GNU General Public License for12* more details.13*14* You should have received a copy of the GNU General Public License15* along with this program. If not, see <http://www.gnu.org/licenses/>.16*/1718#ifndef __JOYCON_H_19#define __JOYCON_H_2021#include <utils/types.h>2223#define JC_BTNS_DIRECTION_PAD 0xF000024#define JC_BTNS_PREV_NEXT 0x80008025#define JC_BTNS_ENTER 0x40000826#define JC_BTNS_ESC 0x42728#define JC_BTNS_ALL (JC_BTNS_PREV_NEXT | JC_BTNS_ENTER | JC_BTNS_DIRECTION_PAD | JC_BTNS_ESC)2930typedef struct _jc_bt_conn_t31{32u8 type;33u8 mac[6];34u8 host_mac[6];35u8 ltk[16];36} jc_bt_conn_t;3738typedef struct _jc_gamepad_rpt_t39{40union41{42struct43{44// Joy-Con (R).45/*00*/ u32 y:1;46/*01*/ u32 x:1;47/*02*/ u32 b:1;48/*03*/ u32 a:1;49/*04*/ u32 sr_r:1;50/*05*/ u32 sl_r:1;51/*06*/ u32 r:1;52/*07*/ u32 zr:1;5354// Shared55/*08*/ u32 minus:1;56/*09*/ u32 plus:1;57/*10*/ u32 r3:1;58/*11*/ u32 l3:1;59/*12*/ u32 home:1;60/*13*/ u32 cap:1;61/*14*/ u32 pad:1;62/*15*/ u32 wired:1;6364// Joy-Con (L).65/*16*/ u32 down:1;66/*17*/ u32 up:1;67/*18*/ u32 right:1;68/*19*/ u32 left:1;69/*20*/ u32 sr_l:1;70/*21*/ u32 sl_l:1;71/*22*/ u32 l:1;72/*23*/ u32 zl:1;73};74u32 buttons;75};7677u16 lstick_x;78u16 lstick_y;79u16 rstick_x;80u16 rstick_y;81bool center_stick_l;82bool center_stick_r;83bool conn_l;84bool conn_r;85bool sio_mode;86u8 batt_info_l; // Also Sio Connected status.87u8 batt_info_r; // Also Sio IRQ.88jc_bt_conn_t bt_conn_l;89jc_bt_conn_t bt_conn_r;90} jc_gamepad_rpt_t;9192typedef struct _jc_calib_t93{94u16 x_max:12;95u16 y_max:12;96u16 x_center:12;97u16 y_center:12;98u16 x_min:12;99u16 y_min:12;100} __attribute__((packed)) jc_calib_t;101102void jc_init_hw();103void jc_deinit();104jc_gamepad_rpt_t *joycon_poll();105jc_gamepad_rpt_t *jc_get_bt_pairing_info(bool *is_l_hos, bool *is_r_hos);106107#endif108109110