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-28-2012, 08:27 AM   #181
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,379
Karma: 2155307
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
In fact I'm always very happy when someone takes work from me to the next level. So I'm not the least annoyed. I just lost track on where you were heading.
hawhill is offline   Reply With Quote
Old 11-28-2012, 09:38 AM   #182
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
Ah. Okay. Abandoned sound for now. till I get a libasound.a that doesn't blow up

Adding TS code. Got some debug output.

Currently have an issue where the graphics get trashed when I change the

Quote:
for(c = 0; c < 3; c++) {
if(inputfds[c] < 0) continue;
while (read(inputfds[c],&iev,sizeof(struct input_event)) == sizeof(struct input_event)) {
loop...

But I'm working on it

Thanks.
twobob is offline   Reply With Quote
Old 11-28-2012, 10:51 AM   #183
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,379
Karma: 2155307
Join Date: Nov 2010
Location: Goettingen, Germany
Device: Kindle Paperwhite, Kobo Mini
Funny, I don't see where this could blow up the graphics... Except, of course, timing issues. Note that all file descriptors must be opened non-blocking, which is different from the default when opening files (and device nodes).
hawhill is offline   Reply With Quote
Old 11-28-2012, 11:27 AM   #184
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
Got some input working now... later 2 posts

Spoiler:
it's the loop that handles the input.h

In essence you export the value into a stuct "&iev" so you can iev.type of whatever.

Quote:
while (read(inputfds[c], &iev, sizeof(struct input_event))
== sizeof(struct input_event)) {
But my TS code is expecting a unsigned char [16] for the event buffer...
maybe this is as simple as a cast or something... but I can't quite get it.

Quote:
while (read(inputfds[c], event_buffer, sizeof(struct input_event))
== sizeof(struct input_event)) {
So yeah I just want the input from inputfds[3] to go into event_buffer and the others [0-2] to go into your struct!!!

I made an unrolled version of the code to show the two bits I am welding together.

(YOU DON'T HAVE TO READ IT... Just showing what I have done)

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>

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

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

#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];
	int deviceCount = 4;
	for (c = 0; c < deviceCount; 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;
	int deviceCount = 4;
	for (c = 0; c < deviceCount; c++) {
		if (inputfds[c] < 0)
			continue;
		close(inputfds[c]);
	}
}

void update(int refresh) {   // #FIXME. Partial screen update. this is horrible
	if (refresh) {
		system("eips -f ''");
	} else {
		system("eips ''");
	}
}

void joy_poll() {
	event_t ev;

	struct input_event iev;
	int c;
	int deviceCount = 4;

	// Add in some TS initial values

	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

	//

	for (c = 0; c < deviceCount - 1; 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 {
					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:
					// This would output the codes for unhandled key presses.
					// fprintf(stderr, "iev.code <%i>\n", iev.code);
					fprintf(stderr, "iev.code <%i>\n", iev.code);
					fprintf(stderr, "ev.code <%i>\n", ev.code);
					continue;
				}
				ev_postevent(&ev);
				fprintf(stderr, "sizeof(struct input_event) %i \n",
						sizeof(struct input_event));
			}
		}
	}

	// AGAIN  !!!!  <-- I would like to handle this loop again. or change the &iev to actually be read in as event_buffer
	// Then I can simply meld what is below into what is above.... 
	// (I did this once and realised the inconsistancy in the buffers types Uchar[16]? and a custom stuct.
	// So I unrolled it all again like this to show you what I meant.
	// Hope that is clear.

/*
	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);
	}
*/

}


And here is a version that squashes them together.
It needs to populate the event_buffer somehow. or cast my struct to an unsigned char [16] - or something : )

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>

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

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

#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) {   // #FIXME. Just add the code for partial screen update on all devices. 

// this is horrible and 5 sets of headers and all the headaches they bring HAVE to be better than this...
	if (refresh) {
		system("eips -f ''");
	} else {
		system("eips ''");
	}
}

void joy_poll() {
	event_t ev;

	struct input_event iev;
	int c;

	// Add in some TS initial values

	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

	//

	for (c = 0; c < 3; c++) {
		if (inputfds[c] < 0)
			continue;
		while (read(inputfds[c], &iev, sizeof(struct input_event))
				== sizeof(struct input_event)) {
			
// Ha. I wish...
//event_buffer = (unsigned char[16])iev;  // or something?? I'm looking into it...

			// This test will obviously never match "event_buffer[0x08] == 0x03" 
			//since event buffer is currently unpopulated
			
				if (iev.type == EV_KEY || event_buffer[0x08] == 0x03 ) {

				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:
						continue;

					}

					// End of Switch

					// TODO: This does what now???

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

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

						// seemingly pointless code TODO: check relevance

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

						/* 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;
							}

						}

						/* END OF: Fingers are up. Did we just push exit / clear? */

					}
					// end of: if (sync)

				}
				// End of if (event_buffer[0x08] == 0x03)

				else if (iev.value == 1) {
					ev.type = EV_PRESS;
				} else if (iev.value == 0) {
					ev.type = EV_RELEASE;
				} else {
					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:
					// This would output the codes for unhandled key presses.
					// fprintf(stderr, "iev.code <%i>\n", iev.code);
					
					continue;
				}
				ev_postevent(&ev);
				// Let's have some output....
				fprintf(stderr, "iev.code <%i>\n", iev.code);
				fprintf(stderr, "ev.code <%i>\n", ev.code);
			}
		}
	}
}

