We are about to switch to a new forum software. Until then we have removed the registration on this forum.
Hello i trie tu test a examle from Ketai library, the name ist BluetoothCursors of samsung device Android 4.4.2. But i don t understand , why, i can not test of the phone. Can somewhere help me please hier ist the code
/** *
Ketai Library for Android: http://KetaiProject.org
* *
<
p>KetaiBluetooth wraps the Android Bluetooth RFCOMM Features: *
Updated: 2012-05-18 Daniel Sauter/j.duran
*/
//required for BT enabling on startup import android.content.Intent; import android.os.Bundle;
import ketai.net.bluetooth.*; import ketai.ui.*; import ketai.net.*;
import oscP5.*;
KetaiBluetooth bt; String info = ""; KetaiList klist; PVector remoteMouse = new PVector();
ArrayList devicesDiscovered = new ArrayList(); boolean isConfiguring = true; String UIText;
//******************************************************************** // The following code is required to enable bluetooth at startup. //******************************************************************** void onCreate(Bundle savedInstanceState) { super.onCreate(savedInstanceState); bt = new KetaiBluetooth(this); }
void onActivityResult(int requestCode, int resultCode, Intent data) { bt.onActivityResult(requestCode, resultCode, data); }
//********************************************************************
void setup()
{
orientation(PORTRAIT);
background(78, 93, 75);
stroke(255);
textSize(24);
//start listening for BT connections bt.start();
UIText = "d - discover devices\n" + "b - make this device discoverable\n" + "c - connect to device\n from discovered list.\n" + "p - list paired devices\n" + "i - Bluetooth info"; }
void draw() { if (isConfiguring) { ArrayList names; background(78, 93, 75);
//based on last key pressed lets display
// appropriately
if (key == 'i')
info = getBluetoothInformation();
else
{
if (key == 'p')
{
info = "Paired Devices:\n";
names = bt.getPairedDeviceNames();
}
else
{
info = "Discovered Devices:\n";
names = bt.getDiscoveredDeviceNames();
}
for (int i=0; i < names.size(); i++)
{
info += "["+i+"] "+names.get(i).toString() + "\n";
}
}
text(UIText + "\n\n" + info, 5, 90);
}
else
{
background(78, 93, 75);
pushStyle();
fill(255);
ellipse(mouseX, mouseY, 20, 20);
fill(0, 255, 0);
stroke(0, 255, 0);
ellipse(remoteMouse.x, remoteMouse.y, 20, 20);
popStyle();
}
drawUI(); }
//Call back method to manage data received void onBluetoothDataEvent(String who, byte[] data) { if (isConfiguring) return;
//KetaiOSCMessage is the same as OscMessage // but allows construction by byte array KetaiOSCMessage m = new KetaiOSCMessage(data); if (m.isValid()) { if (m.checkAddrPattern("/remoteMouse/")) { if (m.checkTypetag("ii")) { remoteMouse.x = m.get(0).intValue(); remoteMouse.y = m.get(1).intValue(); } } } }
String getBluetoothInformation() { String btInfo = "Server Running: "; btInfo += bt.isStarted() + "\n"; btInfo += "Discovering: " + bt.isDiscovering() + "\n"; btInfo += "Device Discoverable: "+bt.isDiscoverable() + "\n"; btInfo += "\nConnected Devices: \n";
ArrayList devices = bt.getConnectedDeviceNames(); for (String device: devices) { btInfo+= device+"\n"; }
return btInfo; }
Answers
You'll get a better response if you format your code. Here's how:
http://forum.processing.org/two/discussion/8045/how-to-format-code-and-text
@dng05///
what version of processing???
hallo i have the last version of processing
@dng== is ketai supposed to work with P3??? -- i think no---try same code with processing 2
oki, but i tried to install Processing 2, and i tried to install android mode, this not work