just deleted useless files
[ppcskel.git] / main.c
diff --git a/main.c b/main.c
index 62116920a79401ed597fd10b3727ec5797da5b1d..a058cfe93d7efd138d2fa467af90e84bdb0372c0 100644 (file)
--- a/main.c
+++ b/main.c
@@ -24,8 +24,11 @@ Copyright (C) 2009              John Kelley <wiidev@kelley.ca>
 #include "video_low.h"
 #include "input.h"
 #include "console.h"
-#include "ohci.h"
 #include "irq.h"
+#include "usb/core/core.h"
+#include "usb/drivers/class/hid.h"
+#include "sha1.h"
+#include "hollywood.h"
 
 #define MINIMUM_MINI_VERSION 0x00010001
 
@@ -85,15 +88,19 @@ int main(void)
        dsp_reset();
 
        irq_initialize();
-       irq_enable(IRQ_OHCI0);
-       
+       irq_bw_enable(BW_PI_IRQ_RESET);
+       irq_bw_enable(BW_PI_IRQ_HW); //hollywood pic
+       /* external ohci */
+       irq_hw_enable(IRQ_OHCI0);
+       /* internal ohci */
+       //irq_hw_enable(IRQ_OHCI1);
+
        ipc_initialize();
        ipc_slowping();
 
        gecko_init();
     input_init();
        init_fb(vmode);
-       ohci_init();
 
        VIDEO_Init(vmode);
        VIDEO_SetFrameBuffer(get_xfb());
@@ -112,19 +119,68 @@ int main(void)
                        ; // better ideas welcome!
        }
 
-    print_str_noscroll(112, 112, "ohai, world!\n");
+       /* external ohci */
+       usb_init(OHCI0_REG_BASE);
 
-       testOTP();
+       /* internal ohci */
+       usb_init(OHCI1_REG_BASE);
 
-       printf("bye, world!\n");
+       /* load HID keyboard driver */
+       usb_hidkb_init();
+
+       /* wait for usb keyboard plugged in */
+       if(!usb_hidkb_inuse()) {
+               print_str("plug in an usb keyboard", 23);
+       }
+       while(!usb_hidkb_inuse());
+
+       /* you are welcome to make this nice :) */
+       char str[7];
+       u16 i, j, y=20, x=20;
+       struct kbrep *k;
 
        while(1) {
-               // just to get sure we are still in this loop
-               //wtf? _CPU_ISR_Enable() // don't know why this is needed...
-               udelay(100000);
-               printf("x");
+               memset(str, '\0', 8);
+               j=0;
+               k = usb_hidkb_getChars();
+               for(i=0; k->keys[i]>0; i++) {
+                       if(x>650) {
+                               x = 20;
+                               y += 15;
+                       }
+                       if(y>440) {
+                               y=20;
+                       }
+                       if((k->keys[i] >= 4) && k->keys[i] <= 4+'z'-'a') {
+                               str[j] = k->keys[i] - 4 + (k->mod & MOD_lshift || k->mod & MOD_rshift ? 'A' : 'a');
+                       } else if ((k->keys[i] >= 0x1e) && (k->keys[i] <= 0x26)) {
+                               str[j] = k->keys[i] - 0x1e + '1';
+                       } else if (k->keys[i] == 0x27) {
+                               str[j] = '0';
+                       }
+                       else if (k->keys[i] == 0x28) {
+                               y += 15;
+                               x = 20;
+                       }
+                       j++;
+               }
+               if(j > 0) {
+                       print_str_noscroll(x, y, str);
+                       printf("y: %d\n", y);
+               }
+               while(j--) {
+                       x += 13;
+               }
        }
 
+#if 0
+       printf("===============================\n");
+
+       SHA1TestCases();
+
+       printf("bye, world!\n");
+#endif
+
        return 0;
 }