PDA

View Full Version : AzboxHD plugins not work sample mwkeytest



kanber_kav
01-06-2009, 11:32 AM
/*
* Nano-X GrGrabKey() demo program.
*
* Copyright(C) 2003 Jon Foster <jon@jon-foster.co.uk>
* Based on demo2.c
*
* This program allows the GrGrabKey() API to be tested.
* It creates a window, and displays key and hotkey events it recieves
* in that window. At startup it registers a key with GrGrabKey().
* The key and the registration type can both be specified on the
* command line.
*
* Usage:
* grabdemo key {n|h|x|s}
* Key is numerical MWKEY value (default 55='a').
* The second parameter is a single letter indicating the reservation
* type. Valid values:
* n - Normal (GR_GRAB_HOTKEY_EXCLUSIVE) (default)
* h - Hotkey (GR_GRAB_HOTKEY)
* x - eXclusive (GR_GRAB_EXCLUSIVE)
* m - Mouse (GR_GRAB_EXCLUSIVE_MOUSE)
*/

#define MWINCLUDECOLORS
#include <stdio.h>
#include <stdlib.h>
#include <unistd.h>
#include "nano-X.h"

#include <signal.h>

static GR_WINDOW_ID main_window;
static GR_GC_ID main_gc;

static char message1[100] = "";
static char message2[100] = "";
static char message3[100] = "";
static char message4[100] = "";
static char message5[100] = "Try pressing keys...";

#define WIDTH 500
#define HEIGHT 110

typedef struct {

const char *name;
int mode;
// key translation pattern
// 0=DOWN/DOWN/.../UP
// 1=DOWN/DOWN/.../LONG/UP
// 2=DOWN/.../LONG/.../UP
// 3=.../LONG --> DOWN+UP or .../UP --> DOWN/UP
int count;
int key[2];
unsigned short mwkey;

}keys_map_td210;

