Dave Jarvis' Repositories

git clone https://repo.autonoma.ca/repo/kmcaster.git

Fix modifiers (again), add regular key release event

Author DaveJarvis <email>
Date 2020-07-16 20:22:54 GMT-0700
Commit e8a1560daf238456d22db5e61221d4b159314a72
Parent 7c9d188
Delta 0 lines added, 0 lines removed
.idea/workspace.xml
<list default="true" id="be1819c5-28d3-4984-9634-0b266734e13c" name="Default Changelist" comment="">
<change beforePath="$PROJECT_DIR$/.idea/workspace.xml" beforeDir="false" afterPath="$PROJECT_DIR$/.idea/workspace.xml" afterDir="false" />
+ <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/EventFrame.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/EventFrame.java" afterDir="false" />
<change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardListener.java" afterDir="false" />
- <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardModifier.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardModifier.java" afterDir="false" />
</list>
<option name="SHOW_DIALOG" value="false" />
</state>
<state x="710" y="704" width="425" height="207" key="DetectedRootsChooserDialog/0.28.2560.1529@0.28.2560.1529" timestamp="1594872764235" />
- <state width="1479" height="330" key="GridCell.Tab.0.bottom" timestamp="1594955521867">
+ <state width="1479" height="330" key="GridCell.Tab.0.bottom" timestamp="1594955986749">
<screen x="0" y="28" width="2560" height="1529" />
</state>
- <state width="1479" height="330" key="GridCell.Tab.0.bottom/0.28.2560.1529@0.28.2560.1529" timestamp="1594955521867" />
- <state width="1479" height="330" key="GridCell.Tab.0.center" timestamp="1594955521866">
+ <state width="1479" height="330" key="GridCell.Tab.0.bottom/0.28.2560.1529@0.28.2560.1529" timestamp="1594955986749" />
+ <state width="1479" height="330" key="GridCell.Tab.0.center" timestamp="1594955986748">
<screen x="0" y="28" width="2560" height="1529" />
</state>
- <state width="1479" height="330" key="GridCell.Tab.0.center/0.28.2560.1529@0.28.2560.1529" timestamp="1594955521866" />
- <state width="1479" height="330" key="GridCell.Tab.0.left" timestamp="1594955521866">
+ <state width="1479" height="330" key="GridCell.Tab.0.center/0.28.2560.1529@0.28.2560.1529" timestamp="1594955986748" />
+ <state width="1479" height="330" key="GridCell.Tab.0.left" timestamp="1594955986748">
<screen x="0" y="28" width="2560" height="1529" />
</state>
- <state width="1479" height="330" key="GridCell.Tab.0.left/0.28.2560.1529@0.28.2560.1529" timestamp="1594955521866" />
- <state width="1479" height="330" key="GridCell.Tab.0.right" timestamp="1594955521867">
+ <state width="1479" height="330" key="GridCell.Tab.0.left/0.28.2560.1529@0.28.2560.1529" timestamp="1594955986748" />
+ <state width="1479" height="330" key="GridCell.Tab.0.right" timestamp="1594955986749">
<screen x="0" y="28" width="2560" height="1529" />
</state>
- <state width="1479" height="330" key="GridCell.Tab.0.right/0.28.2560.1529@0.28.2560.1529" timestamp="1594955521867" />
+ <state width="1479" height="330" key="GridCell.Tab.0.right/0.28.2560.1529@0.28.2560.1529" timestamp="1594955986749" />
<state width="1479" height="406" key="GridCell.Tab.1.bottom" timestamp="1594948352434">
<screen x="0" y="28" width="2560" height="1529" />
src/main/com/whitemagicsoftware/kmcaster/EventFrame.java
private static final Color TRANSPARENT = new Color( 0, 0, 0, 0 );
+
+
public EventFrame() {
setLocationRelativeTo( null );
src/main/com/whitemagicsoftware/kmcaster/listeners/KeyboardListener.java
public void nativeKeyPressed( final NativeKeyEvent e ) {
final String regularHeld = getDisplayText( e );
- boolean isRegular = true;
+ boolean isModifier = false;
// The key is regular iff its name does not match any modifier name.
for( final var modifier : mModifiers ) {
- isRegular &= modifier.isKeyName( regularHeld );
+ isModifier |= modifier.isKeyName( regularHeld );
}
// If it's not a modifier key, broadcast the regular value.
- if( isRegular ) {
+ if( !isModifier ) {
tryFire( KEY_REGULAR, mRegularHeld, regularHeld );
mRegularHeld = regularHeld;
}
updateModifiers( e );
}
@Override
public void nativeKeyReleased( final NativeKeyEvent e ) {
- mRegularHeld = "";
+ final String oldValue = getDisplayText( e );
+ final String newValue = "";
+
+ tryFire( KEY_REGULAR, oldValue, newValue );
+ mRegularHeld = newValue;
+
updateModifiers( e );
}