Register Guidelines E-Books Today's Posts Search

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

Notices

Reply
 
Thread Tools Search this Thread
Old 10-09-2012, 04:08 AM   #31
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,586
Karma: 6299991
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
my B011 KT International has TTS. I think there may be one or two of them left for sale. (link on here somewhere).

It is entirely possible to initiate TTS programmatically (and thus off of a button)
here's the relevant bits to prod.
Quote:
com.lab126.tts
w Int pause
w Int unpause
w Int CtrlBookmark
w Int stop
rw Str logLevel
rw Str logMask
rw Has playFile
rw Str TtsSModel
rw Int TextToProcess
rw Str TtsSVoice
rw Int TtsISpeed
However you say you have a KK.

and running a lipc-probe -a on there tells the same story

Quote:
com.lab126.tts
rw Str TtsSVoice
w Int CtrlBookmark
rw Has playFile
rw Int TextToProcess
w Int stop
rw Str logMask
w Int pause
rw Str logLevel
w Int unpause
rw Str TtsSModel
rw Int TtsISpeed
so again, should be just as easy to make a KK use ONE key to do both jobs as it would be to make a KT do it with one "button" push.
My thought would be dig around and see if there is already a solution to just trigger that. I am guessing not but it shouldn't be too difficult to rig up...

Hope that help some.

Last edited by twobob; 10-09-2012 at 04:12 AM.
twobob is offline   Reply With Quote
Old 10-10-2012, 08:18 PM   #32
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,586
Karma: 6299991
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
Quote:
Originally Posted by baf View Post
I want to add my brute force contribution to this topic. I wrote a very simple program, whose main aim is to turn Kindle Touch into a Non-Touch .

It just grabs all X events – keyboard (read One Key) and touchscreen input, so that the events don't reach other apps. It is just a proof of concept which may be further developed or used for some other project.

I adjusted the program to what was asked for in one of the previous posts in this thread. It disables touchscreen input and turns home button events into touchscreen events, so that home button may be used to turn pages in reader application.
When started program waits for pressing home button. When you press the home button, the touchscreen becomes inactive. There is only small 50×50 pixels active area in the upper right corner of the screen. Touching this area turns the program off.
Home button presses are translated into touchscreen clicks. Short button press simulates click on the right side of the screen – forward page turn. Long button press imitates click on the left side of the screen – backward page turn. Duration of the long press may be adjusted on command line.

I also prepared a GUI Launcher extension for those who don't want to mess around with command line. To use for reading a book start the extension from extensions folder. Then click on the book you want to read and when it opens just press home button. From this moment home button will work as described above and touchscreen will not work. To turn it off you will need to click in the upper right corner of the screen.

You will find everything on my webpage.

Code:
[root@kindle bin]# ./untouchable -h
Usage: untouchable [OPTION]
	-t <milliseconds> - minimal time home button should be hold to be treated as long press (default 1500)
	-d               - debug
	-h               - show this message
untouchable.c:

Spoiler:
Code:
/*  
    untouchable - filter all input and make Kindle Touch "untouchable" :)
    Copyright (c) 2012 by baf (www.fabiszewski.net), with MIT license:
    http://www.opensource.org/licenses/mit-license.php

    gcc untouchable.c -O2 -Wall -lX11 -o untouchable
*/

#include <stdio.h> // printf
#include <stdbool.h> // bool
#include <string.h> // memset
#include <stdlib.h> // strtol
#include <unistd.h> // usleep
#include <X11/keysym.h>
#include <X11/XKBlib.h>

void pageForward(Display *display);
void pageBackward(Display *display);
void SendMouseEvent(Display *display, int button, int x, int y, bool pressed);
void usage();

bool debug = false;

