]> git.ozlabs.org Git - petitboot/commitdiff
Add ps3 controller support
authorJeremy Kerr <jk@ozlabs.org>
Thu, 23 Aug 2007 07:36:34 +0000 (15:36 +0800)
committerJeremy Kerr <jk@ozlabs.org>
Thu, 23 Aug 2007 08:27:29 +0000 (16:27 +0800)
Using the new twin joystick API, map some of the sixaxis controller
events to key events.

Signed-off-by: Jeremy Kerr <jk@ozlabs.org>
petitboot.c
utils/ps3-kboot-0.1-petitboot.patch

index f8757689b53b59ef2ebc673a26ee6736d730f29f..fc72fd8103c95f2c59bc235ccf36fa49a394597f 100644 (file)
@@ -14,6 +14,7 @@
 
 #include <libtwin/twin.h>
 #include <libtwin/twin_linux_mouse.h>
+#include <libtwin/twin_linux_js.h>
 #include <libtwin/twin_png.h>
 #include <libtwin/twin_jpeg.h>
 
@@ -141,6 +142,30 @@ static pboot_lpane_t       *pboot_lpane;
 static pboot_rpane_t   *pboot_rpane;
 static pboot_spane_t   *pboot_spane;
 
+/* control to keyboard mappings for the sixaxis controller */
+uint8_t sixaxis_map[] = {
+       0,              /*   0  Select          */
+       0,              /*   1  L3              */
+       0,              /*   2  R3              */
+       0,              /*   3  Start           */
+       KEY_UP,         /*   4  Dpad Up         */
+       KEY_RIGHT,      /*   5  Dpad Right      */
+       KEY_DOWN,       /*   6  Dpad Down       */
+       KEY_LEFT,       /*   7  Dpad Left       */
+       0,              /*   8  L2              */
+       0,              /*   9  R2              */
+       0,              /*  10  L1              */
+       0,              /*  11  R1              */
+       0,              /*  12  Triangle        */
+       KEY_ENTER,      /*  13  Circle          */
+       0,              /*  14  Cross           */
+       KEY_DELETE,     /*  15  Square          */
+       0,              /*  16  PS Button       */
+       0,              /*  17  nothing      */
+       0,              /*  18  nothing      */
+};
+
+
 static int pboot_vmode_change = -1;
 
 /* XXX move to twin */
@@ -729,6 +754,20 @@ twin_bool_t pboot_event_filter(twin_screen_t           *screen,
                                               pboot_cursor_hx,
                                               pboot_cursor_hy);
                break;
+       case TwinEventJoyButton:
+               /* map joystick events into key events */
+               if (event->u.js.control >= sizeof(sixaxis_map))
+                       break;
+
+               event->u.key.key = sixaxis_map[event->u.js.control];
+               if (event->u.js.value == 0) {
+                       event->kind = TwinEventKeyUp;
+                       break;
+               } else {
+                       event->kind = TwinEventKeyDown;
+               }
+
+               /* fall through.. */
        case TwinEventKeyDown:
                switch(event->u.key.key) {
                /* Gross hack for video modes, need something better ! */
@@ -1099,6 +1138,7 @@ int main(int argc, char **argv)
        }
        pboot_screen = pboot_fbdev->screen;
        twin_linux_mouse_create(NULL, pboot_screen);
+       twin_linux_js_create(pboot_screen);
 
        if (pboot_fbdev != NULL) {
                char *cursor_path = artwork_pathname("cursor.gz");
index a33fa24697c40cd53129a2c64f460dd6602144f7..bd1d20748c1f7d5db29955a84c1d32c441423a34 100644 (file)
@@ -7,12 +7,13 @@ More info at http://ozlabs.org/~jk/projects/petitboot/
 
 --- ps3-kboot.orig/ps3-kboot-0.1/Makefile      2007-04-05 20:10:44.000000000 +1000
 +++ ps3-kboot/ps3-kboot-0.1/Makefile   2007-04-04 20:54:40.000000000 +1000
-@@ -20,6 +20,8 @@
+@@ -20,6 +20,9 @@
  LOCAL_KERNEL_CONFIG=$(PWD)/config/kernel-config
  LOCAL_KBOOT_CONF=$(PWD)/config/kboot.conf
  LOCAL_FSTAB=$(PWD)/config/fstab
 +LOCAL_UDEV_RULES=$(PWD)/config/65-persistent-storage.rules \
-+               $(PWD)/config/99-petitboot.rules
++               $(PWD)/config/99-petitboot.rules \
++              $(PWD)/config/20-input-names.rules
  KBOOT_MESSAGE=$(PWD)/config/message
  KBOOT_FEATURES=$(PWD)/config/kboot-features
  
@@ -305,3 +306,38 @@ diff -urN ps3-kboot.orig/ps3-kboot-0.1/scripts/petitboot-init ps3-kboot/ps3-kboo
  Standards-Version: 3.6.1
  
  Package: ps3-kboot
+--- ps3-kboot.orig/config/kernel-config        2007-06-27 14:25:08.000000000 +1000
++++ ps3-kboot/config/kernel-config 7-06-27 14:28:28.000000000 +1000
+@@ -449,10 +449,13 @@
+ #
+ # Userland interfaces
+ #
+-# CONFIG_INPUT_MOUSEDEV is not set
+-# CONFIG_INPUT_JOYDEV is not set
++CONFIG_INPUT_MOUSEDEV=y
++# CONFIG_INPUT_MOUSEDEV_PSAUX is not set
++CONFIG_INPUT_MOUSEDEV_SCREEN_X=1024
++CONFIG_INPUT_MOUSEDEV_SCREEN_Y=768
++CONFIG_INPUT_JOYDEV=y
+ # CONFIG_INPUT_TSDEV is not set
+-# CONFIG_INPUT_EVDEV is not set
++CONFIG_INPUT_EVDEV=y
+ # CONFIG_INPUT_EVBUG is not set
+ #
+@@ -668,6 +671,7 @@
+ # CONFIG_USB_STORAGE_SDDR55 is not set
+ # CONFIG_USB_STORAGE_JUMPSHOT is not set
+ # CONFIG_USB_STORAGE_ALAUDA is not set
++# CONFIG_USB_STORAGE_ONETOUCH is not set
+ # CONFIG_USB_LIBUSUAL is not set
+ #
+-- /dev/null   2007-04-18 20:56:03.000000000 +1000
++++ ps3-kboot-0.1/config/20-input-names.rules   2007-06-27 14:34:05.000000000 +1000
+@@ -0,0 +1,5 @@
++# Input devices, group under /dev/input
++KERNEL=="event[0-9]*",                 NAME="input/%k"
++KERNEL=="mice",                                NAME="input/%k"
++KERNEL=="mouse[0-9]*",                 NAME="input/%k"
++KERNEL=="js[0-9]*",                    NAME="input/%k"