Register Guidelines E-Books Search Today's Posts Mark Forums Read

Go Back   MobileRead Forums > E-Book Readers > Amazon Kindle > Kindle Developer's Corner

Notices

Reply
 
Thread Tools Search this Thread
Old 11-26-2012, 02:26 PM   #166
hawhill
Wizard
hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.
 
hawhill's Avatar
 
Posts: 1,219
Karma: 2124593
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
smartgenes: You asked earlier whether using Notepad will have an effect. It might. Different line endings between DOS (+Windows) and Unix might render the interpreter incantation in the first line of the script broken. Also a UTF-8 BOM might get inserted under certain circumstances, I think. Use an editor that is capable of using Unix conventions. I think the eips calls should work. I strongly suggest to call the runscript.sh in a terminal, either using USB networking, or in myts (search this forum, it's a terminal application).

In the launchpad config you posted, there's a space between runscript.sh and its path. That would be an error, but might also be a C&P error on your side? Also, on this board it is probably more wise to create a ZIP of the actual files you use and upload it. It gives us a 100% expression of what you're using. C&P is error prone.
hawhill is offline   Reply With Quote
Old 11-26-2012, 09:59 PM   #167
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
This (eips) is tested on the 3, that is what I was using.

Could be a line endings problem then? you say you are editing this on windows?

I have attached a zipped version of the file with Unix line endings. check it over (for errors in translation, but it should be 100%) and give that a go.

Also change the "G B = !/mnt/us/fbgnuboy/ rungame.sh"

to "G B = !/mnt/us/fbgnuboy/rungame.sh"

(since this is a single command).

And give that a try.
Attached Files
File Type: zip script.zip (929 Bytes, 34 views)

Last edited by twobob; 11-26-2012 at 10:02 PM. Reason: G B = !/mnt/us/fbgnuboy/ rungame.sh is G B = !/mnt/us/fbgnuboy/rungame.sh
twobob is offline   Reply With Quote
Old 11-26-2012, 10:17 PM   #168
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Okay so I am just going to ask it on here.

Before this gets silly. Exactly what is actually required to build this for a kindle 3?
Spoiler:

I know you suggested arm-2011.09 from Codesourcery but does this mean I have to get hacking on the makefile? Sorry to be a total pain.

If I am better off trying to get together a CTNG that actually works then I will put my efforts into that. it would be really nice to actually be able to build this.

Surely I'm not the only person who would like to have a chance to expand it.

Anyways, I know you are stupid busy and you already advised me you misplaced the CTNG profile you use (did you build this with it?)

But I really would like to give this a go. Much obliged. If CTNG is the only way I will make it happen, just a bit frustrated at "getting it going"

Will hack on it with the arm-2011.09 and see what falls out.

Thanks.

EDIT: Obviously if this could be built with arm-2007q3 that would be the route of least resistance. <- I went with this

Last edited by twobob; 11-27-2012 at 05:23 PM.
twobob is offline   Reply With Quote
Old 11-27-2012, 11:13 AM   #169
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
So I gave compiling this another go. Why not.

Spoiler:
me@dev /usr/local/src/gnuboy-1.0.3.kindle $ strace -fF -o ~/gnuboy-strace.txt make
Quote:
arm-none-linux-gnueabi-gcc -march=armv6 --sysroot=/arm -O0 -Wall -Wno-implicit -Wno-long-long -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -I. -I./sys/nix -DHAVE_CONFIG_H -DIS_LITTLE_ENDIAN -DIS_LINUX -c sys/fbdev/fbdev.c -o sys/fbdev/fbdev.o
sys/fbdev/fbdev.c:20:26: error: linux/einkfb.h: No such file or directory
Okay I thought. The TC must be missing the headers. (Thought I had actually done this?)

so I tried

cd /usr/local/src/BUILD_KERNAL/linux-2.6.26/
make headers_install ARCH=arm INSTALL_HDR_PATH=/arm/usr/include

which (incredibly?) doesn't actually emit an einkfb.h file (did I get the ARCH wrong?)

SEE EDIT BELOW:

so I thought I would just try including this by-hand

Quote:
me@dev /usr/local/src/gnuboy-1.0.3.kindle $ strace -fF -o ~/gnuboy-strace2.txt make
arm-none-linux-gnueabi-gcc -march=armv6 --sysroot=/arm -O0 -Wall -Wno-implicit -Wno-long-long -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -I. -I./sys/nix -DHAVE_CONFIG_H -DIS_LITTLE_ENDIAN -DIS_LINUX -c lcd.c -o lcd.o

..Blah...

arm-none-linux-gnueabi-gcc -march=armv6 --sysroot=/arm -O0 -Wall -Wno-implicit -Wno-long-long -fstrength-reduce -fthread-jumps -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop -I. -I./sys/nix -DHAVE_CONFIG_H -DIS_LITTLE_ENDIAN -DIS_LINUX -c sys/fbdev/fbdev.c -o sys/fbdev/fbdev.o
In file included from sys/fbdev/fbdev.c:20:
/arm/usr/include/linux/einkfb.h:39: error: expected specifier-qualifier-list before 'u8'
/arm/usr/include/linux/einkfb.h:50: error: expected specifier-qualifier-list before 'u8'

make: *** [sys/fbdev/fbdev.o] Error 1
reading around the only thing I could find (so far) that makes reference to this error is

http://www.linuxquestions.org/questi...ml#post4008056

Which is completely unrelated to my issue... (other than perhaps inferring I actually need another file entirely that I don't have)

and the more general http://stackoverflow.com/questions/6...ist-before-typ

Now this one infers that I am indeed an idiot and this is PEBCAK...

Clues? anyone?

So I tried patching ./sys/fbdev/fbdev.c

Quote:
#include <linux/fb.h>
#include <linux/einkfb.h>

// just to make the compiler happy
#include <asm/types.h>
typedef __u8 u8;

#include "fb.h"
#include "input.h"
This was something I noted in the fbKindle project that I thought may be relevant... Still didn't swallow it.

Hmm. running out of ideas. Any clues anyone?

EDIT: me@dev /usr/local/src/BUILD_KERNAL/linux-2.6.26 $ ls -d include/asm-* | sed 's/.*-//'
Quote:
alpha
arm
Spoiler:
arm26
avr32
blackfin
cris
frv
generic
h8300
ia64
m32r
m68k
m68knommu
mips
mn10300
parisc
powerpc
ppc
s390
sh
sparc
sparc64
um
v850
x86
xtensa


err? I dunno, don't think so. I will try again with arm26


Err.. no I wont...

me@dev /usr/local/src/BUILD_KERNAL/linux-2.6.26/arch $ ls
Quote:
alpha blackfin h8300 m32r mips powerpc sh um xtensa
arm cris ia64 m68k mn10300 ppc sparc v850
avr32 frv Kconfig m68knommu parisc s390 sparc64 x86
there is no arm26... sigh... perhaps my sed was mangled.

... erm no...

me@dev /usr/local/src/BUILD_KERNAL/linux-2.6.26/include $ ls -d asm-*
Quote:
asm-alpha asm-cris asm-m32r asm-parisc asm-sparc asm-xtensa
asm-arm asm-frv asm-m68k asm-powerpc asm-sparc64
asm-arm26 asm-generic asm-m68knommu asm-ppc asm-um
asm-avr32 asm-h8300 asm-mips asm-s390 asm-v850
asm-blackfin asm-ia64 asm-mn10300 asm-sh asm-x86
but it simply contains a single ref to a pci include. as opposed to a full set of headers

DOH! why it it so difficult. : ) Oh that's right! because I obviously don't understand the instructions...


Solution below (4 posts down)

Last edited by twobob; 11-27-2012 at 04:53 PM. Reason: perhaps inferring, PEBCAK
twobob is offline   Reply With Quote
Old 11-27-2012, 11:52 AM   #170
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Spoiler:
So I checked... and none of the stuff in asm-* actually contains the einkfb.h, it's in the parent ../linux/einkfb.h

which either infers that it should a) be included in all header creation requests - and isn't being

