PDA

View Full Version : need advise on adding my ir keyboard to pikey



robar810
April 25th, 2008, 20:39
I am wondering how much of a hassle it is to add support for my ir keyboard in pikey. Anyone done this themselves? I know I could just buy a targus board but I would really like to make mine work regardless of the time it takes. It is a dhintec. I have some programming experience oldshcool like in basic and machine language from my C64 days and have experience in programming in C+ and serial device input/output mapping to complete small projects I have done in the past (for the old footbal card hacking direct tv... it was fun while it lasted) so I am hoping this wouldnt be much more difficult. Any pointing in the right directions would be greatly appreaciated :)

robar810
April 25th, 2008, 20:58
well.. i think I got it nailed down as far as what needs to be done..
1) Get familiar with the keyboard!
2) Google for pspirdacapture.zip
Play around and find out what the keyboard sends to PSP
You might have to use your PC if the keyboard has a non 9600
baud mode.
3) Add a new enum to pspirkeyb.h
4) Add a new function handler to pspirkeyb.c and update pspIrKeybSetKeyboard()
5) Add a raw mode map to kbdkeyboards.h
6) Add a new keyboard map to keymap
7) Test with irkeybtest in RAW mode and SCAN mode

I found lots of information at http://www.koders.com/noncode/fidA68D9AF877585F1D3432DB1D04D4FBD8E2587D24.aspx

Once I get my keyboard working for pikey I will post it here nad since I sit home all day ( I have MS.leisions on my brain..) I will take requests for anyone needing support for a ir keyboard that has none as of yet in pikey. Wish me luck! And of course please post any information you think would be useful.


edit--
I have succesfully character mapped what my ir keyboard is sending to my psp but am having trouble making raw mode map in pspirkeyb.c file. on key down it is 192,5,2,*,193 (*=diffrent value on every key) key up is 192,*,*,193 with the 2 values being the same for every key. here is the mapout I have using lua player to run a script that gave me the input values from my keyboard.
ROW1

1- 192,5,2,162,193
192,34,34,193
2- 192,5,2,254,193
192,126,126,193
3- 192,5,2,163,193
192,35,35,193
4- 192,5,2,251,193
192,123,123,193
5- 192,5,2,250,193
192,122,122,193
6- 192,5,2,249,193
192,121,121,193
7- 192,5,2,248,193
192,120,120,193
8- 192,5,2,203,193
192,75,75,193
9- 192,5,2,202,193
192,74,74,193
0- 192,5,2,201,193
192,73,73,193
-- 192,5,2,207,193
192,79,79,193
=- 192,5,2,206,193
192,78,78,193
BKSP- 192,5,2,205,193
192,77,77,193

ROW2

TAB- 192,5,2,230,193
192,102,102,193
Q- 192,5,2,246,193
192,118,118,193
W- 192,5,2,245,193
192,117,117,193
E- 192,5,2,244,193
192,116,116,193
R- 192,5,2,243,193
192,115,115,193
T- 192,5,2,242,193
192,114,114,193
Y- 192,5,2,241,193
192,113,113,193
U- 192,5,2,195,193
192,67,67,193
I- 192,5,2,194,193
192,66,66,193
O- 192,5,2,161,193
192,33,33,193
P- 192,5,2,160,193
192,32,32,193
[- 192,5,2,199,193
192,71,71,193
]- 192,5,2,198,193
192,70,70,193

ROW3

CPLK- 192,5,2,231,193
192,103,103,193
A- 192,5,2238,193
192,110,110,193
S- 192,5,2,237,193
192,109,109,193
D- 192,5,2,236,193
192,108,108,193
F- 192,5,2,235,193
192,107,107,193
G- 192,5,2,234,193
192,106,106,193
H- 192,5,2,233,193
192,105,105,193
J- 192,5,2,187,193
192,59,59,193
K- 192,5,2,186,193
192,58,58,193
L- 192,5,2,185,193
192,57,57,193
;- 192,5,2,184,193
192,56,56,193
'- 192,5,2,191,193
192,63,63,193
ENTR- 192,5,2,190,193
192,62,62,193

ROW4

