generic PSP IR Keyboard library now in SVN

Discuss the development of new homebrew software, tools and libraries.

Moderators: cheriff, TyRaNiD

tyranos
Posts: 8
Joined: Thu Apr 20, 2006 10:49 am

Post by tyranos »

@J.F

did u update the hama driver also , or should i send fanjita the updated non blocking code .
anyway i got the prx code also working, but pikey only works partially that i can use the keyboard to browse the xmb but when i try to go to the game menu the psp freezes completely and most of the xmb funktion dont work .

BTW i 'm on 3.03 0e-c,
futaris
Posts: 45
Joined: Wed Dec 28, 2005 7:47 am

Post by futaris »

This is the latest code in SVN:

http://svn.pspdev.org/diff.php?repname= ... =2211&sc=1

I think the non-blocking stuff is already in there for PalmUW and hama.
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

tyranos wrote:@J.F

did u update the hama driver also , or should i send fanjita the updated non blocking code .
anyway i got the prx code also working, but pikey only works partially that i can use the keyboard to browse the xmb but when i try to go to the game menu the psp freezes completely and most of the xmb funktion dont work .

BTW i 'm on 3.03 0e-c,
No, just the palm driver. He was working on problems with pikey on newer OE firmwares, so you might just want to send him the driver code and wait for a newer update and try again.
saintshark
Posts: 3
Joined: Wed Jul 04, 2007 12:29 pm

Apps(with Irda Keyboard Support) crashes with some KBs confs

Post by saintshark »

Hi Fanjita and Montsi!

First of all, i want to congratulate you for rocking, supporting and encouraging the PSP Scene.

Now the motivation for this msg is that i've tried to load the PSPoste(with Irda kb support) changing the parameter of the keyboard and i've obtained these results:

# 1 - Compaq/HP foldable keyboard - APP CRASH!
# 2 - Snap'n'Type - APP CRASH!
# 5 - HP Slim keyboard - APP CRASH!
# 8 - Belkin IR (not IrDA) - APP Loads OK
# 9 - Flexis FX-100 keyboard - APP Loads OK
# 10 - Benq G250 gamepad - APP CRASH!
# 12 - Micro Innovations Foldaway keyboard - APP LoadsOK
# 13 - Micro Innovations Datapad - APP Loads OK
# 14 - Compaq MicroKeyboard - APP CRASH!
# 15 - Targus Universal Wireless keyboard - APP Loads OK
# 18 - Freedom keyboard - APP Loads OK
# 19 - NOVAETS - KIS2 - IR Keyboard - APP Loads OK
# 20 - Palm Universal Wireless Keyboard - APP CRASH!
# 21 - Hama Palm IR keyboard - APP CRASH!

Besides, i've a snapNtype IR keyboard and when i change in the .ini file the 'keyboard' value to number "2" and try to run the PSP-PDA(with irda kb support) it crashed, with a BSOD and address values ended by this line:
"The offending routine may be identified with:

psp-addr2line -e target.elf -f -C 0x8a10138 0xbe540024 0x8a10290"

Any ideas? It's very extrange... there's no obvious reason for these errors. But it happens with all the apps of ZX-81 that i've tried. That makes me think that it's caused by the lib or by the way that ZX-81 use the lib.

I've been checking the code of the lib with no success. I've 3.4 OE FW in my PSP... i'm thinking that probably fanjita or monsti will know what is the problem with the lib or the use of it.

Thanks in advance for all your help and ideas.
saintshark
Posts: 3
Joined: Wed Jul 04, 2007 12:29 pm

piKey with Snap'n'Type

Post by saintshark »

Ok, i've reading Fanjita and then i've decide to install pikey, it's activated in the recovery menu, and i've also modified the ini file with the keyboard = 2.

But when i've push the keys there is only noise... i don't know what is wrong... any ideas? i think that everything indicate some bug in the pspirkeyb lib... what do you think Fanjita?

Probably pikey is the best way for support keyboards on our psp, i will be very happy if someday i can use my snapNtype in my psp :D :D :D

