/** * @file lv_ctr_indev.c * */ #if 1 /********************* * INCLUDES *********************/ #include "lv_ctr_indev.h" #include <3ds.h> /********************* * DEFINES *********************/ /********************** * TYPEDEFS **********************/ /********************** * STATIC PROTOTYPES **********************/ static void touchpad_read(lv_indev_t * indev, lv_indev_data_t * data); /********************** * STATIC VARIABLES **********************/ lv_indev_t * indev_touchpad; /********************** * MACROS **********************/ /********************** * GLOBAL FUNCTIONS **********************/ void lv_ctr_indev_init(void) { /*Register a touch screen input device*/ indev_touchpad = lv_indev_create(); lv_indev_set_type(indev_touchpad, LV_INDEV_TYPE_POINTER); lv_indev_set_read_cb(indev_touchpad, touchpad_read); /*Later you should create group(s) with `lv_group_t * group = lv_group_create()`, *add objects to the group with `lv_group_add_obj(group, obj)` *and assign this input device to group to navigate in it: *`lv_indev_set_group(indev_keypad, group);`*/ } /********************** * STATIC FUNCTIONS **********************/ /*------------------ * Touchpad * -----------------*/ static void touchpad_read(lv_indev_t * indev_drv, lv_indev_data_t * data) { static int32_t last_x = 0; static int32_t last_y = 0; touchPosition touch; hidScanInput(); /*Save the pressed coordinates and the state*/ if(hidKeysHeld() & KEY_TOUCH) { hidTouchRead(&touch); last_x = touch.px; last_y = touch.py; data->state = LV_INDEV_STATE_PRESSED; } else { data->state = LV_INDEV_STATE_RELEASED; } /*Set the last pressed coordinates*/ data->point.x = last_x; data->point.y = last_y; } #else /*Enable this file at the top*/ /*This dummy typedef exists purely to silence -Wpedantic.*/ typedef int keep_pedantic_happy; #endif