| <component name="ChangeListManager"> | ||
| <list default="true" id="be1819c5-28d3-4984-9634-0b266734e13c" name="Default Changelist" comment=""> | ||
| - <change afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/HardwareSwitches.java" afterDir="false" /> | ||
| <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/AppImage.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/SvgRasterizer.java" 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/HardwareState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/HardwareState.java" afterDir="false" /> | ||
| + <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/HardwareSwitches.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/HardwareSwitches.java" afterDir="false" /> | ||
| <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/ImageComponent.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/ImageComponent.java" afterDir="false" /> | ||
| - <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/KeyState.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/HardwareState.java" afterDir="false" /> | ||
| <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/KmCaster.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/KmCaster.java" afterDir="false" /> | ||
| - <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/Key.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/SwitchName.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" /> | ||
| + <change beforePath="$PROJECT_DIR$/src/main/resources/images/key/dn/short.svg" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/images/key/dn/short.svg" afterDir="false" /> | ||
| </list> | ||
| <option name="SHOW_DIALOG" value="false" /> | ||
| <tree_state> | ||
| <expand> | ||
| - <path> | ||
| - <item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" /> | ||
| - <item name="kmcaster" type="f1a62948:ProjectNode" /> | ||
| - </path> | ||
| <path> | ||
| <item name="" type="6a2764b6:ExternalProjectsStructure$RootNode" /> | ||
| <item name="kmcaster" type="f1a62948:ProjectNode" /> | ||
| - <item name="Tasks" type="e4a08cd1:TasksNode" /> | ||
| </path> | ||
| </expand> | ||
| </state> | ||
| <state x="813" y="683" width="218" height="250" key="#Notifications/0.28.2560.1529@0.28.2560.1529" timestamp="1594856235998" /> | ||
| - <state x="314" y="436" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1594963749524"> | ||
| + <state x="314" y="436" key="#com.intellij.execution.impl.EditConfigurationsDialog" timestamp="1594970464272"> | ||
| <screen x="0" y="28" width="2560" height="1529" /> | ||
| </state> | ||
| - <state x="314" y="436" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.28.2560.1529@0.28.2560.1529" timestamp="1594963749524" /> | ||
| - <state x="734" y="519" width="376" height="578" key="#com.intellij.ide.util.MemberChooser" timestamp="1594883540197"> | ||
| + <state x="314" y="436" key="#com.intellij.execution.impl.EditConfigurationsDialog/0.28.2560.1529@0.28.2560.1529" timestamp="1594970464272" /> | ||
| + <state x="734" y="519" width="477" height="578" key="#com.intellij.ide.util.MemberChooser" timestamp="1594969516839"> | ||
| <screen x="0" y="28" width="2560" height="1529" /> | ||
| </state> | ||
| - <state x="734" y="519" width="376" height="578" key="#com.intellij.ide.util.MemberChooser/0.28.2560.1529@0.28.2560.1529" timestamp="1594883540197" /> | ||
| + <state x="734" y="519" width="477" height="578" key="#com.intellij.ide.util.MemberChooser/0.28.2560.1529@0.28.2560.1529" timestamp="1594969516839" /> | ||
| <state x="745" y="737" key="#com.intellij.refactoring.move.MoveHandler.SelectRefactoringDialog" timestamp="1594958988910"> | ||
| <screen x="0" y="28" width="2560" height="1529" /> | ||
| </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="1594967617575"> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.bottom" timestamp="1594971628573"> | ||
| <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="1594967617575" /> | ||
| - <state width="1479" height="330" key="GridCell.Tab.0.center" timestamp="1594967617574"> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.bottom/0.28.2560.1529@0.28.2560.1529" timestamp="1594971628573" /> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.center" timestamp="1594971628572"> | ||
| <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="1594967617574" /> | ||
| - <state width="1479" height="330" key="GridCell.Tab.0.left" timestamp="1594967617574"> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.center/0.28.2560.1529@0.28.2560.1529" timestamp="1594971628572" /> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.left" timestamp="1594971628572"> | ||
| <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="1594967617574" /> | ||
| - <state width="1479" height="330" key="GridCell.Tab.0.right" timestamp="1594967617575"> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.left/0.28.2560.1529@0.28.2560.1529" timestamp="1594971628572" /> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.right" timestamp="1594971628573"> | ||
| <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="1594967617575" /> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.right/0.28.2560.1529@0.28.2560.1529" timestamp="1594971628573" /> | ||
| <state width="1479" height="406" key="GridCell.Tab.1.bottom" timestamp="1594959771008"> | ||
| <screen x="0" y="28" width="2560" height="1529" /> | ||
| </state> | ||
| <state x="840" y="410" width="564" height="770" key="com.intellij.openapi.editor.actions.MultiplePasteAction$ClipboardContentChooser/0.28.2560.1529@0.28.2560.1529" timestamp="1594946566725" /> | ||
| - <state x="833" y="545" width="586" height="502" key="find.popup" timestamp="1594949350582"> | ||
| + <state x="833" y="545" width="586" height="502" key="find.popup" timestamp="1594969799927"> | ||
| <screen x="0" y="28" width="2560" height="1529" /> | ||
| </state> | ||
| - <state x="833" y="545" width="586" height="502" key="find.popup/0.28.2560.1529@0.28.2560.1529" timestamp="1594949350582" /> | ||
| + <state x="833" y="545" width="586" height="502" key="find.popup/0.28.2560.1529@0.28.2560.1529" timestamp="1594969799927" /> | ||
| <state x="915" y="547" width="415" height="496" key="refactoring.ChangeSignatureDialog" timestamp="1594967617639"> | ||
| <screen x="0" y="28" width="2560" height="1529" /> | ||
| private final HardwareSwitches mSwitches; | ||
| - private final Map<SwitchName, ImageComponent> mKeyViews = new HashMap<>(); | ||
| + private final Map<SwitchName, ImageComponent> mSwitchViews = new HashMap<>(); | ||
| public EventFrame() { | ||
| content.add( panel ); | ||
| - mKeyViews.put( KEY_SHIFT, shiftComponent ); | ||
| - mKeyViews.put( KEY_CTRL, ctrlComponent ); | ||
| - mKeyViews.put( KEY_ALT, altComponent ); | ||
| - mKeyViews.put( KEY_REGULAR, regularComponent ); | ||
| + mSwitchViews.put( KEY_SHIFT, shiftComponent ); | ||
| + mSwitchViews.put( KEY_CTRL, ctrlComponent ); | ||
| + mSwitchViews.put( KEY_ALT, altComponent ); | ||
| + mSwitchViews.put( KEY_REGULAR, regularComponent ); | ||
| } | ||
| - protected void updateKeys( final HardwareState keyState ) { | ||
| + protected void updateSwitchState( final HardwareState keyState ) { | ||
| final var image = mSwitches.get( keyState ); | ||
| - final var component = mKeyViews.get( keyState.getKey() ); | ||
| + final var component = mSwitchViews.get( keyState.getKey() ); | ||
| - component.repaint( image ); | ||
| + System.out.println( keyState ); | ||
| + | ||
| + component.redraw( image ); | ||
| + } | ||
| + | ||
| + protected void updateSwitchLabel( | ||
| + final SwitchName name, final String label ) { | ||
| + System.out.printf( "%s = %s%n", name, label ); | ||
| } | ||
| */ | ||
| public class HardwareState { | ||
| - private final SwitchName mKey; | ||
| + private final SwitchName mName; | ||
| private final String mState; | ||
| - public HardwareState( final SwitchName key, final boolean pressed ) { | ||
| - assert key != null; | ||
| + /** | ||
| + * Constructs a new instance that represents whether a key or mouse button | ||
| + * was pressed. | ||
| + * | ||
| + * @param name The {@link SwitchName} representing the type of switch | ||
| + * state to represent. | ||
| + * @param state A value of "*' means a regular key was pressed; otherwise, | ||
| + * "true" or "false" indicate pressed or released, respectively. | ||
| + */ | ||
| + public HardwareState( final SwitchName name, final String state ) { | ||
| + assert name != null; | ||
| + assert valid( state ); | ||
| - mKey = key; | ||
| - mState = Boolean.toString( pressed ); | ||
| + mName = name; | ||
| + mState = state; | ||
| } | ||
| public SwitchName getKey() { | ||
| - return mKey; | ||
| + return mName; | ||
| + } | ||
| + | ||
| + /** | ||
| + * Test whether the given state conforms to specification. | ||
| + * | ||
| + * @param state A value of "*' means a regular key was pressed; otherwise, | ||
| + * "true" or "false" indicate pressed or released, respectively. | ||
| + * @return {@code true} The given {@code state} is a known value. | ||
| + */ | ||
| + private boolean valid( final String state ) { | ||
| + return "*".equals( state ) || | ||
| + "true".equals( state ) || | ||
| + "false".equals( state ); | ||
| } | ||
| final HardwareState that = (HardwareState) o; | ||
| - if( mKey != that.mKey ) { | ||
| + if( mName != that.mName ) { | ||
| return false; | ||
| } | ||
| return mState.equals( that.mState ); | ||
| } | ||
| @Override | ||
| public int hashCode() { | ||
| - int result = mKey.hashCode(); | ||
| + int result = mName.hashCode(); | ||
| result = 31 * result + mState.hashCode(); | ||
| return result; | ||
| + } | ||
| + | ||
| + @Override | ||
| + public String toString() { | ||
| + return getClass().getName() + "{" + | ||
| + "mKey=" + mName + | ||
| + ", mState='" + mState + '\'' + | ||
| + '}'; | ||
| } | ||
| } | ||
| mImages.put( state( KEY_SHIFT, true ), keyDnImage( "long" ) ); | ||
| mImages.put( state( KEY_SHIFT, false ), keyUpImage( "long" ) ); | ||
| - mImages.put( state( KEY_REGULAR, true ), keyDnImage( "short" ) ); | ||
| + mImages.put( state( KEY_REGULAR, "*" ), keyDnImage( "short" ) ); | ||
| mImages.put( state( KEY_REGULAR, false ), keyUpImage( "short" ) ); | ||
| } | ||
| public Image get( final HardwareState state ) { | ||
| return mImages.get( state ); | ||
| } | ||
| - public static HardwareState state( final SwitchName name, final boolean state ) { | ||
| + public static HardwareState state( | ||
| + final SwitchName name, final boolean state ) { | ||
| + return state( name, Boolean.toString( state ) ); | ||
| + } | ||
| + | ||
| + public static HardwareState state( | ||
| + final SwitchName name, final String state ) { | ||
| return new HardwareState( name, state ); | ||
| } |
| @Override | ||
| public Dimension getPreferredSize() { | ||
| + // Race-condition guard. | ||
| final var image = mImage; | ||
| final var g = (Graphics2D) graphics.create(); | ||
| g.drawImage( mImage, 0, 0, this ); | ||
| - } | ||
| - | ||
| - public Image getImage() { | ||
| - return mImage; | ||
| } | ||
| /** | ||
| * Repaints this component using the given image. This is a mutable | ||
| * operation that changes the internal {@link Image} instance. | ||
| * | ||
| * @param image The new image to use for painting. | ||
| */ | ||
| - public void repaint( final Image image ) { | ||
| + public void redraw( final Image image ) { | ||
| mImage = image; | ||
| repaint(); | ||
| import java.util.logging.Level; | ||
| -import static java.lang.Boolean.parseBoolean; | ||
| import static java.util.logging.Logger.getLogger; | ||
| import static javax.swing.SwingUtilities.invokeLater; | ||
| @Override | ||
| public void propertyChange( final PropertyChangeEvent e ) { | ||
| - final var keyState = createKeyState( e.getPropertyName(), e.getNewValue() ); | ||
| - updateKeys( keyState ); | ||
| + var switchValue = e.getNewValue().toString(); | ||
| + | ||
| + if( !"false".equals( switchValue ) && !"true".equals( switchValue ) ) { | ||
| + switchValue = "*"; | ||
| + } | ||
| + | ||
| + final var switchState = createState( e.getPropertyName(), switchValue ); | ||
| + updateSwitchState( switchState ); | ||
| + updateSwitchLabel( switchState.getKey(), switchValue ); | ||
| } | ||
| - private HardwareState createKeyState( final String name, final Object bool ) { | ||
| + private HardwareState createState( | ||
| + final String name, final String state ) { | ||
| assert name != null; | ||
| - assert bool != null; | ||
| + assert state != null; | ||
| final var key = SwitchName.valueFrom( name ); | ||
| - final var state = parseBoolean( bool.toString() ); | ||
| return new HardwareState( key, state ); | ||
| @Override | ||
| public void nativeKeyReleased( final NativeKeyEvent e ) { | ||
| - updateRegular( getDisplayText( e ), "" ); | ||
| + updateRegular( getDisplayText( e ), "false" ); | ||
| updateModifiers( e ); | ||
| } |
| -<svg height="11.615047mm" viewBox="0 0 12.362682 11.615047" width="12.362682mm" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientTransform="matrix(-.16684802 0 0 .16684802 457.8413 214.08468)" gradientUnits="userSpaceOnUse" x1="338.63031" x2="358.67578" y1="522.47595" y2="538.1333"><stop offset="0" stop-color="#d6d6d6"/><stop offset="1" stop-color="#939393"/></linearGradient><linearGradient id="b" gradientUnits="userSpaceOnUse" x1="360.03877876328" x2="363.86003389461" y1="300.90122247002" y2="303.51362031597"><stop offset="0" stop-color="#656565"/><stop offset="1" stop-color="#939393"/></linearGradient><linearGradient id="c" gradientUnits="userSpaceOnUse" x1="398.36286129201" x2="397.8572450522" y1="267.73274772245" y2="265.62598113264"><stop offset="0" stop-color="#d6d6d6"/><stop offset="1" stop-color="#656565"/></linearGradient><linearGradient id="d" gradientTransform="matrix(.19208083 0 0 .50174705 278.16509 190.95032)" gradientUnits="userSpaceOnUse" x1="506.54913" x2="586.02765" y1="186.9615" y2="186.9615"><stop offset="0" stop-color="#d8d8d8"/><stop offset="1" stop-color="#b1b1b1"/></linearGradient><linearGradient id="e" gradientTransform="matrix(.19208083 0 0 .50174705 278.16509 190.95032)" gradientUnits="userSpaceOnUse" x1="447.03323" x2="516.2417" y1="177.95511" y2="177.95511"><stop offset="0" stop-color="#f1f1f1"/><stop offset="1" stop-color="#b1b1b1"/></linearGradient><g fill-rule="evenodd" transform="matrix(.26458333 0 0 .26458333 -94.66906 -69.95494)"><path d="m360.1253 264.39661h37.14661c1.28583 0 2.32099 1.03516 2.32099 2.32099v29.65406h-41.75697l-.0316-29.65406c-.001-1.28583 1.03516-2.32099 2.32099-2.32099z" fill="#656565"/><path d="m360.73083 302.54279h36.954876v5.733785h-36.954876z" fill="#929292"/><path d="m393.20774 267.61445h11.32169v28.78137h-11.32169z" fill="#d6d6d6"/><path d="m395.86 295.44468 8.66943.95114v8.40293c-.005 2.17337-1.73219 3.42204-3.51833 3.49725l-3.85072-.0194-4.24981-9.92456z" fill="url(#a)"/><path d="m363.81917 295.3604-5.98324 1.01126-.0316 8.42709c.004 2.17337 1.73217 3.42204 3.51832 3.49725l3.84486-.0421 1.34834-9.8597z" fill="url(#b)"/><path d="m397.25962 269.99799 7.26981-2.38354c-.28879-2.2916-1.8612-3.11162-4.05203-3.15819-.56277-.012-1.0254-.0443-1.62233-.0544-.59693-.0102-1.95889-.001-1.95889-.001-1.37344.26896-2.44856 1.05576-3.20013 2.34598z" fill="url(#c)"/><rect fill="url(#d)" height="35.645615" ry="2.704166" stroke="url(#e)" stroke-width=".498687" width="34.355576" x="363.95416" y="266.93491"/></g></svg> | ||
| +<svg height="43.899" viewBox="0 0 48.304 43.899" width="48.304" xmlns="http://www.w3.org/2000/svg" xmlns:xlink="http://www.w3.org/1999/xlink"><linearGradient id="a" gradientTransform="matrix(-.16685 0 0 .16685 101.61 -50.311)" gradientUnits="userSpaceOnUse" x1="338.63" x2="358.68" y1="522.48" y2="538.13"><stop offset="0" stop-color="#d6d6d6"/><stop offset="1" stop-color="#939393"/></linearGradient><linearGradient id="b" gradientUnits="userSpaceOnUse" x1="2.2280017" x2="6.0479635" y1="36.4977665" y2="39.1077404"><stop offset="0" stop-color="#656565"/><stop offset="1" stop-color="#939393"/></linearGradient><linearGradient id="c" gradientUnits="userSpaceOnUse" x1="42.1473329" x2="41.637338" y1="3.3280982" y2="1.2281192"><stop offset="0" stop-color="#d6d6d6"/><stop offset="1" stop-color="#656565"/></linearGradient><linearGradient id="d" gradientTransform="matrix(.35393 0 0 .49978 -151.86 -73.08)" gradientUnits="userSpaceOnUse" x1="461.97" x2="535.38" y1="186.96" y2="186.96"><stop offset="0" stop-color="#d8d8d8"/><stop offset="1" stop-color="#b1b1b1"/></linearGradient><linearGradient id="e" gradientTransform="matrix(.35393 0 0 .49978 -151.86 -73.08)" gradientUnits="userSpaceOnUse" x1="453.41" x2="483.79" y1="177.84" y2="177.84"><stop offset="0" stop-color="#f1f1f1"/><stop offset="1" stop-color="#c1c1c1"/></linearGradient><g fill-rule="evenodd"><g stroke-width=".99999"><path d="m2.3216 0h41.37c1.2858 0 2.4075 1.0381 2.321 2.321v29.654h-45.98l-.0316-29.654c-.00099999-1.2858 1.0352-2.321 2.321-2.321z" fill="#656565"/><path d="m4.9942 38.142h37.058v5.7337h-37.058z" fill="#929292"/><path d="m36.981 3.218h11.322v28.781h-11.322z" fill="#d6d6d6"/><path d="m39.634 31.048 8.6693.95114v8.4028c-.005 2.1734-1.7322 3.422-3.5183 3.4972l-3.8507-.0194-4.2498-9.9245z" fill="url(#a)"/><path d="m6.0154 30.964-5.9831 1.0112-.0316 8.427c.004 2.1734 1.7322 3.422 3.5183 3.4972l3.8449-.0421 1.3483-9.8596z" fill="url(#b)"/><path d="m41.033 5.6009 7.2697-2.3835c-.28879-2.2916-1.8612-3.1116-4.052-3.1582-.56276-.012-1.0254-.0443-1.6223-.054399-.59692-.0102-1.9589-.00098999-1.9589-.00098999-1.3734.26896-2.4486 1.0558-3.2001 2.346z" fill="url(#c)"/></g><rect fill="url(#d)" height="35.507" ry="2.6936" stroke="url(#e)" stroke-width=".49868" width="35.948" x="6.2198" y="2.608"/></g></svg> |
| Author | DaveJarvis <email> |
|---|---|
| Date | 2020-07-17 00:46:19 GMT-0700 |
| Commit | 10284d35590680eab1a97bda64ff137b8f9678c9 |
| Parent | 57413d2 |
| Delta | 95 lines added, 55 lines removed, 40-line increase |