frontend/320240/caanoo.gpe frontend/320240/pcsx26.png \
frontend/320240/pcsxb.png frontend/320240/skin \
frontend/warm/bin/warm_2.6.24.ko frontend/320240/pollux_set \
- frontend/320240/pcsx_rearmed.ini frontend/320240/haptic.txt \
+ frontend/320240/pcsx_rearmed.ini frontend/320240/haptic_w.cfg \
+ frontend/320240/haptic_s.cfg \
readme.txt COPYING
rm -rf out
mkdir -p out/pcsx_rearmed/plugins
#define HAPTIC_SET_VIB_LEVEL _IOW(HAPTIC_IOCTL_MAGIC, 9, unsigned int)
static int hapticdev = -1;
-static struct haptic_data haptic_seq;
+static struct haptic_data haptic_seq[2];
-static int haptic_init(void)
+static int haptic_read(const char *fname, struct haptic_data *data)
{
int i, ret, v1, v2;
char buf[128], *p;
FILE *f;
- f = fopen("haptic.txt", "r");
+ f = fopen(fname, "r");
if (f == NULL) {
- perror("fopen(haptic.txt)");
+ fprintf("fopen(%s)", fname);
+ perror("");
return -1;
}
- for (i = 0; i < sizeof(haptic_seq.actions) / sizeof(haptic_seq.actions[0]); ) {
+ for (i = 0; i < sizeof(data->actions) / sizeof(data->actions[0]); ) {
p = fgets(buf, sizeof(buf), f);
if (p == NULL)
break;
continue;
}
- haptic_seq.actions[i].time = v1;
- haptic_seq.actions[i].strength = v2;
+ data->actions[i].time = v1;
+ data->actions[i].strength = v2;
i++;
}
fclose(f);
if (i == 0) {
- fprintf(stderr, "bad haptic.txt\n");
+ fprintf(stderr, "bad haptic file: %s\n", fname);
return -1;
}
- haptic_seq.count = i;
+ data->count = i;
+
+ return 0;
+}
+
+static int haptic_init(void)
+{
+ int ret, i;
+
+ ret = haptic_read("haptic_w.cfg", &haptic_seq[0]);
+ if (ret != 0)
+ return -1;
+ ret = haptic_read("haptic_s.cfg", &haptic_seq[1]);
+ if (ret != 0)
+ return -1;
hapticdev = open("/dev/isa1200", O_RDWR | O_NONBLOCK);
if (hapticdev == -1) {
return 0;
}
-void plat_trigger_vibrate(void)
+void plat_trigger_vibrate(int is_strong)
{
int ret;
}
}
- ioctl(hapticdev, HAPTIC_PLAY_PATTERN, &haptic_seq);
+ ioctl(hapticdev, HAPTIC_PLAY_PATTERN, &haptic_seq[!!is_strong]);
}
/* Wiz stuff */
case CMD_READ_DATA_AND_VIBRATE:
if (value == 1 && CurPad == 0 && in_enable_vibration)
- plat_trigger_vibrate();
+ plat_trigger_vibrate(0);
break;
}
}
+static void do_cmd3(unsigned char value)
+{
+ if (in_enable_vibration && CurCmd == CMD_READ_DATA_AND_VIBRATE && CurPad == 0) {
+ if (value >= 0xf0)
+ plat_trigger_vibrate(1);
+ else if (value > 0x40)
+ plat_trigger_vibrate(0);
+ }
+}
+
#if 0
#include <stdio.h>
unsigned char PADpoll_(unsigned char value);
unsigned char PADpoll_pad(unsigned char value) {
- if (CurByte == 0) {
+ switch (CurByte) {
+ case 0:
CurCmd = value;
CurByte++;
CurCmd = CMD_READ_DATA_AND_VIBRATE;
return do_cmd();
- }
-
- if (CurByte == 2)
+ case 2:
do_cmd2(value);
+ break;
+ case 3:
+ do_cmd3(value);
+ break;
+ }
if (CurByte >= CmdLen)
return 0xff; // verified