Quote:
The system's libc headers are usually installed at the default location /usr/include and the kernel headers in subdirectories under that (most notably /usr/include/linux and
/usr/include/asm).
or b) I am not understanding exactly what the kernel header stuff should include properly??

or c) there is some other process that I am missing.

Sigh... out of ideas now. Will google around for a while.

Reading: http://kernel.org/doc/Documentation/...rs_install.txt

Quote:
The linux/asm directory of the exported kernel headers
is platform-specific, to see a complete list of supported architectures use
the command: ls -d include/asm-* | sed 's/.*-//'
so I think I was right in saying all header exports should include the linux directory. still don't understand therefore why einkfb.h is not included in the output. Daaaiiiieeee : )


Solution below

Last edited by twobob; 11-27-2012 at 04:53 PM.
twobob is offline   Reply With Quote
Old 11-27-2012, 12:09 PM   #171
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Spoiler:
okay. let's ignore the header thing for a moment

I will state my assuptions:

Assume that copying out /opt/arm-2007q3/arm-none-linux-gnueabi/libc across to /arm
and then using that as our sysroot in our amended makefile (below) should actually compile:

Code:
prefix = /usr
exec_prefix = ${prefix}
bindir = ${exec_prefix}/bin

CC = arm-none-linux-gnueabi-gcc
LD = $(CC)
AS = $(CC)
INSTALL = /bin/install -c