#define MAX_KEY 60
keys_map_td210 keys_td210[MAX_KEY] = {
{ "MWKEY_ASCII_0", 0, 3, { 0, 4 }, '0'}, // 0 T0
{ "MWKEY_ASCII_1", 0, 3, { 1, 5 }, '1'}, // 1 T1
{ "MWKEY_ASCII_2", 0, 3, { 2, 6 }, '2'}, // 2 T2
{ "MWKEY_ASCII_3", 0, 3, { 3, 7 }, '3'}, // 3 T3
{ "MWKEY_ASCII_4", 0, 3, { 4, 8 }, '4'}, // 4 T4
{ "MWKEY_ASCII_5", 0, 3, { 5, 9 }, '5'}, // 5 T5
{ "MWKEY_ASCII_6", 0, 3, { 6, 10 }, '6'}, // 6 T6
{ "MWKEY_ASCII_7", 0, 3, { 7, 11 }, '7'}, // 7 T7
{ "MWKEY_ASCII_8", 0, 3, { 8, 12 }, '8'}, // 8 T8
{ "MWKEY_ASCII_9", 0, 3, { 9, 13 }, '9'}, // 9 T9
{ "MWKEY_CHANNEL_UP", 0, 3, { 10, 16 }, MWKEY_CHANNEL_UP}, // A CHUP
{ "MWKEY_CHANNEL_DOWN", 0, 3, { 11, 17 }, MWKEY_CHANNEL_DOWN}, // B CHDOWN
{ "Not Allowed", 0, 3, { 12, 18 }, 0}, // C VOLDOWN
{ "Not Allowed", 0, 3, { 13, 19 }, 0}, // D VOLUP
{ "Not Allowed", 2, 6, { 14, 20 }, 0}, // E MUTE
{ "MWKEY_UNKNOWN", 0, 3, { 15, 0 }, MWKEY_UNKNOWN}, // F NONE
{ "MWKEY_ENTER", 0, 3, { 16, 21 }, MWKEY_ENTER}, // 10 OK
{ "MWKEY_MENU", 0, 3, { 17, 22 }, MWKEY_MENU}, // 11 MENU
{ "MWKEY_UP", 0, 3, { 18, 23 }, MWKEY_UP}, // 12 UP
{ "MWKEY_DOWN", 0, 3, { 19, 24 }, MWKEY_DOWN}, // 13 DOWN
{ "MWKEY_LEFT", 0, 3, { 20, 25 }, MWKEY_LEFT}, // 14 LEFT
{ "MWKEY_RIGHT", 0, 3, { 21, 26 }, MWKEY_RIGHT}, // 15 RIGHT
{ "MWKEY_ESCAPE", 0, 3, { 22, 28 }, MWKEY_ESCAPE}, // 16 EXIT
{ "MWKEY_REWIND", 0, 3, { 23, 34 }, MWKEY_REWIND}, // 17 REW
{ "MWKEY_STOP", 0, 3, { 24, 35 }, MWKEY_STOP}, // 18 STOP
{ "MWKEY_PLAY", 0, 3, { 25, 36 }, MWKEY_PLAY}, // 19 PLAY
{ "MWKEY_FAST_FWD", 0, 3, { 26, 37 }, MWKEY_FAST_FWD}, // 1A FWD
{ "MWKEY_TRACK_PREV", 0, 3, { 27, 38 }, MWKEY_TRACK_PREV}, // 1B PREV
{ "MWKEY_TRACK_NEXT", 0, 3, { 28, 39 }, MWKEY_TRACK_NEXT}, // 1C NEXT
{ "MWKEY_RECORD", 0, 3, { 29, 40 }, MWKEY_RECORD}, // 1D RECORD
{ "MWKEY_BACKSPACE", 0, 3, { 30, 14 }, MWKEY_BACKSPACE}, // 1E DEL
{ "MWKEY_UNKNOWN", 0, 3, { 31, 0 }, MWKEY_UNKNOWN}, // 1F NONE
{ "MWKEY_CAPSLOCK", 0, 3, { 32, 15 }, MWKEY_CAPSLOCK}, // 20 CAPS
{ "MWKEY_COLORED_KEY_0", 0, 3, { 33, 58 }, MWKEY_COLORED_KEY_0}, // 21 RED
{ "MWKEY_COLORED_KEY_1", 0, 3, { 34, 59 }, MWKEY_COLORED_KEY_1}, // 22 GREEN
{ "MWKEY_COLORED_KEY_2", 0, 3, { 35, 60 }, MWKEY_COLORED_KEY_2}, // 23 YELLOW
{ "MWKEY_COLORED_KEY_3", 0, 3, { 36, 61 }, MWKEY_COLORED_KEY_3}, // 24 BLUE
{ "MWKEY_GUIDE", 0, 3, { 37, 41 }, MWKEY_GUIDE}, // 25 Guide
{ "MWKEY_F1", 0, 3, { 38, 30 }, MWKEY_F1}, // 26 CHECK
{ "Not Allowed", 0, 3, { 39, 56 }, 0}, // 27 RESOL
{ "MWKEY_INFO", 0, 3, { 40, 47 }, MWKEY_INFO}, // 28 INFO
{ "MWKEY_F2", 0, 3, { 41, 57 }, MWKEY_F2}, // 29 TVRADIO
{ "MWKEY_UNKNOWN", 2, 7, { 42, 1 }, MWKEY_UNKNOWN}, // 2A Power
{ "MWKEY_HOME", 2, 3, { 43, 46 }, MWKEY_HOME}, // 2B Home
{ "Not Allowed", 0, 3, { 44, 53 }, 0}, // 2C UHF
{ "Not Allowed", 0, 3, { 45, 54 }, 0}, // 2D AUX
{ "Not Allowed", 0, 3, { 46, 55 }, 0}, // 2E USB Eject
{ "MWKEY_F3", 0, 3, { 47, 29 }, MWKEY_F3}, // 2F Search
/* New Key */
{ "MWKEY_ESCAPE", 0, 3, { 48, 63 }, MWKEY_ESCAPE}, // 30 UTUBE
{ "MWKEY_ESCAPE", 0, 3, { 49, 64 }, MWKEY_ESCAPE}, // 31 WWW
{ "MWKEY_ESCAPE", 0, 3, { 50, 65 }, MWKEY_ESCAPE}, // 32 EMAIL
/* Front Key */
{ "MWKEY_UP", 0, 3, { 51, 44 }, MWKEY_UP}, // 33 ---UP
{ "MWKEY_DOWN", 0, 3, { 52, 45 }, MWKEY_DOWN}, // 34 ---DOWN
{ "MWKEY_LEFT", 3, 3, { 53, 42 }, MWKEY_LEFT}, // 35 ---LEFT
{ "MWKEY_RIGHT", 3, 3, { 54, 43 }, MWKEY_RIGHT}, // 36 ---RIGHT
{ "MWKEY_HOME", 0, 3, { 55, 46 }, MWKEY_HOME}, // 37 ---LAN(HOME)
//{ "K_LAN__", 0, 3, { 55, 62 }, }, // 37 ---LAN(HOME)
/* Virtual Key */
{ "MWKEY_ESCAPE", 0, 3, { 56, 49 }, MWKEY_ESCAPE}, // 38 SLEEP
{ "MWKEY_ESCAPE", 0, 3, { 57, 50 }, MWKEY_ESCAPE}, // 39 WAKEUP
{ "", 0, 3, { 58, 51 }, MWKEY_UNKNOWN}, // 40 VSLEEP
{ "", 0, 3, { 59, 52 }, MWKEY_UNKNOWN}, // 41 VWAKEUP
};