Regards,

saintshark
saintshark
Posts: 3
Joined: Wed Jul 04, 2007 12:29 pm

Reading Keys from a Snap'N'Type

Post by saintshark »

Well like i can't achieve to modify correctly pikey, i'll contribute to the comunity with the scancodes, and the modification of a test of concept i've found in internet and complete with the scancodes of the snapNtype:

Code: Select all

/*
 * PSP Software Development Kit - http://www.pspdev.org
 * -----------------------------------------------------------------------
 * Licensed under the BSD license, see LICENSE in PSPSDK root for details.
 *
 * main.c - IrDA Type - Modified by saintshark for Display text typed on a SnapNtype T806 PDA keyboard.
 * 
 * 
 * Based on the work of Frank Buss <fb@frank-buss.de> &#40;aka Shine&#41;
 *
 * 01-JUL-2007
 *
 * $Id$
 */

#include <pspkernel.h>
#include <pspdebug.h>
#include <pspdisplay.h>
#include <pspctrl.h>
#include <pspsircs.h>
#include <stdlib.h>
#include <string.h>

typedef int bool;
const bool false = 0;
const bool true = 1;

/* Define the module info section */
PSP_MODULE_INFO&#40;"SnapNType", 0, 1, 1&#41;;

/* Define the main thread's attribute value &#40;optional&#41; */
PSP_MAIN_THREAD_ATTR&#40;THREAD_ATTR_USER | THREAD_ATTR_VFPU&#41;;

/* Define printf, just to make typing easier */
#define printf	pspDebugScreenPrintf

/* Exit callback */
int exit_callback&#40;int arg1, int arg2, void *common&#41;
&#123;
	sceKernelExitGame&#40;&#41;;

	return 0;
&#125;

/* Callback thread */
int CallbackThread&#40;SceSize args, void *argp&#41;
&#123;
	int cbid;

	cbid = sceKernelCreateCallback&#40;"Exit Callback", exit_callback, NULL&#41;;
	sceKernelRegisterExitCallback&#40;cbid&#41;;
	sceKernelSleepThreadCB&#40;&#41;;

	return 0;
&#125;

/* Sets up the callback thread and returns its thread id */
int SetupCallbacks&#40;void&#41;
&#123;
	int thid = 0;

	thid = sceKernelCreateThread&#40;"update_thread", CallbackThread, 0x11, 0xFA0, 0, 0&#41;;
	if&#40;thid >= 0&#41;
	&#123;
		sceKernelStartThread&#40;thid, 0, 0&#41;;
	&#125;

	return thid;
&#125;

void clearScreen&#40;void&#41;
&#123;
	pspDebugScreenInit&#40;&#41;;
	printf&#40;" IrDA Type - Display text typed on a SnapNtype T806 keyboard\n"&#41;;
	printf&#40;" based on IrDA sample by Shine\n"&#41;;
        printf&#40;"      CROSS&#58; insert newline, SQUARE&#58; clear screen, CIRCLE&#58; quit\n"&#41;;
        printf&#40;"--------------------------------------------------------------------"&#41;;
&#125;

// The SnapNtype T806 keyboard sends a 4-byte packet for each keydown and another for
// each key up.  These packets start with 0xC0 and 0xC1, with 2 unique scancode
// bytes at the end.  The following structure is used to define table entries to map these
// 2-byte payloads into ASCII key values&#58;

struct SCANCODE
&#123;
	unsigned char first;		// First payload byte inside keycode packet
	unsigned char second;	// Second payload byte
	unsigned char key;		// ASCII key value
	unsigned char shiftKey;	// ASCII key value &#40;shifted&#41;
&#125;;