CFLAGS:=-march=armv6 --sysroot=/arm
CFLAGS+= -O0 -Wall -Wno-implicit -Wno-long-long -fstrength-reduce -fthread-jumps  -fcse-follow-jumps -fcse-skip-blocks -frerun-cse-after-loop

LDFLAGS = $(CFLAGS)  -s
ASFLAGS = $(CFLAGS)

TARGETS =  fbgnuboy

ASM_OBJS = 

SYS_DEFS = -DHAVE_CONFIG_H -DIS_LITTLE_ENDIAN  -DIS_LINUX
SYS_OBJS = sys/nix/nix.o $(ASM_OBJS)
SYS_INCS = -I./sys/nix

#FB_OBJS =  sys/linux/joy.o sys/dummy/nosound.o
#FB_LIBS = 

SVGA_OBJS = sys/svga/svgalib.o sys/pc/keymap.o sys/linux/joy.o sys/dummy/nosound.o
SVGA_LIBS = -L/usr/local/lib -lvga

SDL_OBJS = sys/sdl/sdl.o sys/sdl/keymap.o
SDL_LIBS = 
SDL_CFLAGS = 

X11_OBJS = sys/x11/xlib.o sys/x11/keymap.o sys/linux/joy.o sys/dummy/nosound.o
X11_LIBS =  -lX11 -lXext

ESD_OBJS = sys/esound/esound.o
ESD_LIBS = -lesd

FB_OBJS = sys/fbdev/fbdev.o sys/linux/kindleinput.o sys/dummy/nosound.o # sys/alsa/alsa.o
FB_LIBS = #-lasound
FB_INCS = 

all: $(TARGETS)

include Rules

