|
Author |
Topic: key q == key F2 (Read 2256 times) |
|
bryandamage
|
key q == key F2
« on: Mar 19th, 2005, 5:31am » |
|
i'm trying to create a virtual control surface to use the video mixing program "veejay" over OSC using oscP5. so far everything is fine and i can communicate with veejay by assigning an osc message to a key like this: void keyPressed(){ String ap; Object[] tObj; ap = "/clip/select"; tObj = new Object[] {new Integer(key)}; oscP5.sendMsg(ap,tObj); } veejay will receive this message and play the clip number of any key i press. the problem i'm having is when i try to assign different messages to different keys. I want the function keys to select a clip so i put this before "oscP5.sendMsg(ap,tObj)": if ((key <= 112) && (key >= 123)){ tObj = new Object[] {new Integer(key-111)}; } this gets the F1-F12 keys to select clips 1-12 and works fine. i then want to assign the keys along the top letter row (q-i) to another function. if i push these keys now veejay will select a clip. key q selects clip 113 and key Q selects clip 81 so i put this before "oscP5.sendMsg(ap,tObj)": if ((key == 'q') || (key == 'Q')) { ap = "/video/play" tObj = new Object[] {}; // /video/play has no arguments } this works great now and i can play the video by pressing the q key and if capslock is on it still works, but now the F2 key plays the video as the key value of F2 is 113. i can't find much documentation on the usage of the key variable so i'm i doing this wrong or is this a bug in the values of key? Edited to add: i've since found the error. sorry about this as it was on my part. although the reference material should include some info about this... using this code the problem is resolved: public void keyReleased(KeyEvent e){ // Needs to use the java function int myKey = e.getKeyCode(); // getKeyCode is unavailable in processing and provides consistent results String ap = "/default/message"; Object[] tObj = new Object[] {}; ap = "/clip/select"; tObj = new Object[] {new Integer(myKey)}; if ((myKey <= 112) && (myKey >= 123)){ tObj = new Object[] {new Integer(myKey-111)}; } if ((myKey == 81)) { ap = "/video/play" tObj = new Object[] {}; // /video/play has no arguments } oscP5.sendMsg(ap,tObj); }
|
« Last Edit: Mar 19th, 2005, 8:57am by bryandamage » |
|
|
|
|
fry
|
Re: key q == key F2
« Reply #1 on: Mar 19th, 2005, 9:54pm » |
|
yeah, the key stuff has been ironed out for 70+. the problem is that 'key' and coded keys need to be separated, so that's been done. in 68/69 you can (as you found) use the KeyEvent that's passed in to and getKeyCode() and getKeyChar() to make it work.
|
|
|
|
|