root/platform/sx230hs/kbd.c

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

DEFINITIONS

This source file includes following definitions.
  1. get_usb_bit
  2. my_blinkk
  3. mykbd_task
  4. jogdial_control
  5. my_kbd_read_keys
  6. kbd_fetch_data
  7. Get_JogDial
  8. 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 
  13 int get_usb_bit() 
  14 {
  15         long usb_physw[3];
  16         usb_physw[USB_IDX] = 0;
  17         _kbd_read_keys_r2(usb_physw);
  18         return(( usb_physw[USB_IDX] & USB_MASK)==USB_MASK) ; 
  19 }
  20 
  21 KeyMap keymap[] = {
  22     { 0, KEY_ZOOM_OUT        , 0x00000003 },
  23     { 0, KEY_ZOOM_OUT        , 0x00000001 },
  24     { 0, KEY_ZOOM_OUT        , 0x00000002 },
  25     { 0, KEY_ZOOM_IN         , 0x0000000C },
  26     { 0, KEY_ZOOM_IN         , 0x00000004 },
  27     { 0, KEY_ZOOM_IN         , 0x00000008 },
  28     { 0, KEY_UP_SOFT         , 0x00000400 },
  29     { 0, KEY_DISPLAY         , 0x00000800 },
  30     { 0, KEY_UP              , 0x00001000 },
  31     { 0, KEY_RIGHT_SOFT      , 0x00002000 },
  32     { 0, KEY_RIGHT           , 0x00006000 },
  33     { 0, KEY_DOWN_SOFT       , 0x00008000 },
  34     { 0, KEY_SET             , 0x00010000 },
  35     { 0, KEY_DOWN            , 0x00020000 },
  36     { 0, KEY_MENU            , 0x00040000 },
  37     { 0, KEY_VIDEO           , 0x00080000 },
  38 
  39     { 1, KEY_PLAYBACK        , 0x00200000 },
  40 
  41     { 2, KEY_LEFT_SOFT       , 0x00000080 },
  42     { 2, KEY_LEFT            , 0x00000100 },
  43     { 2, KEY_SHOOT_FULL      , 0x00002002 },
  44     { 2, KEY_SHOOT_FULL_ONLY , 0x00000002 },
  45     { 2, KEY_SHOOT_HALF      , 0x00002000 },
  46 
  47     { 0, 0, 0 }
  48 };
  49 
  50 
  51 #if 0
  52 void my_blinkk(void) {
  53         int i;
  54         while(1) {
  55                 *((volatile int *) 0xC0220130) = 0x46; // Turn on LED
  56                 for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  57 
  58                 *((volatile int *) 0xC0220130) = 0x44; // Turn off LED
  59                 for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  60 
  61                 *((volatile int *) 0xC0220130) = 0x46; // Turn on LED
  62                 for (i=0; i<0x200000; i++) { asm volatile ( "nop\n" ); }
  63 
  64                 *((volatile int *) 0xC0220130) = 0x44; // Turn off LED
  65                 for (i=0; i<0x900000; i++) { asm volatile ( "nop\n" ); }
  66         }
  67 }
  68 #endif
  69 
  70 int jogdial_stopped=0;
  71 
  72 extern long __attribute__((naked)) wrap_kbd_p1_f();
  73 
  74 // no stack manipulation needed here, since we create the task directly
  75 void __attribute__((noinline)) mykbd_task() {
  76         while (physw_run) {
  77         _SleepTask(physw_sleep_delay); //  @FF0248AC
  78 
  79                 if (wrap_kbd_p1_f() == 1) {   // autorepeat ?
  80                 _kbd_p2_f();
  81         }
  82     }
  83 
  84 // function can be modified to restore SP here...
  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 {
  96     if (jogdial_stopped && !n)
  97     {
  98         // If re-enabling jogdial set the task code current & previous positions to the actual
  99         // dial positions so that the change won't get processed by the firmware
 100         jog_position[0] = jog_position[2] = (*(short*)0xC0240106);  // Rear dial
 101     }
 102     jogdial_stopped = n;
 103 }
 104 
 105 void my_kbd_read_keys()
 106 {
 107     kbd_update_key_state();
 108     kbd_update_physw_bits();
 109 }
 110 
 111 void kbd_fetch_data(long *dst)
 112 {
 113     _GetKbdState(dst);
 114     _kbd_read_keys_r2(dst);
 115 }
 116 
 117 int Get_JogDial(void) {
 118         return (*(int*)0xC0240104)>>16;     // 0xC0240000 + 0x104
 119 }
 120 
 121 static int new_jogdial=0, old_jogdial=0;
 122 
 123 long get_jogdial_direction(void) {
 124         old_jogdial=new_jogdial;
 125     new_jogdial=Get_JogDial();
 126 
 127     if (old_jogdial<new_jogdial) {
 128         return JOGDIAL_RIGHT;
 129     } else if (old_jogdial>new_jogdial) {
 130         return JOGDIAL_LEFT;
 131     } else {
 132         return 0;
 133     }
 134 }

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