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
69c8bb90
Commit
69c8bb90
authored
4 years ago
by
Dallin Nickel (djn011)
Browse files
Options
Downloads
Patches
Plain Diff
Now can bind any key to another, cannot bind multiple though
parent
924c674b
No related branches found
Branches containing commit
No related tags found
2 merge requests
!45
Prototype to Master for Milestone 5
,
!44
Demo
Changes
4
Hide whitespace changes
Inline
Side-by-side
Showing
4 changed files
src/model/Action.java
+0
-38
0 additions, 38 deletions
src/model/Action.java
src/model/Binding.java
+17
-13
17 additions, 13 deletions
src/model/Binding.java
src/model/Demo.java
+12
-4
12 additions, 4 deletions
src/model/Demo.java
src/ui/MainScreen.java
+8
-0
8 additions, 0 deletions
src/ui/MainScreen.java
with
37 additions
and
55 deletions
src/model/Action.java
deleted
100644 → 0
+
0
−
38
View file @
924c674b
package
model
;
import
java.awt.*
;
/**
* Testing program while the program is not yet completed so that we may test the system simulating keypresses.
*/
public
class
Action
extends
Hotkey
implements
InputEmulator
{
/**
* Robot which simulates user key presses
*/
Robot
robot
;
/**
* Constructs an immutable hotkey.
* @param keyCode The virtual keycode of the hotkey.
* @param id The unique ID of the hotkey.
* @param modifier The modifier of the hotkey.
*/
public
Action
(
int
keyCode
,
int
id
,
int
modifier
)
throws
AWTException
{
super
(
keyCode
,
id
,
modifier
);
this
.
robot
=
new
Robot
();
}
/**
* Sends a given key to be emulated.
* @param keyCode The virtual keycode of the key.
* @param release True if the key is to be a key release input.
*/
@Override
public
void
sendKey
(
int
keyCode
,
boolean
release
)
{
if
(
release
)
{
robot
.
keyPress
(
this
.
getKeyCode
());
robot
.
keyRelease
(
this
.
getKeyCode
());
}
}
}
This diff is collapsed.
Click to expand it.
src/model/Binding.java
+
17
−
13
View file @
69c8bb90
...
...
@@ -4,26 +4,30 @@ public class Binding {
/**
* Hotkey to be bound to an action
*/
Hotkey
h
otkey
;
Hotkey
h
k1
;
/**
* Action preformed when hotkey is pressed
*/
Action
action
;
Hotkey
hk2
;
/**
* The id of the hotkey and action pairing
*/
int
id
;
/**
* Constructor to bind the hotkey and the action together
* @param hotkey hotkey which is submitted
* @param action the action to be preformed when the hotkey is pressed
*
* @param hotkey1 hotkey which is submitted
* @param hotkey2 the action to be preformed when the hotkey is pressed
*/
public
Binding
(
Hotkey
hotkey
,
Action
action
){
this
.
hotkey
=
hotkey
;
this
.
action
=
action
;
this
.
id
=
hotkey
.
getID
();
public
Binding
(
Hotkey
hotkey1
,
Hotkey
hotkey2
)
{
this
.
hk1
=
hotkey1
;
this
.
hk2
=
hotkey2
;
}
public
int
getID
()
{
return
this
.
hk1
.
getID
();
}
public
int
getActionCode
()
{
return
this
.
hk2
.
getKeyCode
();
}
}
}
\ No newline at end of file
This diff is collapsed.
Click to expand it.
src/model/Demo.java
+
12
−
4
View file @
69c8bb90
package
model
;
import
ui.MainScreen
;
import
java.util.ArrayList
;
import
java.util.List
;
public
class
Demo
implements
Runnable
{
int
id
=
0
;
int
id
;
boolean
stop
=
false
;
ArrayList
<
Binding
>
list
=
MainScreen
.
list
;
public
Demo
()
{
...
...
@@ -10,11 +16,13 @@ public class Demo implements Runnable {
public
void
run
()
{
while
(!
stop
)
{
if
(
OSInterface
.
getInstance
().
wasPressed
(
id
))
{
OSInterface
.
getInstance
().
sendKey
(
0x70
,
false
);
for
(
Binding
binding
:
list
)
{
if
(
OSInterface
.
getInstance
().
wasPressed
(
binding
.
getID
()))
{
OSInterface
.
getInstance
().
sendKey
(
binding
.
getActionCode
(),
true
);
}
}
}
}
}
public
void
stop
()
{
stop
=
true
;
...
...
This diff is collapsed.
Click to expand it.
src/ui/MainScreen.java
+
8
−
0
View file @
69c8bb90
...
...
@@ -5,10 +5,14 @@ import javafx.scene.control.Button;
import
javafx.scene.control.ComboBox
;
import
javafx.scene.layout.Pane
;
import
javafx.stage.Stage
;
import
model.Binding
;
import
model.Hotkey
;
import
model.Modifier
;
import
model.OSInterface
;
import
java.util.ArrayList
;
import
java.util.List
;
/**
* mainScreen is the main UI page for the program. All user functions start here.
*/
...
...
@@ -17,6 +21,7 @@ public class MainScreen extends Pane {
Stage
primaryStage
=
new
Stage
();
Scene
mainScreenScene
=
new
Scene
(
this
,
800
,
800
);
int
id
=
0
;
public
static
ArrayList
<
Binding
>
list
=
new
ArrayList
<>();
public
MainScreen
()
{
...
...
@@ -146,6 +151,9 @@ public class MainScreen extends Pane {
"-fx-pref-width: 100px; -fx-pref-height: 50px; -fx-text-align: center;"
);
save
.
setOnAction
(
e
->
{
Hotkey
newHotkey
=
new
Hotkey
(
KBV
.
getKeyToBind
(),
id
,
Modifier
.
NONE
.
val
());
Hotkey
action
=
new
Hotkey
(
KBV
.
getKeyAction
(),
id
,
Modifier
.
NONE
.
val
());
Binding
binding
=
new
Binding
(
newHotkey
,
action
);
list
.
add
(
binding
);
id
++;
boolean
register
=
OSInterface
.
getInstance
().
registerHotkey
(
newHotkey
);
primaryStage
.
setScene
(
mainScreenScene
);
...
...
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