Last edited by twobob; 11-28-2012 at 02:01 PM. Reason: added almost complete version.
twobob is offline   Reply With Quote
Old 11-28-2012, 11:44 AM   #185
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
Issues with casting

Spoiler:
while (read(inputfds[c], &iev, sizeof(struct input_event))
== sizeof(struct input_event)) {
event_buffer = (unsigned char*)&iev;
if (iev.type == EV_KEY || event_buffer[0x08] == 0x03 ) {

Quote:
sys/linux/kindleinput.c:92: error: incompatible types in assignment
??? grr Syntax unsigned char?

meh. casting. meh.

I have also had

Quote:
sys/linux/kindleinput.c:92: error: cannot convert to a pointer type
Hmm.. goes to read up on casting. in c...

Last edited by twobob; 11-28-2012 at 01:09 PM.
twobob is offline   Reply With Quote
Old 11-28-2012, 12:05 PM   #186
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
ah phooey. Will just abandon trying to make it work on both devices for now.

Will revisit when I get my head round if I can read from the buffer twice. or reading into a temp location. or something.

will concentrate on the TS implementation.
twobob is offline   Reply With Quote
Old 11-28-2012, 02:01 PM   #187
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
okay. I have some input working now. will expand on it.

This more or less works,

with a few issues.

need to send the right Key RELEASE codes I think to stop the infinite Joy Direction repeat.

But essentially working (other than that show-stopping niggle)
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>

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

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

#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 < 4; 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 < 4; c++) {
		if (inputfds[c] < 0)
			continue;
		close(inputfds[c]);
	}
}

void update(int refresh) {   // #FIXME. Partial screen update. this is horrible
	if (refresh) {
		system("eips -f ''");
	} else {
		system("eips ''");
	}
}

