Index: cwiid-0.6.00+svn184.orig/wminput/plugins/Makefile.in =================================================================== --- cwiid-0.6.00+svn184.orig.orig/wminput/plugins/Makefile.in 2008-06-24 21:43:05.000000000 +0200 +++ cwiid-0.6.00+svn184.orig/wminput/plugins/Makefile.in 2009-03-27 13:15:50.000000000 +0100 @@ -2,7 +2,7 @@ include @top_builddir@/defs.mak -PLUGINS = ir_ptr acc nunchuk_acc led nunchuk_stick2btn +PLUGINS = ir_ptr ir_fps acc nunchuk_acc led nunchuk_stick2btn nunchuk_kb all install clean distclean uninstall: TARGET += $(MAKECMDGOALS) Index: cwiid-0.6.00+svn184.orig/wminput/plugins/ir_fps/Makefile.in =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ cwiid-0.6.00+svn184.orig/wminput/plugins/ir_fps/Makefile.in 2009-03-27 13:15:50.000000000 +0100 @@ -0,0 +1,15 @@ +#Copyright (C) 2007 L. Donnie Smith + +include @top_builddir@/defs.mak + +PLUGIN_NAME = ir_fps +SOURCES = ir_fps.c +CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/libcwiid +INST_DIR = $(CWIID_PLUGINS_DIR) + +include $(COMMON)/include/plugin.mak + +distclean: clean + rm Makefile + +.PHONY: distclean Index: cwiid-0.6.00+svn184.orig/wminput/plugins/ir_fps/ir_fps.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ cwiid-0.6.00+svn184.orig/wminput/plugins/ir_fps/ir_fps.c 2009-03-27 13:15:50.000000000 +0100 @@ -0,0 +1,162 @@ +/* Copyright (C) 2007 L. Donnie Smith + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include "wmplugin.h" + +#define DEBOUNCE_THRESHOLD 50 + +//deadzone is a circle of diameter a 10th of the screen +#define DEADZONE (CWIID_IR_X_MAX*CWIID_IR_X_MAX+CWIID_IR_Y_MAX*CWIID_IR_Y_MAX)/100 + +//speed is here +#define XSPEED 10/(CWIID_IR_X_MAX/2) +#define YSPEED 10/(CWIID_IR_Y_MAX/2) + +cwiid_wiimote_t *wiimote; + +static struct wmplugin_info info; +static struct wmplugin_data data; + +wmplugin_info_t wmplugin_info; +wmplugin_init_t wmplugin_init; +wmplugin_exec_t wmplugin_exec; + +struct wmplugin_info *wmplugin_info() { + static unsigned char info_init = 0; + + if (!info_init) { + info.button_count = 0; + info.axis_count = 2; + info.axis_info[0].name = "X"; + info.axis_info[0].type = WMPLUGIN_REL; + info.axis_info[0].max = CWIID_IR_X_MAX; + info.axis_info[0].min = 0; + info.axis_info[0].fuzz = 0; + info.axis_info[0].flat = 0; + info.axis_info[1].name = "Y"; + info.axis_info[1].type = WMPLUGIN_REL; + info.axis_info[1].max = CWIID_IR_Y_MAX; + info.axis_info[1].min = 0; + info.axis_info[1].fuzz = 0; + info.axis_info[1].flat = 0; + info.param_count = 0; + info_init = 1; + } + return &info; +} + +int wmplugin_init(int id, cwiid_wiimote_t *arg_wiimote) +{ + wiimote = arg_wiimote; + + data.buttons = 0; + + if (wmplugin_set_rpt_mode(id, CWIID_RPT_IR)) { + return -1; + } + + return 0; +} + +struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg mesg[]) +{ + static int src_index = -1; + static int debounce = 0; + static uint8_t old_flag; + + int i; + uint8_t flag; + struct cwiid_ir_mesg *ir_mesg; + int dx, dy; + + ir_mesg = NULL; + for (i=0; i < mesg_count; i++) { + if (mesg[i].type == CWIID_MESG_IR) { + ir_mesg = &mesg[i].ir_mesg; + } + } + + if (!ir_mesg) { + return NULL; + } + + /* invalidate src index if source is no longer present */ + if ((src_index != -1) && !ir_mesg->src[src_index].valid) { + if (debounce > DEBOUNCE_THRESHOLD) { + src_index = -1; + } + else { + debounce++; + } + } + else { + debounce = 0; + } + + /* of not set, pick largest available source */ + if (src_index == -1) { + for (i=0; i < CWIID_IR_SRC_COUNT; i++) { + if (ir_mesg->src[i].valid) { + if ((src_index == -1) || + (ir_mesg->src[i].size > ir_mesg->src[src_index].size)) { + src_index = i; + } + } + } + } + + /* LEDs */ + switch (src_index) { + case 0: + flag = CWIID_LED1_ON; + break; + case 1: + flag = CWIID_LED2_ON; + break; + case 2: + flag = CWIID_LED3_ON; + break; + case 3: + flag = CWIID_LED4_ON; + break; + default: + flag = 0; + break; + } + if (flag != old_flag) { + cwiid_set_led(wiimote, flag); + old_flag = flag; + } + + if ((src_index == -1) || !ir_mesg->src[src_index].valid) { + data.axes[0].valid = data.axes[1].valid = 0; + } + else { + data.axes[0].valid = data.axes[1].valid = 1; + dx = CWIID_IR_X_MAX/2 - ir_mesg->src[src_index].pos[CWIID_X]; + dy = ir_mesg->src[src_index].pos[CWIID_Y] - CWIID_IR_Y_MAX/2; + if (dx*dx+dy*dy > DEADZONE){ + data.axes[0].value = dx*XSPEED; + data.axes[1].value = dy*YSPEED; + }else { + data.axes[0].value = 0; + data.axes[1].value = 0; + } + } + return &data; +} Index: cwiid-0.6.00+svn184.orig/wminput/plugins/nunchuk_kb/Makefile.in =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ cwiid-0.6.00+svn184.orig/wminput/plugins/nunchuk_kb/Makefile.in 2009-03-27 13:15:50.000000000 +0100 @@ -0,0 +1,16 @@ +#Copyright (C) 2007 L. Donnie Smith + +include @top_builddir@/defs.mak + +PLUGIN_NAME = nunchuk_kb +SOURCES = nunchuk_kb.c +CFLAGS += -I@top_builddir@/wminput -I@top_builddir@/libcwiid +LDLIBS += -lm +INST_DIR = $(CWIID_PLUGINS_DIR) + +include $(COMMON)/include/plugin.mak + +distclean: clean + rm Makefile + +.PHONY: distclean Index: cwiid-0.6.00+svn184.orig/wminput/plugins/nunchuk_kb/nunchuk_kb.c =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ cwiid-0.6.00+svn184.orig/wminput/plugins/nunchuk_kb/nunchuk_kb.c 2009-03-27 13:15:50.000000000 +0100 @@ -0,0 +1,116 @@ +/* Copyright (C) 2007 L. Donnie Smith + * + * 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., 51 Franklin Street, Fifth Floor, Boston, MA 02110-1301 USA + * + */ + +#include + +#include "wmplugin.h" + +/* Button flags */ +#define STICK_KEY_UP 0x0001 +#define STICK_KEY_DOWN 0x0002 +#define STICK_KEY_RIGHT 0x0004 +#define STICK_KEY_LEFT 0x0008 +#define STICK_MID_VAL 128 +#define STICK_NEUTRAL 20 + +static unsigned char info_init = 0; +static struct wmplugin_info info; +static struct wmplugin_data data; + +static cwiid_wiimote_t *wiimote; + +static struct acc_cal acc_cal; +static int plugin_id; + +wmplugin_info_t wmplugin_info; +wmplugin_init_t wmplugin_init; +wmplugin_exec_t wmplugin_exec; +static void process_nunchuk(struct cwiid_nunchuk_mesg *mesg); + +static float Roll_Scale = 1.0; +static float Pitch_Scale = 1.0; +static float X_Scale = 1.0; +static float Y_Scale = 1.0; + +struct wmplugin_info *wmplugin_info() { + if (!info_init) { + info.button_count = 4; + info.button_info[0].name = "Up"; + info.button_info[1].name = "Down"; + info.button_info[2].name = "Right"; + info.button_info[3].name = "Left"; + info.axis_count = 0; + info_init = 1; + } + return &info; +} + +int wmplugin_init(int id, cwiid_wiimote_t *arg_wiimote) +{ + plugin_id = id; + wiimote = arg_wiimote; + data.buttons = 0; + data.axes[0].valid = 1; + data.axes[1].valid = 1; + if (wmplugin_set_rpt_mode(id, CWIID_RPT_STATUS | CWIID_RPT_NUNCHUK)) { + return -1; + } + + return 0; +} + +struct wmplugin_data *wmplugin_exec(int mesg_count, union cwiid_mesg mesg[]) +{ + int i; + enum cwiid_ext_type ext_type = CWIID_EXT_NONE; + struct wmplugin_data *ret = NULL; + + for (i=0; i < mesg_count; i++) { + switch (mesg[i].type) { + case CWIID_MESG_STATUS: + if ((mesg[i].status_mesg.ext_type == CWIID_EXT_NUNCHUK) && + (ext_type != CWIID_EXT_NUNCHUK)) { + if (cwiid_get_acc_cal(wiimote, CWIID_EXT_NUNCHUK, &acc_cal)) { + wmplugin_err(plugin_id, "calibration error"); + } + } + ext_type = mesg[i].status_mesg.ext_type; + break; + case CWIID_MESG_NUNCHUK: + process_nunchuk(&mesg[i].nunchuk_mesg); + ret = &data; + break; + default: + break; + } + } + + return ret; +} + +static void process_nunchuk(struct cwiid_nunchuk_mesg *mesg) +{ + double stx=(double)mesg->stick[CWIID_X]; + double sty=(double)mesg->stick[CWIID_Y]; + data.buttons=0; + if (sty > STICK_MID_VAL+STICK_NEUTRAL) data.buttons |= STICK_KEY_UP; + if (sty < STICK_MID_VAL-STICK_NEUTRAL) data.buttons |= STICK_KEY_DOWN; + if (stx > STICK_MID_VAL+STICK_NEUTRAL) data.buttons |= STICK_KEY_RIGHT; + if (stx < STICK_MID_VAL-STICK_NEUTRAL) data.buttons |= STICK_KEY_LEFT; +} + Index: cwiid-0.6.00+svn184.orig/wminput/configs/fps_config =================================================================== --- /dev/null 1970-01-01 00:00:00.000000000 +0000 +++ cwiid-0.6.00+svn184.orig/wminput/configs/fps_config 2009-03-27 13:15:50.000000000 +0100 @@ -0,0 +1,32 @@ +# Fps config for wminput by kyrlian +# needs plugins ir_fps and nunchuk_kb +# available from http://kyrlian.free.fr/binaries/cwiid/latest/ +# wminput source and info at http://abstrakraft.org/cwiid/ + +# IR for mouse REL - fps style +Plugin.ir_fps.X = REL_X +Plugin.ir_fps.Y = REL_Y + +#custom buttons +Wiimote.A = BTN_LEFT +Wiimote.B = BTN_RIGHT +Wiimote.Up = KEY_UP +Wiimote.Down = KEY_DOWN +Wiimote.Left = KEY_LEFT +Wiimote.Right = KEY_RIGHT +Wiimote.Minus = KEY_PAGEDOWN +Wiimote.Plus = KEY_PAGEUP +Wiimote.Home = KEY_ESC + +Wiimote.1 = KEY_TAB +Wiimote.2 = KEY_ESC + +Nunchuk.C = KEY_C +Nunchuk.Z = KEY_SPACE + +#plugin for nunchuk stick +Plugin.nunchuk_kb.Up = KEY_W +Plugin.nunchuk_kb.Down = KEY_S +Plugin.nunchuk_kb.Left = KEY_A +Plugin.nunchuk_kb.Right = KEY_D + Index: cwiid-0.6.00+svn184.orig/configure.ac =================================================================== --- cwiid-0.6.00+svn184.orig.orig/configure.ac 2008-06-24 21:43:05.000000000 +0200 +++ cwiid-0.6.00+svn184.orig/configure.ac 2009-03-27 13:15:50.000000000 +0100 @@ -142,8 +142,10 @@ [wminput/Makefile] [wminput/plugins/Makefile] [wminput/plugins/ir_ptr/Makefile] + [wminput/plugins/ir_fps/Makefile] [wminput/plugins/acc/Makefile] [wminput/plugins/nunchuk_acc/Makefile] + [wminput/plugins/nunchuk_kb/Makefile] [wminput/plugins/led/Makefile] [wminput/plugins/nunchuk_stick2btn/Makefile] [lswm/Makefile]