# vrpn_Android_Server

This is an Android server implementation. It has as members a `vrpn_Button_Server` and some number of `vrpn_Analog_Servers`, as determined by the Java side. This implementation also has `vrpn_Button_Remote` and `vrpn_Analog_Remote` clients for the sole purpose of testing. All data from the Android is represented here as either Analogs or Buttons.

All interaction between this class and the Java side are handled by the jni layer.

It's worth noting that it is possible to pipe stdout to the Android log - directions for doing so are in the manual for this project - and all output is in the form of: `fprintf(stderr, "...")`, which we've found to be more reliable than other methods, including `fprintf(stdout, "...")`.

## class vrpn_Android_Server:

### public members:

- `vrpn_Android_Server(vrpn_int32 num_analogs, vrpn_int32 * analog_sizes, vrpn_int32 num_buttons, vrpn_int32 port);`
  Constructor. Takes an array of integers representing the number of channels for each analog server, the number of buttons, and the port number.
- `~vrpn_Android_Server();`
  Destructor.
- `void mainloop();`
  Main loop to be called at every time step. Calls the `mainloop()` functions of the member servers.
- `void set_analog(vrpn_int32 analog_id, vrpn_int32 channel, vrpn_float64 val);`
  Set the value for the given channel of the given vrpn_Analog_Server
- `void set_button(vrpn_int32 button_id, vrpn_int32 state);`
  Set the value for the given button
- `void report_analog_chg(vrpn_int32 analog_id);`
  Called when changes are made to any of the analog values

### private members:

- `void initialize(vrpn_int32 num_analogs, vrpn_int32 * analog_sizes, vrpn_int32 num_buttons);`
  Sets up the member servers
- `const char * ANALOG_SERVER_NAME;`
- `const char * BUTTON_SERVER_NAME;`
  Names of the member servers. Only used by the local clients
- `vrpn_int32 num_analogs;`
  Number of vrpn_Analog_Servers
- `vrpn_int32 * analog_sizes;`
  Array of numbers of channels in the analog servers
- `vrpn_Analog_Server ** analog_server;`
  Handles multi-touch x and y as well as any sliders, dials, etc
- `vrpn_Button_Server * button_server;`
  Handles all button press data
- `vrpn_Analog_Remote ** analog_client;`
- `vrpn_Button_Remote * button_client;`
  Local test clients, used for testing only.
- `vrpn_Connection * connection;`
  The connection over which data from the phone is sent
- `vrpn_int32 port;`
  The port over which the `vrpn_Connection` communicates