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
a3bdbc68
Commit
a3bdbc68
authored
1 year ago
by
Deucе
Browse files
Options
Downloads
Patches
Plain Diff
Implement kbhit() and getch() so we can exit.
parent
7cd0bf7f
No related branches found
No related tags found
1 merge request
!463
MRC mods by Codefenix (2024-10-20)
Pipeline
#4141
failed
1 year ago
Stage: build
Changes
1
Pipelines
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/conio/win32gdi.c
+29
-2
29 additions, 2 deletions
src/conio/win32gdi.c
with
29 additions
and
2 deletions
src/conio/win32gdi.c
+
29
−
2
View file @
a3bdbc68
...
...
@@ -9,6 +9,8 @@
HBITMAP
bmp
;
HWND
win
;
FILE
*
debug
;
HANDLE
rch
;
HANDLE
wch
;
#define LCS_WINDOWS_COLOR_SPACE 0x57696E20
...
...
@@ -37,6 +39,20 @@ static int bitmap_width,bitmap_height;
// Internal implementation
static
void
add_key
(
uint16_t
key
)
{
uint8_t
buf
[
2
];
DWORD
added
;
DWORD
remain
=
sizeof
(
buf
);
buf
[
0
]
=
key
&
0xff
;
buf
[
1
]
=
key
>>
8
;
do
{
WriteFile
(
wch
,
buf
,
remain
,
&
added
,
NULL
);
remain
-=
added
;
}
while
(
remain
>
0
);
}
static
LRESULT
CALLBACK
gdi_WndProc
(
HWND
hwnd
,
UINT
msg
,
WPARAM
wParam
,
LPARAM
lParam
)
{
PAINTSTRUCT
ps
;
...
...
@@ -121,6 +137,7 @@ gdi_thread(void *arg)
// This may not be necessary...
DestroyWindow
(
win
);
UnregisterClassW
(
wc
.
lpszClassName
,
NULL
);
add_key
(
CIO_KEY_QUIT
);
}
// Public API
...
...
@@ -128,13 +145,22 @@ gdi_thread(void *arg)
int
gdi_kbhit
(
void
)
{
return
0
;
DWORD
avail
;
PeekNamedPipe
(
rch
,
NULL
,
0
,
NULL
,
&
avail
,
NULL
);
return
(
avail
>
0
);
}
int
gdi_getch
(
void
)
{
return
0
;
uint8_t
ch
;
DWORD
got
;
do
{
ReadFile
(
rch
,
&
ch
,
1
,
&
got
,
NULL
);
}
while
(
got
==
0
);
return
ch
;
}
void
...
...
@@ -230,6 +256,7 @@ gdi_init(int mode)
{
pthread_mutex_init
(
&
gdi_headlock
,
NULL
);
pthread_mutex_init
(
&
bmp_lock
,
NULL
);
CreatePipe
(
&
rch
,
&
wch
,
NULL
,
0
);
bitmap_drv_init
(
gdi_drawrect
,
gdi_flush
);
gdi_textmode
(
mode
);
...
...
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