struct SCANCODE scanCodes&#91;&#93; =
&#123;
	&#123; 0xD1, 0x5E, 'a', 'A' &#125;,
	&#123; 0x41, 0x42, 'b', 'B' &#125;,
	&#123; 0xC1, 0x43, 'c', 'C' &#125;,
	&#123; 0x41, 0x44, 'd', 'D' &#125;,
	&#123; 0xC1, 0x45, 'e', 'E' &#125;,
	&#123; 0xC1, 0x46, 'f', 'F' &#125;,
	&#123; 0x41, 0x47, 'g', 'G' &#125;,
	&#123; 0x51, 0x48, 'h', 'H' &#125;,
	&#123; 0xD1, 0x49, 'i', 'I' &#125;,
	&#123; 0xD1, 0x4A, 'j', 'J' &#125;,
	&#123; 0x51, 0x4B, 'k', 'K' &#125;,
	&#123; 0xD1, 0x4C, 'l', 'L' &#125;,
	&#123; 0x51, 0x4D, 'm', 'M' &#125;,
	&#123; 0x51, 0x4E, 'n', 'N' &#125;,
	&#123; 0xD1, 0x4F, 'o', 'O' &#125;,
	&#123; 0x41, 0x50, 'p', 'P' &#125;,
	&#123; 0xC1, 0x51, 'q', 'Q' &#125;,
	&#123; 0xC1, 0x52, 'r', 'R' &#125;,
	&#123; 0x41, 0x53, 's', 'S' &#125;,
	&#123; 0xC1, 0x54, 't', 'T' &#125;,
	&#123; 0x41, 0x55, 'u', 'U' &#125;,
	&#123; 0x41, 0x56, 'v', 'V' &#125;,
	&#123; 0xC1, 0x57, 'w', 'W' &#125;,
	&#123; 0xD1, 0x58, 'x', 'X' &#125;,
	&#123; 0x51, 0x59, 'y', 'Y' &#125;,
	&#123; 0x51, 0x5A, 'z', 'Z' &#125;,
	&#123; 0x21, 0x30, '0', '&#41;' &#125;,
	&#123; 0xA1, 0x31, '1', '!' &#125;,
	&#123; 0xA1, 0x32, '2', '@' &#125;,
	&#123; 0x21, 0x33, '3', '#' &#125;,
	&#123; 0xA1, 0x34, '4', '$' &#125;,
	&#123; 0x21, 0x35, '5', '%' &#125;,
	&#123; 0x21, 0x36, '6', '^' &#125;,
	&#123; 0xA1, 0x37, '7', '&' &#125;,
	&#123; 0xB1, 0x38, '8', '*' &#125;,
	&#123; 0x31, 0x39, '9', '&#40;' &#125;,
	&#123; 0x11, 0x1B, '`', '~' &#125;,
	&#123; 0x31, 0x2D, '-', '_' &#125;,
	&#123; 0xB1, 0x3D, '=', '+' &#125;,
	&#123; 0xD1, 0x5B, '&#91;', '&#123;' &#125;,
	&#123; 0xD1, 0x5D, '&#93;', '&#125;' &#125;,
	&#123; 0xB1, 0x3B, ';', '&#58;' &#125;,
	&#123; 0xB1, 0x2C, '\'', '"' &#125;,
	&#123; 0x31, 0x3C, ',', '<' &#125;,
	&#123; 0x31, 0x2E, '.', '>' &#125;,
	&#123; 0xB1, 0x2F, '/', '?' &#125;,
	&#123; 0x51, 0x5C, '\\', '|' &#125;,
	&#123; 0x91, 0x0D, '\n', '\n' &#125;,
	&#123; 0x11, 0x09, '\t', '\t' &#125;,
	&#123; 0xA1, 0x20, ' ', ' ' &#125;,	// Left side of split Space bar
	&#123; 0x21, 0x21, ' ', ' ' &#125;,	// Right side of split Space bar

	// Modifier keys&#58;
	&#123; 0x01, 0x14, 0x80, 0x80 &#125;,	// Shift Toggle &#40;Caps Lock&#41;
	&#123; 0x90, 0x90, 0x81, 0x81 &#125;,	// &#40;Left&#41; Shift OFF
	&#123; 0x92, 0x92, 0x81, 0x81 &#125;,	// &#40;Right&#41; Shift OFF
	&#123; 0x81, 0x10, 0x82, 0x82 &#125;,	// &#40;Left&#41; Shift ON
	&#123; 0x01, 0x12, 0x82, 0x82 &#125;,	// &#40;Right&#41; Shift ON
	&#123; 0x91, 0x91, 0x83, 0x83 &#125;,	// Ctrl OFF
	&#123; 0x01, 0x11, 0x84, 0x84 &#125;,	// Ctrl ON
	&#123; 0x9D, 0x9D, 0x85, 0x85 &#125;,	// Alt OFF
	&#123; 0x11, 0x1D, 0x86, 0x86 &#125;,	// Alt ON