SHFT- 192,5,2,167,193
192,39,39,193
Z- 192,5,2,252,193
192,124,124,193
X- 192,5,2,239,193
192,111,111,193
C- 192,5,2,211,193
192,83,83,193
V- 192,5,2,210,193
192,82,82,193
B- 192,5,2,209,193
192,81,81,193
N- 192,5,2,208,193
192,80,80,193
M- 192,5,2,179,193
192,51,51,193
,- 192,5,2,178,193
192,50,50,193
.- 192,5,2,177,193
192,49,49,193
/- 192,5,2,183,193
192,55,55,193
UP- 192,5,2,182,193
192,54,54,193
SHFT- 192,5,2,167,193
192,39,39,193

ROW5

CTRL- 192,5,2,229,193
192,101,101,193
CMD- 192,5,2,247,193
192,119,119,193
SYMBL- 192,5,2,240,193
192,112,112,193
FN- 192,5,2,221,193
192,93,93,193
L SPC- 192,5,2,200,193
192,72,72,193
R SPC- 192,5,2,232,193
192,104,104,193
ALT- 192,5,2,220,193
192,92,92,193
DEL- 192,5,2,175,193
192,47,47,193
LEFT- 192,5,2,174,193
192,46,46,193
DWN- 192,5,2,173,193
192,45,45,193
RGHT- 192,5,2,172,193
192,44,44,193


INBOX KEY- 192,5,2,204,193
192,76,76,193
CONTACTS KEY- 192,5,2,196,193
192,68,68,193
CALENDAR KEY- 192,5,2,189,193
192,61,61,193
TASKS KEY- 192,5,2,181,193
192,53,53,193


Anyone have some ideas on what I should change in this below to make it work?? it appears to be the closest to what I need with each key down and up inputing multiple values.

my keyboard is keydown sends=5 with positions 123 and 5 always being the same value and position 4 being diffrent for each key. keyup sends =4 with positions 1 and 4 always being the same value and values 2+3 being a new pair with every difrent key.

This is for a palm.. the one with the closest keydown/keyup sends..
* key down sends: 0xFF 0xC0 key ~key key' 0xC1
* key up sends: 0xFF 0xC0 key+0x80 ~(key+0x80) key'+0x80 0xC1

static int palmuw(unsigned char* buffer, int *length)
{
unsigned char keycode=0;
unsigned int key_down=0;
unsigned char buf1;
int len;
static int pi = 0;
static unsigned char pbuf[6] = {0,0,0,0,0,0};

loop:
len = sceIoRead(g_irdafd, &buf1, 1);
if (len <= 0)
return -1;
// must be 1... can't be anything else at this point
if (pi == 0)
{
// wait on 0xff
if (buf1 == 0xff)
{
pbuf[0] = 0xff;
pi++;
}
goto loop;
}

pbuf[pi] = buf1;
pi++;
if (pi < 6)
goto loop;

pi = 0;

/* resume display */
scePowerTick(0);

//printf( "0%c - %d\n", buf[0], buf[0] );
//printf( "1%c - %d\n", buf[1], buf[1] );
//printf( "5%c - %d\n", buf[5], buf[5] );

if( pbuf[0] != 0xff || pbuf[1] != 0xc0 || pbuf[5] != 0xc1 )
return -1;

//printf( "2%c - %d\n", buf[2], buf[2] );
//printf( "3%c - %d\n", buf[3], buf[3] );

if( ( pbuf[2] + pbuf[3] ) != 0xff )
return -1;

/* 3rd pos is the key we need */
keycode = pbuf[2];

if( keycode < 128 )
key_down = 1;
else
keycode -= 128;

if ( key_down ) {
//if (debug)
//fprintf(stdout,"press %d\n", keycode);
keymap_decode( g_outputmode, palmuw_normal[keycode], KEY_PRESSED, buffer, length );
} else {
//if (debug)
//fprintf(stderr,"release %d\n", keycode);
keymap_decode( g_outputmode, palmuw_normal[keycode], KEY_RELEASED, buffer, length );
}

return 0;
}



Once again.. any help is greatly appreaciated..

zx-81
April 26th, 2008, 14:25
You can post your comments on ps2dev, i'm sure you will find help over there.

The 7 points you described are the good way to add a new keyboard. About your particular dhintec keyboard, you have to find the closet existing driver (in your case it seems to be the palm one).

I haven't written a driver keyboard myself but only used existing one (in irkeyboard library).

I'm using this simple program to test my targus :
http://zx81.zx81.free.fr/serendipity/index.php?/categories/8-Keyboard

