Merge branch 'torsten/js64'
This commit is contained in:
commit
ed36a06509
2 changed files with 16 additions and 17 deletions
|
@ -27,6 +27,7 @@
|
||||||
|
|
||||||
#include <simgear/debug/logstream.hxx>
|
#include <simgear/debug/logstream.hxx>
|
||||||
#include <simgear/io/iochannel.hxx>
|
#include <simgear/io/iochannel.hxx>
|
||||||
|
#include <simgear/misc/stdint.hxx>
|
||||||
|
|
||||||
#include <Aircraft/aircraft.hxx>
|
#include <Aircraft/aircraft.hxx>
|
||||||
#include <Main/fg_props.hxx>
|
#include <Main/fg_props.hxx>
|
||||||
|
@ -91,8 +92,7 @@ bool FGJsClient::process() {
|
||||||
if ( io->get_type() == sgFileType ) {
|
if ( io->get_type() == sgFileType ) {
|
||||||
if ( io->read( (char *)(& buf), length ) == length ) {
|
if ( io->read( (char *)(& buf), length ) == length ) {
|
||||||
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
||||||
long int *msg;
|
int32_t *msg = (int32_t *)buf;
|
||||||
msg = (long int *)buf;
|
|
||||||
for( int i = 0; i < 4; ++i )
|
for( int i = 0; i < 4; ++i )
|
||||||
{
|
{
|
||||||
axis[i] = ((double)msg[i] / 2147483647.0);
|
axis[i] = ((double)msg[i] / 2147483647.0);
|
||||||
|
@ -105,8 +105,7 @@ bool FGJsClient::process() {
|
||||||
} else {
|
} else {
|
||||||
while ( io->read( (char *)(& buf), length ) == length ) {
|
while ( io->read( (char *)(& buf), length ) == length ) {
|
||||||
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
SG_LOG( SG_IO, SG_DEBUG, "Success reading data." );
|
||||||
long int *msg;
|
int32_t *msg = (int32_t *)buf;
|
||||||
msg = (long int *)buf;
|
|
||||||
SG_LOG( SG_IO, SG_DEBUG, "ax0 = " << msg[0] << " ax1 = "
|
SG_LOG( SG_IO, SG_DEBUG, "ax0 = " << msg[0] << " ax1 = "
|
||||||
<< msg[1] << "ax2 = " << msg[2] << "ax3 = " << msg[3]);
|
<< msg[1] << "ax2 = " << msg[2] << "ax3 = " << msg[3]);
|
||||||
for( int i = 0; i < 4; ++i )
|
for( int i = 0; i < 4; ++i )
|
||||||
|
|
|
@ -67,7 +67,7 @@ int main ( int argc, char ** argv )
|
||||||
ax = new float [ numaxes ] ;
|
ax = new float [ numaxes ] ;
|
||||||
activeaxes = numaxes;
|
activeaxes = numaxes;
|
||||||
|
|
||||||
if( numaxes < 4 )
|
if( numaxes > 4 )
|
||||||
{
|
{
|
||||||
printf("max 4 axes joysticks supported at the moment, however %i axes were detected\nWill only use the first 4 axes!\n", numaxes);
|
printf("max 4 axes joysticks supported at the moment, however %i axes were detected\nWill only use the first 4 axes!\n", numaxes);
|
||||||
activeaxes = 4;
|
activeaxes = 4;
|
||||||
|
@ -101,25 +101,25 @@ int main ( int argc, char ** argv )
|
||||||
js->read( &b, ax );
|
js->read( &b, ax );
|
||||||
for ( axis = 0 ; axis < activeaxes ; axis++ )
|
for ( axis = 0 ; axis < activeaxes ; axis++ )
|
||||||
{
|
{
|
||||||
long axisvalue = (long int)(ax[axis]*2147483647.0);
|
int32_t axisvalue = (int32_t)(ax[axis]*2147483647.0);
|
||||||
printf("axisval=%li\n", axisvalue);
|
printf("axisval=%li\n", (long)axisvalue);
|
||||||
memcpy(packet+len, &axisvalue, 4);
|
memcpy(packet+len, &axisvalue, sizeof(axisvalue));
|
||||||
len+=4;
|
len+=sizeof(axisvalue);
|
||||||
}
|
}
|
||||||
// fill emtpy values into packes when less than 4 axes
|
// fill emtpy values into packes when less than 4 axes
|
||||||
for( ; axis < 4; axis++ )
|
for( ; axis < 4; axis++ )
|
||||||
{
|
{
|
||||||
long axisvalue = 0;
|
int32_t axisvalue = 0;
|
||||||
memcpy(packet+len, &axisvalue, 4);
|
memcpy(packet+len, &axisvalue, sizeof(axisvalue));
|
||||||
len+=4;
|
len+=sizeof(axisvalue);
|
||||||
}
|
}
|
||||||
|
|
||||||
long int b_l = b;
|
int32_t b_l = b;
|
||||||
memcpy(packet+len, &b_l, 4);
|
memcpy(packet+len, &b_l, sizeof(b_l));
|
||||||
len+=4;
|
len+=sizeof(b_l);
|
||||||
|
|
||||||
char termstr[5] = "\0\0\r\n";
|
const char * termstr = "\0\0\r\n";
|
||||||
memcpy(packet+len, &termstr, 4);
|
memcpy(packet+len, termstr, 4);
|
||||||
len += 4;
|
len += 4;
|
||||||
|
|
||||||
c.send( packet, len, 0 );
|
c.send( packet, len, 0 );
|
||||||
|
|
Loading…
Reference in a new issue