From: johann d. <jd...@us...> - 2001-10-23 21:20:57
|
Update of /cvsroot/linuxconsole/ruby/linux/drivers/input In directory usw-pr-cvs1:/tmp/cvs-serv22934 Modified Files: iforce-ff.c iforce-main.c iforce-packets.c iforce.h Log Message: Added a function iforce_control_playback. It can be used to bypass input_event to start/stop an effect, which necessary when updating effects. Do not restart an effect that stops. We had no way to tell if the effect stopped normally or too early. Instead, make_core_effect restart the effects if necessary. Index: iforce-ff.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/iforce-ff.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- iforce-ff.c 2001/10/16 21:05:57 1.2 +++ iforce-ff.c 2001/10/23 21:20:54 1.3 @@ -336,7 +336,16 @@ data[12] = LO(delay); data[13] = HI(delay); + /* Stop effect */ +/* iforce_control_playback(iforce, id, 0);*/ + iforce_send_packet(iforce, FF_CMD_EFFECT, data); + + /* If needed, restart effect */ + if (test_bit(FF_CORE_SHOULD_PLAY, iforce->core_effects[id].flags)) { + /* BUG: perhaps we should replay n times, instead of 1. But we do not know n */ + iforce_control_playback(iforce, id, 1); + } return 0; } Index: iforce-main.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/iforce-main.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- iforce-main.c 2001/10/16 21:05:57 1.2 +++ iforce-main.c 2001/10/23 21:20:54 1.3 @@ -101,11 +101,8 @@ else { clear_bit(FF_CORE_SHOULD_PLAY, iforce->core_effects[code].flags); } - data[0] = LO(code); - data[1] = (value > 0) ? ((value > 1) ? 0x41 : 0x01) : 0; - data[2] = LO(value); - iforce_send_packet(iforce, FF_CMD_PLAY, data); + iforce_control_playback(iforce, code, value); return 0; } Index: iforce-packets.c =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/iforce-packets.c,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- iforce-packets.c 2001/10/16 21:05:57 1.2 +++ iforce-packets.c 2001/10/23 21:20:54 1.3 @@ -119,6 +119,19 @@ return 0; } +/* Start or stop an effect */ +int iforce_control_playback(struct iforce* iforce, u16 id, unsigned int value) +{ + unsigned char data[3]; + +printk(KERN_DEBUG "iforce-packets.c: control_playback %d %d\n", id, value); + + data[0] = LO(id); + data[1] = (value > 0) ? ((value > 1) ? 0x41 : 0x01) : 0; + data[2] = LO(value); + return iforce_send_packet(iforce, FF_CMD_PLAY, data); +} + /* Mark an effect that was being updated as ready. That means it can be updated * again */ static int mark_core_as_ready(struct iforce *iforce, unsigned short addr) @@ -195,22 +208,12 @@ if (data[1] & 0x80) { if (!test_and_set_bit(FF_CORE_IS_PLAYED, iforce->core_effects[i].flags)) { /* Report play event */ - input_report_ff_status(dev, i, FF_STATUS_PLAYING); -printk(KERN_DEBUG "iforce.c: effect %d started to play\n", i); + input_report_ff_status(dev, i, FF_STATUS_PLAYING); } } - else { - if (!test_bit(FF_CORE_SHOULD_PLAY, iforce->core_effects[i].flags)) { - if (test_and_clear_bit(FF_CORE_IS_PLAYED, iforce->core_effects[i].flags)) { - /* Report stop event */ - input_report_ff_status(dev, i, FF_STATUS_STOPPED); -printk(KERN_DEBUG "iforce.c: effect %d stopped to play\n", i); - } - } - else { -printk(KERN_WARNING "iforce.c: effect %d stopped, while it should not\nStarting again\n", i); - input_report_ff(dev, i, 1); - } + else if (test_and_clear_bit(FF_CORE_IS_PLAYED, iforce->core_effects[i].flags)) { + /* Report stop event */ + input_report_ff_status(dev, i, FF_STATUS_STOPPED); } if (LO(cmd) > 3) { int j; Index: iforce.h =================================================================== RCS file: /cvsroot/linuxconsole/ruby/linux/drivers/input/iforce.h,v retrieving revision 1.2 retrieving revision 1.3 diff -u -d -r1.2 -r1.3 --- iforce.h 2001/10/16 21:05:57 1.2 +++ iforce.h 2001/10/23 21:20:54 1.3 @@ -179,6 +179,7 @@ int iforce_init_device(struct iforce *iforce); /* iforce-packets.c */ +int iforce_control_playback(struct iforce*, u16 id, unsigned int); void iforce_process_packet(struct iforce *iforce, u16 cmd, unsigned char *data); int iforce_send_packet(struct iforce *iforce, u16 cmd, unsigned char* data); void iforce_dump_packet(char *msg, u16 cmd, unsigned char *data) ; |