| <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/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/SwitchName.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/SwitchName.java" afterDir="false" /> | ||
| + <change beforePath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/FrameDragListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/FrameDragListener.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/resources/images/key/dn/short.svg" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/resources/images/key/dn/short.svg" 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/com/whitemagicsoftware/kmcaster/listeners/MouseListener.java" beforeDir="false" afterPath="$PROJECT_DIR$/src/main/com/whitemagicsoftware/kmcaster/listeners/MouseListener.java" afterDir="false" /> | ||
| </list> | ||
| <option name="SHOW_DIALOG" value="false" /> | ||
| <extension name="coverage"> | ||
| <pattern> | ||
| - <option name="PATTERN" value="com.whitemagicsoftware.kmcaster.*" /> | ||
| + <option name="PATTERN" value="com.whitemagicsoftware.kmcaster.listeners.*" /> | ||
| <option name="ENABLED" value="true" /> | ||
| </pattern> | ||
| </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="1594971628573"> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.bottom" timestamp="1594972026417"> | ||
| <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="1594971628573" /> | ||
| - <state width="1479" height="330" key="GridCell.Tab.0.center" timestamp="1594971628572"> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.bottom/0.28.2560.1529@0.28.2560.1529" timestamp="1594972026417" /> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.center" timestamp="1594972026417"> | ||
| <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="1594971628572" /> | ||
| - <state width="1479" height="330" key="GridCell.Tab.0.left" timestamp="1594971628572"> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.center/0.28.2560.1529@0.28.2560.1529" timestamp="1594972026417" /> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.left" timestamp="1594972026416"> | ||
| <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="1594971628572" /> | ||
| - <state width="1479" height="330" key="GridCell.Tab.0.right" timestamp="1594971628573"> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.left/0.28.2560.1529@0.28.2560.1529" timestamp="1594972026416" /> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.right" timestamp="1594972026417"> | ||
| <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="1594971628573" /> | ||
| + <state width="1479" height="330" key="GridCell.Tab.0.right/0.28.2560.1529@0.28.2560.1529" timestamp="1594972026417" /> | ||
| <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="1594969799927"> | ||
| + <state x="833" y="545" width="586" height="502" key="find.popup" timestamp="1594972340355"> | ||
| <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="1594969799927" /> | ||
| + <state x="833" y="545" width="586" height="502" key="find.popup/0.28.2560.1529@0.28.2560.1529" timestamp="1594972340355" /> | ||
| <state x="915" y="547" width="415" height="496" key="refactoring.ChangeSignatureDialog" timestamp="1594967617639"> | ||
| <screen x="0" y="28" width="2560" height="1529" /> | ||
| import com.whitemagicsoftware.kmcaster.listeners.FrameDragListener; | ||
| +import com.whitemagicsoftware.kmcaster.listeners.SwitchName; | ||
| import javax.swing.*; | ||
| import java.awt.*; | ||
| import java.awt.geom.RoundRectangle2D; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| import static com.whitemagicsoftware.kmcaster.HardwareSwitches.state; | ||
| -import static com.whitemagicsoftware.kmcaster.SwitchName.*; | ||
| +import static com.whitemagicsoftware.kmcaster.listeners.SwitchName.*; | ||
| public class EventFrame extends JFrame { | ||
| final var image = mSwitches.get( keyState ); | ||
| final var component = mSwitchViews.get( keyState.getKey() ); | ||
| - | ||
| - System.out.println( keyState ); | ||
| component.redraw( image ); | ||
| } | ||
| protected void updateSwitchLabel( | ||
| final SwitchName name, final String label ) { | ||
| - System.out.printf( "%s = %s%n", name, label ); | ||
| } | ||
| package com.whitemagicsoftware.kmcaster; | ||
| +import com.whitemagicsoftware.kmcaster.listeners.SwitchName; | ||
| + | ||
| /** | ||
| * Responsible for defining hardware switch states. | ||
| */ | ||
| public class HardwareState { | ||
| + public final static String ANY_KEY = "*"; | ||
| + | ||
| private final SwitchName mName; | ||
| private final String mState; | ||
| */ | ||
| private boolean valid( final String state ) { | ||
| - return "*".equals( state ) || | ||
| + return ANY_KEY.equals( state ) || | ||
| "true".equals( state ) || | ||
| "false".equals( state ); | ||
| package com.whitemagicsoftware.kmcaster; | ||
| +import com.whitemagicsoftware.kmcaster.listeners.SwitchName; | ||
| + | ||
| import java.awt.*; | ||
| import java.util.HashMap; | ||
| import java.util.Map; | ||
| -import static com.whitemagicsoftware.kmcaster.SwitchName.*; | ||
| +import static com.whitemagicsoftware.kmcaster.HardwareState.ANY_KEY; | ||
| +import static com.whitemagicsoftware.kmcaster.listeners.SwitchName.*; | ||
| import static java.lang.String.format; | ||
| mImages.put( state( KEY_SHIFT, true ), keyDnImage( "long" ) ); | ||
| mImages.put( state( KEY_SHIFT, false ), keyUpImage( "long" ) ); | ||
| - mImages.put( state( KEY_REGULAR, "*" ), keyDnImage( "short" ) ); | ||
| + mImages.put( state( KEY_REGULAR, ANY_KEY ), keyDnImage( "short" ) ); | ||
| mImages.put( state( KEY_REGULAR, false ), keyUpImage( "short" ) ); | ||
| } | ||
| import com.whitemagicsoftware.kmcaster.listeners.KeyboardListener; | ||
| import com.whitemagicsoftware.kmcaster.listeners.MouseListener; | ||
| +import com.whitemagicsoftware.kmcaster.listeners.SwitchName; | ||
| import org.jnativehook.GlobalScreen; | ||
| import java.beans.PropertyChangeEvent; | ||
| import java.beans.PropertyChangeListener; | ||
| import java.util.logging.Level; | ||
| +import static com.whitemagicsoftware.kmcaster.HardwareState.ANY_KEY; | ||
| import static java.util.logging.Logger.getLogger; | ||
| import static javax.swing.SwingUtilities.invokeLater; | ||
| var switchValue = e.getNewValue().toString(); | ||
| + // True or false indicates a non-regular key was pressed. | ||
| if( !"false".equals( switchValue ) && !"true".equals( switchValue ) ) { | ||
| - switchValue = "*"; | ||
| + switchValue = ANY_KEY; | ||
| } | ||
| -/* | ||
| - * Copyright 2020 White Magic Software, Ltd. | ||
| - * | ||
| - * All rights reserved. | ||
| - * | ||
| - * Redistribution and use in source and binary forms, with or without | ||
| - * modification, are permitted provided that the following conditions are met: | ||
| - * | ||
| - * o Redistributions of source code must retain the above copyright | ||
| - * notice, this list of conditions and the following disclaimer. | ||
| - * | ||
| - * o Redistributions in binary form must reproduce the above copyright | ||
| - * notice, this list of conditions and the following disclaimer in the | ||
| - * documentation and/or other materials provided with the distribution. | ||
| - * | ||
| - * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| - * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| - * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| - * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| - * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| - * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| - * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| - * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| - * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| - * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| - * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| - */ | ||
| -package com.whitemagicsoftware.kmcaster; | ||
| - | ||
| -/** | ||
| - * Used for compile-time binding between change listeners input events. | ||
| - */ | ||
| -public enum SwitchName { | ||
| - KEY_ALT( "alt" ), | ||
| - KEY_CTRL( "ctrl" ), | ||
| - KEY_SHIFT( "shift" ), | ||
| - KEY_REGULAR( "regular" ), | ||
| - MOUSE_LEFT( "button 1" ), | ||
| - MOUSE_WHEEL( "button 2" ), | ||
| - MOUSE_RIGHT( "button 3" ), | ||
| - MOUSE_LR( "button 1-3" ); | ||
| - | ||
| - private final String mName; | ||
| - | ||
| - SwitchName( final String name ) { | ||
| - mName = name; | ||
| - } | ||
| - | ||
| - public boolean isName( final String name ) { | ||
| - return mName.equalsIgnoreCase( name ); | ||
| - } | ||
| - | ||
| - /** | ||
| - * Looks up the key that matches the given name, case-insensitively. | ||
| - * | ||
| - * @param name The name of the key to find in this enum. | ||
| - * @return The {@link SwitchName} object that matches the name. | ||
| - */ | ||
| - public static SwitchName valueFrom( final String name ) { | ||
| - for( final var b : SwitchName.values() ) { | ||
| - if( b.isName( name ) ) { | ||
| - return b; | ||
| - } | ||
| - } | ||
| - | ||
| - return KEY_REGULAR; | ||
| - } | ||
| - | ||
| - @Override | ||
| - public String toString() { | ||
| - return mName; | ||
| - } | ||
| -} | ||
| +/* | ||
| + * Copyright 2020 White Magic Software, Ltd. | ||
| + * | ||
| + * All rights reserved. | ||
| + * | ||
| + * Redistribution and use in source and binary forms, with or without | ||
| + * modification, are permitted provided that the following conditions are met: | ||
| + * | ||
| + * o Redistributions of source code must retain the above copyright | ||
| + * notice, this list of conditions and the following disclaimer. | ||
| + * | ||
| + * o Redistributions in binary form must reproduce the above copyright | ||
| + * notice, this list of conditions and the following disclaimer in the | ||
| + * documentation and/or other materials provided with the distribution. | ||
| + * | ||
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| + */ | ||
| package com.whitemagicsoftware.kmcaster.listeners; | ||
| package com.whitemagicsoftware.kmcaster.listeners; | ||
| -import com.whitemagicsoftware.kmcaster.SwitchName; | ||
| import org.jnativehook.keyboard.NativeKeyEvent; | ||
| import org.jnativehook.keyboard.NativeKeyListener; | ||
| import java.beans.PropertyChangeListener; | ||
| import java.beans.PropertyChangeSupport; | ||
| import java.util.List; | ||
| import java.util.Map; | ||
| -import static com.whitemagicsoftware.kmcaster.SwitchName.*; | ||
| +import static com.whitemagicsoftware.kmcaster.listeners.SwitchName.*; | ||
| import static java.util.Map.entry; | ||
| import static org.jnativehook.NativeInputEvent.*; |
| package com.whitemagicsoftware.kmcaster.listeners; | ||
| -import com.whitemagicsoftware.kmcaster.SwitchName; | ||
| import org.jnativehook.keyboard.NativeKeyEvent; | ||
| /** | ||
| * Responsible for tracking the state of modifier keys. | ||
| */ | ||
| -class KeyboardModifier { | ||
| +public class KeyboardModifier { | ||
| private boolean mHeld; | ||
| private final int mMask; |
| public void nativeMouseWheelMoved( NativeMouseWheelEvent e ) { | ||
| - System.out.println( "Mouse Scroll: " + e.getWheelRotation() ); | ||
| +// System.out.println( "Mouse Scroll: " + e.getWheelRotation() ); | ||
| } | ||
| } |
| +/* | ||
| + * Copyright 2020 White Magic Software, Ltd. | ||
| + * | ||
| + * All rights reserved. | ||
| + * | ||
| + * Redistribution and use in source and binary forms, with or without | ||
| + * modification, are permitted provided that the following conditions are met: | ||
| + * | ||
| + * o Redistributions of source code must retain the above copyright | ||
| + * notice, this list of conditions and the following disclaimer. | ||
| + * | ||
| + * o Redistributions in binary form must reproduce the above copyright | ||
| + * notice, this list of conditions and the following disclaimer in the | ||
| + * documentation and/or other materials provided with the distribution. | ||
| + * | ||
| + * THIS SOFTWARE IS PROVIDED BY THE COPYRIGHT HOLDERS AND CONTRIBUTORS | ||
| + * "AS IS" AND ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT | ||
| + * LIMITED TO, THE IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR | ||
| + * A PARTICULAR PURPOSE ARE DISCLAIMED. IN NO EVENT SHALL THE COPYRIGHT | ||
| + * HOLDER OR CONTRIBUTORS BE LIABLE FOR ANY DIRECT, INDIRECT, INCIDENTAL, | ||
| + * SPECIAL, EXEMPLARY, OR CONSEQUENTIAL DAMAGES (INCLUDING, BUT NOT | ||
| + * LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS OR SERVICES; LOSS OF USE, | ||
| + * DATA, OR PROFITS; OR BUSINESS INTERRUPTION) HOWEVER CAUSED AND ON ANY | ||
| + * THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT LIABILITY, OR TORT | ||
| + * (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY OUT OF THE USE | ||
| + * OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF SUCH DAMAGE. | ||
| + */ | ||
| +package com.whitemagicsoftware.kmcaster.listeners; | ||
| + | ||
| +/** | ||
| + * Used for compile-time binding between change listeners input events. | ||
| + */ | ||
| +public enum SwitchName { | ||
| + KEY_ALT( "alt" ), | ||
| + KEY_CTRL( "ctrl" ), | ||
| + KEY_SHIFT( "shift" ), | ||
| + KEY_REGULAR( "regular" ), | ||
| + MOUSE_LEFT( "button 1" ), | ||
| + MOUSE_WHEEL( "button 2" ), | ||
| + MOUSE_RIGHT( "button 3" ), | ||
| + MOUSE_LR( "button 1-3" ); | ||
| + | ||
| + private final String mName; | ||
| + | ||
| + SwitchName( final String name ) { | ||
| + mName = name; | ||
| + } | ||
| + | ||
| + public boolean isName( final String name ) { | ||
| + return mName.equalsIgnoreCase( name ); | ||
| + } | ||
| + | ||
| + /** | ||
| + * Looks up the key that matches the given name, case-insensitively. | ||
| + * | ||
| + * @param name The name of the key to find in this enum. | ||
| + * @return The {@link SwitchName} object that matches the name. | ||
| + */ | ||
| + public static SwitchName valueFrom( final String name ) { | ||
| + for( final var b : SwitchName.values() ) { | ||
| + if( b.isName( name ) ) { | ||
| + return b; | ||
| + } | ||
| + } | ||
| + | ||
| + return KEY_REGULAR; | ||
| + } | ||
| + | ||
| + @Override | ||
| + public String toString() { | ||
| + return mName; | ||
| + } | ||
| +} | ||
| Author | DaveJarvis <email> |
|---|---|
| Date | 2020-07-17 00:54:46 GMT-0700 |
| Commit | 27637a3a7314c0b27c290219770f644cfeaa3bfe |
| Parent | 10284d3 |
| Delta | 134 lines added, 99 lines removed, 35-line increase |