Skip to content
GitLab
Explore
Sign in
Register
Primary navigation
Search or go to…
Project
Synchronet
Manage
Activity
Members
Labels
Plan
Issues
Issue boards
Milestones
Wiki
Code
Merge requests
Repository
Branches
Commits
Tags
Repository graph
Compare revisions
Snippets
Build
Pipelines
Jobs
Pipeline schedules
Artifacts
Deploy
Releases
Package registry
Container Registry
Model registry
Operate
Environments
Terraform modules
Monitor
Incidents
Analyze
Value stream analytics
Contributor analytics
CI/CD analytics
Repository analytics
Model experiments
Help
Help
Support
GitLab documentation
Compare GitLab plans
Community forum
Contribute to GitLab
Provide feedback
Keyboard shortcuts
?
Snippets
Groups
Projects
Show more breadcrumbs
Main
Synchronet
Commits
d9aeaae3
Commit
d9aeaae3
authored
5 years ago
by
deuce
Browse files
Options
Downloads
Patches
Plain Diff
Overhaul input yet again... this *should* fix Ragnorok's problem... but
*may* break all sorts of other things.
parent
fd94a3b6
No related branches found
Branches containing commit
No related tags found
Tags containing commit
No related merge requests found
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/conio/sdl_con.c
+74
-46
74 additions, 46 deletions
src/conio/sdl_con.c
with
74 additions
and
46 deletions
src/conio/sdl_con.c
+
74
−
46
View file @
d9aeaae3
...
...
@@ -703,6 +703,23 @@ static unsigned int sdl_get_char_code(unsigned int keysym, unsigned int mod)
return
(
0x0001ffff
);
}
static
void
sdl_add_keys
(
uint8_t
*
utf8s
)
{
char
*
chars
;
char
*
p
;
chars
=
utf8_to_cp437
(
utf8s
,
'\x0d'
);
if
(
chars
)
{
for
(
p
=
chars
;
*
p
;
p
++
)
{
if
(
*
p
==
'\x0d'
)
continue
;
sdl_add_key
(
*
((
uint8_t
*
)
p
));
}
free
(
chars
);
}
}
/* Mouse event/keyboard thread */
static
void
sdl_mouse_thread
(
void
*
data
)
{
...
...
@@ -744,7 +761,8 @@ static int win_to_text_ypos(int winpos)
static
void
sdl_video_event_thread
(
void
*
data
)
{
SDL_Event
ev
;
int
old_w
,
old_h
;
int
old_w
,
old_h
;
int
block_text
=
0
;
pthread_mutex_lock
(
&
vstatlock
);
old_w
=
cvstat
.
winwidth
;
...
...
@@ -766,55 +784,65 @@ static void sdl_video_event_thread(void *data)
else
{
switch
(
ev
.
type
)
{
case
SDL_KEYDOWN
:
/* Keypress */
if
((
ev
.
key
.
keysym
.
mod
&
KMOD_ALT
)
&&
(
ev
.
key
.
keysym
.
sym
==
SDLK_LEFT
||
ev
.
key
.
keysym
.
sym
==
SDLK_RIGHT
||
ev
.
key
.
keysym
.
sym
==
SDLK_UP
||
ev
.
key
.
keysym
.
sym
==
SDLK_DOWN
))
{
int
w
,
h
;
pthread_mutex_lock
(
&
vstatlock
);
w
=
cvstat
.
winwidth
;
h
=
cvstat
.
winheight
;
switch
(
ev
.
key
.
keysym
.
sym
)
{
case
SDLK_LEFT
:
if
(
w
%
(
cvstat
.
charwidth
*
cvstat
.
cols
))
{
w
=
w
-
w
%
(
cvstat
.
charwidth
*
cvstat
.
cols
);
}
else
{
w
-=
(
cvstat
.
charwidth
*
cvstat
.
cols
);
if
(
w
<
(
cvstat
.
charwidth
*
cvstat
.
cols
))
w
=
cvstat
.
charwidth
*
cvstat
.
cols
;
}
break
;
case
SDLK_RIGHT
:
w
=
(
w
-
w
%
(
cvstat
.
charwidth
*
cvstat
.
cols
))
+
(
cvstat
.
charwidth
*
cvstat
.
cols
);
break
;
case
SDLK_UP
:
if
(
h
%
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
))
{
h
=
h
-
h
%
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
);
}
else
{
h
-=
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
);
if
(
h
<
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
))
h
=
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
;
}
break
;
case
SDLK_DOWN
:
h
=
(
h
-
h
%
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
))
+
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
);
break
;
}
if
(
w
>
16384
||
h
>
16384
)
beep
();
else
{
cvstat
.
winwidth
=
w
;
cvstat
.
winheight
=
h
;
if
(
ev
.
key
.
keysym
.
mod
&
(
KMOD_CTRL
|
KMOD_ALT
|
KMOD_GUI
))
{
block_text
=
1
;
if
((
ev
.
key
.
keysym
.
mod
&
KMOD_ALT
)
&&
(
ev
.
key
.
keysym
.
sym
==
SDLK_LEFT
||
ev
.
key
.
keysym
.
sym
==
SDLK_RIGHT
||
ev
.
key
.
keysym
.
sym
==
SDLK_UP
||
ev
.
key
.
keysym
.
sym
==
SDLK_DOWN
))
{
int
w
,
h
;
pthread_mutex_lock
(
&
vstatlock
);
w
=
cvstat
.
winwidth
;
h
=
cvstat
.
winheight
;
switch
(
ev
.
key
.
keysym
.
sym
)
{
case
SDLK_LEFT
:
if
(
w
%
(
cvstat
.
charwidth
*
cvstat
.
cols
))
{
w
=
w
-
w
%
(
cvstat
.
charwidth
*
cvstat
.
cols
);
}
else
{
w
-=
(
cvstat
.
charwidth
*
cvstat
.
cols
);
if
(
w
<
(
cvstat
.
charwidth
*
cvstat
.
cols
))
w
=
cvstat
.
charwidth
*
cvstat
.
cols
;
}
break
;
case
SDLK_RIGHT
:
w
=
(
w
-
w
%
(
cvstat
.
charwidth
*
cvstat
.
cols
))
+
(
cvstat
.
charwidth
*
cvstat
.
cols
);
break
;
case
SDLK_UP
:
if
(
h
%
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
))
{
h
=
h
-
h
%
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
);
}
else
{
h
-=
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
);
if
(
h
<
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
))
h
=
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
;
}
break
;
case
SDLK_DOWN
:
h
=
(
h
-
h
%
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
))
+
(
cvstat
.
charheight
*
cvstat
.
rows
*
cvstat
.
vmultiplier
);
break
;
}
if
(
w
>
16384
||
h
>
16384
)
beep
();
else
{
cvstat
.
winwidth
=
w
;
cvstat
.
winheight
=
h
;
}
pthread_mutex_unlock
(
&
vstatlock
);
break
;
}
pthread_mutex_unlock
(
&
vstatlock
);
}
else
if
(
block_text
||
!
isprint
(
ev
.
key
.
keysym
.
sym
))
sdl_add_key
(
sdl_get_char_code
(
ev
.
key
.
keysym
.
sym
,
ev
.
key
.
keysym
.
mod
));
break
;
case
SDL_KEYUP
:
/* Ignored (handled in KEYDOWN event) */
case
SDL_TEXTINPUT
:
if
(
!
block_text
)
sdl_add_keys
((
uint8_t
*
)
ev
.
text
.
text
);
break
;
case
SDL_KEYUP
:
if
(
!
(
ev
.
key
.
keysym
.
mod
&
(
KMOD_CTRL
|
KMOD_ALT
|
KMOD_GUI
)))
block_text
=
0
;
break
;
case
SDL_MOUSEMOTION
:
if
(
!
ciolib_mouse_initialized
)
...
...
This diff is collapsed.
Click to expand it.
Preview
0%
Loading
Try again
or
attach a new file
.
Cancel
You are about to add
0
people
to the discussion. Proceed with caution.
Finish editing this message first!
Save comment
Cancel
Please
register
or
sign in
to comment