diff --git a/apps/Makefile b/apps/Makefile index 1d81d74d3283b548ebb16990466c05b4bcc905ba..c59cd12dcb3d00429ef6e47b16e808e607ad8f07 100644 --- a/apps/Makefile +++ b/apps/Makefile @@ -19,7 +19,7 @@ $(error unsupported arch!) endif -X_CFLAGS := $(MCFLAGS) -fno-builtin -fno-stack-protector +X_CFLAGS := $(MCFLAGS) -fno-builtin -fno-stack-protector X_CFLAGS += -nostdlib -nostdinc -Wall -O3 -ffunction-sections -fdata-sections -ffreestanding -std=gnu99 X_CFLAGS += -DNXOS -D__NXOS__ -D__nxos__ @@ -56,3 +56,4 @@ MODULE += gnuboy MODULE += showimage MODULE += showfont MODULE += sdl_audio +MODULE += key_test diff --git a/apps/install.mk b/apps/install.mk index 50d92a985cd6c9698e64095333da5b114a5b2a2c..6a07f7fb9869ac9160aebd69036be4430c7bf12b 100644 --- a/apps/install.mk +++ b/apps/install.mk @@ -17,9 +17,10 @@ apps: cp build/gnuboy/gnuboy.xapp $(APP_DIR) cp build/showimage/showimage.xapp $(APP_DIR) cp build/showfont/showfont.xapp $(APP_DIR) + cp build/key_test/key_test.xapp $(APP_DIR) tests: cp build/LVGL_Demo/LVGL_Demo.xapp $(APP_DIR) cp build/WinTest/WinTest.xapp $(APP_DIR) cp build/SDL_Demo/SDL_Demo.xapp $(APP_DIR) - cp build/sdl_audio/sdl_audio.xapp $(APP_DIR) \ No newline at end of file + cp build/sdl_audio/sdl_audio.xapp $(APP_DIR) diff --git a/apps/key_test/Makefile b/apps/key_test/Makefile new file mode 100644 index 0000000000000000000000000000000000000000..3db506825daff4723ec872a2da689390be8f1c9e --- /dev/null +++ b/apps/key_test/Makefile @@ -0,0 +1,9 @@ +NAME := key_test.xapp +SRC += *.c + +define CUSTOM_TARGET_CMD +echo [APP] $@; \ +$(LD) $(X_LDFLAGS) $(X_OBJS) -o $@ $(patsubst %, -L%, $(X_LIBDIRS)) \ + --start-group $(patsubst %, -l:%, $(X_LIBS)) --end-group; \ +$(OD) -D -S $@ > $@.dump.S +endef diff --git a/apps/key_test/key_test.c b/apps/key_test/key_test.c new file mode 100644 index 0000000000000000000000000000000000000000..0fb166e8167d2d456fc6de5874c673340581e6c6 --- /dev/null +++ b/apps/key_test/key_test.c @@ -0,0 +1,48 @@ +#include + +#define calibrate 0 + +NX_Error NX_Main(char *cmdline, char *envline) +{ + NX_ThreadSleep(2000); // 避免该应用的log被shell打印打乱 + NX_InputEvent e; + NX_U32 i = 0; + + NX_Printf("[%s %d] APP Start!\n", __func__, __LINE__); + + NX_Solt key0 = NX_DeviceOpen("KeyBoard_DRV", 0); + if (key0 < 0) { + NX_Printf("open KeyBoard_DRV device failed!\n"); + return NX_ENOSRCH; + } + +#if calibrate + NX_U32 info; + // 校准键盘测试 + if (NX_DeviceControl(key0, NX_INPUT_EVENT_CMD_CALIBRATE, &info) != NX_EOK) + { + NX_Printf("get fb info failed!\n"); + NX_SoltClose(key0); + return NX_EPERM; + } + NX_Printf("info:%d\n", info); +#endif + + NX_U32 run = 1; + while (run) { + if (NX_DeviceRead(key0, &e, 0, sizeof(e)) > 0) { + if (e.type == NX_EV_KEY) { + if ((e.value & 0xffff) == 0) { + NX_Printf("keydown: %x/%c\n", e.code, e.code); + } + } + } + if (i++ > 1000) + run = 0; + NX_ThreadSleep(10); + } + NX_SoltClose(key0); + + NX_Printf("[%s %d] APP Run finish!\n", __func__, __LINE__); + return 0; +} \ No newline at end of file