Skip to content
GitLab
Projects
Groups
Snippets
Help
Loading...
Help
Help
Support
Community forum
Keyboard shortcuts
?
Submit feedback
Contribute to GitLab
Sign in / Register
Toggle navigation
Open sidebar
Main
Synchronet
Commits
ab0456f2
Commit
ab0456f2
authored
May 07, 2020
by
deuce
Browse files
Implement mousepointer() for SDL mode.
parent
c1b6e99a
Changes
5
Hide whitespace changes
Inline
Side-by-side
Showing
5 changed files
with
62 additions
and
2 deletions
+62
-2
src/conio/ciolib.c
src/conio/ciolib.c
+1
-0
src/conio/sdl_con.c
src/conio/sdl_con.c
+39
-0
src/conio/sdl_con.h
src/conio/sdl_con.h
+1
-0
src/conio/sdlfuncs.c
src/conio/sdlfuncs.c
+17
-2
src/conio/sdlfuncs.h
src/conio/sdlfuncs.h
+4
-0
No files found.
src/conio/ciolib.c
View file @
ab0456f2
...
...
@@ -191,6 +191,7 @@ static int try_sdl_init(int mode)
cio_api
.
map_rgb
=
bitmap_map_rgb
;
cio_api
.
replace_font
=
bitmap_replace_font
;
cio_api
.
beep
=
sdl_beep
;
cio_api
.
mousepointer
=
sdl_mousepointer
;
return
(
1
);
}
return
(
0
);
...
...
src/conio/sdl_con.c
View file @
ab0456f2
...
...
@@ -39,6 +39,7 @@ unsigned char sdl_keynext=0; /* Index into keybuf for next free position */
int
sdl_exitcode
=
0
;
SDL_Window
*
win
=
NULL
;
SDL_Cursor
*
curs
=
NULL
;
SDL_Renderer
*
renderer
=
NULL
;
SDL_Texture
*
texture
=
NULL
;
pthread_mutex_t
win_mutex
;
...
...
@@ -84,6 +85,7 @@ enum {
,
SDL_USEREVENT_INIT
,
SDL_USEREVENT_QUIT
,
SDL_USEREVENT_GETWINPOS
,
SDL_USEREVENT_MOUSEPOINTER
};
const
struct
sdl_keyvals
sdl_keyval
[]
=
...
...
@@ -214,6 +216,9 @@ static void sdl_user_func(int func, ...)
return
;
}
break
;
case
SDL_USEREVENT_MOUSEPOINTER
:
ev
.
user
.
data1
=
(
void
*
)(
intptr_t
)
va_arg
(
argptr
,
int
);
break
;
case
SDL_USEREVENT_SHOWMOUSE
:
case
SDL_USEREVENT_HIDEMOUSE
:
case
SDL_USEREVENT_FLUSH
:
...
...
@@ -1047,6 +1052,33 @@ void sdl_video_event_thread(void *data)
case
SDL_USEREVENT_GETWINPOS
:
sdl
.
GetWindowPosition
(
win
,
ev
.
user
.
data1
,
ev
.
user
.
data2
);
sem_post
(
&
sdl_ufunc_ret
);
break
;
case
SDL_USEREVENT_MOUSEPOINTER
:
{
int
cid
=
INT_MIN
;
SDL_Cursor
*
oc
=
curs
;
switch
((
intptr_t
)
ev
.
user
.
data1
)
{
case
CIOLIB_MOUSEPTR_ARROW
:
break
;
// Default
case
CIOLIB_MOUSEPTR_BAR
:
cid
=
SDL_SYSTEM_CURSOR_IBEAM
;
break
;
}
if
(
cid
==
INT_MIN
)
{
sdl
.
SetCursor
(
sdl
.
GetDefaultCursor
());
curs
=
NULL
;
}
else
{
curs
=
sdl
.
CreateSystemCursor
(
cid
);
if
(
curs
==
NULL
)
sdl
.
SetCursor
(
sdl
.
GetDefaultCursor
());
else
sdl
.
SetCursor
(
curs
);
}
if
(
oc
)
sdl
.
FreeCursor
(
oc
);
break
;
}
}
break
;
}
...
...
@@ -1097,3 +1129,10 @@ sdl_beep(void)
}
xp_play_sample
(
wave
,
2205
,
TRUE
);
}
/* Called from main thread only (Passes Event) */
int
sdl_mousepointer
(
enum
ciolib_mouse_ptr
type
)
{
sdl_user_func
(
SDL_USEREVENT_MOUSEPOINTER
,
type
);
return
(
0
);
}
src/conio/sdl_con.h
View file @
ab0456f2
...
...
@@ -38,6 +38,7 @@ int sdl_setpalette(uint32_t index, uint16_t r, uint16_t g, uint16_t b);
void
sdl_setwinsize
(
int
w
,
int
h
);
void
sdl_setwinposition
(
int
x
,
int
y
);
void
sdl_beep
(
void
);
int
sdl_mousepointer
(
enum
ciolib_mouse_ptr
type
);
#if defined(__DARWIN__)
void
sdl_init_darwin
(
void
*
args
);
...
...
src/conio/sdlfuncs.c
View file @
ab0456f2
...
...
@@ -4,6 +4,7 @@
#include "gen_defs.h"
#include "threadwrap.h"
#include <SDL.h>
#include "ciolib.h"
#include "sdlfuncs.h"
#include "sdl_con.h"
extern
int
sdl_video_initialized
;
...
...
@@ -16,8 +17,6 @@ struct sdlfuncs sdl;
#endif
#include <xp_dl.h>
#include "ciolib.h"
static
int
sdl_funcs_loaded
=
0
;
static
void
QuitWrap
(
void
);
...
...
@@ -179,6 +178,22 @@ int load_sdl_funcs(struct sdlfuncs *sdlf)
xp_dlclose
(
sdl_dll
);
return
(
-
1
);
}
if
((
sdlf
->
CreateSystemCursor
=
xp_dlsym
(
sdl_dll
,
SDL_CreateSystemCursor
))
==
NULL
)
{
xp_dlclose
(
sdl_dll
);
return
(
-
1
);
}
if
((
sdlf
->
GetDefaultCursor
=
xp_dlsym
(
sdl_dll
,
SDL_GetDefaultCursor
))
==
NULL
)
{
xp_dlclose
(
sdl_dll
);
return
(
-
1
);
}
if
((
sdlf
->
FreeCursor
=
xp_dlsym
(
sdl_dll
,
SDL_FreeCursor
))
==
NULL
)
{
xp_dlclose
(
sdl_dll
);
return
(
-
1
);
}
if
((
sdlf
->
SetCursor
=
xp_dlsym
(
sdl_dll
,
SDL_SetCursor
))
==
NULL
)
{
xp_dlclose
(
sdl_dll
);
return
(
-
1
);
}
if
((
sdlf
->
free
=
xp_dlsym
(
sdl_dll
,
SDL_free
))
==
NULL
)
{
xp_dlclose
(
sdl_dll
);
return
(
-
1
);
...
...
src/conio/sdlfuncs.h
View file @
ab0456f2
...
...
@@ -50,6 +50,10 @@ struct sdlfuncs {
void
(
HACK_HACK_HACK
*
SetWindowMinimumSize
)
(
SDL_Window
*
window
,
int
w
,
int
y
);
void
(
HACK_HACK_HACK
*
SetClipboardText
)
(
const
char
*
);
char
*
(
HACK_HACK_HACK
*
GetClipboardText
)
(
void
);
SDL_Cursor
*
(
HACK_HACK_HACK
*
CreateSystemCursor
)
(
SDL_SystemCursor
id
);
SDL_Cursor
*
(
HACK_HACK_HACK
*
GetDefaultCursor
)
(
void
);
void
(
HACK_HACK_HACK
*
SetCursor
)
(
SDL_Cursor
*
curs
);
void
(
HACK_HACK_HACK
*
FreeCursor
)
(
SDL_Cursor
*
curs
);
void
(
HACK_HACK_HACK
*
free
)
(
void
*
);
int
gotfuncs
;
};
...
...
Write
Preview
Markdown
is supported
0%
Try again
or
attach a new file
.
Attach a file
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Cancel
Please
register
or
sign in
to comment