Skip to content

Commit a274d27

Browse files
authored
Merge pull request #39 from ardera/feature-gpio-spi-plugin
GPIO, SPI and 64-bit support, platform channel refactor
2 parents 920a549 + ba3fc26 commit a274d27

22 files changed

+3221
-985
lines changed

Makefile

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,16 +1,16 @@
11
CC = cc
22
LD = cc
3-
REAL_CFLAGS = -I./include $(shell pkg-config --cflags gbm libdrm glesv2 egl) -DBUILD_ELM327_PLUGIN -DBUILD_TEST_PLUGIN -ggdb $(CFLAGS)
3+
REAL_CFLAGS = -I./include $(shell pkg-config --cflags gbm libdrm glesv2 egl) -DBUILD_ELM327_PLUGIN -DBUILD_GPIOD_PLUGIN -DBUILD_SPIDEV_PLUGIN -DBUILD_TEST_PLUGIN -ggdb $(CFLAGS)
44
REAL_LDFLAGS = $(shell pkg-config --libs gbm libdrm glesv2 egl) -lrt -lflutter_engine -lpthread -ldl $(LDFLAGS)
55

66
SOURCES = src/flutter-pi.c src/platformchannel.c src/pluginregistry.c src/console_keyboard.c \
7-
src/plugins/elm327plugin.c src/plugins/services-plugin.c src/plugins/testplugin.c src/plugins/text_input.c \
8-
src/plugins/raw_keyboard.c
7+
src/plugins/elm327plugin.c src/plugins/services.c src/plugins/testplugin.c src/plugins/text_input.c \
8+
src/plugins/raw_keyboard.c src/plugins/gpiod.c src/plugins/spidev.c
99
OBJECTS = $(patsubst src/%.c,out/obj/%.o,$(SOURCES))
1010

1111
all: out/flutter-pi
1212

13-
out/obj/%.o: src/%.c
13+
out/obj/%.o: src/%.c
1414
@mkdir -p $(@D)
1515
$(CC) -c $(REAL_CFLAGS) $(REAL_LDFLAGS) $< -o $@
1616

include/flutter-pi.h

Lines changed: 31 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -9,6 +9,8 @@
99
#include <xf86drmMode.h>
1010
#include <stdint.h>
1111
#include <flutter_embedder.h>
12+
#include <stdlib.h>
13+
#include <string.h>
1214

1315
#define EGL_PLATFORM_GBM_KHR 0x31D7
1416

@@ -34,6 +36,8 @@ typedef enum {
3436
kVBlankRequest,
3537
kVBlankReply,
3638
kUpdateOrientation,
39+
kSendPlatformMessage,
40+
kRespondToPlatformMessage,
3741
kFlutterTask
3842
} flutterpi_task_type;
3943

@@ -47,11 +51,26 @@ struct flutterpi_task {
4751
intptr_t baton;
4852
};
4953
enum device_orientation orientation;
54+
struct {
55+
char *channel;
56+
const FlutterPlatformMessageResponseHandle *responsehandle;
57+
size_t message_size;
58+
uint8_t *message;
59+
};
5060
};
5161
uint64_t target_time;
5262
};
5363

54-
void post_platform_task(struct flutterpi_task *task);
64+
static inline void *memdup(const void *restrict src, const size_t n) {
65+
void *__restrict__ dest;
66+
67+
if ((src == NULL) || (n == 0)) return NULL;
68+
69+
dest = malloc(n);
70+
if (dest == NULL) return NULL;
71+
72+
return memcpy(dest, src, n);
73+
}
5574

5675
struct drm_fb {
5776
struct gbm_bo *bo;
@@ -111,8 +130,6 @@ struct mousepointer_mtslot {
111130

112131
#define ISSET(uint32bitmap, bit) (uint32bitmap[(bit)/32] & (1 << ((bit) & 0x1F)))
113132

114-
#define STREQ(a, b) (strcmp(a, b) == 0)
115-
116133
struct input_device {
117134
char path[PATH_MAX];
118135
char name[256];
@@ -147,4 +164,15 @@ extern struct mousepointer_mtslot mousepointer;
147164

148165
extern FlutterEngine engine;
149166

167+
void post_platform_task(struct flutterpi_task *task);
168+
169+
int flutterpi_send_platform_message(const char *channel,
170+
const uint8_t *restrict message,
171+
size_t message_size,
172+
FlutterPlatformMessageResponseHandle *responsehandle);
173+
174+
int flutterpi_respond_to_platform_message(FlutterPlatformMessageResponseHandle *handle,
175+
const uint8_t *restrict message,
176+
size_t message_size);
177+
150178
#endif

0 commit comments

Comments
 (0)