Skip to content

Commit

Permalink
improve for qnx
Browse files Browse the repository at this point in the history
  • Loading branch information
xianjimli committed Jan 11, 2025
1 parent 8614a30 commit 78ecaab
Show file tree
Hide file tree
Showing 12 changed files with 61 additions and 5 deletions.
2 changes: 2 additions & 0 deletions 3rd/SDL/include/SDL_config_minimal.h
Original file line number Diff line number Diff line change
Expand Up @@ -86,6 +86,8 @@ typedef unsigned long uintptr_t;
#define SDL_FILESYSTEM_DUMMY 1

/* Enable the dummy filesystem driver (src/audio/alsa/\*.c) */
#ifndef SDL_AUDIO_DRIVER_DUMMY
#define SDL_AUDIO_DRIVER_ALSA 1
#endif/*SDL_AUDIO_DRIVER_DUMMY*/

#endif /* SDL_config_minimal_h_ */
1 change: 1 addition & 0 deletions 3rd/SDL/src/stdlib/SDL_malloc.c
Original file line number Diff line number Diff line change
Expand Up @@ -5245,6 +5245,7 @@ mspace_mallopt(int param_number, int value)
#endif /* !HAVE_MALLOC */

#ifdef HAVE_MALLOC
#include <stdlib.h>
#define real_malloc malloc
#define real_calloc calloc
#define real_realloc realloc
Expand Down
35 changes: 34 additions & 1 deletion 3rd/SDL/src/video/qnx/video.c
Original file line number Diff line number Diff line change
Expand Up @@ -21,9 +21,14 @@
#include "../../SDL_internal.h"
#include "../SDL_sysvideo.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_event_t event;
static int prev_pressed = 0;

/**
* Initializes the QNX video plugin.
Expand Down Expand Up @@ -52,6 +57,7 @@ videoInit(_THIS)
}

_this->num_displays = 1;

return 0;
}

Expand Down Expand Up @@ -211,6 +217,9 @@ static void
pumpEvents(_THIS)
{
int type;
int val; /* used for simple property queries */
int pair[2]; /* used to query pos, size */
screen_event_t screen_ev;

for (;;) {
if (screen_get_event(context, event, 0) < 0) {
Expand All @@ -226,11 +235,33 @@ pumpEvents(_THIS)
break;
}

screen_ev = event;
switch (type) {
case SCREEN_EVENT_KEYBOARD:
handleKeyboardEvent(event);
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:
break;
}
Expand Down Expand Up @@ -269,6 +300,7 @@ showWindow(_THIS, SDL_Window *window)

screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
&visible);
SDL_SetMouseFocus(window);
}

/**
Expand All @@ -284,6 +316,7 @@ hideWindow(_THIS, SDL_Window *window)

screen_set_window_property_iv(impl->window, SCREEN_PROPERTY_VISIBLE,
&visible);
SDL_SetMouseFocus(NULL);
}

/**
Expand Down
1 change: 1 addition & 0 deletions 3rd/mbedtls/3rdparty/.gitignore
Original file line number Diff line number Diff line change
@@ -1 +1,2 @@
/Makefile
/build/
1 change: 1 addition & 0 deletions 3rd/mbedtls/3rdparty/everest/.gitignore
Original file line number Diff line number Diff line change
@@ -1,2 +1,3 @@
*.o
Makefile
/build/
1 change: 1 addition & 0 deletions 3rd/mbedtls/include/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@ Makefile
*.sln
*.vcxproj
mbedtls/check_config
/build/
1 change: 1 addition & 0 deletions 3rd/mbedtls/library/.gitignore
Original file line number Diff line number Diff line change
Expand Up @@ -2,3 +2,4 @@
libmbed*
*.sln
*.vcxproj
/build/
2 changes: 2 additions & 0 deletions docs/changes.md
Original file line number Diff line number Diff line change
@@ -1,5 +1,7 @@
# 最新动态

2025/01/11
* improve for qnx
2025/01/08
* 修改定义WITH_LCD_MONO宏的时候会链接到SDL的文件(感谢智明提供补丁)
* 完善 draggable_create(感谢俊杰发现问题)
Expand Down
5 changes: 4 additions & 1 deletion src/native_window/native_window_sdl.c
Original file line number Diff line number Diff line change
Expand Up @@ -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,
wh_t h) {
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.y = x;
Expand Down Expand Up @@ -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_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) {
#endif /*SDL_AUDIO_DISABLED*/
log_debug("Failed to initialize SDL: %s", SDL_GetError());
exit(0);
return RET_FAIL;
Expand Down
6 changes: 6 additions & 0 deletions src/platforms/pc/fs_os.c
Original file line number Diff line number Diff line change
Expand Up @@ -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));
if (ent != NULL) {
#ifdef QNX
/*FIXME*/
item->is_reg_file = 1;
#else
uint8_t type = ent->d_type;
item->is_dir = (type & DT_DIR) != 0;
item->is_link = (type & DT_LNK) != 0;
item->is_reg_file = (type & DT_REG) != 0;
#endif

#ifdef WIN32
str_t str;
str_init(&str, wcslen(ent->d_name) * 4 + 1);
Expand Down
1 change: 0 additions & 1 deletion src/streams/inet/istream_udp.c
Original file line number Diff line number Diff line change
Expand Up @@ -22,7 +22,6 @@
#ifndef WIN32_LEAN_AND_MEAN
#define WIN32_LEAN_AND_MEAN 1
#endif /*WIN32_LEAN_AND_MEAN*/

#include "tkc/mem.h"
#include "tkc/socket_helper.h"
#include "streams/inet/istream_udp.h"
Expand Down
10 changes: 8 additions & 2 deletions src/tkc/serial_helper.c
Original file line number Diff line number Diff line change
Expand Up @@ -535,14 +535,19 @@ ret_t serial_wait_for_data(serial_handle_t handle, uint32_t timeout_ms) {
#include <unistd.h>
#include <fcntl.h>
#include <sys/ioctl.h>
#include <sys/signal.h>
#include <errno.h>
#include <paths.h>
#include <sysexits.h>
#include <termios.h>
#include <sys/param.h>
#include <pthread.h>

#ifndef QNX
#include <sysexits.h>
#include <sys/signal.h>
#else
#include <signal.h>
#endif/*QNX*/

#if defined(__linux__)
#include <linux/serial.h>
#endif
Expand Down Expand Up @@ -934,6 +939,7 @@ ret_t serial_config(serial_handle_t handle, uint32_t baudrate, bytesize_t bytesi
options.c_cflag |= (CNEW_RTSCTS);
else
options.c_cflag &= (unsigned long)~(CNEW_RTSCTS);
#elif defined(QNX)
#else
#error "OS Support seems wrong."
#endif
Expand Down

0 comments on commit 78ecaab

Please sign in to comment.