int main(int argc, char * argv[]) {
	Window root;
	Display * display;
	XEvent xev;
	Time clickTime = CurrentTime;
	int longPressDuration = 1500;
	int timeDiff;
	int screenWidth;
	
	// parse options
	while ((argc > 1) && (argv[1][0] == '-')){
		switch (argv[1][1]){
			case 't':
				++argv;
				if (--argc <= 1){
					printf("Option -t requires numeric argument\n");
					usage();
					return 1;
				}
				longPressDuration = strtol(argv[1],0,0); 
				break;
                        case 'd':
				debug = true;
                                break;
                        case 'h':
				usage();
                                return 0;
		}
		++argv;
		--argc;
	}

	if(debug) printf("Long press duration: %i\n", longPressDuration);

	display = XOpenDisplay(NULL);
	if(display == NULL) {
		if(debug) printf("Could not open display\n");
		return 1;
	}

	root = DefaultRootWindow(display);
	screenWidth = WidthOfScreen(DefaultScreenOfDisplay(display));
	if(debug) printf("Screen width: %i\n", screenWidth);

	XAllowEvents(display, AsyncBoth, CurrentTime);
	// grab key events
	if(debug) printf("Grab key events\n");
	XGrabKeyboard(display, root, true, GrabModeAsync, GrabModeAsync, CurrentTime); 

	bool go = true;
	bool grabOn = false; // we start grabbing mouse events only after first press of home button
	while(go){
		XNextEvent(display, &xev);
	        int keycode = (int) XLookupKeysym(&xev.xkey, 0);

		switch(xev.type){
			case ButtonPress:
				if(debug) printf("Button press - %i\n", xev.xbutton.button);
				if(debug) printf("Coordinates - %i, %i\n", xev.xbutton.x, xev.xbutton.y);
			break;

			case ButtonRelease:
				if(debug) printf("Button release - %i\n", xev.xbutton.button);
				if(xev.xbutton.x>screenWidth-50 && xev.xbutton.y<50)
					go = false;
			break;
			case KeyPress:
				clickTime = xev.xkey.time;
				if(debug) printf("Key press - %i\n", keycode);
			break;
			case KeyRelease:
				timeDiff = (long) xev.xkey.time - (long) clickTime;
				if(debug) printf("Key release - %i\n", keycode);
				if(debug) printf("Key press duration - %i\n", timeDiff);
				// FIXME: test for keycode is rather useless :)
			        if(keycode == XK_Home && grabOn){
					if(timeDiff < longPressDuration)
						pageForward(display);
					else
						pageBackward(display);
				} else {
					// first press of home button
					if(debug) printf("Grab mouse events\n");
					grabOn = true;
					XGrabButton(display, AnyButton, AnyModifier, root, true, ButtonPressMask | ButtonReleaseMask, GrabModeAsync, GrabModeAsync, None, None);
				}
			break;
		}
	}

	XUngrabKeyboard(display, CurrentTime);
	if(grabOn) XUngrabButton(display, AnyButton, AnyModifier, root);

	XCloseDisplay(display);

	return 0;
}

void pageForward(Display *display){
	SendMouseEvent(display, Button1, 500, 300, true);
	usleep(10000);
	SendMouseEvent(display, Button1, 500, 300, false);
}

void pageBackward(Display *display){
        SendMouseEvent(display, Button1, 50, 300, true);
        usleep(10000);
        SendMouseEvent(display, Button1, 50, 300, false);
}

void SendMouseEvent(Display *display, int button, int x, int y, bool pressed){
	XEvent event;
	memset(&event, 0, sizeof(event));
	event.xbutton.type = pressed ? ButtonPress : ButtonRelease;
	event.xbutton.button = button;
	event.xbutton.same_screen = true;
	XQueryPointer(display, RootWindow(display, DefaultScreen(display)), 
		&event.xbutton.root, &event.xbutton.window, &event.xbutton.x_root, 
		&event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
	
	event.xbutton.subwindow = event.xbutton.window;
	
	while(event.xbutton.subwindow){
		event.xbutton.window = event.xbutton.subwindow;
		
		XQueryPointer(display, event.xbutton.window, 
			&event.xbutton.root, &event.xbutton.subwindow, &event.xbutton.x_root, 
			&event.xbutton.y_root, &event.xbutton.x, &event.xbutton.y, &event.xbutton.state);
	}
	event.xbutton.x = x;
	event.xbutton.y = y;
	if(debug) printf("Sending %i %i event: %ix%i\n", event.xbutton.type, event.xbutton.button, x, y); 

	if (!XSendEvent(display, PointerWindow, true, 0xfff, &event))
		printf("Failed to send mouse event\n");
	XFlush(display);
}

void usage(){
	printf("Usage: untouchable [OPTION]\n");
	printf("	-t <milliseconds> - minimal time home button should be hold to be treated as long press (default 1500)\n");
	printf("	-d               - debug\n");
	printf("	-h               - show this message\n");
}

Hi Baf. Do you think this would be a sensible starting place for a nicely locked down games interface?

I got the prboom thing to finally not lock due to Xorg hating on SDL and I guess I'm looking for a few other pieces of the puzzle. I do already have two TS parsing bits of code (mplayer gui, and GM code) but this actually seemed like a nice way to -STOP cvm (or not) and just overlay the game.
twobob is offline   Reply With Quote
Advert
Old 09-26-2016, 05:30 AM   #33
zxczxc
Addict
zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.zxczxc knows how many angels can dance on the head of a pin.
 
Posts: 229
Karma: 136002
Join Date: Apr 2013
Device: PW
Looking at the code, this probably will work as is for the current generation of devices... yes?

As in, it would be useful for some people for Oasis, since it has page turn buttons already.

http://www.fabiszewski.net/kindle-un...ouchable-0.1.c
zxczxc is offline   Reply With Quote
Reply


Forum Jump

Similar Threads
Thread Thread Starter Forum Replies Last Post
I removed the hacks, installed 3.1, then new hacks, and now Kindle is dead cloudyvisions Amazon Kindle 55 11-29-2023 07:27 PM
is there any way to get kindle 3 hacks/mods on a kindle touch? macman134 Kindle Developer's Corner 7 03-10-2012 10:33 AM
Handicapped man's moving endorsement of Kindle 2 Dr. Drib Amazon Kindle 1 02-28-2009 10:43 AM


All times are GMT -4. The time now is 07:13 PM.


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