From 6bac7912f48a5c176176c2cb9d8d33c1de076e02 Mon Sep 17 00:00:00 2001 From: Surinder Singh Date: Mon, 8 Sep 2008 22:06:30 -0700 Subject: [PATCH] Fixed the keyboard --- zbrainz/source/com/zbrainz/gui/EK1.java | 29 ++++++++++++++++------------- 1 file changed, 16 insertions(+), 13 deletions(-) diff --git a/zbrainz/source/com/zbrainz/gui/EK1.java b/zbrainz/source/com/zbrainz/gui/EK1.java index 88c12d1..bc2b9e2 100755 --- a/zbrainz/source/com/zbrainz/gui/EK1.java +++ b/zbrainz/source/com/zbrainz/gui/EK1.java @@ -16,6 +16,7 @@ public class EK1 public static void main( String[] args ) { + ZLog.init(); EK1 gui = new EK1(); gui.go(); }// main @@ -35,6 +36,7 @@ public class EK1 m_KBsound.Start(); m_panel.setBackground(Color.YELLOW); m_panel.addMouseListener(m_panel); + m_frame.addKeyListener(m_panel); m_frame.setVisible(true); } @@ -43,7 +45,7 @@ public class EK1 { public void paintComponent( Graphics g) { - System.out.println("Hello"); + ZLog.logInfo("Hello"); m_KBgui.draw(g); } @@ -53,12 +55,12 @@ public class EK1 int x = e.getX(); int y = e.getY(); int i = m_KBgui.convertMouseClickToKey(x, y); - System.out.println("Key Press event"); + ZLog.logInfo("Key Press event"); if ( i >= 0 ) { m_KBgui.keyPressed(i); m_KBsound.PlayStart(24+i); - System.out.format("Key Pressed[%d]\n", i); + ZLog.logInfo("Key Pressed[%d]\n", i); } m_frame.requestFocus(); repaint(); @@ -69,12 +71,12 @@ public class EK1 int x = e.getX(); int y = e.getY(); int i = m_KBgui.convertMouseClickToKey(x, y); - System.out.println("Key release event"); + ZLog.logInfo("Key release event"); if ( i >= 0 ) { m_KBgui.keyReleased(i); m_KBsound.PlayStop(24+i); - System.out.format("Key Released[%d]\n", i); + ZLog.logInfo("Key Released[%d]\n", i); } m_frame.requestFocus(); repaint(); @@ -100,6 +102,7 @@ public class EK1 int i = -1; char c = e.getKeyChar(); c = Character.toLowerCase(c); + ZLog.logInfo("KeyPressed Event : %c", c); if (c == 'a') i=0; else if (c == 'w') i=1; else if (c == 's') i=2; @@ -115,10 +118,11 @@ public class EK1 else if (c == ';') i=12; if ( i < 0 ) return; - m_KBsound.PlayStart(i); this.requestFocus(); + m_KBgui.keyPressed(i); + m_KBsound.PlayStart(48+i); this.repaint(); - m_panel.requestFocus(); + m_frame.requestFocus(); } public void keyReleased(KeyEvent e) @@ -126,6 +130,7 @@ public class EK1 int i = -1; char c = e.getKeyChar(); c = Character.toLowerCase(c); + ZLog.logInfo("KeyReleased Event : %c", c); if (c == 'a') i=0; else if (c == 'w') i=1; else if (c == 's') i=2; @@ -142,19 +147,17 @@ public class EK1 if ( i < 0 ) return; m_frame.requestFocus(); - m_KBsound.PlayStop(i); + m_KBgui.keyReleased(i); + m_KBsound.PlayStop(24+i); this.repaint(); - m_panel.requestFocus(); + m_frame.requestFocus(); } public void keyTyped(KeyEvent e) { char c = e.getKeyChar(); m_frame.requestFocus(); - m_panel.requestFocus(); } - - - } + } } -- 2.11.4.GIT