improve for qnx

This commit is contained in:
lixianjing 2025-01-11 08:18:46 +08:00
parent 8614a30b6b
commit 78ecaabb50
12 changed files with 60 additions and 4 deletions

View File

@ -86,6 +86,8 @@ typedef unsigned long uintptr_t;
#define SDL_FILESYSTEM_DUMMY 1 #define SDL_FILESYSTEM_DUMMY 1
/* Enable the dummy filesystem driver (src/audio/alsa/\*.c) */ /* Enable the dummy filesystem driver (src/audio/alsa/\*.c) */
#ifndef SDL_AUDIO_DRIVER_DUMMY
#define SDL_AUDIO_DRIVER_ALSA 1 #define SDL_AUDIO_DRIVER_ALSA 1
#endif/*SDL_AUDIO_DRIVER_DUMMY*/
#endif /* SDL_config_minimal_h_ */ #endif /* SDL_config_minimal_h_ */

View File

@ -5245,6 +5245,7 @@ History:
#endif /* !HAVE_MALLOC */ #endif /* !HAVE_MALLOC */
#ifdef HAVE_MALLOC #ifdef HAVE_MALLOC
#include <stdlib.h>
#define real_malloc malloc #define real_malloc malloc
#define real_calloc calloc #define real_calloc calloc
#define real_realloc realloc #define real_realloc realloc

View File

@ -21,9 +21,14 @@
#include "../../SDL_internal.h" #include "../../SDL_internal.h"
#include "../SDL_sysvideo.h" #include "../SDL_sysvideo.h"
#include "sdl_qnx.h" #include "sdl_qnx.h"
#include "SDL_events.h"
#include "../../events/SDL_events_c.h"
#include "../../events/SDL_mouse_c.h"
#include "../../events/SDL_touch_c.h"
static screen_context_t context; static screen_context_t context;
static screen_event_t event; static screen_event_t event;
static int prev_pressed = 0;
/** /**
* Initializes the QNX video plugin. * Initializes the QNX video plugin.
@ -52,6 +57,7 @@ videoInit(_THIS)
} }
_this->num_displays = 1; _this->num_displays = 1;
return 0; return 0;
} }
@ -211,6 +217,9 @@ static void
pumpEvents(_THIS) pumpEvents(_THIS)
{ {
int type; int type;
int val; /* used for simple property queries */
int pair[2]; /* used to query pos, size */
screen_event_t screen_ev;
for (;;) { for (;;) {
if (screen_get_event(context, event, 0) < 0) { if (screen_get_event(context, event, 0) < 0) {
@ -226,11 +235,33 @@ pumpEvents(_THIS)
break; break;
} }
screen_ev = event;
switch (type) { switch (type) {
case SCREEN_EVENT_KEYBOARD: case SCREEN_EVENT_KEYBOARD:
handleKeyboardEvent(event); handleKeyboardEvent(event);
break; break;
case SCREEN_EVENT_POINTER: {
int x = 0;
int y = 0;
int pressed = 0;
SDL_Mouse *mouse = SDL_GetMouse();
screen_get_event_property_iv(screen_ev, SCREEN_PROPERTY_DEVICE, &val);
screen_get_event_property_iv(screen_ev, SCREEN_PROPERTY_POSITION, pair);
x = pair[0];
y = pair[1];
screen_get_event_property_iv(screen_ev, SCREEN_PROPERTY_DISPLACEMENT, pair);
pressed = val;
screen_get_event_property_iv(screen_ev, SCREEN_PROPERTY_MOUSE_HORIZONTAL_WHEEL, &val);
screen_get_event_property_iv(screen_ev, SCREEN_PROPERTY_MOUSE_WHEEL, &val);
if (prev_pressed == pressed) {
SDL_SendMouseMotion(mouse->focus, mouse->mouseID, 0, x, y);
} else {
prev_pressed = pressed;
SDL_SendMouseButton(mouse->focus, mouse->mouseID, pressed ? SDL_PRESSED : SDL_RELEASED, 1);
}
}
default: default:
break; break;
} }
@ -269,6 +300,7 @@ showWindow(_THIS, SDL_Window *window)
screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE, screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
&visible); &visible);
SDL_SetMouseFocus(window);
} }
/** /**
@ -284,6 +316,7 @@ hideWindow(_THIS, SDL_Window *window)
screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE, screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
&visible); &visible);
SDL_SetMouseFocus(NULL);
} }
/** /**

View File

@ -1 +1,2 @@
/Makefile /Makefile
/build/

View File

@ -1,2 +1,3 @@
*.o *.o
Makefile Makefile
/build/

View File

@ -2,3 +2,4 @@ Makefile
*.sln *.sln
*.vcxproj *.vcxproj
mbedtls/check_config mbedtls/check_config
/build/

View File

@ -2,3 +2,4 @@
libmbed* libmbed*
*.sln *.sln
*.vcxproj *.vcxproj
/build/

View File

@ -1,5 +1,7 @@
# 最新动态 # 最新动态
2025/01/11
* improve for qnx
2025/01/08 2025/01/08
* 修改定义WITH_LCD_MONO宏的时候会链接到SDL的文件(感谢智明提供补丁) * 修改定义WITH_LCD_MONO宏的时候会链接到SDL的文件(感谢智明提供补丁)
* 完善 draggable_create(感谢俊杰发现问题) * 完善 draggable_create(感谢俊杰发现问题)

View File

@ -185,7 +185,6 @@ static SDL_HitTestResult hit_test_imp(SDL_Window* window, const SDL_Point* pt, v
static ret_t native_window_sdl_set_window_hit_test(native_window_t* win, xy_t x, xy_t y, wh_t w, static ret_t native_window_sdl_set_window_hit_test(native_window_t* win, xy_t x, xy_t y, wh_t w,
wh_t h) { wh_t h) {
native_window_sdl_t* sdl = NATIVE_WINDOW_SDL(win); native_window_sdl_t* sdl = NATIVE_WINDOW_SDL(win);
SDL_Rect area = {x, y, w, h};
sdl->hit_test_rect.x = x; sdl->hit_test_rect.x = x;
sdl->hit_test_rect.y = x; sdl->hit_test_rect.y = x;
@ -691,7 +690,11 @@ ret_t native_window_sdl_init(bool_t shared, uint32_t w, uint32_t h) {
SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1"); SDL_SetHint(SDL_HINT_VIDEO_ALLOW_SCREENSAVER, "1");
SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1"); SDL_SetHint(SDL_HINT_MOUSE_FOCUS_CLICKTHROUGH, "1");
#if defined(SDL_AUDIO_DISABLED)
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS) != 0) {
#else
if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_AUDIO) != 0) { if (SDL_Init(SDL_INIT_VIDEO | SDL_INIT_EVENTS | SDL_INIT_AUDIO) != 0) {
#endif /*SDL_AUDIO_DISABLED*/
log_debug("Failed to initialize SDL: %s", SDL_GetError()); log_debug("Failed to initialize SDL: %s", SDL_GetError());
exit(0); exit(0);
return RET_FAIL; return RET_FAIL;

