diff -ru xjump-2.7.5.orig/game.c xjump-2.7.5-wii/game.c
--- xjump-2.7.5.orig/game.c	1997-10-28 11:22:50.000000000 +0100
+++ xjump-2.7.5-wii/game.c	2008-05-08 01:26:10.000000000 +0200
@@ -9,8 +9,13 @@
 #include<stdio.h>
 #include<X11/Xlib.h>
 
+#include <cwiid.h>
+
 #include"xjump.h"
 
+extern cwiid_wiimote_t *wiimote;
+extern struct cwiid_state state;
+extern unsigned char led_state;
 
 /* マクロ */
 
@@ -135,6 +140,21 @@
 }
 
 
+int up(void) {
+  cwiid_get_state(wiimote, &state);
+  return (state.buttons & CWIID_BTN_B);
+}
+
+int right(void) {
+  cwiid_get_state(wiimote, &state);
+  return (state.buttons & CWIID_BTN_RIGHT);
+}
+
+int left(void) {
+  cwiid_get_state(wiimote, &state);
+  return (state.buttons & CWIID_BTN_LEFT);
+}
+
 /* 主人公の移動 */
 
 int move( void )
@@ -185,7 +205,7 @@
       Hero.pic ^= 1;
     }
 
-    if( Key[ KEY_UP ] ){
+    if( up() ){
       Hero.jump = abs(Hero.vx)/4+7;
       Hero.vy = -Hero.jump/2-12;
       Hero.pic = 2;
@@ -197,12 +217,12 @@
     floor = 0;
   }
 
-  if( Key[ KEY_LEFT ] ){
+  if( left() ){
     Hero.vx -= acc;
     if( Hero.vx < -32 )
       Hero.vx = -32;
     Hero.dir = 0;
-  }else if( Key[ KEY_RIGHT ] ){
+  }else if( right() ){
     Hero.vx += acc;
     if( Hero.vx > 32 )
       Hero.vx = 32;
@@ -219,7 +239,7 @@
   if( !st ){
     if( Hero.jump ){
       Hero.vy = -Hero.jump/2-12;
-      if( Key[ KEY_UP ] )
+      if( up() )
 	Hero.jump--;
       else
 	Hero.jump = 0;
Seulement dans xjump-2.7.5-wii: game.o
diff -ru xjump-2.7.5.orig/key.c xjump-2.7.5-wii/key.c
--- xjump-2.7.5.orig/key.c	1997-10-28 12:45:17.000000000 +0100
+++ xjump-2.7.5-wii/key.c	2008-05-08 01:23:52.000000000 +0200
@@ -10,7 +10,7 @@
 #include<X11/Xlib.h>
 #include<X11/keysym.h>
 
-#include"xjump.h"
+#include "xjump.h"
 
 static int Keycode_raw[3];
 static int Keycode_col[3];
@@ -43,11 +43,3 @@
       Key[i] = 0;
 }
 
-
-void wait_keyup( void )
-{
-  do{
-    keymap();
-  }while( Key[0] || Key[1] || Key[2] );
-}
-
diff -ru xjump-2.7.5.orig/main.c xjump-2.7.5-wii/main.c
--- xjump-2.7.5.orig/main.c	1999-08-20 05:47:44.000000000 +0200
+++ xjump-2.7.5-wii/main.c	2008-05-08 01:39:15.000000000 +0200
@@ -5,7 +5,7 @@
 
   (C) Oct 28, 1997  ROYALPANDA
 *****************************************/
-
+#include <stdlib.h>
 #include<stdio.h>
 #include<unistd.h>
 #include<limits.h>
@@ -19,6 +19,8 @@
 #include<X11/Shell.h>
 #include<X11/xpm.h>
 
+#include <cwiid.h>
+
 #include"xjump.h"
 #include"record.h"
 
@@ -62,8 +64,6 @@
 static XKeyboardState Keyboard;  /* キーボードステータス */
 static int Repeat_mode = 1;      /* キーリピートの状態(1:default 0:off) */
 
-static int Use_keymap = 0;       /* キーマップを直接読むか？ */
-
 /* プロトタイプ宣言 */
 
 static void timi( XtPointer c, XtIntervalId id );
@@ -82,6 +82,12 @@
 Pixmap Floor_p;          /* 床 */
 Pixmap Back_p;           /* 背景 */
 
+cwiid_mesg_callback_t cwiid_callback;
+cwiid_wiimote_t *wiimote;
+struct cwiid_state state;
+unsigned char led_state = 0;
+unsigned char rpt_mode = 0;
+
 int Key[3] = {0,0,0};    /* キーの状態 */
 
 hero_t Hero;             /* 主人公の状態 */
@@ -97,6 +103,29 @@
 
 char *Myname;   /* プログラム名 */
 
+void set_led_state(cwiid_wiimote_t *wiimote, unsigned char led_state)
+{
+    if (cwiid_set_led(wiimote, led_state)) {
+        fprintf(stderr, "Error setting LEDs \n");
+    }
+}
+
+void set_rpt_mode(cwiid_wiimote_t *wiimote, unsigned char rpt_mode)
+{
+    if (cwiid_set_rpt_mode(wiimote, rpt_mode)) {
+        fprintf(stderr, "Error setting report mode\n");
+    }
+}
+
+void wait_keyup( void )
+{
+  printf("0\n");
+  do{
+/*     printf("%X\n", state.buttons); */
+    cwiid_get_state(wiimote, &state);
+  }while(!state.buttons);
+  printf("1\n");
+}
 
 /* キーリピートを止める */
 
@@ -192,9 +221,6 @@
 {
   XtMapWidget( Gameover );
 
-  if( Use_keymap )
-    wait_keyup();
-
   GameMode = OVER;
 
   save_record( Sc_now );
@@ -231,8 +257,6 @@
   switch( GameMode ){
 
   case GAME:
-    if( Use_keymap )
-      keymap();
     floor = move();
     if( floor == DEAD ){
       gameover();
@@ -280,6 +304,11 @@
 {
   repeat_on();
   XFlush( Disp );
+
+  if (cwiid_close(wiimote)) {
+    fprintf(stderr, "Error on wiimote disconnect\n");
+  }
+
   exit(0);
 }
 
@@ -301,9 +330,6 @@
   switch( GameMode ){
   case TITLE:
 
-    if( Use_keymap )
-      wait_keyup();
-
     XtUnmapWidget( Score_v );
     XtUnmapWidget( Gameover );
     reset_timer();
@@ -337,53 +363,6 @@
   }
 }
 
-
-
-/* キー押された(アクションハンドラ) */
-
-static void key_on( Widget w,XEvent *e,String *s,Cardinal *num )
-{
-  if( Use_keymap )
-    return;
-
-  switch( **s ){
-  case 'U':
-    Key[ KEY_UP ] = 1;
-    break;
-
-  case 'R':
-    Key[ KEY_RIGHT ] = 1;
-    break;
-
-  case 'L':
-    Key[ KEY_LEFT ] = 1;
-    break;
-  }
-}
-
-/* キー離された (アクションハンドラ) */
-
-static void key_off( Widget w,XEvent *e,String *s,Cardinal *num )
-{
-  if( Use_keymap )
-    return;
-
-  switch( **s ){
-  case 'U':
-    Key[ KEY_UP ] = 0;
-    break;
-
-  case 'R':
-    Key[ KEY_RIGHT ] = 0;
-    break;
-
-  case 'L':
-    Key[ KEY_LEFT ] = 0;
-    break;
-  }
-}
-
-
 /* アイコンの設定 */
 
 static void set_icon( void )
@@ -434,18 +413,13 @@
       continue;
     }
 
-    if( strcmp( argv[i],"-keymap" ) == 0 ){
-      Use_keymap = 1;
-      continue;
-    }
-
     if( strcmp( argv[i],"-help" ) == 0 ){
       help();
       exit(0);
     }
-    fprintf(stderr,"%s: Unknown command line option \"%s\".\n",Myname,argv[i]);
-    help();
-    exit(1);
+/*     fprintf(stderr,"%s: Unknown command line option \"%s\".\n",Myname,argv[i]); */
+/*     help(); */
+/*     exit(1); */
   }
 }  
 
@@ -514,10 +488,28 @@
     {"start",  (XtActionProc)start_game},
     {"pause",  (XtActionProc)pause_game},
     {"quit",   (XtActionProc)quit_game},
-    {"key_on", (XtActionProc)key_on},
-    {"key_off",(XtActionProc)key_off},
   };
 
+  bdaddr_t bdaddr;
+  if (argc > 1) {
+    str2ba(argv[1], &bdaddr);
+  }
+  else {
+    bdaddr = *BDADDR_ANY;
+  }
+  /* Connect to the wiimote */
+  printf("Put Wiimote in discoverable mode now (press 1+2)...\n");
+  if (!(wiimote = cwiid_open(&bdaddr, 0))) {
+    fprintf(stderr, "Unable to connect to wiimote\n");
+    return -1;
+  }
+
+  toggle_bit(led_state, CWIID_LED1_ON);
+  set_led_state(wiimote, led_state);
+
+  toggle_bit(rpt_mode, CWIID_RPT_BTN);
+  set_rpt_mode(wiimote, rpt_mode);
+
   Widget game,w;
 
   uid_t uid;
@@ -586,9 +578,6 @@
 
   XtAppAddActions( App,a_table,XtNumber(a_table) );
 
-  if( Use_keymap )
-    query_keycode();
-
   if( signal( SIGINT,SIG_IGN ) != SIG_IGN )
     signal( SIGINT,sig_handler );
 
Seulement dans xjump-2.7.5-wii: main.o
diff -ru xjump-2.7.5.orig/Makefile xjump-2.7.5-wii/Makefile
--- xjump-2.7.5.orig/Makefile	2002-01-24 12:44:14.000000000 +0100
+++ xjump-2.7.5-wii/Makefile	2008-05-08 01:38:02.000000000 +0200
@@ -1,7 +1,7 @@
 ########################################################
 
 # 使用するコンパイラとオプションを指定
-CC      = gcc -O2 
+CC      = gcc -O2 -g
 
 # 標準以外のインクルードファイルのディレクトリを指定
 IDIR    = -I/usr/X11R6/include
@@ -27,10 +27,10 @@
 
 ##########################################################
 
-xjump : main.o game.o key.o misc.o record.o resource.o
+xjump : main.o game.o misc.o record.o resource.o
 	$(CC) -o xjump \
-		main.o game.o key.o misc.o record.o resource.o\
-		-lXaw -lXmu -lXt -lXpm -lXext -lX11 $(LDIR)
+		main.o game.o misc.o record.o resource.o\
+		-lXaw -lXmu -lXt -lXpm -lXext -lX11 -lcwiid $(LDIR)
 
 main.o : main.c xjump.h record.h \
 		picture.xpm icon.xbm icon_msk.xbm Makefile
@@ -42,9 +42,6 @@
 game.o : game.c xjump.h
 	$(CC) -c game.c $(IDIR)
 
-key.o : key.c xjump.h
-	$(CC) -c key.c $(IDIR)
-
 misc.o : misc.c
 	$(CC) -c misc.c
 
Seulement dans xjump-2.7.5-wii: misc.o
Seulement dans xjump-2.7.5-wii: record.o
Seulement dans xjump-2.7.5-wii: resource.o
Seulement dans xjump-2.7.5-wii: xjump
diff -ru xjump-2.7.5.orig/xjump.h xjump-2.7.5-wii/xjump.h
--- xjump-2.7.5.orig/xjump.h	1997-10-28 12:45:33.000000000 +0100
+++ xjump-2.7.5-wii/xjump.h	2008-05-08 00:37:49.000000000 +0200
@@ -23,7 +23,6 @@
 #define WIDTH  32
 #define HEIGHT 24
 
-
 typedef struct{
 
   int x;         /* 座標 x */
@@ -73,3 +72,10 @@
 
 #define floor_r(y)  Floor_R[ ( y+Map_index) % HEIGHT ]
 #define floor_l(y)  Floor_L[ ( y+Map_index) % HEIGHT ]
+
+#define toggle_bit(bf,b)    \
+    (bf) = ((bf) & b)       \
+           ? ((bf) & ~(b))  \
+           : ((bf) | (b))
+
+
