Compare commits
2 Commits
| Author | SHA1 | Date | |
|---|---|---|---|
| 3c6acf47a5 | |||
| 23e969c1b6 |
@@ -10,7 +10,7 @@ static void onShowApp(AppHandle app, void* data, lv_obj_t* parent) {
|
|||||||
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
lv_obj_align(toolbar, LV_ALIGN_TOP_MID, 0, 0);
|
||||||
|
|
||||||
lv_obj_t* label = lv_label_create(parent);
|
lv_obj_t* label = lv_label_create(parent);
|
||||||
lv_label_set_text(label, "Hello, world!");
|
lv_label_set_text(label, "Hello, world!\n(Loaded via LAN!)");
|
||||||
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
lv_obj_align(label, LV_ALIGN_CENTER, 0, 0);
|
||||||
}
|
}
|
||||||
|
|
||||||
|
|||||||
@@ -2,7 +2,7 @@
|
|||||||
version=0.1
|
version=0.1
|
||||||
[target]
|
[target]
|
||||||
sdk=0.7.0-dev
|
sdk=0.7.0-dev
|
||||||
platforms=esp32,esp32s3,esp32c6,esp32p4
|
platforms=esp32s3
|
||||||
[app]
|
[app]
|
||||||
id=one.tactility.helloworld
|
id=one.tactility.helloworld
|
||||||
versionName=0.3.0
|
versionName=0.3.0
|
||||||
|
|||||||
@@ -245,6 +245,41 @@ static void game_play_event(lv_event_t* e) {
|
|||||||
default:
|
default:
|
||||||
break;
|
break;
|
||||||
}
|
}
|
||||||
|
} else if (code == LV_EVENT_CLICKED) {
|
||||||
|
lv_indev_t* indev = lv_indev_active();
|
||||||
|
if (indev) {
|
||||||
|
lv_point_t point;
|
||||||
|
lv_indev_get_point(indev, &point);
|
||||||
|
|
||||||
|
lv_area_t coords;
|
||||||
|
lv_obj_get_coords(game->container, &coords);
|
||||||
|
|
||||||
|
lv_coord_t w = coords.x2 - coords.x1 + 1;
|
||||||
|
lv_coord_t h = coords.y2 - coords.y1 + 1;
|
||||||
|
lv_coord_t cx = coords.x1 + w / 2;
|
||||||
|
lv_coord_t cy = coords.y1 + h / 2;
|
||||||
|
|
||||||
|
lv_coord_t rx = point.x - cx;
|
||||||
|
lv_coord_t ry = point.y - cy;
|
||||||
|
|
||||||
|
if (rx != 0 || ry != 0) {
|
||||||
|
if (abs(rx) * h > abs(ry) * w) {
|
||||||
|
// Horizontal touch
|
||||||
|
if (rx > 0) {
|
||||||
|
snake_set_direction(game, SNAKE_DIR_RIGHT);
|
||||||
|
} else {
|
||||||
|
snake_set_direction(game, SNAKE_DIR_LEFT);
|
||||||
|
}
|
||||||
|
} else {
|
||||||
|
// Vertical touch
|
||||||
|
if (ry > 0) {
|
||||||
|
snake_set_direction(game, SNAKE_DIR_DOWN);
|
||||||
|
} else {
|
||||||
|
snake_set_direction(game, SNAKE_DIR_UP);
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
|
}
|
||||||
} else if (code == LV_EVENT_KEY) {
|
} else if (code == LV_EVENT_KEY) {
|
||||||
uint32_t key = lv_event_get_key(e);
|
uint32_t key = lv_event_get_key(e);
|
||||||
// Arrow keys, WASD, and punctuation keys for cardputer
|
// Arrow keys, WASD, and punctuation keys for cardputer
|
||||||
@@ -394,6 +429,7 @@ lv_obj_t* snake_create(lv_obj_t* parent, uint16_t cell_size, bool wall_collision
|
|||||||
// Add event callbacks for touch gestures and keyboard
|
// Add event callbacks for touch gestures and keyboard
|
||||||
lv_obj_add_event_cb(game->container, game_play_event, LV_EVENT_GESTURE, obj);
|
lv_obj_add_event_cb(game->container, game_play_event, LV_EVENT_GESTURE, obj);
|
||||||
lv_obj_add_event_cb(game->container, game_play_event, LV_EVENT_KEY, obj);
|
lv_obj_add_event_cb(game->container, game_play_event, LV_EVENT_KEY, obj);
|
||||||
|
lv_obj_add_event_cb(game->container, game_play_event, LV_EVENT_CLICKED, obj);
|
||||||
lv_obj_add_event_cb(obj, delete_event, LV_EVENT_DELETE, NULL);
|
lv_obj_add_event_cb(obj, delete_event, LV_EVENT_DELETE, NULL);
|
||||||
|
|
||||||
// Set up keyboard focus if available
|
// Set up keyboard focus if available
|
||||||
|
|||||||
Reference in New Issue
Block a user