View File

@ -169,10 +169,16 @@ static ret_t fs_os_dir_read(fs_dir_t* dir, fs_item_t* item) {
memset(item, 0x00, sizeof(fs_item_t)); memset(item, 0x00, sizeof(fs_item_t));
if (ent != NULL) { if (ent != NULL) {
#ifdef QNX
/*FIXME*/
item->is_reg_file = 1;
#else
uint8_t type = ent->d_type; uint8_t type = ent->d_type;
item->is_dir = (type & DT_DIR) != 0; item->is_dir = (type & DT_DIR) != 0;
item->is_link = (type & DT_LNK) != 0; item->is_link = (type & DT_LNK) != 0;
item->is_reg_file = (type & DT_REG) != 0; item->is_reg_file = (type & DT_REG) != 0;
#endif
#ifdef WIN32 #ifdef WIN32
str_t str; str_t str;
str_init(&str, wcslen(ent->d_name) * 4 + 1); str_init(&str, wcslen(ent->d_name) * 4 + 1);

View File

@ -22,7 +22,6 @@
#ifndef WIN32_LEAN_AND_MEAN #ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1 #define WIN32_LEAN_AND_MEAN 1
#endif /*WIN32_LEAN_AND_MEAN*/ #endif /*WIN32_LEAN_AND_MEAN*/
#include "tkc/mem.h" #include "tkc/mem.h"
#include "tkc/socket_helper.h" #include "tkc/socket_helper.h"
#include "streams/inet/istream_udp.h" #include "streams/inet/istream_udp.h"

View File

@ -535,14 +535,19 @@ ret_t serial_wait_for_data(serial_handle_t handle, uint32_t timeout_ms) {
#include <unistd.h> #include <unistd.h>
#include <fcntl.h> #include <fcntl.h>
#include <sys/ioctl.h> #include <sys/ioctl.h>
#include <sys/signal.h>
#include <errno.h> #include <errno.h>
#include <paths.h> #include <paths.h>
#include <sysexits.h>
#include <termios.h> #include <termios.h>
#include <sys/param.h> #include <sys/param.h>
#include <pthread.h> #include <pthread.h>
#ifndef QNX
#include <sysexits.h>
#include <sys/signal.h>
#else
#include <signal.h>
#endif/*QNX*/
#if defined(__linux__) #if defined(__linux__)
#include <linux/serial.h> #include <linux/serial.h>
#endif #endif
@ -934,6 +939,7 @@ ret_t serial_config(serial_handle_t handle, uint32_t baudrate, bytesize_t bytesi
options.c_cflag |= (CNEW_RTSCTS); options.c_cflag |= (CNEW_RTSCTS);
else else
options.c_cflag &= (unsigned long)~(CNEW_RTSCTS); options.c_cflag &= (unsigned long)~(CNEW_RTSCTS);
#elif defined(QNX)
#else #else
#error "OS Support seems wrong." #error "OS Support seems wrong."
#endif #endif