public static int sendEventToNode(NodeHandle calcHandle, IEvent event)
throws Exception {
int status = 0;
if (calcHandle != null) {
NspireVirtualKeyStroke key = (NspireVirtualKeyStroke) event;
byte[] keyBytesCode = key.getKeyCode();
if (keyBytesCode != null) {
ConnectionHandle ch = new ConnectionHandle();
status = NavNet.connect(calcHandle, 16450, ch);
if (status == 1) {
status = NavNet.write(ch, NspireVirtualKeyStroke.VIRTUAL_KEY_STROKE_EVENT_COMMAND, NspireVirtualKeyStroke.VIRTUAL_KEY_STROKE_EVENT_COMMAND.length);
if (status == 1) {
byte[] keyEvent = {0, 0, 0, 0, (byte) (key.getEventType() & 0xFF), 2, (byte) (keyBytesCode[0] & 0xFF), 0, (byte) (keyBytesCode[1] & 0xFF), 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, 0, (byte) (keyBytesCode[2] & 0xFF), 0};
status = NavNet.write(ch, keyEvent, keyEvent.length);
Thread.sleep(80L);
}
NavNet.disconnect(ch);
}