Debugging walkie talkies, don't use this build unless you like console spam

This commit is contained in:
Aidan Brady 2013-10-18 19:09:08 -04:00
parent 0350eef398
commit d8a806ebab
4 changed files with 25 additions and 4 deletions

View file

@ -17,6 +17,8 @@ public class MekanismKeyHandler extends KeyHandler
public static KeyBinding modeSwitch = new KeyBinding("Mekanism Mode Switch", Keyboard.KEY_M);
public static KeyBinding voice = new KeyBinding("Mekanism Voice", Keyboard.KEY_U);
public static boolean voiceKeyDown = false;
public MekanismKeyHandler()
{
super(new KeyBinding[] {modeSwitch, voice}, new boolean[] {false, false});
@ -29,10 +31,22 @@ public class MekanismKeyHandler extends KeyHandler
}
@Override
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat) {}
public void keyDown(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd, boolean isRepeat)
{
if(tickEnd && kb.keyCode == voice.keyCode)
{
voiceKeyDown = true;
}
}
@Override
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd) {}
public void keyUp(EnumSet<TickType> types, KeyBinding kb, boolean tickEnd)
{
if(tickEnd && kb.keyCode == voice.keyCode)
{
voiceKeyDown = false;
}
}
@Override
public EnumSet<TickType> ticks()

View file

@ -40,11 +40,12 @@ public class VoiceInput extends Thread
while(voiceClient.running)
{
if(MekanismKeyHandler.voice.isPressed())
if(MekanismKeyHandler.voiceKeyDown)
{
System.out.println("Pressed");
targetLine.flush();
while(voiceClient.running && MekanismKeyHandler.voice.isPressed())
while(voiceClient.running && MekanismKeyHandler.voiceKeyDown)
{
int availableBytes = audioInput.available();
byte[] audioData = new byte[availableBytes > 2200 ? 2200 : availableBytes];
@ -54,6 +55,7 @@ public class VoiceInput extends Thread
{
voiceClient.output.writeShort(audioData.length);
voiceClient.output.write(audioData);
System.out.println("Wrote");
}
}
@ -65,6 +67,7 @@ public class VoiceInput extends Thread
}
else if(doFlush)
{
System.out.println("Flushed");
voiceClient.output.flush();
doFlush = false;
}

View file

@ -39,6 +39,8 @@ public class VoiceOutput extends Thread
byte[] audioData = new byte[byteCount];
voiceClient.input.readFully(audioData);
System.out.println("Got");
sourceLine.write(audioData, 0, audioData.length);
}
} catch(Exception e) {

View file

@ -117,6 +117,8 @@ public class VoiceConnection
output.write(audioData);
output.flush();
System.out.println("Sent");
} catch(Exception e) {
System.err.println("[Mekanism] VoiceServer: Error while sending data to player.");
e.printStackTrace();