sfox72 Posted September 4, 2008 Report Posted September 4, 2008 Hi, I'm currently developing with the Java-API and this is working really fine :-) Also i'm using the macro function to connect Goflight-modules with special aircraft functions. Quick question: Could I trigger these macros from the API? I'm currently developing a checklist manager which should do also some automations with lights/TCAS and so on. But not all aircrafts are able to deal with the standart-API. Triggering macros via the API could solve the problem. Regards Stefan
Pete Dowson Posted September 4, 2008 Report Posted September 4, 2008 Quick question: Could I trigger these macros from the API? I'm currently developing a checklist manager which should do also some automations with lights/TCAS and so on. But not all aircrafts are able to deal with the standart-API. Triggering macros via the API could solve the problem. I think this is the same question answered in an earlier thread, here: viewtopic.php?f=54&t=72264 Can you check and see if that helps? Regards Pete
sfox72 Posted September 5, 2008 Author Report Posted September 5, 2008 Hi Pete, this is exact the same I want to do and also I agree that macros could be different on each computer. Currently it's not clear for me how to operate these virtual buttons, but I will try to find out. Thank you for support Stefan
sfox72 Posted September 5, 2008 Author Report Posted September 5, 2008 Hi Pete, have managed the virtual buttons, problem is solved! :-) Regards Stefan
sfox72 Posted September 5, 2008 Author Report Posted September 5, 2008 If somebody would like to trigger the virtual buttons with the Java-API, this works: public void setButton(int joystick, int button) { // joystick 64-72 // button 0-31 byte[] data = new byte[36]; joystick -= 64; int offset = joystick * 4; data[((button) / 8) + offset] = (byte) Math.pow(2, button % 8); fsuipc_wrapper.WriteData(0x3340, 36, data); }
Pete Dowson Posted September 5, 2008 Report Posted September 5, 2008 If somebody would like to trigger the virtual buttons with the Java-API, this works: It would do, but it appears to only switch one button on and all the other 287 off. And if another application is also using virtual buttons you could easily interfere with their operations quite severely, because you are writing all 288 button bits. I don't know Java, but wouldn't something like this be better, just to change the one byte you need to? public void setButton(int joystick, int button) { // joystick 64-72 // button 0-31 byte data = new byte; joystick -= 64; int offset = 0x3340 + (joystick * 4) + (button / 8); fsuipc_wrapper.ReadData(offset, 1, data); data = data | (byte) Math.pow(2, button % 8); // Here I am assuming logical "OR" is '|' as in C -- if not change it // If you have shifts in Java then it would be more efficient to comput the value by "1 << (button%8)" where << is left shift fsuipc_wrapper.WriteData(offset, 1, data); } The clear button routine would be the same except you'd use Logical AND instead of OR, with the logicl NOT of the computed value, and you could have a Toggle gacility by using "Exclusive Or" with the computed value. I'm assuming Java has some Logical facilities in its repetoire, else you'd need to do everything using maths which is pretty horrible. If you know you have exlusive use of a range of 8 buttons then you wouldn't need to read them and manipulate them this way, you could simply set whatever combination you liked the way you are doing it but for 1 byte not 36. Writing all 288 buttons every time is not only uncooperative but it also prevents you using more than one button in your own program, at least without some changes. Regards Pete
sfox72 Posted September 5, 2008 Author Report Posted September 5, 2008 public void setButton(int joystick, int button) { // joystick 64-72 // button 0-31 joystick -= 64; int offset = 0x3340 + (joystick * 4) + (button / 8); byte[] data = new byte[1]; fsuipc_wrapper.ReadData(offset, 1, data); data[0] = (byte) (data[0] | 1 << (button % 8)); fsuipc_wrapper.WriteData(offset, 1, data); } Based on your comments I have rewritten the code and it's working really fine! :-) It was not clear for me that I have no exclusive area to write the buttons. I will keep this in mind. Thank you for support! Stefan
Recommended Posts
Create an account or sign in to comment
You need to be a member in order to leave a comment
Create an account
Sign up for a new account in our community. It's easy!
Register a new accountSign in
Already have an account? Sign in here.
Sign In Now