// TODO&#58; Backspace &#123;0x91, 0x08&#125;
// TODO&#58; Del &#123;0x81, 0x13&#125;
// TODO&#58; Arrows&#58; Up &#123;0xA1, 0x26&#125;, Down &#123;0x31, 0x28&#125;, Left&#123;0x21, 0x27&#125;, Right &#123;0xA1, 0x25&#125;
// TODO&#58; Fn &#123;0x11, 0x1E&#125;
// TODO&#58; Cmd key &#40;windows Menu&#41;&#58; &#123;0x91, 0x1C&#125;
// TODO&#58; Programmable Function Button #1&#58; &#123;0x61, 0x71&#125;
// TODO&#58; Programmable Function Button #2&#58; &#123;0x61, 0x72&#125;
// TODO&#58; Programmable Function Button #3&#58; &#123;0xE1, 0x73&#125;
// TODO&#58; Programmable Function Button #4&#58; &#123;0x61, 0x74&#125;
&#125;;

const int nScanCodes = sizeof&#40;scanCodes&#41; / sizeof&#40;scanCodes&#91;0&#93;&#41;;


int main&#40;void&#41;
&#123;
	unsigned char scanCode&#91;2&#93; = &#123;0, 0&#125;;
	int byteCount = 0;

	bool shift = false;
	bool ctrl = false;	// TODO&#58; Ctrl keys printed in "^C" format.
	bool alt = false;	// TODO&#58; Alt keystate currently ignored!

	SceCtrlData pad;
	u32 buttonsold = 0;

	SetupCallbacks&#40;&#41;;

	sceCtrlSetSamplingCycle&#40;0&#41;;
	sceCtrlSetSamplingMode&#40;PSP_CTRL_MODE_DIGITAL&#41;;

	clearScreen&#40;&#41;;

	int fd = sceIoOpen&#40;"irda0&#58;", PSP_O_RDWR, 0&#41;;

	while &#40;1&#41;
	&#123;
		// read pad
		sceCtrlReadBufferPositive&#40;&pad, 1&#41;;
		if &#40;pad.Buttons != buttonsold&#41;
		&#123;
			if &#40;pad.Buttons & PSP_CTRL_CROSS&#41;
				printf&#40;"\n"&#41;;
			if &#40;pad.Buttons & PSP_CTRL_SQUARE&#41;
				clearScreen&#40;&#41;;
			if &#40;pad.Buttons & PSP_CTRL_CIRCLE&#41;
				sceKernelExitGame&#40;&#41;;

			buttonsold = pad.Buttons;
		&#125;

		// check for IrDA input&#58;
		unsigned char data;
		int len = sceIoRead&#40;fd, &data, 1&#41;;
		while &#40;len == 1&#41;
		&#123;
			switch &#40;byteCount&#41;
			&#123;
				case 0&#58;
					if &#40;0xC1 == data&#41;
						byteCount++;
					break;

				case 1&#58;
					if &#40;0xC0 == data&#41;
						byteCount++;
					break;

				case 2&#58;
					scanCode&#91;0&#93; = data;
					byteCount++;
					break;

				case 3&#58;
					scanCode&#91;1&#93; = data;
					byteCount++;
					int n;
					for &#40;n=0; n<nScanCodes; n++&#41;
						&#123;
							if &#40;&#40;scanCode&#91;0&#93; == scanCodes&#91;n&#93;.first&#41;
							&&  &#40;scanCode&#91;1&#93; == scanCodes&#91;n&#93;.second&#41;&#41;
							&#123;
								if &#40;scanCodes&#91;n&#93;.key < 0x80&#41;
								&#123;
									// Display keypress character
									if &#40;ctrl&#41;
										printf&#40;"^"&#41;;
									printf&#40;"%c", &#40;shift? scanCodes&#91;n&#93;.shiftKey &#58; scanCodes&#91;n&#93;.key&#41;&#41;;
								&#125;
								else
								&#123;
									// Special modifier key&#58;
									switch &#40;scanCodes&#91;n&#93;.key & 0x7F&#41;
									&#123;
										case 0x00&#58;	// Shift Toggle
											shift = !shift;
											break;

										case 0x01&#58;	// Shift OFF
											shift = false;
											break;

										case 0x02&#58;	// Shift ON
											shift = true;
											break;

										case 0x03&#58;	// Ctrl OFF
											ctrl = false;
											break;

										case 0x04&#58;	// Ctrl ON
											ctrl = true;
											break;

										case 0x05&#58;	// Alt OFF
											alt = false;
											break;

										case 0x06&#58;	// Alt ON
											alt = true;
											break;
									&#125;
								&#125;
							&#125;
						&#125;
				default&#58;
					byteCount = 0;
					break;
			&#125;

			//printf&#40;"%02X ", data&#41;;

			len = sceIoRead&#40;fd, &data, 1&#41;;
		&#125;
		
		sceDisplayWaitVblankStart&#40;&#41;; 
	&#125;

	return 0;
