mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-06-15 21:31:12 +00:00
added support for keyboard keys a-z
This commit is contained in:
@@ -4,5 +4,6 @@
|
|||||||
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
<classpathentry kind="con" path="org.eclipse.jdt.launching.JRE_CONTAINER/org.eclipse.jdt.internal.debug.ui.launcher.StandardVMType/JavaSE-1.6"/>
|
||||||
<classpathentry kind="lib" path="libs/limelight-common.jar"/>
|
<classpathentry kind="lib" path="libs/limelight-common.jar"/>
|
||||||
<classpathentry kind="lib" path="libs/xpp3-1.1.4c.jar"/>
|
<classpathentry kind="lib" path="libs/xpp3-1.1.4c.jar"/>
|
||||||
|
<classpathentry combineaccessrules="false" kind="src" path="/limelight-common"/>
|
||||||
<classpathentry kind="output" path="bin"/>
|
<classpathentry kind="output" path="bin"/>
|
||||||
</classpath>
|
</classpath>
|
||||||
|
|||||||
@@ -1,13 +1,7 @@
|
|||||||
package com.limelight;
|
package com.limelight;
|
||||||
|
|
||||||
import java.net.NetworkInterface;
|
|
||||||
import java.util.Enumeration;
|
|
||||||
|
|
||||||
import javax.swing.JOptionPane;
|
import javax.swing.JOptionPane;
|
||||||
import javax.swing.JSpinner;
|
|
||||||
import javax.swing.UIManager;
|
import javax.swing.UIManager;
|
||||||
import javax.swing.UnsupportedLookAndFeelException;
|
|
||||||
|
|
||||||
import com.limelight.binding.PlatformBinding;
|
import com.limelight.binding.PlatformBinding;
|
||||||
import com.limelight.gui.MainFrame;
|
import com.limelight.gui.MainFrame;
|
||||||
import com.limelight.gui.StreamFrame;
|
import com.limelight.gui.StreamFrame;
|
||||||
@@ -28,12 +22,12 @@ public class Limelight implements NvConnectionListener {
|
|||||||
|
|
||||||
private void startUp() {
|
private void startUp() {
|
||||||
streamFrame = new StreamFrame();
|
streamFrame = new StreamFrame();
|
||||||
streamFrame.build();
|
|
||||||
conn = new NvConnection(host, this);
|
conn = new NvConnection(host, this);
|
||||||
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
||||||
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
||||||
PlatformBinding.getAudioRenderer(),
|
PlatformBinding.getAudioRenderer(),
|
||||||
PlatformBinding.getVideoDecoderRenderer());
|
PlatformBinding.getVideoDecoderRenderer());
|
||||||
|
streamFrame.build(conn);
|
||||||
}
|
}
|
||||||
|
|
||||||
public static void createInstance(String host) {
|
public static void createInstance(String host) {
|
||||||
|
|||||||
@@ -5,10 +5,17 @@ import java.awt.Toolkit;
|
|||||||
|
|
||||||
import javax.swing.JFrame;
|
import javax.swing.JFrame;
|
||||||
|
|
||||||
|
import com.limelight.input.KeyboardHandler;
|
||||||
|
import com.limelight.nvstream.NvConnection;
|
||||||
|
|
||||||
public class StreamFrame extends JFrame {
|
public class StreamFrame extends JFrame {
|
||||||
private static final long serialVersionUID = 1L;
|
private static final long serialVersionUID = 1L;
|
||||||
|
|
||||||
public void build() {
|
private KeyboardHandler keyboard;
|
||||||
|
|
||||||
|
public void build(NvConnection conn) {
|
||||||
|
keyboard = new KeyboardHandler(conn);
|
||||||
|
this.addKeyListener(keyboard);
|
||||||
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
Dimension dim = Toolkit.getDefaultToolkit().getScreenSize();
|
||||||
this.setSize(1280,720);
|
this.setSize(1280,720);
|
||||||
//This might break if the screen res is too small...not sure though
|
//This might break if the screen res is too small...not sure though
|
||||||
|
|||||||
@@ -3,17 +3,26 @@ package com.limelight.input;
|
|||||||
import java.awt.event.KeyEvent;
|
import java.awt.event.KeyEvent;
|
||||||
import java.awt.event.KeyListener;
|
import java.awt.event.KeyListener;
|
||||||
|
|
||||||
|
import com.limelight.nvstream.NvConnection;
|
||||||
|
|
||||||
public class KeyboardHandler implements KeyListener {
|
public class KeyboardHandler implements KeyListener {
|
||||||
|
|
||||||
|
private static KeyboardTranslator translator;
|
||||||
|
|
||||||
|
public KeyboardHandler(NvConnection conn) {
|
||||||
|
translator = new KeyboardTranslator(conn);
|
||||||
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyPressed(KeyEvent event) {
|
public void keyPressed(KeyEvent event) {
|
||||||
|
short keyMap = translator.translate(event.getKeyCode());
|
||||||
|
translator.sendKeyDown(keyMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
public void keyReleased(KeyEvent event) {
|
public void keyReleased(KeyEvent event) {
|
||||||
// TODO Auto-generated method stub
|
short keyMap = translator.translate(event.getKeyCode());
|
||||||
|
translator.sendKeyUp(keyMap);
|
||||||
}
|
}
|
||||||
|
|
||||||
@Override
|
@Override
|
||||||
|
|||||||
@@ -0,0 +1,24 @@
|
|||||||
|
package com.limelight.input;
|
||||||
|
|
||||||
|
import java.awt.event.KeyEvent;
|
||||||
|
|
||||||
|
import com.limelight.nvstream.NvConnection;
|
||||||
|
import com.limelight.nvstream.input.KeycodeTranslator;
|
||||||
|
|
||||||
|
public class KeyboardTranslator extends KeycodeTranslator {
|
||||||
|
|
||||||
|
public static final short KEYCODE_A = (short) 0x8041;
|
||||||
|
|
||||||
|
public KeyboardTranslator(NvConnection conn) {
|
||||||
|
super(conn);
|
||||||
|
}
|
||||||
|
|
||||||
|
@Override
|
||||||
|
public short translate(int keycode) {
|
||||||
|
if (keycode >= KeyEvent.VK_A && keycode <= KeyEvent.VK_Z) {
|
||||||
|
return (short) (KEYCODE_A + (short)(keycode - KeyEvent.VK_A));
|
||||||
|
}
|
||||||
|
return 0;
|
||||||
|
}
|
||||||
|
|
||||||
|
}
|
||||||
Reference in New Issue
Block a user