/* A counter - used so you can see the display being updated. */
static int getSerialNumber(void)
{
static int serial = 0;
if (++serial >= 1000)
serial = 0;
return serial;
}

/* If a character is ASCII, return it, else return a question mark. */
static char keyToChar(int key)
{
if ((key >= 32) && (key <= 127)) {
return (char)key;
} else {
return '?';
}
}

/* Makes a GrGrabKey() type paramater into a human-readable string */
static const char *grabKindName(int kind)
{
switch (kind) {
case GR_GRAB_HOTKEY_EXCLUSIVE:
return "GR_GRAB_HOTKEY_EXCLUSIVE";
case GR_GRAB_HOTKEY:
return "GR_GRAB_HOTKEY";
case GR_GRAB_EXCLUSIVE:
return "GR_GRAB_EXCLUSIVE";
case GR_GRAB_EXCLUSIVE_MOUSE:
return "GR_GRAB_EXCLUSIVE_MOUSE";
default:
return "Invalid GR_GRAB_ mode";
}
}

/* Repaint a specified area of the window */
static void repaint(int x, int y, int width, int height)
{
GrSetGCForeground(main_gc, GrGetSysColor(GR_COLOR_APPWINDOW) );
GrFillRect(main_window, main_gc, x, y, width, height);
GrSetGCForeground(main_gc, GrGetSysColor(GR_COLOR_APPTEXT));
GrSetGCUseBackground(main_gc, GR_FALSE);
GrText(main_window, main_gc, 10, 20, message1, -1, GR_TFASCII);
GrText(main_window, main_gc, 10, 40, message2, -1, GR_TFASCII);
GrText(main_window, main_gc, 10, 60, message3, -1, GR_TFASCII);
GrText(main_window, main_gc, 10, 80, message4, -1, GR_TFASCII);
GrText(main_window, main_gc, 10, 100, message5, -1, GR_TFASCII);
GrRect(main_window, main_gc, 5, 5, WIDTH - 10, HEIGHT - 10);
}

/* Repaint the entire window */
static void repaintAll(void)
{
repaint(0,0,WIDTH,HEIGHT);
}

int
main(int argc,char **argv)
{
GR_EVENT event;
GR_WM_PROPERTIES props;
int grabResult;
int key = 'a';
int grabKind = GR_GRAB_HOTKEY_EXCLUSIVE;

if (argc >= 2)
key = atoi(argv[1]);

if (argc >= 3) {
switch (argv[2][0]) {
case 'n':
grabKind = GR_GRAB_HOTKEY_EXCLUSIVE;
break;
case 'h':
grabKind = GR_GRAB_HOTKEY;
break;
case 'x':
grabKind = GR_GRAB_EXCLUSIVE;
break;
case 'm':
grabKind = GR_GRAB_EXCLUSIVE_MOUSE;
break;
default:
printf( "Usage: %s key {n|h|x|s}\n"
"Key is numeric MWKEY value (default 55='a'), type is:\n"
" n - Normal (GR_GRAB_HOTKEY_EXCLUSIVE) (default)\n"
" h - Hotkey (GR_GRAB_HOTKEY)\n"
" x - eXclusive (GR_GRAB_EXCLUSIVE)\n"
" m - Mouse (GR_GRAB_EXCLUSIVE_MOUSE)\n",
argv[0]);
break;
}
}

if (GrOpen() < 0) {
printf("Can't open graphics\n");
exit(1);
}

/* pass errors through main loop*/
GrSetErrorHandler(NULL);

main_window = GrNewWindow(GR_ROOT_WINDOW_ID, 20, 20, WIDTH, HEIGHT,
0, GREEN, BLACK);

props.flags = GR_WM_FLAGS_PROPS | GR_WM_FLAGS_TITLE;
props.props = GR_WM_PROPS_NOBACKGROUND;
props.title = "Nano-X GrabKey Demo";
GrSetWMProperties(main_window, &props);

main_gc = GrNewGC();

printf("Exclusively reserving key %d ('%c'): ", key, keyToChar(key));
grabResult = GrGrabKey(main_window, key, grabKind);
printf("%d\n", grabResult);

GrSelectEvents(main_window, GR_EVENT_MASK_EXPOSURE | GR_EVENT_MASK_CLOSE_REQ
| GR_EVENT_MASK_KEY_DOWN | GR_EVENT_MASK_KEY_UP);
GrMapWindow(main_window);
GrSetFocus(main_window);

sprintf(message1,"Exclusively reserving key %d ('%c'): %s (Mode: %s)\n",
key, keyToChar(key),
(grabResult ? "success" : "failure"),
grabKindName(grabKind));

for (;;) {
GrGetNextEvent(&event);
switch (event.type) {
case GR_EVENT_TYPE_EXPOSURE:
repaint(event.exposure.x, event.exposure.y,
event.exposure.width, event.exposure.height);
break;
case GR_EVENT_TYPE_CLOSE_REQ:
GrClose();
exit(0);
break;
case GR_EVENT_TYPE_ERROR:
printf("\7grabdemo: Error (%s) ", event.error.name);
printf(nxErrorStrings[event.error.code],event.error.id);
break;
case GR_EVENT_TYPE_KEY_DOWN:
if (event.keystroke.hotkey)
sprintf(message4, "%03d Hotkey %d ('%c') scan %d pressed\n",
getSerialNumber(), event.keystroke.ch,
keyToChar(event.keystroke.ch), event.keystroke.scancode);
else
{
int i;
for(i=0;i<MAX_KEY;i++)
{
if(keys_td210[i].mwkey == event.keystroke.ch)
{

sprintf(message2, "%03d Key %d (%s) scan %d pressed\n",
getSerialNumber(), event.keystroke.ch,
keys_td210[i].name, event.keystroke.scancode);
break;
}

}
if(i >= MAX_KEY)
{
sprintf(message2, "%03d Key %d ('%c') scan %d pressed\n",
getSerialNumber(), event.keystroke.ch,
keyToChar(event.keystroke.ch), event.keystroke.scancode);

}
}
repaintAll();
break;
case GR_EVENT_TYPE_KEY_UP:
if (event.keystroke.hotkey)
sprintf(message5, "%03d Hotkey %d ('%c') released\n",
getSerialNumber(), event.keystroke.ch, keyToChar(event.keystroke.ch));
else
sprintf(message3, "%03d Key %d ('%c') released\n",
getSerialNumber(), event.keystroke.ch, keyToChar(event.keystroke.ch));
repaintAll();
break;
}
}

GrClose();
return 0;
}

