[linuxconsoletools] Merging the 64bit patch from ff-utils

Jaromír Cápík jcapik at fedoraproject.org
Wed Feb 6 16:50:59 UTC 2013


commit 549c6018d44bbdd5ed2d5f369208646509e17eb0
Author: Jaromir Capik <jcapik at redhat.com>
Date:   Wed Feb 6 17:50:50 2013 +0100

    Merging the 64bit patch from ff-utils

 linuxconsoletools-64bitPort-ffutils.patch |  636 +++++++++++++++++++++++++++++
 linuxconsoletools.spec                    |   11 +-
 2 files changed, 646 insertions(+), 1 deletions(-)
---
diff --git a/linuxconsoletools-64bitPort-ffutils.patch b/linuxconsoletools-64bitPort-ffutils.patch
new file mode 100644
index 0000000..0cc637a
--- /dev/null
+++ b/linuxconsoletools-64bitPort-ffutils.patch
@@ -0,0 +1,636 @@
+diff -Naur linuxconsoletools-1.4.4.orig/utils/bitmaskros.h linuxconsoletools-1.4.4/utils/bitmaskros.h
+--- linuxconsoletools-1.4.4.orig/utils/bitmaskros.h	1970-01-01 01:00:00.000000000 +0100
++++ linuxconsoletools-1.4.4/utils/bitmaskros.h	2013-02-06 16:37:24.609765086 +0100
+@@ -0,0 +1,40 @@
++/*
++ * bitmaskros.h
++ *
++ * Helper macros for large bit masks management
++ *
++ * Copyright (C) 2008 Jean-Philippe Meuret
++ *
++ * This program is free software; you can redistribute it and/or modify
++ * it under the terms of the GNU General Public License as published by
++ * the Free Software Foundation; either version 2 of the License, or
++ * (at your option) any later version.
++ *
++ * This program is distributed in the hope that it will be useful,
++ * but WITHOUT ANY WARRANTY; without even the implied warranty of
++ * MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE.  See the
++ * GNU General Public License for more details.
++ *
++ * You should have received a copy of the GNU General Public License
++ * along with this program; if not, write to the Free Software
++ * Foundation, Inc., 59 Temple Place, Suite 330, Boston, MA  02111-1307  USA
++ */
++
++/* Number of bits for 1 unsigned char */
++#define nBitsPerUchar          (sizeof(unsigned char) * 8)
++
++/* Number of unsigned chars to contain a given number of bits */
++#define nUcharsForNBits(nBits) ((((nBits)-1)/nBitsPerUchar)+1)
++
++/* Index=Offset of given bit in 1 unsigned char */
++#define bitOffsetInUchar(bit)  ((bit)%nBitsPerUchar)
++
++/* Index=Offset of the unsigned char associated to the bit
++   at the given index=offset */
++#define ucharIndexForBit(bit)  ((bit)/nBitsPerUchar)
++
++/* Value of an unsigned char with bit set at given index=offset */
++#define ucharValueForBit(bit)  (((unsigned char)(1))<<bitOffsetInUchar(bit))
++
++/* Test the bit with given index=offset in an unsigned char array */
++#define testBit(bit, array)    ((array[ucharIndexForBit(bit)] >> bitOffsetInUchar(bit)) & 1)
+diff -Naur linuxconsoletools-1.4.4.orig/utils/ffcfstress.c linuxconsoletools-1.4.4/utils/ffcfstress.c
+--- linuxconsoletools-1.4.4.orig/utils/ffcfstress.c	2011-12-15 16:49:01.000000000 +0100
++++ linuxconsoletools-1.4.4/utils/ffcfstress.c	2013-02-06 17:38:47.661870645 +0100
+@@ -31,9 +31,7 @@
+ #include <errno.h>
+ #include <math.h>
+ 
+-
+-/* Helper for testing large bit masks */
+-#define TEST_BIT(bit,bits) (((bits[bit>>5]>>(bit&0x1f))&1)!=0)
++#include "bitmaskros.h"
+ 
+ 
+ /* Default values for the options */
+@@ -42,7 +40,11 @@
+ #define DEFAULT_MOTION_FREQUENCY  0.1
+ #define DEFAULT_MOTION_AMPLITUDE  1.0
+ #define DEFAULT_SPRING_STRENGTH   1.0
++#define DEFAULT_AXIS_INDEX          0
++#define DEFAULT_AXIS_CODE       ABS_X
+ 
++static const char* axis_names[] = { "X", "Y", "Z", "RX", "RY", "RZ", "WHEEL" };
++static const int axis_codes[] = { ABS_X, ABS_Y, ABS_Z, ABS_RX, ABS_RY, ABS_RZ, ABS_WHEEL };
+ 
+ /* Options */
+ const char * device_name = DEFAULT_DEVICE_NAME;
+@@ -50,12 +52,15 @@
+ double motion_frequency  = DEFAULT_MOTION_FREQUENCY;
+ double motion_amplitude  = DEFAULT_MOTION_AMPLITUDE;
+ double spring_strength   = DEFAULT_SPRING_STRENGTH;
++int    axis_index        = DEFAULT_AXIS_INDEX;
++int    axis_code         = DEFAULT_AXIS_CODE;
+ int stop_and_play = 0;  /* Stop-upload-play effects instead of updating */
++int autocenter_off = 0; /* switch the autocentering off */
+ 
+ 
+ /* Global variables about the initialized device */
+ int device_handle;
+-int axis_code, axis_min, axis_max;
++int axis_min, axis_max;
+ struct ff_effect effect;
+ 
+ 
+@@ -64,45 +69,69 @@
+ {
+ 	int i;
+ 
+-	if (argc<2) goto l_help;
++	int help = (argc < 2);
+ 
+-	for (i=1; i<argc; i++) {
+-		if      (!strcmp(argv[i],"-d") && i<argc-1) device_name     =argv[++i];
+-		else if (!strcmp(argv[i],"-u") && i<argc-1) update_rate     =atof(argv[++i]);
+-		else if (!strcmp(argv[i],"-f") && i<argc-1) motion_frequency=atof(argv[++i]);
+-		else if (!strcmp(argv[i],"-a") && i<argc-1) motion_amplitude=atof(argv[++i]);
+-		else if (!strcmp(argv[i],"-s") && i<argc-1) spring_strength =atof(argv[++i]);
+-		else if (!strcmp(argv[i],"-o")) ;
+-		else goto l_help;
+-	}
+-	return;
+-
+-l_help:
+-	printf("-------- ffcfstress - Force Feedback: Constant Force Stress Test --------\n");
+-	printf("Description:\n");
+-	printf("  This program is for stress testing constant non-enveloped forces on\n");
+-	printf("  a force feedback device via the event interface. It simulates a\n");
+-	printf("  moving spring force by a frequently updated constant force effect.\n");
+-	printf("  BE CAREFUL IN USAGE, YOUR DEVICE MAY GET DAMAGED BY THE STRESS TEST!\n");
+-	printf("Usage:\n");
+-	printf("  %s <option> [<option>...]\n",argv[0]);
+-	printf("Options:\n");
+-	printf("  -d <string>  device name (default: %s)\n",DEFAULT_DEVICE_NAME);
+-	printf("  -u <double>  update rate in Hz (default: %.2f)\n",DEFAULT_UPDATE_RATE);
+-	printf("  -f <double>  spring center motion frequency in Hz (default: %.2f)\n",DEFAULT_MOTION_FREQUENCY);
+-	printf("  -a <double>  spring center motion amplitude 0.0..1.0 (default: %.2f)\n",DEFAULT_MOTION_AMPLITUDE);
+-	printf("  -s <double>  spring strength factor (default: %.2f)\n",DEFAULT_SPRING_STRENGTH);
+-	printf("  -o           dummy option (useful because at least one option is needed)\n");
+-	exit(1);
++	for (i=1; i<argc && !help; i++) {
++	        if (!strcmp(argv[i],"-d")) {
++		        if (i<argc-1) device_name = argv[++i]; else help = 1;
++		} else if (!strcmp(argv[i],"-u")) {
++		        if (i<argc-1) update_rate = atof(argv[++i]); else help = 1;
++		} else if (!strcmp(argv[i],"-f")) {
++		        if (i<argc-1) motion_frequency=atof(argv[++i]); else help = 1;
++		} else if (!strcmp(argv[i],"-a")) {
++		        if (i<argc-1) motion_amplitude=atof(argv[++i]); else help = 1;
++		} else if (!strcmp(argv[i],"-s")) {
++		        if (i<argc-1) spring_strength =atof(argv[++i]); else help = 1;
++		} else if (!strcmp(argv[i],"-x")) {
++		        if (i<argc-1) { 
++			        axis_index = atoi(argv[++i]); 
++				if (axis_index < 0 || axis_index >= sizeof(axis_names)/sizeof(char*))
++				    help = 1;
++				else
++				    axis_code = axis_codes[axis_index];
++			} else help = 1;
++		} else if (!strcmp(argv[i],"-o")) {
++			;
++		} else if (!strcmp(argv[i],"-A")) {
++			autocenter_off = 1;
++		} else help = 1;
++	}
++ 
++
++	if (help) {
++		printf("-------- ffcfstress - Force Feedback: Constant Force Stress Test --------\n");
++		printf("Description:\n");
++		printf("  This program is for stress testing constant non-enveloped forces on\n");
++		printf("  a force feedback device via the event interface. It simulates a\n");
++		printf("  moving spring force by a frequently updated constant force effect.\n");
++		printf("  BE CAREFUL IN USAGE, YOUR DEVICE MAY GET DAMAGED BY THE STRESS TEST!\n");
++		printf("Usage:\n");
++		printf("  %s <option> [<option>...]\n",argv[0]);
++		printf("Options:\n");
++		printf("  -d <string>  device name (default: %s)\n",DEFAULT_DEVICE_NAME);
++		printf("  -u <double>  update rate in Hz (default: %.2f)\n",DEFAULT_UPDATE_RATE);
++		printf("  -f <double>  spring center motion frequency in Hz (default: %.2f)\n",DEFAULT_MOTION_FREQUENCY);
++		printf("  -a <double>  spring center motion amplitude 0.0..1.0 (default: %.2f)\n",DEFAULT_MOTION_AMPLITUDE);
++		printf("  -s <double>  spring strength factor (default: %.2f)\n",DEFAULT_SPRING_STRENGTH);
++		printf("  -x <int>     absolute axis to test (default: %d=%s)\n",DEFAULT_AXIS_INDEX, axis_names[DEFAULT_AXIS_INDEX]);
++		printf("               (0 = X, 1 = Y, 2 = Z, 3 = RX, 4 = RY, 5 = RZ, 6 = WHEEL)\n");
++		printf("  -A           switch off auto-centering\n");
++		printf("  -o           dummy option (useful because at least one option is needed)\n");
++		exit(1);
++	}
+ }
+ 
+ 
++
+ /* Initialize device, create constant force effect */
+ void init_device()
+ {
+-	unsigned long key_bits[32],abs_bits[32],ff_bits[32];
++	unsigned char key_bits[1 + KEY_MAX/8/sizeof(unsigned char)];
++	unsigned char abs_bits[1 + ABS_MAX/8/sizeof(unsigned char)];
++	unsigned char ff_bits[1 + FF_MAX/8/sizeof(unsigned char)];
++
+ 	struct input_event event;
+-	int valbuf[16];
++	struct input_absinfo absinfo;
+ 
+ 	/* Open event device with write permission */
+ 	device_handle = open(device_name,O_RDWR|O_NONBLOCK);
+@@ -113,47 +142,44 @@
+ 	}
+ 
+ 	/* Which buttons has the device? */
+-	memset(key_bits,0,32*sizeof(unsigned long));
+-	if (ioctl(device_handle,EVIOCGBIT(EV_KEY,32*sizeof(unsigned long)),key_bits)<0) {
++	memset(key_bits,0,sizeof(key_bits));
++	if (ioctl(device_handle,EVIOCGBIT(EV_KEY,sizeof(key_bits)),key_bits)<0) {
+ 		fprintf(stderr,"ERROR: can not get key bits (%s) [%s:%d]\n",
+ 		        strerror(errno),__FILE__,__LINE__);
+ 		exit(1);
+ 	}
+ 
+ 	/* Which axes has the device? */
+-	memset(abs_bits,0,32*sizeof(unsigned long));
+-	if (ioctl(device_handle,EVIOCGBIT(EV_ABS,32*sizeof(unsigned long)),abs_bits)<0) {
++	memset(abs_bits,0,sizeof(abs_bits));
++	if (ioctl(device_handle,EVIOCGBIT(EV_ABS,sizeof(abs_bits)),abs_bits)<0) {
+ 		fprintf(stderr,"ERROR: can not get abs bits (%s) [%s:%d]\n",
+ 		        strerror(errno),__FILE__,__LINE__);
+ 		exit(1);
+ 	}
+ 
+ 	/* Now get some information about force feedback */
+-	memset(ff_bits,0,32*sizeof(unsigned long));
+-	if (ioctl(device_handle,EVIOCGBIT(EV_FF ,32*sizeof(unsigned long)),ff_bits)<0) {
++	memset(ff_bits,0,sizeof(ff_bits));
++	if (ioctl(device_handle,EVIOCGBIT(EV_FF ,sizeof(ff_bits)),ff_bits)<0) {
+ 		fprintf(stderr,"ERROR: can not get ff bits (%s) [%s:%d]\n",
+ 		        strerror(errno),__FILE__,__LINE__);
+ 		exit(1);
+ 	}
+ 
+-	/* Which axis is the x-axis? */
+-	if      (TEST_BIT(ABS_X    ,abs_bits)) axis_code=ABS_X;
+-	else if (TEST_BIT(ABS_RX   ,abs_bits)) axis_code=ABS_RX;
+-	else if (TEST_BIT(ABS_WHEEL,abs_bits)) axis_code=ABS_WHEEL;
+-	else {
+-		fprintf(stderr,"ERROR: no suitable x-axis found [%s:%d]\n",
+-		        __FILE__,__LINE__);
++	/* Check if selected axis is available */
++	if (!testBit(axis_code, abs_bits)) {
++		fprintf(stderr,"ERROR: selected axis %s not available [%s:%d] (see available ones with fftest)\n",
++		        axis_names[axis_index], __FILE__,__LINE__);
+ 		exit(1);
+ 	}
+ 
+ 	/* get axis value range */
+-	if (ioctl(device_handle,EVIOCGABS(axis_code),valbuf)<0) {
++	if (ioctl(device_handle,EVIOCGABS(axis_code),&absinfo)<0) {
+ 		fprintf(stderr,"ERROR: can not get axis value range (%s) [%s:%d]\n",
+ 		        strerror(errno),__FILE__,__LINE__);
+ 		exit(1);
+ 	}
+-	axis_min=valbuf[1];
+-	axis_max=valbuf[2];
++	axis_min=absinfo.minimum;
++	axis_max=absinfo.maximum;
+ 	if (axis_min>=axis_max) {
+ 		fprintf(stderr,"ERROR: bad axis value range (%d,%d) [%s:%d]\n",
+ 		        axis_min,axis_max,__FILE__,__LINE__);
+@@ -161,21 +187,23 @@
+ 	}
+ 
+ 	/* force feedback supported? */
+-	if (!TEST_BIT(FF_CONSTANT,ff_bits)) {
+-		fprintf(stderr,"ERROR: device (or driver) has no force feedback support [%s:%d]\n",
++	if (!testBit(FF_CONSTANT,ff_bits)) {
++		fprintf(stderr,"ERROR: device (or driver) has no constant force feedback support [%s:%d]\n",
+ 		        __FILE__,__LINE__);
+ 		exit(1);
+ 	}
+ 
+ 	/* Switch off auto centering */
+-	memset(&event,0,sizeof(event));
+-	event.type=EV_FF;
+-	event.code=FF_AUTOCENTER;
+-	event.value=0;
+-	if (write(device_handle,&event,sizeof(event))!=sizeof(event)) {
+-		fprintf(stderr,"ERROR: failed to disable auto centering (%s) [%s:%d]\n",
+-		        strerror(errno),__FILE__,__LINE__);
+-		exit(1);
++	if (autocenter_off) {
++		memset(&event,0,sizeof(event));
++		event.type=EV_FF;
++		event.code=FF_AUTOCENTER;
++		event.value=0;
++		if (write(device_handle,&event,sizeof(event))!=sizeof(event)) {
++			fprintf(stderr,"ERROR: failed to disable auto centering (%s) [%s:%d]\n",
++				strerror(errno),__FILE__,__LINE__);
++			exit(1);
++		}
+ 	}
+ 
+ 	/* Initialize constant force effect */
+@@ -230,8 +258,8 @@
+ 
+ 	/* Set force */
+ 	if (force>1.0) force=1.0;
+-	if (force<-1.0) force=1.0;
+-	effect.u.constant.level=(short)(force*32767.0); /* only to be safe */
++	else if (force<-1.0) force=-1.0;
++	effect.u.constant.level=(short)(force*32767.0);
+ 	effect.direction=0xC000;
+ 	effect.u.constant.envelope.attack_level=(short)(force*32767.0); /* this one counts! */
+ 	effect.u.constant.envelope.fade_level=(short)(force*32767.0); /* only to be safe */
+diff -Naur linuxconsoletools-1.4.4.orig/utils/fftest.c linuxconsoletools-1.4.4/utils/fftest.c
+--- linuxconsoletools-1.4.4.orig/utils/fftest.c	2012-09-06 07:11:53.000000000 +0200
++++ linuxconsoletools-1.4.4/utils/fftest.c	2013-02-06 17:26:05.309156128 +0100
+@@ -35,11 +35,8 @@
+ #include <sys/ioctl.h>
+ #include <linux/input.h>
+ 
+-#define BITS_PER_LONG (sizeof(long) * 8)
+-#define OFF(x)  ((x)%BITS_PER_LONG)
+-#define BIT(x)  (1UL<<OFF(x))
+-#define LONG(x) ((x)/BITS_PER_LONG)
+-#define test_bit(bit, array)    ((array[LONG(bit)] >> OFF(bit)) & 1)
++#include "bitmaskros.h"
++
+ 
+ #define N_EFFECTS 6
+ 
+@@ -55,10 +52,12 @@
+ int main(int argc, char** argv)
+ {
+ 	struct ff_effect effects[N_EFFECTS];
+-	struct input_event play, stop;
++	struct input_event play, stop, gain;
+ 	int fd;
+ 	char device_file_name[64];
+-	unsigned long features[4];
++	unsigned char relFeatures[1 + REL_MAX/8/sizeof(unsigned char)];
++	unsigned char absFeatures[1 + ABS_MAX/8/sizeof(unsigned char)];
++	unsigned char ffFeatures[1 + FF_MAX/8/sizeof(unsigned char)];
+ 	int n_effects;	/* Number of effects the device can play at the same time */
+ 	int i;
+ 
+@@ -87,53 +86,157 @@
+ 	printf("Device %s opened\n", device_file_name);
+ 
+ 	/* Query device */
+-	if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(unsigned long) * 4), features) < 0) {
+-		perror("Ioctl query");
++	printf("Features:\n");
++
++	/* Absolute axes */
++	memset(absFeatures, 0, sizeof(absFeatures)*sizeof(unsigned char));
++	if (ioctl(fd, EVIOCGBIT(EV_ABS, sizeof(absFeatures)*sizeof(unsigned char)), absFeatures) == -1) {
++		perror("Ioctl absolute axes features query");
++		exit(1);
++	}
++
++	printf("  * Absolute axes: ");
++
++	if (testBit(ABS_X, absFeatures)) printf("X, ");
++	if (testBit(ABS_Y, absFeatures)) printf("Y, ");
++	if (testBit(ABS_Z, absFeatures)) printf("Z, ");
++	if (testBit(ABS_RX, absFeatures)) printf("RX, ");
++	if (testBit(ABS_RY, absFeatures)) printf("RY, ");
++	if (testBit(ABS_RZ, absFeatures)) printf("RZ, ");
++	if (testBit(ABS_THROTTLE, absFeatures)) printf("Throttle, ");
++	if (testBit(ABS_RUDDER, absFeatures)) printf("Rudder, ");
++	if (testBit(ABS_WHEEL, absFeatures)) printf("Wheel, ");
++	if (testBit(ABS_GAS, absFeatures)) printf("Gas, ");
++	if (testBit(ABS_BRAKE, absFeatures)) printf("Brake, ");
++	if (testBit(ABS_HAT0X, absFeatures)) printf("Hat 0 X, ");
++	if (testBit(ABS_HAT0Y, absFeatures)) printf("Hat 0 Y, ");
++	if (testBit(ABS_HAT1X, absFeatures)) printf("Hat 1 X, ");
++	if (testBit(ABS_HAT1Y, absFeatures)) printf("Hat 1 Y, ");
++	if (testBit(ABS_HAT2X, absFeatures)) printf("Hat 2 X, ");
++	if (testBit(ABS_HAT2Y, absFeatures)) printf("Hat 2 Y, ");
++	if (testBit(ABS_HAT3X, absFeatures)) printf("Hat 3 X, ");
++	if (testBit(ABS_HAT3Y, absFeatures)) printf("Hat 3 Y, ");
++	if (testBit(ABS_PRESSURE, absFeatures)) printf("Pressure, ");
++	if (testBit(ABS_DISTANCE, absFeatures)) printf("Distance, ");
++	if (testBit(ABS_TILT_X, absFeatures)) printf("Tilt X, ");
++	if (testBit(ABS_TILT_Y, absFeatures)) printf("Tilt Y, ");
++	if (testBit(ABS_TOOL_WIDTH, absFeatures)) printf("Tool width, ");
++	if (testBit(ABS_VOLUME, absFeatures)) printf("Volume, ");
++	if (testBit(ABS_MISC, absFeatures)) printf("Misc ,");
++
++	printf("\n    [");
++	for (i=0; i<sizeof(absFeatures)/sizeof(unsigned char);i++)
++	    printf("%02X ", absFeatures[i]);
++	printf("]\n");
++
++	/* Relative axes */
++	memset(relFeatures, 0, sizeof(relFeatures)*sizeof(unsigned char));
++	if (ioctl(fd, EVIOCGBIT(EV_REL, sizeof(relFeatures)*sizeof(unsigned char)), relFeatures) == -1) {
++		perror("Ioctl relative axes features query");
+ 		exit(1);
+ 	}
+ 
+-	printf("Axes query: ");
++	printf("  * Relative axes: ");
+ 
+-	if (test_bit(ABS_X, features)) printf("Axis X ");
+-	if (test_bit(ABS_Y, features)) printf("Axis Y ");
+-	if (test_bit(ABS_WHEEL, features)) printf("Wheel ");
++	if (testBit(REL_X, relFeatures)) printf("X, ");
++	if (testBit(REL_Y, relFeatures)) printf("Y, ");
++	if (testBit(REL_Z, relFeatures)) printf("Z, ");
++	if (testBit(REL_RX, relFeatures)) printf("RX, ");
++	if (testBit(REL_RY, relFeatures)) printf("RY, ");
++	if (testBit(REL_RZ, relFeatures)) printf("RZ, ");
++	if (testBit(REL_HWHEEL, relFeatures)) printf("HWheel, ");
++	if (testBit(REL_DIAL, relFeatures)) printf("Dial, ");
++	if (testBit(REL_WHEEL, relFeatures)) printf("Wheel, ");
++	if (testBit(REL_MISC, relFeatures)) printf("Misc, ");
++
++	printf("\n    [");
++	for (i=0; i<sizeof(relFeatures)/sizeof(unsigned char);i++)
++	    printf("%02X ", relFeatures[i]);
++	printf("]\n");
++
++	/* Force feedback effects */
++	memset(ffFeatures, 0, sizeof(ffFeatures)*sizeof(unsigned char));
++	if (ioctl(fd, EVIOCGBIT(EV_FF, sizeof(ffFeatures)*sizeof(unsigned char)), ffFeatures) == -1) {
++		perror("Ioctl force feedback features query");
++		exit(1);
++	}
+ 
+-	printf("\nEffects: ");
++	printf("  * Force feedback effects types: ");
+ 
+-	if (test_bit(FF_CONSTANT, features)) printf("Constant ");
+-	if (test_bit(FF_PERIODIC, features)) printf("Periodic ");
+-	if (test_bit(FF_SPRING, features)) printf("Spring ");
+-	if (test_bit(FF_FRICTION, features)) printf("Friction ");
+-	if (test_bit(FF_RUMBLE, features)) printf("Rumble ");
++	if (testBit(FF_CONSTANT, ffFeatures)) printf("Constant, ");
++	if (testBit(FF_PERIODIC, ffFeatures)) printf("Periodic, ");
++	if (testBit(FF_RAMP, ffFeatures)) printf("Ramp, ");
++	if (testBit(FF_SPRING, ffFeatures)) printf("Spring, ");
++	if (testBit(FF_FRICTION, ffFeatures)) printf("Friction, ");
++	if (testBit(FF_DAMPER, ffFeatures)) printf("Damper, ");
++	if (testBit(FF_RUMBLE, ffFeatures)) printf("Rumble, ");
++	if (testBit(FF_INERTIA, ffFeatures)) printf("Inertia, ");
++	if (testBit(FF_GAIN, ffFeatures)) printf("Gain, ");
++	if (testBit(FF_AUTOCENTER, ffFeatures)) printf("Autocenter, ");
++
++	printf("\n    Force feedback periodic effects: ");
++
++	if (testBit(FF_SQUARE, ffFeatures)) printf("Square, ");
++	if (testBit(FF_TRIANGLE, ffFeatures)) printf("Triangle, ");
++	if (testBit(FF_SINE, ffFeatures)) printf("Sine, ");
++	if (testBit(FF_SAW_UP, ffFeatures)) printf("Saw up, ");
++	if (testBit(FF_SAW_DOWN, ffFeatures)) printf("Saw down, ");
++	if (testBit(FF_CUSTOM, ffFeatures)) printf("Custom, ");
++
++	printf("\n    [");
++	for (i=0; i<sizeof(ffFeatures)/sizeof(unsigned char);i++)
++	    printf("%02X ", ffFeatures[i]);
++	printf("]\n");
+ 
+-	printf("\nNumber of simultaneous effects: ");
++	printf("  * Number of simultaneous effects: ");
+ 
+-	if (ioctl(fd, EVIOCGEFFECTS, &n_effects) < 0) {
++	if (ioctl(fd, EVIOCGEFFECTS, &n_effects) == -1) {
+ 		perror("Ioctl number of effects");
+ 	}
+ 
+-	printf("%d\n", n_effects);
++	printf("%d\n\n", n_effects);
++
++	/* Set master gain to 75% if supported */
++	if (testBit(FF_GAIN, ffFeatures)) {
++		memset(&gain, 0, sizeof(gain));
++		gain.type = EV_FF;
++		gain.code = FF_GAIN;
++		gain.value = 0xC000; /* [0, 0xFFFF]) */
++
++		printf("Setting master gain to 75%% ... ");
++		fflush(stdout);
++		if (write(fd, &gain, sizeof(gain)) != sizeof(gain)) {
++		  perror("Error:");
++		} else {
++		  printf("OK\n");
++		}
++	}
+ 
+ 	/* download a periodic sinusoidal effect */
++	memset(&effects[0],0,sizeof(effects[0]));
+ 	effects[0].type = FF_PERIODIC;
+ 	effects[0].id = -1;
+ 	effects[0].u.periodic.waveform = FF_SINE;
+-	effects[0].u.periodic.period = 0.1*0x100;	/* 0.1 second */
+-	effects[0].u.periodic.magnitude = 0x4000;	/* 0.5 * Maximum magnitude */
++	effects[0].u.periodic.period = 10;	/* 0.1 second */
++	effects[0].u.periodic.magnitude = 0x7fff;	/* 0.5 * Maximum magnitude */
+ 	effects[0].u.periodic.offset = 0;
+ 	effects[0].u.periodic.phase = 0;
+ 	effects[0].direction = 0x4000;	/* Along X axis */
+-	effects[0].u.periodic.envelope.attack_length = 0x100;
+-	effects[0].u.periodic.envelope.attack_level = 0;
+-	effects[0].u.periodic.envelope.fade_length = 0x100;
+-	effects[0].u.periodic.envelope.fade_level = 0;
++	effects[0].u.periodic.envelope.attack_length = 1000;
++	effects[0].u.periodic.envelope.attack_level = 0x7fff;
++	effects[0].u.periodic.envelope.fade_length = 1000;
++	effects[0].u.periodic.envelope.fade_level = 0x7fff;
+ 	effects[0].trigger.button = 0;
+ 	effects[0].trigger.interval = 0;
+ 	effects[0].replay.length = 20000;  /* 20 seconds */
+-	effects[0].replay.delay = 0;
++	effects[0].replay.delay = 1000;
+ 
+-	if (ioctl(fd, EVIOCSFF, &effects[0]) < 0) {
+-		perror("Upload effects[0]");
++	printf("Uploading effect #0 (Periodic sinusoidal) ... ");
++	fflush(stdout);
++	if (ioctl(fd, EVIOCSFF, &effects[0]) == -1) {
++		perror("Error:");
++	} else {
++		printf("OK (id %d)\n", effects[0].id);
+ 	}
+ 	
+ 	/* download a constant effect */
+@@ -141,20 +244,24 @@
+ 	effects[1].id = -1;
+ 	effects[1].u.constant.level = 0x2000;	/* Strength : 25 % */
+ 	effects[1].direction = 0x6000;	/* 135 degrees */
+-	effects[1].u.constant.envelope.attack_length = 0x100;
+-	effects[1].u.constant.envelope.attack_level = 0;
+-	effects[1].u.constant.envelope.fade_length = 0x100;
+-	effects[1].u.constant.envelope.fade_level = 0;
++	effects[1].u.constant.envelope.attack_length = 1000;
++	effects[1].u.constant.envelope.attack_level = 0x1000;
++	effects[1].u.constant.envelope.fade_length = 1000;
++	effects[1].u.constant.envelope.fade_level = 0x1000;
+ 	effects[1].trigger.button = 0;
+ 	effects[1].trigger.interval = 0;
+ 	effects[1].replay.length = 20000;  /* 20 seconds */
+ 	effects[1].replay.delay = 0;
+ 
+-	if (ioctl(fd, EVIOCSFF, &effects[1]) < 0) {
+-		perror("Upload effects[1]");
++	printf("Uploading effect #1 (Constant) ... ");
++	fflush(stdout);
++	if (ioctl(fd, EVIOCSFF, &effects[1]) == -1) {
++		perror("Error");
++	} else {
++		printf("OK (id %d)\n", effects[1].id);
+ 	}
+ 
+-	/* download an condition spring effect */
++	/* download a condition spring effect */
+ 	effects[2].type = FF_SPRING;
+ 	effects[2].id = -1;
+ 	effects[2].u.condition[0].right_saturation = 0x7fff;
+@@ -169,11 +276,15 @@
+ 	effects[2].replay.length = 20000;  /* 20 seconds */
+ 	effects[2].replay.delay = 0;
+ 
+-	if (ioctl(fd, EVIOCSFF, &effects[2]) < 0) {
+-		perror("Upload effects[2]");
++	printf("Uploading effect #2 (Spring) ... ");
++	fflush(stdout);
++	if (ioctl(fd, EVIOCSFF, &effects[2]) == -1) {
++		perror("Error");
++	} else {
++		printf("OK (id %d)\n", effects[2].id);
+ 	}
+ 
+-	/* download an condition damper effect */
++	/* download a condition damper effect */
+ 	effects[3].type = FF_DAMPER;
+ 	effects[3].id = -1;
+ 	effects[3].u.condition[0].right_saturation = 0x7fff;
+@@ -188,8 +299,12 @@
+ 	effects[3].replay.length = 20000;  /* 20 seconds */
+ 	effects[3].replay.delay = 0;
+ 
+-	if (ioctl(fd, EVIOCSFF, &effects[3]) < 0) {
+-		perror("Upload effects[3]");
++	printf("Uploading effect #3 (Damper) ... ");
++	fflush(stdout);
++	if (ioctl(fd, EVIOCSFF, &effects[3]) == -1) {
++		perror("Error");
++	} else {
++		printf("OK (id %d)\n", effects[3].id);
+ 	}
+ 
+ 	/* a strong rumbling effect */
+@@ -200,8 +315,12 @@
+ 	effects[4].replay.length = 5000;
+ 	effects[4].replay.delay = 1000;
+ 
+-	if (ioctl(fd, EVIOCSFF, &effects[4]) < 0) {
+-		perror("Upload effects[4]");
++	printf("Uploading effect #4 (Strong rumble, with heavy motor) ... ");
++	fflush(stdout);
++	if (ioctl(fd, EVIOCSFF, &effects[4]) == -1) {
++		perror("Error");
++	} else {
++		printf("OK (id %d)\n", effects[4].id);
+ 	}
+ 
+ 	/* a weak rumbling effect */
+@@ -212,8 +331,12 @@
+ 	effects[5].replay.length = 5000;
+ 	effects[5].replay.delay = 0;
+ 
+-	if (ioctl(fd, EVIOCSFF, &effects[5]) < 0) {
+-		perror("Upload effects[5]");
++	printf("Uploading effect #5 (Weak rumble, with light motor) ... ");
++	fflush(stdout);
++	if (ioctl(fd, EVIOCSFF, &effects[5]) == -1) {
++		perror("Error");
++	} else {
++		printf("OK (id %d)\n", effects[5].id);
+ 	}
+ 
+ 
+@@ -225,6 +348,7 @@
+ 			printf("Read error\n");
+ 		}
+ 		else if (i >= 0 && i < N_EFFECTS) {
++			memset(&play,0,sizeof(play));
+ 			play.type = EV_FF;
+ 			play.code = effects[i].id;
+ 			play.value = 1;
+@@ -241,19 +365,21 @@
+ 			int i = *((int *)0);
+ 			printf("Crash test: %d\n", i);
+ 		}
+-		else {
++		else if (i != -1) {
+ 			printf("No such effect\n");
+ 		}
+ 	} while (i>=0);
+ 
+ 	/* Stop the effects */
++	printf("Stopping effects\n");
+ 	for (i=0; i<N_EFFECTS; ++i) {
++		memset(&stop,0,sizeof(stop));
+ 		stop.type = EV_FF;
+ 		stop.code =  effects[i].id;
+ 		stop.value = 0;
+         
+ 		if (write(fd, (const void*) &stop, sizeof(stop)) == -1) {
+-			perror("Stop effect");
++			perror("");
+ 			exit(1);
+ 		}
+ 	}
diff --git a/linuxconsoletools.spec b/linuxconsoletools.spec
index 43dca48..40a680d 100644
--- a/linuxconsoletools.spec
+++ b/linuxconsoletools.spec
@@ -1,6 +1,6 @@
 Name: linuxconsoletools
 Version: 1.4.4
-Release: 5%{?dist}
+Release: 6%{?dist}
 Summary: Tools for connecting joysticks & legacy devices to the kernel's input subsystem
 Group: Applications/System
 License: GPLv2+
@@ -8,6 +8,11 @@ URL: http://sourceforge.net/projects/linuxconsole/
 
 Source: http://downloads.sourceforge.net/linuxconsole/%{name}-%{version}.tar.bz2
 
+#Add 64-bit port and kernel 2.6.22 compatibility
+#http://sourceforge.net/tracker/download.php?group_id=44724&atid=440671&file_id=292511&aid=2098907
+#The following patch is a result of merging the original patch from ff-utils to linuxconsoletools
+Patch0: linuxconsoletools-64bitPort-ffutils.patch
+
 BuildRequires: SDL-devel
 
 Provides: joystick = %{version}-%{release}
@@ -24,6 +29,7 @@ for serial mice, touchscreens etc.), and test the input event layer.
 %prep
 %setup -q
 
+%patch0 -p1
 
 %build
 make PREFIX=%{_prefix} CFLAGS="%{optflags}" %{?_smp_mflags}
@@ -63,6 +69,9 @@ chmod -x %{buildroot}%{_mandir}/man1/*
 
 
 %changelog
+* Wed Feb 06 2013 Jaromir Capik <jcapik at redhat.com> - 1.4.4-6
+- Merging the 64bit patch from ff-utils
+
 * Mon Feb 04 2013 Jaromir Capik <jcapik at redhat.com> - 1.4.4-5
 - Resolving conflicts with ff-utils
 


More information about the scm-commits mailing list