void joy_poll() {
	event_t ev;

	struct input_event iev;
	int c;

	// Add in some TS initial values

	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

	//

	for (c = 2; c < 4; c++) {
		if (inputfds[c] < 0)
			continue;
		//while (read(inputfds[c], &iev, sizeof(struct input_event))
		//			== sizeof(struct input_event)) {

		while (read(inputfds[c], event_buffer, 16) == 16) {

			//	event_buffer = (unsigned char *)&iev;

			//	&iev = (struct input_event)event_buffer;

			if (event_buffer[0x08] == 0x03) {

				// if (iev.type == EV_KEY || 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;
						ev.type = EV_PRESS;

					} else if (event_buffer[0x0C] == 0x01) {
						ev.type = EV_PRESS;
						finger2 = DOWN;
					} else {
						if (finger2 == DOWN) {
							ev.type = EV_PRESS;
							finger2 = UP;
						} else {
							ev.type = EV_RELEASE;
							finger = UP;
						}

					}
					break;
				default:
					update(0);
					//continue;
					break;

				}

				// End of Switch

				// TODO: This does what now???

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

				//if (sync) { /* We have received a sync */
				if (1) { /* We have received a sync */

					// seemingly pointless code TODO: check relevance

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

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

						}

						if (x <= 290 && y >= 210 && y <= 560) {

							// S (start)
							ev.code = K_JOY3;
							ev_postevent(&ev);
							fprintf(stderr, "RELEASE <%i>\n", ev.code);
							sync = 0;
							fprintf(stderr, "ev.code <%i>\n", K_JOY3);

						}

						else if (x >= 310 && y >= 210 && y <= 560) {

							// A (select)
							ev.code = K_JOY2;
							ev_postevent(&ev);
							fprintf(stderr, "RELEASE <%i>\n", ev.code);
							sync = 0;

						}

						else if (x <= 160 && y >= 580) {

							// Z  (left fire)
							ev.code = K_JOY1;
							ev_postevent(&ev);
							fprintf(stderr, "RELEASE <%i>\n", ev.code);
							sync = 0;

						}

						else if (x >= 170 && x <= 300 && y >= 580) {

							// X  (right fire)
							ev.code = K_JOY0;
							ev_postevent(&ev);
							fprintf(stderr, "RELEASE <%i>\n", ev.code);
							sync = 0;

						}

						else if (x >= 400 && x <= 510 && y >= 580 && y <= 650) {

							// Joy Up  
							ev.code = K_JOYUP;
							ev_postevent(&ev);
							fprintf(stderr, "RELEASE <%i>\n", ev.code);
							sync = 0;

						}

						else if (x >= 400 && x <= 510 && y >= 710) {

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

						}

						else if (x >= 370 && x <= 440 && y >= 650 && y <= 710) {

							// Joy LEFT  
							ev.code = K_JOYLEFT;
							ev_postevent(&ev);
							fprintf(stderr, "RELEASE <%i>\n", ev.code);
							sync = 0;

						}

						else if (x >= 510 && y >= 650 && y <= 710) {

							// Joy RIGHT  
							ev.code = K_JOYRIGHT;
							ev_postevent(&ev);
							fprintf(stderr, "RELEASE <%i>\n", ev.code);
							sync = 0;

						}

						// End of else if's
					}

					/* END OF: Fingers are up. Did we just push exit / clear? */

				}
				// end of: if (sync)

			}
		}
	}
}

Last edited by twobob; 11-28-2012 at 07:04 PM. Reason: && not &
twobob is offline   Reply With Quote
Old 11-28-2012, 05:19 PM   #188
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
okay... so there are obviously a few inconsistencies in the way a TS and a button work.

Basically it would seem I need to stuff a EV_RELEASE into the relevant code after an instance/sequence of EV_PRESS since they are very often not posted.

I suspect my TS logic is flawed (I was hoping to just post back two events in the same "while" loop but that seems to not work) but yeah. I have it working from the TS . all buttons accounted for. just need to control the flood a but more
twobob is offline   Reply With Quote
Old 11-28-2012, 07:44 PM   #189
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
Hmm any clues on how to "fake" a button press...

My events aren't neatly triggering Pressed / Unpressed. I need to tidy them up...

Perhaps I should query the event queue contents and insert something there?

As Hawhill pointed out before, I'm not 100% what is the right solution to this issue.
Reticent to smear the thread with more ideas.

Input gratefully accepted : )

EDIT: Added screenie of the files involved in the events chain for the next poor soul

I WILL find a place to emulate a click!
Attached Thumbnails
Click image for larger version

Name:	Selection_014.png
Views:	283
Size:	20.3 KB
ID:	96970  

