From f3677a4ddfb8cd87f693c8bd9da1de329e70b534 Mon Sep 17 00:00:00 2001 From: torsten Date: Wed, 10 Mar 2010 08:29:08 +0000 Subject: [PATCH 1/4] David Fries: Fixes for 64bit systems --- utils/js_server/js_server.cxx | 16 ++++++++-------- 1 file changed, 8 insertions(+), 8 deletions(-) diff --git a/utils/js_server/js_server.cxx b/utils/js_server/js_server.cxx index 620b4b57e..64a3422ba 100644 --- a/utils/js_server/js_server.cxx +++ b/utils/js_server/js_server.cxx @@ -67,7 +67,7 @@ int main ( int argc, char ** argv ) ax = new float [ 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); activeaxes = 4; @@ -101,17 +101,17 @@ int main ( int argc, char ** argv ) js->read( &b, ax ); for ( axis = 0 ; axis < activeaxes ; axis++ ) { - long axisvalue = (long int)(ax[axis]*2147483647.0); - printf("axisval=%li\n", axisvalue); - memcpy(packet+len, &axisvalue, 4); - len+=4; + int32_t axisvalue = (int32_t)(ax[axis]*2147483647.0); + printf("axisval=%li\n", (long)axisvalue); + memcpy(packet+len, &axisvalue, sizeof(axisvalue)); + len+=sizeof(axisvalue); } // fill emtpy values into packes when less than 4 axes for( ; axis < 4; axis++ ) { - long axisvalue = 0; - memcpy(packet+len, &axisvalue, 4); - len+=4; + int32_t axisvalue = 0; + memcpy(packet+len, &axisvalue, sizeof(axisvalue)); + len+=sizeof(axisvalue); } long int b_l = b; From 91f0059c89c92ce18caec3d173ec07fd402bdc3f Mon Sep 17 00:00:00 2001 From: torsten Date: Wed, 10 Mar 2010 08:33:10 +0000 Subject: [PATCH 2/4] David Fries: 64bit fixes --- src/Network/jsclient.cxx | 6 ++---- 1 file changed, 2 insertions(+), 4 deletions(-) diff --git a/src/Network/jsclient.cxx b/src/Network/jsclient.cxx index 1fff200ad..c94aeb66b 100644 --- a/src/Network/jsclient.cxx +++ b/src/Network/jsclient.cxx @@ -91,8 +91,7 @@ bool FGJsClient::process() { if ( io->get_type() == sgFileType ) { if ( io->read( (char *)(& buf), length ) == length ) { SG_LOG( SG_IO, SG_DEBUG, "Success reading data." ); - long int *msg; - msg = (long int *)buf; + int32_t *msg = (int32_t *)buf; for( int i = 0; i < 4; ++i ) { axis[i] = ((double)msg[i] / 2147483647.0); @@ -105,8 +104,7 @@ bool FGJsClient::process() { } else { while ( io->read( (char *)(& buf), length ) == length ) { SG_LOG( SG_IO, SG_DEBUG, "Success reading data." ); - long int *msg; - msg = (long int *)buf; + int32_t *msg = (int32_t *)buf; SG_LOG( SG_IO, SG_DEBUG, "ax0 = " << msg[0] << " ax1 = " << msg[1] << "ax2 = " << msg[2] << "ax3 = " << msg[3]); for( int i = 0; i < 4; ++i ) From 0288a8af4c4ccb56d703af4beb76577c88cd8650 Mon Sep 17 00:00:00 2001 From: torsten Date: Wed, 10 Mar 2010 08:42:34 +0000 Subject: [PATCH 3/4] Just another 64bit fix --- utils/js_server/js_server.cxx | 10 +++++----- 1 file changed, 5 insertions(+), 5 deletions(-) diff --git a/utils/js_server/js_server.cxx b/utils/js_server/js_server.cxx index 64a3422ba..4da358ce7 100644 --- a/utils/js_server/js_server.cxx +++ b/utils/js_server/js_server.cxx @@ -114,12 +114,12 @@ int main ( int argc, char ** argv ) len+=sizeof(axisvalue); } - long int b_l = b; - memcpy(packet+len, &b_l, 4); - len+=4; + int32_t b_l = b; + memcpy(packet+len, &b_l, sizeof(b_l)); + len+=sizeof(b_l); - char termstr[5] = "\0\0\r\n"; - memcpy(packet+len, &termstr, 4); + const char * termstr = "\0\0\r\n"; + memcpy(packet+len, termstr, 4); len += 4; c.send( packet, len, 0 ); From 32f8d1a11073bf9f6a279ceb50791029e3e96a7a Mon Sep 17 00:00:00 2001 From: torsten Date: Fri, 12 Mar 2010 17:30:19 +0000 Subject: [PATCH 4/4] Compile again for MSVC --- src/Network/jsclient.cxx | 1 + 1 file changed, 1 insertion(+) diff --git a/src/Network/jsclient.cxx b/src/Network/jsclient.cxx index c94aeb66b..33c80d24b 100644 --- a/src/Network/jsclient.cxx +++ b/src/Network/jsclient.cxx @@ -27,6 +27,7 @@ #include #include +#include #include #include