I wish you good luck :)

robar810
April 26th, 2008, 14:29
I am trying. I tried registering at ps2dev but it wont send me the confirmation email and there is no link to contact an administrator so I cannot post there... very fustrating. thanx for the program link.

kloplop321
April 26th, 2008, 15:54
you could make a new keymap or just edit the keymap. I would start by finding the keycodes to all the keys and doing stuff like

[keycode_number_here]
Normal = '(letter/number here)';
Shift = '(well... you know what shift does)';

here is a list of the scan codes with the name that you can use in the config as well.
KEYNAME_ENTRY key_names[] =
{
{ KEY_ESC , "ESC" },// 001
{ KEY_1 , "1" },// 002
{ KEY_2 , "2" },// 003
{ KEY_3 , "3" },// 004
{ KEY_4 , "4" },// 005
{ KEY_5 , "5" },// 006
{ KEY_6 , "6" },// 007
{ KEY_7 , "7" },// 008
{ KEY_8 , "8" },// 009
{ KEY_9 , "9" },// 010
{ KEY_0 , "0" },// 011
{ KEY_MINUS , "MINUS" },// 012
{ KEY_EQUAL , "EQUAL" },// 013
{ KEY_BACKSPACE , "BACKSPACE" },// 014
{ KEY_TAB , "TAB" },// 015
{ KEY_Q , "Q" },// 016
{ KEY_W , "W" },// 017
{ KEY_E , "E" },// 018
{ KEY_R , "R" },// 019
{ KEY_T , "T" },// 020
{ KEY_Y , "Y" },// 021
{ KEY_U , "U" },// 022
{ KEY_I , "I" },// 023
{ KEY_O , "O" },// 024
{ KEY_P , "P" },// 025
{ KEY_LEFTBRACE , "LEFTBRACE" },// 026
{ KEY_RIGHTBRACE , "RIGHTBRACE" },// 027
{ KEY_ENTER , "ENTER" },// 028
{ KEY_LEFTCTRL , "LEFTCTRL" },// 029
{ KEY_A , "A" },// 030
{ KEY_S , "S" },// 031
{ KEY_D , "D" },// 032
{ KEY_F , "F" },// 033
{ KEY_G , "G" },// 034
{ KEY_H , "H" },// 035
{ KEY_J , "J" },// 036
{ KEY_K , "K" },// 037
{ KEY_L , "L" },// 038
{ KEY_SEMICOLON , "SEMICOLON" },// 039
{ KEY_APOSTROPHE , "APOSTROPHE" },// 040
{ KEY_GRAVE , "GRAVE" },// 041
{ KEY_LEFTSHIFT , "LEFTSHIFT" },// 042
{ KEY_BACKSLASH , "BACKSLASH" },// 043
{ KEY_Z , "Z" },// 044
{ KEY_X , "X" },// 045
{ KEY_C , "C" },// 046
{ KEY_V , "V" },// 047
{ KEY_B , "B" },// 048
{ KEY_N , "N" },// 049
{ KEY_M , "M" },// 050
{ KEY_COMMA , "COMMA" },// 051
{ KEY_DOT , "DOT" },// 052
{ KEY_SLASH , "SLASH" },// 053
{ KEY_RIGHTSHIFT , "RIGHTSHIFT" },// 054
{ KEY_KPASTERISK , "KPASTERISK" },// 055
{ KEY_LEFTALT , "LEFTALT" },// 056
{ KEY_SPACE , "SPACE" },// 057
{ KEY_CAPSLOCK , "CAPSLOCK" },// 058
{ KEY_F1 , "F1" },// 059
{ KEY_F2 , "F2" },// 060
{ KEY_F3 , "F3" },// 061
{ KEY_F4 , "F4" },// 062
{ KEY_F5 , "F5" },// 063
{ KEY_F6 , "F6" },// 064
{ KEY_F7 , "F7" },// 065
{ KEY_F8 , "F8" },// 066
{ KEY_F9 , "F9" },// 067
{ KEY_F10 , "F10" },// 068
{ KEY_NUMLOCK , "NUMLOCK" },// 069
{ KEY_SCROLLLOCK , "SCROLLLOCK" },// 070
{ KEY_KP7 , "KP7" },// 071
{ KEY_KP8 , "KP8" },// 072
{ KEY_KP9 , "KP9" },// 073
{ KEY_KPMINUS , "KPMINUS" },// 074
{ KEY_KP4 , "KP4" },// 075
{ KEY_KP5 , "KP5" },// 076
{ KEY_KP6 , "KP6" },// 077
{ KEY_KPPLUS , "KPPLUS" },// 078
{ KEY_KP1 , "KP1" },// 079
{ KEY_KP2 , "KP2" },// 080
{ KEY_KP3 , "KP3" },// 081
{ KEY_KP0 , "KP0" },// 082
{ KEY_KPDOT , "KPDOT" },// 083
{ KEY_103RD , "103RD" },// 084
{ KEY_F13 , "F13" },// 085
{ KEY_102ND , "102ND" },// 086
{ KEY_F11 , "F11" },// 087
{ KEY_F12 , "F12" },// 088
{ KEY_F14 , "F14" },// 089
{ KEY_F15 , "F15" },// 090
{ KEY_F16 , "F16" },// 091
{ KEY_F17 , "F17" },// 092
{ KEY_F18 , "F18" },// 093
{ KEY_F19 , "F19" },// 094
{ KEY_F20 , "F20" },// 095
{ KEY_KPENTER , "KPENTER" },// 096
{ KEY_RIGHTCTRL , "RIGHTCTRL" },// 097
{ KEY_KPSLASH , "KPSLASH" },// 098
{ KEY_SYSRQ , "SYSRQ" },// 099
{ KEY_RIGHTALT , "RIGHTALT" },// 100
{ KEY_LINEFEED , "LINEFEED" },// 101
{ KEY_HOME , "HOME" },// 102
{ KEY_UP , "UP" },// 103
{ KEY_PAGEUP , "PAGEUP" },// 104
{ KEY_LEFT , "LEFT" },// 105
{ KEY_RIGHT , "RIGHT" },// 106
{ KEY_END , "END" },// 107
{ KEY_DOWN , "DOWN" },// 108
{ KEY_PAGEDOWN , "PAGEDOWN" },// 109
{ KEY_INSERT , "INSERT" },// 110
{ KEY_DELETE , "DELETE" },// 111
{ KEY_MACRO , "MACRO" },// 112
{ KEY_MUTE , "MUTE" },// 113
{ KEY_VOLUMEDOWN , "VOLUMEDOWN" },// 114
{ KEY_VOLUMEUP , "VOLUMEUP" },// 115
{ KEY_POWER , "POWER" },// 116
{ KEY_KPEQUAL , "KPEQUAL" },// 117
{ KEY_KPPLUSMINUS , "KPPLUSMINUS" },// 118
{ KEY_PAUSE , "PAUSE" },// 119
{ KEY_F21 , "F21" },// 120
{ KEY_F22 , "F22" },// 121
{ KEY_F23 , "F23" },// 122
{ KEY_F24 , "F24" },// 123
{ KEY_KPCOMMA , "KPCOMMA" },// 124
{ KEY_LEFTMETA , "LEFTMETA" },// 125
{ KEY_RIGHTMETA , "RIGHTMETA" },// 126
{ KEY_COMPOSE , "COMPOSE" },// 127
{ KEY_STOP , "STOP" },// 128
{ KEY_AGAIN , "AGAIN" },// 129
{ KEY_PROPS , "PROPS" },// 130
{ KEY_UNDO , "UNDO" },// 131
{ KEY_FRONT , "FRONT" },// 132
{ KEY_COPY , "COPY" },// 133
{ KEY_OPEN , "OPEN" },// 134
{ KEY_PASTE , "PASTE" },// 135
{ KEY_FIND , "FIND" },// 136
{ KEY_CUT , "CUT" },// 137
{ KEY_HELP , "HELP" },// 138
{ KEY_MENU , "MENU" },// 139
{ KEY_CALC , "CALC" },// 140
{ KEY_SETUP , "SETUP" },// 141
{ KEY_SLEEP , "SLEEP" },// 142
{ KEY_WAKEUP , "WAKEUP" },// 143
{ KEY_FILE , "FILE" },// 144
{ KEY_SENDFILE , "SENDFILE" },// 145
{ KEY_DELETEFILE , "DELETEFILE" },// 146
{ KEY_XFER , "XFER" },// 147
{ KEY_PROG1 , "PROG1" },// 148
{ KEY_PROG2 , "PROG2" },// 149
{ KEY_WWW , "WWW" },// 150
{ KEY_MSDOS , "MSDOS" },// 151
{ KEY_COFFEE , "COFFEE" },// 152
{ KEY_DIRECTION , "DIRECTION" },// 153
{ KEY_CYCLEWINDOWS , "CYCLEWINDOWS" },// 154
{ KEY_MAIL , "MAIL" },// 155
{ KEY_BOOKMARKS , "BOOKMARKS" },// 156
{ KEY_COMPUTER , "COMPUTER" },// 157
{ KEY_BACK , "BACK" },// 158
{ KEY_FORWARD , "FORWARD" },// 159
{ KEY_CLOSECD , "CLOSECD" },// 160
{ KEY_EJECTCD , "EJECTCD" },// 161
{ KEY_EJECTCLOSECD , "EJECTCLOSECD" },// 162
{ KEY_NEXTSONG , "NEXTSONG" },// 163
{ KEY_PLAYPAUSE , "PLAYPAUSE" },// 164
{ KEY_PREVIOUSSONG , "PREVIOUSSONG" },// 165
{ KEY_STOPCD , "STOPCD" },// 166
{ KEY_RECORD , "RECORD" },// 167
{ KEY_REWIND , "REWIND" },// 168
{ KEY_PHONE , "PHONE" },// 169
{ KEY_ISO , "ISO" },// 170
{ KEY_CONFIG , "CONFIG" },// 171
{ KEY_HOMEPAGE , "HOMEPAGE" },// 172
{ KEY_REFRESH , "REFRESH" },// 173
{ KEY_EXIT , "EXIT" },// 174
{ KEY_MOVE , "MOVE" },// 175
{ KEY_EDIT , "EDIT" },// 176
{ KEY_SCROLLUP , "SCROLLUP" },// 177
{ KEY_SCROLLDOWN , "SCROLLDOWN" },// 178
{ KEY_KPLEFTPAREN , "KPLEFTPAREN" },// 179
{ KEY_KPRIGHTPAREN , "KPRIGHTPAREN" },// 180
{ KEY_INTL1 , "INTL1" },// 181
{ KEY_INTL2 , "INTL2" },// 182
{ KEY_INTL3 , "INTL3" },// 183
{ KEY_INTL4 , "INTL4" },// 184
{ KEY_INTL5 , "INTL5" },// 185
{ KEY_INTL6 , "INTL6" },// 186
{ KEY_INTL7 , "INTL7" },// 187
{ KEY_INTL8 , "INTL8" },// 188
{ KEY_INTL9 , "INTL9" },// 189
{ KEY_LANG1 , "LANG1" },// 190
{ KEY_LANG2 , "LANG2" },// 191
{ KEY_LANG3 , "LANG3" },// 192
{ KEY_LANG4 , "LANG4" },// 193
{ KEY_LANG5 , "LANG5" },// 194
{ KEY_LANG6 , "LANG6" },// 195
{ KEY_LANG7 , "LANG7" },// 196
{ KEY_LANG8 , "LANG8" },// 197
{ KEY_LANG9 , "LANG9" },// 198
{ KEY_PLAYCD , "PLAYCD" },// 199
{ KEY_PAUSECD , "PAUSECD" },// 200
{ KEY_PROG3 , "PROG3" },// 201
{ KEY_PROG4 , "PROG4" },// 202
{ KEY_SUSPEND , "SUSPEND" },// 203
{ KEY_CLOSE , "CLOSE" },// 204
{ KEY_UNKNOWN , "UNKNOWN" },// 205
{ KEY_BRIGHTNESSDOWN , "BRIGHTNESSDOWN"},// 206
{ KEY_BRIGHTNESSUP , "BRIGHTNESSUP" },// 207

// terminator
{ 0, NULL },
};

robar810
April 26th, 2008, 19:21
That helps some but just making a new keymap wont work. The keyboard I have sends 5 chars on keydown and 4 on keyup. thats 9 chars for one keystroke. I have to figure out how to edit the pspirbkey.c file. I have to make it ignore the 1,2,3,5 chars in the keydown and the 1,4 in keyup. The entry I am trying to edit to accomplish this just doesnt seem to make sense.... the math just isnt adding up. Thanks for that list of scancodes though... I didnt have them.