Last edited by twobob; 11-28-2012 at 08:48 PM.
twobob is offline   Reply With Quote
Old 11-29-2012, 01:27 AM   #190
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
hmm hacked together something using Xephyr. need to dither it...
Attached Thumbnails
Click image for larger version

Name:	TightVNC: kindle:0.0_015.png
Views:	292
Size:	21.6 KB
ID:	96972   Click image for larger version

Name:	TightVNC: kindle:0.0_016.png
Views:	299
Size:	10.8 KB
ID:	96973   Click image for larger version

Name:	TightVNC: kindle:0.0_017.png
Views:	293
Size:	12.4 KB
ID:	96974  

Last edited by twobob; 11-29-2012 at 01:33 AM.
twobob is offline   Reply With Quote
Old 12-07-2012, 09:55 PM   #191
jackhulk
Connoisseur
jackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austen
 
Posts: 52
Karma: 23642
Join Date: Oct 2011
Device: K3 3G
Hello All

Perhaps one of you nice fellows could help me please?

Just when I was due to go to sleep early tonight, I came across this awesome kindlet (or app - not sure of the correct terminology?)! Well that was about 2 hours ago now, read through the whole thread several times and still haven't got this running yet!

Running W7, so on root I have the following....

fbgnuboy [Dir]
>roms [Dir]
>fbgnuboy
>gb-flash.jpg
>rungame

rungame is script from post #145.

In launchpad I have...

fbgnuboy.ini

...which reads...

Quote:
[Actions]

## Launch the Gameboy Emulator
G B = !/mnt/us/fbgnuboy/rungame
Every time I try to run, it fails. Any idea where I am going wrong please?

Thank you

Last edited by jackhulk; 12-07-2012 at 10:04 PM.
jackhulk is offline   Reply With Quote
Old 12-07-2012, 09:58 PM   #192
qlob
Official Lurker
qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.
 
qlob's Avatar
 
Posts: 1,050
Karma: 7096675
Join Date: Apr 2012
Device: Kindle 3.4
can you elaborate on "fails"?

you might need to press shift shift space before pressing shift g b
qlob is offline   Reply With Quote
Old 12-07-2012, 10:01 PM   #193
jackhulk
Connoisseur
jackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austen
 
Posts: 52
Karma: 23642
Join Date: Oct 2011
Device: K3 3G
Sorry, launchpad is running and when I enter G B which is registered, launchpad states 'Failure.'
jackhulk is offline   Reply With Quote
Old 12-07-2012, 10:02 PM   #194
jackhulk
Connoisseur
jackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austenjackhulk has memorized the entire works of Homer, Shakespeare, and Jane Austen
 
Posts: 52
Karma: 23642
Join Date: Oct 2011
Device: K3 3G
Please delete this post.

Last edited by jackhulk; 12-07-2012 at 10:03 PM. Reason: Hit wrong button, I was trying to edit prev post.
jackhulk is offline   Reply With Quote
Old 12-07-2012, 10:06 PM   #195
qlob
Official Lurker
qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.qlob ought to be getting tired of karma fortunes by now.
 
qlob's Avatar
 
Posts: 1,050
Karma: 7096675
Join Date: Apr 2012
Device: Kindle 3.4
Errrr do you have roms in the roms folder? that's the only thing I can think of, you'll just have to wait for twobob or someone more knowledgeable to come help i guess...

do you have USBnet installed? do you know how to use it?
qlob 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 531 12-11-2020 02:55 PM
Gameboy emulator on PE bunodosoma enTourage eDGe 2 11-16-2011 08:19 PM
Gameboy screen bookmeal General Discussions 7 10-03-2011 02:40 PM
software suggestion: virtualboy(gameboy emulator) arfarf624 Kindle Developer's Corner 3 07-27-2011 05:06 AM
Free (GPLv2) Translation Dictionaries Elleo Amazon Kindle 3 01-11-2011 10:57 PM


All times are GMT -4. The time now is 09:54 AM.


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