plugin dont work.

Where there are errors?

terminal output.

nxclient: retry connect attempt 1
nxclient: retry connect attempt 2
nxclient: retry connect attempt 3
nxclient: retry connect attempt 4
nxclient: retry connect attempt 5
nxclient: retry connect attempt 6
nxclient: retry connect attempt 7
nxclient: retry connect attempt 8
nxclient: retry connect attempt 9
nxclient: retry connect attempt 10

Can't open graphics

Help me.....


Thanks.

tinos
01-06-2009, 11:35 AM
I think nano-x plugins fail with latest firmware try with 2032. Are you on latest firmware?

kanber_kav
01-06-2009, 12:12 PM
firmware 2163 but notwork plugins , OpanXCAS2 not work . uuff

tinos
01-06-2009, 01:59 PM
Yes, both plugins use nano-x... others work. I use 2032 firmware and mwkeytest is Ok.

kanber_kav
02-06-2009, 04:08 PM
http://img37.imageshack.us/img37/5144/screenshotucy.png

Microwindows runing Ubuntu 8.04 runin azbox plugins file hehehe

tinos
02-06-2009, 04:23 PM
Nice!!! Can you post a small howto or what is needed to run it inside Ubuntu?

DJBlu
09-06-2009, 07:20 PM
If anyone knows how to get debugging to work in Eclipse Platform then please can you let me know.

Thanks.

kanber_kav
09-06-2009, 11:36 PM
If anyone knows how to get debugging to work in Eclipse Platform then please can you let me know.

Thanks.


wait...

give a faq soon.

medmed
17-06-2009, 10:03 AM
@kanber_kav
what's new for mini "how to" or faq

goran
17-06-2009, 10:35 AM
OpenXCAS2 is only meant for developers, btw - very buggy...

It's an example and a tool to develop more plug-ins.

I was told... ;)

medmed
17-06-2009, 01:48 PM
@kanber_kav

wait...

give a faq soon.

what's new for mini "how to" or faq

nobbystyles
17-06-2009, 01:59 PM
@kanber_kav
what's new for mini "how to" or faq


@kanber_kav
what's new for mini "how to" or faq

Have you been watching groundhog day mate? :D

medmed
17-06-2009, 02:04 PM
english please ! english :respect-050:

pr2
17-06-2009, 05:15 PM
Groundhog day is a movie with Bill Murray.
He starts over always the same day.

h**p://www.imdb.com/title/tt0107048/

(C'est "un jour sans fin" en français).

Pr2