mirror of
https://github.com/moonlight-stream/moonlight-embedded.git
synced 2026-04-05 07:26:07 +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="lib" path="libs/limelight-common.jar"/>
|
||||
<classpathentry kind="lib" path="libs/xpp3-1.1.4c.jar"/>
|
||||
<classpathentry combineaccessrules="false" kind="src" path="/limelight-common"/>
|
||||
<classpathentry kind="output" path="bin"/>
|
||||
</classpath>
|
||||
|
||||
@@ -1,13 +1,7 @@
|
||||
package com.limelight;
|
||||
|
||||
import java.net.NetworkInterface;
|
||||
import java.util.Enumeration;
|
||||
|
||||
import javax.swing.JOptionPane;
|
||||
import javax.swing.JSpinner;
|
||||
import javax.swing.UIManager;
|
||||
import javax.swing.UnsupportedLookAndFeelException;
|
||||
|
||||
import com.limelight.binding.PlatformBinding;
|
||||
import com.limelight.gui.MainFrame;
|
||||
import com.limelight.gui.StreamFrame;
|
||||
@@ -21,19 +15,19 @@ public class Limelight implements NvConnectionListener {
|
||||
private String host;
|
||||
private StreamFrame streamFrame;
|
||||
private NvConnection conn;
|
||||
|
||||
|
||||
public Limelight(String host) {
|
||||
this.host = host;
|
||||
}
|
||||
|
||||
private void startUp() {
|
||||
streamFrame = new StreamFrame();
|
||||
streamFrame.build();
|
||||
conn = new NvConnection(host, this);
|
||||
conn.start(PlatformBinding.getDeviceName(), streamFrame,
|
||||
VideoDecoderRenderer.FLAG_PREFER_QUALITY,
|
||||
PlatformBinding.getAudioRenderer(),
|
||||
PlatformBinding.getVideoDecoderRenderer());
|
||||
streamFrame.build(conn);
|
||||
}
|
||||
|
||||
public static void createInstance(String host) {
|
||||
|
||||
@@ -5,10 +5,17 @@ import java.awt.Toolkit;
|
||||
|
||||
import javax.swing.JFrame;
|
||||
|
||||
import com.limelight.input.KeyboardHandler;
|
||||
import com.limelight.nvstream.NvConnection;
|
||||
|
||||
public class StreamFrame extends JFrame {
|
||||
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();
|
||||
this.setSize(1280,720);
|
||||
//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.KeyListener;
|
||||
|
||||
public class KeyboardHandler implements KeyListener {
|
||||
import com.limelight.nvstream.NvConnection;
|
||||
|
||||
public class KeyboardHandler implements KeyListener {
|
||||
|
||||
private static KeyboardTranslator translator;
|
||||
|
||||
public KeyboardHandler(NvConnection conn) {
|
||||
translator = new KeyboardTranslator(conn);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyPressed(KeyEvent event) {
|
||||
|
||||
short keyMap = translator.translate(event.getKeyCode());
|
||||
translator.sendKeyDown(keyMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
public void keyReleased(KeyEvent event) {
|
||||
// TODO Auto-generated method stub
|
||||
|
||||
short keyMap = translator.translate(event.getKeyCode());
|
||||
translator.sendKeyUp(keyMap);
|
||||
}
|
||||
|
||||
@Override
|
||||
|
||||
24
limelight-pc/src/com/limelight/input/KeyboardTranslator.java
Normal file
24
limelight-pc/src/com/limelight/input/KeyboardTranslator.java
Normal file
@@ -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