fbgnuboy: $(OBJS) $(SYS_OBJS) $(FB_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(FB_OBJS) -o $@ $(FB_LIBS)

sgnuboy: $(OBJS) $(SYS_OBJS) $(SVGA_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SVGA_OBJS) -o $@ $(SVGA_LIBS)

sdlgnuboy: $(OBJS) $(SYS_OBJS) $(SDL_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(SDL_OBJS) -o $@ $(SDL_LIBS)

sys/sdl/sdl.o: sys/sdl/sdl.c
	$(MYCC) $(SDL_CFLAGS) -c $< -o $@

sys/sdl/keymap.o: sys/sdl/keymap.c
	$(MYCC) $(SDL_CFLAGS) -c $< -o $@

xgnuboy: $(OBJS) $(SYS_OBJS) $(X11_OBJS)
	$(LD) $(LDFLAGS) $(OBJS) $(SYS_OBJS) $(X11_OBJS) -o $@ $(X11_LIBS)

sys/directfb/directfb.o: sys/directfb/directfb.c
	$(MYCC) $(DFB_INCS) -c $< -o $@

install: all
	$(INSTALL) -d $(bindir)
	$(INSTALL) -m 755 $(TARGETS) $(bindir)

clean:
	rm -f *gnuboy gmon.out *.o sys/*.o sys/*/*.o asm/*/*.o

distclean: clean
	rm -f config.* sys/nix/config.h Makefile
This would also mean manually including the einkfb.h (into /arm/usr/include/linux/ (and patching the reference to asm/types.h)

So those are my assumptions. Can someone confirm they are correct?


Solution below

Last edited by twobob; 11-27-2012 at 04:52 PM.
twobob is offline   Reply With Quote
Old 11-27-2012, 12:24 PM   #172
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
so I changed order of the "addition" in /usr/local/src/gnuboy-1.0.3.kindle/sys/fbdev/fbdev.c to come BEFORE the einkfb.h: (duh)

Quote:
#include <linux/fb.h>

// just to make the compiler happy (do this first?)
#include <asm/types.h>
typedef __u8 u8;

#include <linux/einkfb.h>

#include "fb.h"
#include "input.h"
#include "rc.h"
which gets me a compile.

Will test it.

Thanks for listening. ;0

EDIT: Yep seems to run.

Success. Okay time to get hacking!

Last edited by twobob; 11-27-2012 at 05:00 PM. Reason: duh ;)
twobob is offline   Reply With Quote
Old 11-27-2012, 09:47 PM   #173
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Notes on Input codes
Spoiler:


okay so. Inputs: input.h

Quote:
#define K_JOY0 0x1b0
#define K_JOY1 0x1b1
#define K_JOY2 0x1b2
#define K_JOY3 0x1b3
#define K_JOY4 0x1b4
#define K_JOY5 0x1b5
#define K_JOY6 0x1b6
referenced by kindleinput.c function joy_poll()

Spoiler:
Code:
void joy_poll()
{
	event_t ev;
	struct input_event iev;
	int c;
	

	for(c = 0; c < 3; c++) {
		if(inputfds[c] < 0) continue;
		while (read(inputfds[c],&iev,sizeof(struct input_event)) == sizeof(struct input_event)) {
			if(iev.type == EV_KEY) {
				if(iev.value == 1) {
					ev.type = EV_PRESS;
				} else if(iev.value == 0) {
					ev.type = EV_RELEASE;
				} else {
//maybe a debug output here?
sprintf(stderr, "couldn't manage input type");

					continue;
				}
				switch(iev.code) {
				case 103:
				case 122: // FW_UP (K3, KDX)
					ev.code = K_JOYUP;
					break;
				case 108:
				case 123: // FW_DOWN (K3, KDX)
					ev.code = K_JOYDOWN;
					break;
				case 105: // FW_LEFT (both)
					ev.code = K_JOYLEFT;
					break;
				case 106: // FW_RIGHT (both)
					ev.code = K_JOYRIGHT;
					break;
				case 102:
				case 98:  // HOME
					ev.code = K_JOY6;
					break;
				case 44:  // Z
					ev.code = K_JOY1;
					break;
				case 45:  // X
					ev.code = K_JOY0;
					break;
				case 30:  // A
					ev.code = K_JOY2;
					break;
				case 31:  // S
					ev.code = K_JOY3;
					break;
				case 16:  // Q
					ev.code = K_JOY4;
					break;
				case 17:  // W
					ev.code = K_JOY5;
					break;
				default:
					continue;
				}
				ev_postevent(&ev);
//			fprintf(stderr, "ev.code = <%i>\n", ev.code);
			}
		}
	}


also we would like to know exactly which /dev/input/event[0-3] it is polling

(2 or 3 look likely surrogate candidates on the 5 - the button and the touchscreen respectively)

Let's just assume we don't know and push to all 4.

The relevant definitions in the Kindle Touch Kernel Sources would seem to be
( File: ./gplrelease/include/linux/input.h )

Spoiler:
Code:
#define KEY_LOGOFF              0x1b1   /* AL Logoff */

#define KEY_DOLLAR              0x1b2
#define KEY_EURO                0x1b3

#define KEY_FRAMEBACK           0x1b4   /* Consumer - transport controls */
#define KEY_FRAMEFORWARD        0x1b5
#define KEY_CONTEXT_MENU        0x1b6   /* GenDesc - system context menu */


so using:

Spoiler:
Code:
#include <stdio.h>
#include <fcntl.h>
#include <linux/input.h>
#include <sstream>
#include <unistd.h> 

#define EV_PRESSED 1
#define EV_RELEASED 0
#define EV_REPEAT 2

#define KEY_SPELLCHECK          0x1b0   /* K_JOY0 = X */
#define KEY_LOGOFF              0x1b1   /* K_JOY1 = Z */

#define KEY_DOLLAR              0x1b2   /* K_JOY2 = A  */
#define KEY_EURO                0x1b3   /* K_JOY3 = S */

#define KEY_FRAMEBACK           0x1b4     /* K_JOY4  = Q */
#define KEY_FRAMEFORWARD        0x1b5   /* K_JOY5  = W */
#define KEY_CONTEXT_MENU        0x1b6     /* K_JOY6  = HOME  */

/*
* Purpose: Stuffs the Linux keyboard buffer with a key and
* reads it back out of the buffer.
*	 All key definitions can be found in input.h file:
*	 /usr/src/linux-headers-3.2.0-23/include/linux
*
*/
main()
{
/************************************************
* IMPORTANT
* you need to execute this code as the su or
* sudo user in order to open the device properly.
***********************************************/
printf("Starting the keyboard buffer writer/reader \n");

int fd = 0;
// char *device = "/dev/input/event2";
// Whitney button
 
char *device = "/dev/input/event3"; 

// PREVIOUS PERSONS NOTES INCLUDED HERE
// This is the TS keyboard device as identified using both: $cat /proc/bus/input/devices
// and looking in the var/log/Xorg.0.log searching for "keyboard"

// Write a key to the keyboard buffer
if( (fd = open(device, O_RDWR)) > 0 )
{
struct input_event event;
printf("The keyboard code is: %d \n", KEY_EURO); // Note: these are not the same as ASCII codes.

// Press a key (stuff the keyboard with a keypress)
event.type = EV_KEY;
event.value = EV_PRESSED;
event.code = KEY_EURO;
write(fd, &event, sizeof(struct input_event));

// Release the key
event.value = EV_RELEASED;
event.code = KEY_EURO;
write(fd, &event, sizeof(struct input_event));
close(fd);
}

// Read the key back from the keyboard buffer
int fd1 = 0;
if( (fd1 = open(device, O_RDONLY)) > 0 ) // It's important to open a new file descriptor here or the program will block.
{
struct input_event event;
unsigned int scan_code = 0;

if(event.type != EV_KEY)
{
return 0; // Keyboard events are always of type EV_KEY
}

if(event.value == EV_RELEASED)
{
scan_code = event.code;
printf("read back scan_code is: %d \n", scan_code);
}
close(fd1);
}
}


One might imagine that might do something...

but seemingly not.

Am I missing something?

Stuff keycode in event thingy? no??

: )

Tips gratefully accepted.

Last edited by twobob; 11-28-2012 at 10:52 AM. Reason: File: ./gplrelease/include/linux/input.h
twobob is offline   Reply With Quote
Old 11-27-2012, 10:58 PM   #174
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Here I notice that all the devices ARE actually getting polled on the touch and decide to go for full TS code integration
Spoiler:

Hmm.. or maybe it's because I can't open the device on the 3.
(at the same time as the gnuboy is using it)

This seems to be borne out by testing. (can't open device on 3 RDWR to inject stuff..)

and also the gnuboy application can't open that device (or any) on the 5... (this part is speculation) as the full compliment are already inited. ?

EDIT: On Touch.

(with some debug chucked in)
Run thing - Then press HOME Button

[root@kindle bin]# HOME=/mnt/us/home/root fbgnuboy ./rom/ast.gb
ev.code = <438>

(Application closes. as it should - with that code)


Hmm.. Head scratch.. So it looks like that method of injection is out.
I need to think more about how to get the codes into the /dev/input/event buffers perhaps?


OR: I need to add some TS code to the main app and be done with it.

Last edited by twobob; 11-28-2012 at 10:53 AM. Reason: more detail. a bit
twobob is offline   Reply With Quote
Old 11-28-2012, 12:09 AM   #175
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
Here I realise that the injection into the /dev/input/event3 buffer isn't working as I might expect. So I abandon it in favour of native code
Spoiler:

Hokay.... I clearly have something else wrong...

on touch: [root@kindle input]# cat /dev/input/event2
(couple of home presses)
Quote:
���Pu�f���P�����Pr�f���P{�
In another shell:
[root@kindle bin]# keywriteEuroEvent2 (writes Euro Symbol to /dev/input/event2) well, it is supposed to anyway

Quote:
Starting the keyboard buffer writer/reader
The keyboard code is: 435
But the cat shows no activity. so it's obviously not doing what I expected.

Hmm..

But it doesn't "hang" like it does on the 3 ... oddness. I obviously need to know more about the locking aspect of this mechanism

Last edited by twobob; 11-28-2012 at 10:55 AM. Reason: I obviously need to know more about the locking aspect of this mechanism
twobob is offline   Reply With Quote
Old 11-28-2012, 01:10 AM   #176
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
This is where I got to (with broken code)
Spoiler:

Something like.... Which is broken.. I will figure out what I did tomorrow.

stupid cut and paste loop error. will pick this up tomorrow.
noted here for the morning.
Spoiler:

Code:
 
#include <stdio.h>
#include <stdlib.h>
#include <string.h>
#include <linux/input.h>
#include <sys/types.h>
#include <sys/stat.h>
#include <fcntl.h>
#include <unistd.h>

#include "input.h"
#include "rc.h"

#define WIDTH 600
#define HEIGHT 800
#define STRIDE 608

#define TOUCH_SCREEN "/dev/input/event3"

#define UP 0
#define DOWN 1

static int inputfds[] = { -1, -1, -1 };

rcvar_t joy_exports[] = { RCV_END };

void joy_init() {
	int c;
	char dev[128];

	for (c = 0; c < 3; c++) {
		sprintf(dev, "/dev/input/event%d", c);
		inputfds[c] = open(dev, O_RDONLY | O_NONBLOCK);
		if (inputfds[c] < 0) {
			fprintf(stderr, "couldn't open <%s>\n", dev);
		}
	}

}

void joy_close() {
	int c;
	for (c = 0; c < 3; c++) {
		if (inputfds[c] < 0)
			continue;
		close(inputfds[c]);
	}
}

void update(int refresh) {
	if (refresh) {
		system("eips -f ''");
	} else {
		system("eips ''");
	}
}

void joy_poll() {

	int touch_screen_fd = 0;
	unsigned char *frame_buffer = NULL;
	unsigned char event_buffer[16];

	/* First finger variables */
	int finger = UP;
	int x = 300;
	int y = 400;

	/* Second finger variables */
	int finger2 = UP;
	int x2 = 0;
	int y2 = 0;
	int f2_mode = 0;

	int i = 0;
	int j = 0;

	int sync = 0;  //? maybe

	event_t ev;

//open it?

	touch_screen_fd = open(TOUCH_SCREEN, O_RDONLY);
	if (touch_screen_fd == -1) {
		fprintf(stderr, "Error: Could not open touch screen.\n");
		exit(EXIT_FAILURE);
	}

// Do the setup

	while (read(touch_screen_fd, event_buffer, 16)) {
		if (event_buffer[0x08] == 0x03) {
			switch (event_buffer[0x0A]) {
			case 0x2F:
				/* When f2_mode is nonzero, data is treated as being for
				 the second finger */
				f2_mode = event_buffer[0x0C];
				break;
			case 0x35:
				/* X Coordinate change */
				if (!f2_mode) {
					x = (WIDTH
							* (event_buffer[0x0C] + (event_buffer[0x0D] << 8)))
							/ 0x1000;
				} else {
					x2 = (WIDTH
							* (event_buffer[0x0C] + (event_buffer[0x0D] << 8)))
							/ 0x1000;
				}
				break;
			case 0x36:
				/* Y Coordinate change */
				if (!f2_mode) {
					y = (HEIGHT
							* (event_buffer[0x0C] + (event_buffer[0x0D] << 8)))
							/ 0x1000;
				} else {
					y2 = (HEIGHT
							* (event_buffer[0x0C] + (event_buffer[0x0D] << 8)))
							/ 0x1000;
				}
				break;
			case 0x39:
				/* Finger up / down */
				if (event_buffer[0x0C] == 0x00) {
					finger = DOWN;
				} else if (event_buffer[0x0C] == 0x01) {
					finger2 = DOWN;
				} else {
					if (finger2 == DOWN) {
						finger2 = UP;
					} else {
						finger = UP;
					}

				}
				break;
			default:
				break;
			}
		}
		if (event_buffer[0x08] == 0x00) {
			sync = 1;
		}

		if (sync) { /* We have recieved a sync */

			/* If finger 1 is down, draw for it */
			if (finger == DOWN) {
				if (finger2 == UP) {

				}
			}

			/* Fingers are up. Did we just push exit / clear? */
			if (finger == UP) { /* Release your finger in the top right to exit */
				if (x > 500 && y < 100) {
					printf("Exiting.\n");
					break;
				}
				if (x < 100 && y < 100) { /* Release your finger in the top left 
				 to clear the screen */
					update(1);
					x = 300;
					y = 400;

				}

				if (x >= 50 && x <= 250 && y >= 140 && y <= 500) {

					// S
					ev.code = K_JOY3;

					sync = 0;
				}
				
			}
		}
		ev_postevent(&ev);
		fprintf(stderr, "ev.code = <%i>\n", ev.code);
	}
}


I will check the matching brackets when I am less tired.

But this is close...
I get the relevant output... mainly...

Quote:
ev.code = <435>
ev.code = <435>
ev.code = <435>
ev.code = <435>
Exiting.
ev.code = <161956>

Last edited by twobob; 11-28-2012 at 10:55 AM.
twobob is offline   Reply With Quote
Old 11-28-2012, 06:47 AM   #177
hawhill
Wizard
hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.hawhill ought to be getting tired of karma fortunes by now.
 
hawhill's Avatar
 
Posts: 1,219
Karma: 2124593
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
I'm not sure what you're currently trying to do on which device. I got irritated by the number of approaches, I guess.
hawhill is offline   Reply With Quote
Old 11-28-2012, 08:19 AM   #178
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
simple.

ditch the keys.

replace with TS code.

add a bit of redraw code.

That is all.

Basically make a " touch specific " version

The previous post
http://www.mobileread.com/forums/sho...&postcount=176
is my last approach.

Just do it in TS code natively. I was up until then trying to look for an "injection" solution.



Spoiler:

I also played initially with getting the sound going.

You don't mean I annoyed you do you? : (

In the valley of the blind the one eyed man types a lot and hopes no one is watching (especially them two-eyed ones that built the city I am trashing)

Well anyways. I got something out of the device last night - even If I did trash the graphics. Spent most of the day figuring out why it wouldn't compile. HEH!

Anyways, thanks for the great application. Sorry I am not a bit more OOTB awesome.
Foolishly wasted most of my life so far becoming a recording studio know-it-all : )
Note -to - self: NEXT TIME stand in the other queue.

Last edited by twobob; 11-28-2012 at 08:59 AM.
twobob is offline   Reply With Quote
Old 11-28-2012, 09:03 AM   #179
knc1
Helpdesk Junkie
knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.knc1 ought to be getting tired of karma fortunes by now.
 
knc1's Avatar
 
Posts: 7,001
Karma: 6359394
Join Date: Feb 2012
Device: Too many.
Quote:
Originally Posted by twobob View Post
Note -to - self: NEXT TIME stand in the other queue.
Or pick the path that was completed before they ran out of the warning sign sets:
"Dead End", "No Outlet", "Rough Road', "Water Over Bridge", etc. etc. etc.
knc1 is offline   Reply With Quote
Old 11-28-2012, 09:24 AM   #180
twobob
( ͡° ͜ʖ ͡°){ʇlnɐɟ ƃǝs}Tır
twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.twobob ought to be getting tired of karma fortunes by now.
 
twobob's Avatar
 
Posts: 6,552
Karma: 6021146
Join Date: Jun 2012
Location: uti gratia usura (Yao ying da ying; Mo ying da yieng)
Device: PW-WIFI|K5-3G+WIFI| K4|K3-3G|DXG|K2| Rooted Nook Touch
heh yeah.

I am currently undoing all my work to see where I effed up the graphics

obviously the "tightness" of the keyscan loop is more critical then I imagined.

ho hum
twobob is offline   Reply With Quote
Reply

Thread Tools Search this Thread
Search this Thread:

Advanced Search

Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
Kindle VNC viewer (native app, GPLv2) hawhill Kindle Developer's Corner 499 12-16-2014 04:31 AM
Gameboy emulator on PE bunodosoma enTourage eDGe 2 11-16-2011 09:19 PM
Gameboy screen bookmeal General Discussions 7 10-03-2011 03:40 PM
software suggestion: virtualboy(gameboy emulator) arfarf624 Kindle Developer's Corner 3 07-27-2011 06:06 AM
Free (GPLv2) Translation Dictionaries Elleo Amazon Kindle 3 01-11-2011 11:57 PM


All times are GMT -4. The time now is 08:27 AM.


MobileRead.com is a privately owned, operated and funded community.