Commit ad52253b authored by Bernhard Link's avatar Bernhard Link

add ft_FIXED3232

parent 09631d4e
......@@ -2,6 +2,7 @@
* Add support for Generic Events (XGE)
* Fix bug in error reporting when multiple STRUCTs have the same name
* add --print-counts --print-offsets
* add FIXED3232 (fixed point with 32 bits before and 32 after the dot)
2010-03-30
* Add support for XInputExtension 1.5, and partial support for
XInputExtension 2.0
......
......@@ -366,6 +366,41 @@ static size_t printLISTofFIXED(struct connection *c,const uint8_t *buffer,size_t
return ofs;
}
static size_t printLISTofFIXED3232(struct connection *c, const uint8_t *buffer, size_t buflen, const struct parameter *p, size_t len, size_t ofs){
bool notfirst = false;
size_t nr = 0;
if( buflen < ofs )
return ofs;
if( (buflen - ofs)/8 <= len )
len = (buflen - ofs)/8;
if( print_offsets )
fprintf(out,"[%d]", (int)ofs);
fprintf(out, "%s=", p->name);
while( len > 0 ) {
int32_t i32;
uint32_t u32;
double d;
if( nr == maxshownlistlen ) {
fputs(",...", out);
} else if( nr < maxshownlistlen ) {
if( notfirst )
putc(',', out);
notfirst = true;
i32 = getCARD32(ofs);
u32 = getCARD32(ofs + 4);
d = i32 + (u32 / ((double)65536.0 * (double)65536.0)) ;
fprintf(out, "%.11f", d);
}
len--; ofs += 8; nr++;
}
putc(';', out);
return ofs;
}
static size_t printLISTofFLOAT32(struct connection *c, const uint8_t *buffer, size_t buflen, const struct parameter *p, size_t len, size_t ofs){
bool notfirst = false;
size_t nr = 0;
......@@ -1036,6 +1071,21 @@ static size_t print_parameters(struct connection *c,const unsigned char *buffer,
case ft_LISTofFIXED:
lastofs = printLISTofFIXED(c,buffer,len,p,stored,ofs);
continue;
case ft_FIXED3232:
if( ofs + 8 > len )
continue;
if( print_offsets )
fprintf(out, "[%d]", (int)ofs);
fputs(p->name, out); putc('=', out);
i32 = getCARD32(ofs);
u32 = getCARD32(ofs + 4);
d = i32 + (u32 / ((double)65536.0 * (double)65536.0));
fprintf(out, "%.11f", d);
continue;
case ft_LISTofFIXED3232:
lastofs = printLISTofFIXED3232(c, buffer, len, p,
stored, ofs);
continue;
case ft_FLOAT32:
if( ofs + 4 > len )
continue;
......@@ -1249,6 +1299,8 @@ static size_t print_parameters(struct connection *c,const unsigned char *buffer,
case ft_FRACTION32_32:
case ft_FIXED:
case ft_LISTofFIXED:
case ft_FIXED3232:
case ft_LISTofFIXED3232:
case ft_FLOAT32:
case ft_LISTofFLOAT32:
assert(0);
......
......@@ -106,6 +106,10 @@ struct parameter {
ft_FIXED,
/* a list of those */
ft_LISTofFIXED,
/* a fixed-point number 32+32 bit */
ft_FIXED3232,
/* a list of those */
ft_LISTofFIXED3232,
/* a 32 bit floating pointer number */
ft_FLOAT32,
/* a list of those */
......
......@@ -94,7 +94,11 @@ static const struct base_type {
{ "FRACTION16_16", ft_FRACTION16_16, 0, 4},
{ "FRACTION32_32", ft_FRACTION32_32, 0, 8},
{ "FIXED", ft_FIXED, 0, 4},
{ "FIXED1616", ft_FIXED, 0, 4},
{ "FIXED3232", ft_FIXED3232, 0, 8},
{ "LISTofFIXED", ft_LISTofFIXED, USES_STORE|SETS_NEXT, 0},
{ "LISTofFIXED1616", ft_LISTofFIXED, USES_STORE|SETS_NEXT, 0},
{ "LISTofFIXED3232", ft_LISTofFIXED3232, USES_STORE|SETS_NEXT, 0},
{ "FLOAT32", ft_FLOAT32, 0, 4},
{ "LISTofFLOAT32", ft_LISTofFLOAT32, USES_STORE|SETS_NEXT, 0},
{ "PUSH8", ft_PUSH8, PUSHES, 1},
......
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment