view test/testendian.c @ 872:e7be95d758e8

Date: Fri, 05 Mar 2004 16:08:01 +0000 From: Alan Swanson Subject: Re: [SDL] Fatal signal when initiaize with USB joystick on 2.6.2 kern On Fri, 2004-03-05 at 15:09, Sam Lantinga wrote: > > Fred, how does the attached patch work for you? Do all your axes work? > > I think you meant the two lines to be reversed. > I checked a more robust version of this into CVS. Fred, can you see if > it works? You've misread the code. :-/ For coef[0] and coef[1], it is (values[2]+values[1]) / 2 and then add or subtract values[4] to the answer.
author Sam Lantinga <slouken@libsdl.org>
date Sat, 06 Mar 2004 02:58:06 +0000
parents c203b4a42701
children 983df4f9c1c6
line wrap: on
line source


/* Test program to check SDL's CPU endian detection and byte swapping routines */

#include <stdio.h>

#include "SDL.h"
#include "SDL_endian.h"

int main(int argc, char *argv[])
{
	Uint16 value16 = 0xCDAB;
	Uint32 value32 = 0xEFBEADDE;
#if defined(__GNUC__) && defined(SDL_HAS_64BIT_TYPE)
	Uint64 value64 = 0xEFBEADDECDAB3412LL;
#endif

	printf("This is a %s endian machine.\n",
		(SDL_BYTEORDER == SDL_LIL_ENDIAN) ? "little" : "big");
	printf("Value 16 = 0x%X, swapped = 0x%X\n", value16, SDL_Swap16(value16));
	printf("Value 32 = 0x%X, swapped = 0x%X\n", value32, SDL_Swap32(value32));
#if defined(__GNUC__) && defined(SDL_HAS_64BIT_TYPE)
	printf("Value 64 = 0x%llX, swapped = 0x%llX\n", value64, SDL_Swap64(value64));
#endif
	return(0);
}