Skip to content
GitLab
Explore
Sign in
Primary navigation
Search or go to…
Project
S
Sinister Zeta Project
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
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
Sinister Zeta
Sinister Zeta Project
Commits
89724102
Commit
89724102
authored
4 years ago
by
NikolaBabic
Browse files
Options
Downloads
Patches
Plain Diff
Added checkMessages method
parent
65c8d3d9
No related branches found
Branches containing commit
No related tags found
Tags containing commit
2 merge requests
!45
Prototype to Master for Milestone 5
,
!41
Feature OS interface
Changes
1
Hide whitespace changes
Inline
Side-by-side
Showing
1 changed file
src/model/OSInterface.java
+21
-1
21 additions, 1 deletion
src/model/OSInterface.java
with
21 additions
and
1 deletion
src/model/OSInterface.java
+
21
−
1
View file @
89724102
...
...
@@ -2,6 +2,7 @@ package model;
import
com.sun.jna.platform.win32.User32
;
import
com.sun.jna.platform.win32.WinDef
;
import
com.sun.jna.platform.win32.WinUser
;
import
java.util.HashMap
;
...
...
@@ -12,9 +13,13 @@ public class OSInterface implements HotkeyDetector, HotkeyRegistration, InputEmu
private
User32
user32
=
User32
.
INSTANCE
;
private
WinDef
.
HWND
hwnd
;
private
HashMap
<
Integer
,
Hotkey
>
registeredKeys
;
private
HashMap
<
Integer
,
Boolean
>
pressedKeys
;
private
WinUser
.
MSG
msg
;
private
OSInterface
()
{
registeredKeys
=
new
HashMap
<>();
pressedKeys
=
new
HashMap
<>();
msg
=
new
WinUser
.
MSG
();
}
/**
...
...
@@ -27,12 +32,27 @@ public class OSInterface implements HotkeyDetector, HotkeyRegistration, InputEmu
return
instance
;
}
/**
* Must be called in a loop to check the message queue of the window.
*/
public
void
checkMessages
()
{
boolean
hotkeyMsg
=
user32
.
PeekMessage
(
msg
,
hwnd
,
0
,
0
,
1
);
if
(
hotkeyMsg
)
{
if
(
msg
.
message
==
User32
.
WM_HOTKEY
)
{
if
(
registeredKeys
.
containsKey
(
msg
.
wParam
.
intValue
()))
{
pressedKeys
.
put
(
msg
.
wParam
.
intValue
(),
true
);
}
}
}
}
/**
* Sets the HWND to use for interfacing with the OS.
* @param hwnd The HWND of a window.
*/
public
void
setHWND
(
WinDef
.
HWND
hwnd
)
{
this
.
hwnd
=
hwnd
;
if
(
this
.
hwnd
==
null
)
this
.
hwnd
=
hwnd
;
}
@Override
...
...
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