#include "config.h"
#include "binary.h"
#include "common.h"
+#ifdef __MAEMO__
+#include "maemo.h"
+#endif
#include "solid_sim.h"
#include "solid_all.h"
else audio_play(AUD_BUMPM, k);
}
else audio_play(AUD_BUMPM, k);
+#ifdef __MAEMO__
+ maemo_vibra(k);
+#endif
}
}
#include "maemo.h"
#include <SDL/SDL_timer.h>
#include <libosso.h>
+#define __USE_BSD
+#include <sys/types.h>
+#include <unistd.h>
+
+#define VIBRA_FILE "/sys/class/i2c-adapter/i2c-1/1-0048/twl4030_vibra/pulse"
static osso_context_t *osso_context = NULL;
static SDL_TimerID screen_timer_id = 0;
#endif /* if __arm__ */
}
+static void drop_root()
+{
+ seteuid(getuid());
+}
+
+static void gain_root()
+{
+ seteuid(0);
+}
+
int maemo_init(const char *program)
{
+ drop_root();
osso_context = osso_initialize(program, "1.0", 0, NULL);
if (!osso_context) {
fprintf(stderr, "osso_initialize failed!\n");
SDL_RemoveTimer(screen_timer_id);
}
+void maemo_vibra(float intensity)
+{
+ FILE *fd;
+ int speed, duration;
+
+ if (intensity < 5) return;
+ else if (intensity < 10) speed = -100;
+ else speed = -500;
+
+ duration = 20 + 5 * intensity;
+ gain_root();
+ fd = fopen(VIBRA_FILE, "w");
+ if (fd != NULL)
+ {
+ fprintf(fd, "%d %d\n", speed, duration);
+ fclose(fd);
+ }
+ else
+ printf("no root");
+ drop_root();
+}
+