root/platform/sx260hs/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 @0xff441578, levent 0x101
  22     { 1, KEY_SHOOT_FULL      ,0x03000000 }, // Found @0xff441588, levent 0x01
  23     { 1, KEY_SHOOT_FULL_ONLY ,0x02000000 }, // Found @0xff441588, levent 0x01
  24     { 1, KEY_SHOOT_HALF      ,0x01000000 }, // Found @0xff441580, levent 0x00
  25     { 1, KEY_ZOOM_OUT        ,0x0C000000 }, // Asm1989 Manual stuff
  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 @0xff4415d8, levent 0x1a
  32     { 2, KEY_MENU            ,0x00000040 }, // Found @0xff4415e0, levent 0x09
  33     { 2, KEY_DISPLAY         ,0x00000080 }, // Found @0xff4415e8, levent 0x0a
  34     { 2, KEY_UP              ,0x00000100 }, // Found @0xff4415f0, levent 0x04
  35     { 2, KEY_DOWN            ,0x00000200 }, // Found @0xff4415f8, levent 0x05
  36     { 2, KEY_RIGHT           ,0x00000400 }, // Found @0xff441600, levent 0x07
  37     { 2, KEY_LEFT            ,0x00000800 }, // Found @0xff441608, levent 0x06
  38     { 2, KEY_SET             ,0x00001000 }, // Found @0xff441610, 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 int jogdial_stopped=0;
  62 
  63 long __attribute__((naked,noinline)) wrap_kbd_p1_f() {
  64 
  65     asm volatile(
  66                 "STMFD   SP!, {R1-R7,LR}\n"
  67                 "MOV     R5, #0\n"
  68                 "BL      my_kbd_read_keys\n"
  69                 "B       _kbd_p1_f_cont\n"
  70     );
  71 
  72     return 0;
  73 }
  74 
  75 // no stack manipulation needed here, since we create the task directly
  76 void __attribute__((noinline)) mykbd_task() {
  77     while (physw_run) {
  78         _SleepTask(physw_sleep_delay);
  79 
  80         if (wrap_kbd_p1_f() == 1) {             // autorepeat ?
  81             _kbd_p2_f();
  82         }
  83     }
  84 
  85     _ExitTask();
  86 }
  87 
  88 // copied from g12 and sx30, thx to philmoz
  89 // Pointer to stack location where jogdial task records previous and current
  90 // jogdial positions
  91 
  92 extern short* jog_position;
  93 
  94 void jogdial_control(int n) {
  95     if (jogdial_stopped && !n) {
  96         // If re-enabling jogdial set the task code current & previous positions to the actual
  97         // dial positions so that the change won't get processed by the firmware
  98         jog_position[0] = jog_position[2] = (*(short*)0xC0240106);  //TODO SX230 CODE  Rear dial
  99     }
 100     jogdial_stopped = n;
 101 }
 102 
 103 void my_kbd_read_keys() {
 104     kbd_update_key_state();
 105     kbd_update_physw_bits();
 106 }
 107 
 108 void kbd_fetch_data(long *dst)
 109 {
 110     _GetKbdState(dst);
 111     _kbd_read_keys_r2(dst);
 112 }
 113 
 114 ///
 115 int Get_JogDial(void) {
 116     return (*(int*)0xC0240104)>>16;     //TODO SX230 CODE 0xC0240000 + 0x104
 117 }
 118 
 119 static int new_jogdial = 0, old_jogdial = 0;
 120 
 121 long get_jogdial_direction(void) {
 122     old_jogdial=new_jogdial;
 123     new_jogdial=Get_JogDial();
 124 
 125     if (old_jogdial<new_jogdial) {
 126         return JOGDIAL_LEFT;
 127     } else if (old_jogdial>new_jogdial) {
 128         return JOGDIAL_RIGHT;
 129     } else {
 130         return 0;
 131     }
 132 }

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