&#125;
Does somebody know how to modify piKey to include a working support for this keyboard? Me and all the keyboard owners of a snapNtype will be very pleased. Thank you in advance. :)

saintshark
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

I haven't had the chance to work on PSP stuff lately. I need to update to the latest in the repo and see if my changes were ever applied.
tyranos
Posts: 8
Joined: Thu Apr 20, 2006 10:49 am

Post by tyranos »

@saintshark :most likely it s not pikey u have to change it s libpspirkeyb and it s prx version .
maybe it s blocking and that s y u hear the sound try pressing the arrow keys very fast and the xmb will move .

if u want to give it a try
1. first u have to map the scancodes ur keyboard sends to to the values defined in "libpspirkey/include/pspirkeyb_rawkeys.h"
-sort them in ascending order in a an "uchar field".
-replace the existing one in this file /libpspirkey/kbdkeyboards.h for ur keyboard.
2.libpspirkey/pspirkeyb.c and either replace or modify the handler function

3. i just remembered :) the rest is well described in the README file . (about keymap,prototypes etc ), better u read it first .

4.compile it and test the prx as this is used by pikey

then u have to compile pikey using the modified version of libpspirkeyb
(dont foget the prx )



@J.F i tried sending it to fanjita but the email wasn't delivered , i ll try to send it to another of his e-adresses .
and

ne e problem i have though is when using pspvnc or pspssh (and most zx-81 s progs ) the enter key and del key dont work even if they work in the menu of those same applications .
if someone test it with another keyboard and not the TARGUS.



[/quote]
J.F.
Posts: 2906
Joined: Sun Feb 22, 2004 11:41 am

Post by J.F. »

I have a Palm 3169WW (their latest IR keyboard). The original Palm driver is blocking, and I modified it to not block. I also made a small change to the raw key mapping and made a keymap file to get many of the other keys (function keys, pgup, pgdn, home, end, etc). I sent those to fanjita's pikey email addy, but haven't checked the repo since then to see if my changes were entered.

Really old Palm code has a tendency to ignore most keys and lock on my Palm keyboard, despite being supposedly compatible. The old palm code was pretty bad, so it wasn't surprising. It wasn't just blocking, but really nasty as well. Easily able to lose bytes and wind up out of sync with the keyboard. I noticed that most of the drivers aren't really coded properly. For example, many simply try to read two bytes and ignore what would happen if only one byte were available. Maybe you're running into that.
Post Reply