root/platform/sx240hs/kbd.c

/* [<][>][^][v][top][bottom][index][help] */

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. my_blinkk
  3. wrap_kbd_p1_f
  4. mykbd_task
  5. jogdial_control
  6. my_kbd_read_keys
  7. kbd_fetch_data
  8. Get_JogDial
  9. get_jogdial_direction

   1 #include "lolevel.h"
   2 #include "platform.h"
   3 #include "keyboard.h"
   4 #include "kbd_common.h"
   5 
   6 long kbd_new_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   7 long kbd_prev_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   8 long kbd_mod_state[3] = { 0xFFFFFFFF, 0xFFFFFFFF, 0xFFFFFFFF };
   9 
  10 extern void _GetKbdState(long*);
  11 
  12 int get_usb_bit() {
  13     long usb_physw[3];
  14     usb_physw[USB_IDX] = 0;
  15     _kbd_read_keys_r2(usb_physw);
  16     return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ;
  17 }
  18 
  19 // Using Finsig
  20 KeyMap keymap[] = {
  21     { 1, KEY_PLAYBACK        ,0x00800000 }, // Found @0xff441550, levent 0x101
  22     { 1, KEY_SHOOT_FULL      ,0x03000000 }, // Found @0xff441560, levent 0x01
  23     { 1, KEY_SHOOT_FULL_ONLY ,0x02000000 }, // Found @0xff441560, levent 0x01
  24     { 1, KEY_SHOOT_HALF      ,0x01000000 }, // Found @0xff441558, levent 0x00
  25     { 1, KEY_ZOOM_OUT        ,0x0C000000 },    // From sx260hs
  26     { 1, KEY_ZOOM_OUT        ,0x04000000 },
  27     { 1, KEY_ZOOM_OUT        ,0x08000000 },
  28     { 1, KEY_ZOOM_IN         ,0x30000000 },
  29     { 1, KEY_ZOOM_IN         ,0x10000000 },
  30     { 1, KEY_ZOOM_IN         ,0x20000000 },
  31     { 2, KEY_VIDEO           ,0x00000020 }, // Found @0xff4415b0, levent 0x1a
  32     { 2, KEY_MENU            ,0x00000040 }, // Found @0xff4415b8, levent 0x09
  33     { 2, KEY_DISPLAY         ,0x00000080 }, // Found @0xff4415c0, levent 0x0a
  34     { 2, KEY_UP              ,0x00000100 }, // Found @0xff4415c8, levent 0x04
  35     { 2, KEY_DOWN            ,0x00000200 }, // Found @0xff4415d0, levent 0x05
  36     { 2, KEY_RIGHT           ,0x00000400 }, // Found @0xff4415d8, levent 0x07
  37     { 2, KEY_LEFT            ,0x00000800 }, // Found @0xff4415e0, levent 0x06
  38     { 2, KEY_SET             ,0x00001000 }, // Found @0xff4415e8, levent 0x08
  39     { 0, 0, 0 }
  40 };
  41 
  42 
  43 #if 0
  44 void my_blinkk(void) {
  45     int i;
  46     while(1) {
  47         *((volatile int *) 0xC0220130) = 0x46;  // Turn on LED
  48         for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  49 
  50         *((volatile int *) 0xC0220130) = 0x44;  // Turn off LED
  51         for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  52 
  53         *((volatile int *) 0xC0220130) = 0x46;  // Turn on LED
  54         for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  55 
  56         *((volatile int *) 0xC0220130) = 0x44;  // Turn off LED
  57         for (i=0; i<0x900000; i++) { asm volatile ( "nop\n" ); }
  58     }
  59 }
  60 #endif
  61 
  62 int jogdial_stopped=0;
  63 
  64 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  65 
  66     asm volatile(
  67                 "STMFD   SP!, {R1-R7,LR}\n"
  68                 "MOV     R5, #0\n"
  69                 "BL      my_kbd_read_keys\n"
  70                 "B       _kbd_p1_f_cont\n"
  71     );
  72 
  73     return 0;
  74 }
  75 
  76 // no stack manipulation needed here, since we create the task directly
  77 void __attribute__((noinline)) mykbd_task() {
  78     while (physw_run) {
  79         _SleepTask(physw_sleep_delay);
  80 
  81         if (wrap_kbd_p1_f() == 1) {             // autorepeat ?
  82             _kbd_p2_f();
  83         }
  84     }
  85 
  86     _ExitTask();
  87 }
  88 
  89 // copied from g12 and sx30, thx to philmoz
  90 // Pointer to stack location where jogdial task records previous and current
  91 // jogdial positions
  92 
  93 extern short* jog_position;
  94 
  95 void jogdial_control(int n) {
  96     if (jogdial_stopped && !n) {
  97         // If re-enabling jogdial set the task code current & previous positions to the actual
  98         // dial positions so that the change won't get processed by the firmware
  99         jog_position[0] = jog_position[2] = (*(short*)0xC0240106);  //TODO SX230 CODE  Rear dial
 100     }
 101     jogdial_stopped = n;
 102 }
 103 
 104 void my_kbd_read_keys() {
 105     kbd_update_key_state();
 106     kbd_update_physw_bits();
 107 }
 108 
 109 void kbd_fetch_data(long *dst)
 110 {
 111     _GetKbdState(dst);
 112     _kbd_read_keys_r2(dst);
 113 }
 114 
 115 ///
 116 int Get_JogDial(void) {
 117     return (*(int*)0xC0240104)>>16;     //TODO SX230 CODE 0xC0240000 + 0x104
 118 }
 119 
 120 static int new_jogdial = 0, old_jogdial = 0;
 121 
 122 long get_jogdial_direction(void) {
 123     old_jogdial=new_jogdial;
 124     new_jogdial=Get_JogDial();
 125 
 126     if (old_jogdial<new_jogdial) {
 127         return JOGDIAL_LEFT;
 128     } else if (old_jogdial>new_jogdial) {
 129         return JOGDIAL_RIGHT;
 130     } else {
 131         return 0;
 132     }
 133 }

/* [<][>][^][v][top][bottom][index][help] */