2011-04-12 21:45:27 +02:00
|
|
|
/*
|
|
|
|
* Copyright (c) 2011, Swedish Institute of Computer Science.
|
|
|
|
* All rights reserved.
|
|
|
|
*
|
|
|
|
* Redistribution and use in source and binary forms, with or without
|
|
|
|
* modification, are permitted provided that the following conditions
|
|
|
|
* are met:
|
|
|
|
* 1. Redistributions of source code must retain the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer.
|
|
|
|
* 2. Redistributions in binary form must reproduce the above copyright
|
|
|
|
* notice, this list of conditions and the following disclaimer in the
|
|
|
|
* documentation and/or other materials provided with the distribution.
|
|
|
|
* 3. Neither the name of the Institute nor the names of its contributors
|
|
|
|
* may be used to endorse or promote products derived from this software
|
|
|
|
* without specific prior written permission.
|
|
|
|
*
|
|
|
|
* THIS SOFTWARE IS PROVIDED BY THE INSTITUTE AND CONTRIBUTORS ``AS IS'' AND
|
|
|
|
* ANY EXPRESS OR IMPLIED WARRANTIES, INCLUDING, BUT NOT LIMITED TO, THE
|
|
|
|
* IMPLIED WARRANTIES OF MERCHANTABILITY AND FITNESS FOR A PARTICULAR PURPOSE
|
|
|
|
* ARE DISCLAIMED. IN NO EVENT SHALL THE INSTITUTE OR CONTRIBUTORS BE LIABLE
|
|
|
|
* FOR ANY DIRECT, INDIRECT, INCIDENTAL, SPECIAL, EXEMPLARY, OR CONSEQUENTIAL
|
|
|
|
* DAMAGES (INCLUDING, BUT NOT LIMITED TO, PROCUREMENT OF SUBSTITUTE GOODS
|
|
|
|
* OR SERVICES; LOSS OF USE, DATA, OR PROFITS; OR BUSINESS INTERRUPTION)
|
|
|
|
* HOWEVER CAUSED AND ON ANY THEORY OF LIABILITY, WHETHER IN CONTRACT, STRICT
|
|
|
|
* LIABILITY, OR TORT (INCLUDING NEGLIGENCE OR OTHERWISE) ARISING IN ANY WAY
|
|
|
|
* OUT OF THE USE OF THIS SOFTWARE, EVEN IF ADVISED OF THE POSSIBILITY OF
|
|
|
|
* SUCH DAMAGE.
|
|
|
|
*
|
|
|
|
* This file is part of the Contiki operating system.
|
|
|
|
*
|
|
|
|
* Author: François Revol <revol@free.fr>
|
|
|
|
*/
|
|
|
|
|
|
|
|
#include <curses.h>
|
|
|
|
#include <signal.h>
|
|
|
|
#include <stdlib.h>
|
|
|
|
#include <string.h>
|
|
|
|
#include <term.h>
|
|
|
|
#include <unistd.h>
|
|
|
|
|
|
|
|
#include "contiki.h"
|
|
|
|
#include "ctk/ctk.h"
|
|
|
|
|
|
|
|
#include "ctk-curses.h"
|
|
|
|
|
|
|
|
/* references:
|
|
|
|
* http://math.hws.edu/orr/s04/cpsc225/curses.html
|
2013-03-30 23:07:38 +01:00
|
|
|
* http://linux.die.net/man/3/ncurses
|
|
|
|
* http://linux.die.net/HOWTO/NCURSES-Programming-HOWTO/index.html
|
2011-04-12 21:45:27 +02:00
|
|
|
*/
|
|
|
|
|
|
|
|
#define MKPAIR(bg, fg) (bg << 3 | fg)
|
|
|
|
|
|
|
|
static unsigned char width;
|
|
|
|
static unsigned char height;
|
|
|
|
|
|
|
|
static unsigned char color;
|
|
|
|
static unsigned char reversed;
|
|
|
|
|
|
|
|
static ctk_arch_key_t keys[256];
|
2012-06-23 13:07:19 +02:00
|
|
|
static unsigned char keys_in, keys_out;
|
|
|
|
static unsigned char available;
|
2011-04-12 21:45:27 +02:00
|
|
|
|
|
|
|
static unsigned short xpos;
|
|
|
|
static unsigned short ypos;
|
2012-06-23 13:07:19 +02:00
|
|
|
static unsigned char button;
|
2011-04-12 21:45:27 +02:00
|
|
|
|
2013-03-26 11:37:10 +01:00
|
|
|
/* map CTK colors to curses colors */
|
|
|
|
static unsigned char ctk_color_map[8] = {
|
|
|
|
COLOR_BLACK,
|
|
|
|
COLOR_RED,
|
|
|
|
COLOR_GREEN,
|
|
|
|
COLOR_YELLOW,
|
|
|
|
COLOR_BLUE,
|
|
|
|
COLOR_MAGENTA,
|
|
|
|
COLOR_CYAN,
|
|
|
|
COLOR_WHITE
|
|
|
|
};
|
|
|
|
|
2013-03-30 17:57:01 +01:00
|
|
|
/*-----------------------------------------------------------------------------------*/
|
2013-03-31 04:07:03 +02:00
|
|
|
static unsigned char
|
|
|
|
map_color(unsigned char color)
|
2013-03-26 11:37:10 +01:00
|
|
|
{
|
|
|
|
unsigned char c;
|
2013-03-31 04:07:03 +02:00
|
|
|
|
2013-03-26 11:37:10 +01:00
|
|
|
c = ctk_color_map[color & 0x0f];
|
|
|
|
c |= ctk_color_map[(color >> 4) & 0x07] << 4;
|
|
|
|
return c;
|
|
|
|
}
|
2011-04-12 21:45:27 +02:00
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
ctrlhandler(int sig)
|
|
|
|
{
|
2013-03-30 17:57:01 +01:00
|
|
|
/* make sure we call console_exit() to leave the terminal in a clean state */
|
2011-04-12 21:45:27 +02:00
|
|
|
exit(EXIT_SUCCESS);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
console_init(void)
|
|
|
|
{
|
2013-03-30 17:57:01 +01:00
|
|
|
/* mouse support is ncurses-specific */
|
2013-03-26 02:01:28 +01:00
|
|
|
#ifdef NCURSES_MOUSE_VERSION
|
2011-04-14 20:26:13 +02:00
|
|
|
mmask_t oldmask;
|
2013-03-26 02:01:28 +01:00
|
|
|
#endif
|
2011-04-12 21:45:27 +02:00
|
|
|
static unsigned char done;
|
2013-03-30 23:26:22 +01:00
|
|
|
int bg, fg;
|
2012-06-23 13:07:19 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
if(done) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
done = 1;
|
|
|
|
|
|
|
|
initscr();
|
|
|
|
start_color();
|
|
|
|
cbreak();
|
2012-06-23 13:07:19 +02:00
|
|
|
|
|
|
|
/* don't echo typed characters */
|
2011-04-12 21:45:27 +02:00
|
|
|
noecho();
|
2013-03-30 23:00:44 +01:00
|
|
|
/* disable return -> newline translation */
|
|
|
|
nonl();
|
2012-06-23 13:07:19 +02:00
|
|
|
|
|
|
|
/* hide text cursor, CTK draws its own */
|
|
|
|
curs_set(0);
|
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
intrflush(stdscr, FALSE);
|
|
|
|
keypad(stdscr, TRUE);
|
|
|
|
|
2013-03-26 02:01:28 +01:00
|
|
|
#ifdef NCURSES_MOUSE_VERSION
|
2011-04-14 20:26:13 +02:00
|
|
|
/* done here because ctk_mouse_init() is called before anyway */
|
|
|
|
mousemask(ALL_MOUSE_EVENTS, &oldmask);
|
2013-03-26 02:01:28 +01:00
|
|
|
#endif
|
2011-04-14 20:26:13 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
screensize(&width, &height);
|
|
|
|
|
2013-03-30 23:26:22 +01:00
|
|
|
/* we must declare all possible color pairs */
|
|
|
|
for(fg = 0; fg < 8; fg++) {
|
|
|
|
for(bg = 0; bg < 8; bg++) {
|
|
|
|
init_pair(MKPAIR(bg, fg), fg, bg);
|
|
|
|
}
|
2011-04-12 21:45:27 +02:00
|
|
|
}
|
|
|
|
|
2012-06-23 13:07:19 +02:00
|
|
|
/* set window title */
|
2011-04-12 21:45:27 +02:00
|
|
|
putp("\033]0;Contiki\a");
|
|
|
|
|
2012-06-23 13:07:19 +02:00
|
|
|
/* don't block on read, just timeout 1ms */
|
|
|
|
timeout(1);
|
2011-04-12 21:45:27 +02:00
|
|
|
|
2013-03-30 17:57:01 +01:00
|
|
|
/* make sure we return the terminal in a clean state */
|
2011-04-12 21:45:27 +02:00
|
|
|
signal(SIGINT, ctrlhandler);
|
|
|
|
atexit(console_exit);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
console_exit(void)
|
|
|
|
{
|
|
|
|
static unsigned char done;
|
|
|
|
|
|
|
|
if(done) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
done = 1;
|
|
|
|
|
|
|
|
revers(0);
|
|
|
|
clrscr();
|
|
|
|
gotoxy(0, 0);
|
|
|
|
|
|
|
|
endwin();
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned char
|
|
|
|
console_resize(void)
|
|
|
|
{
|
|
|
|
unsigned char new_width;
|
|
|
|
unsigned char new_height;
|
|
|
|
|
|
|
|
screensize(&new_width, &new_height);
|
|
|
|
|
2012-06-23 13:07:19 +02:00
|
|
|
if(new_width != width || new_height != height) {
|
|
|
|
width = new_width;
|
2011-04-12 21:45:27 +02:00
|
|
|
height = new_height;
|
|
|
|
return 1;
|
|
|
|
}
|
|
|
|
|
|
|
|
return 0;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
setcolor(void)
|
|
|
|
{
|
|
|
|
int bg, fg;
|
|
|
|
int attrs;
|
2012-06-23 13:07:19 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
fg = (color & 0x0F);
|
|
|
|
bg = (color & 0xF0) >> 4;
|
|
|
|
|
|
|
|
attrs = COLOR_PAIR(MKPAIR(bg, fg));
|
2013-03-30 23:26:22 +01:00
|
|
|
if(reversed) {
|
2011-04-12 21:45:27 +02:00
|
|
|
attrs |= WA_REVERSE;
|
2013-03-30 23:26:22 +01:00
|
|
|
}
|
2011-04-12 21:45:27 +02:00
|
|
|
attrset(attrs);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned char
|
|
|
|
wherex(void)
|
|
|
|
{
|
|
|
|
int x, y;
|
2012-06-23 13:07:19 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
getyx(stdscr, y, x);
|
2012-06-23 13:07:19 +02:00
|
|
|
(void)y;
|
2011-04-12 21:45:27 +02:00
|
|
|
return (unsigned char)x;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned char
|
|
|
|
wherey(void)
|
|
|
|
{
|
|
|
|
int x, y;
|
2012-06-23 13:07:19 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
getyx(stdscr, y, x);
|
2012-06-23 13:07:19 +02:00
|
|
|
(void)x;
|
2011-04-12 21:45:27 +02:00
|
|
|
return (unsigned char)y;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
clrscr(void)
|
|
|
|
{
|
|
|
|
clear();
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
bgcolor(unsigned char c)
|
|
|
|
{
|
2013-03-26 11:37:10 +01:00
|
|
|
c = map_color(c);
|
2012-06-23 13:07:19 +02:00
|
|
|
color = ((c << 4) | (color & 0xF0));
|
2011-04-12 21:45:27 +02:00
|
|
|
/* Presume this to be one of the first calls. */
|
|
|
|
console_init();
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
bordercolor(unsigned char c)
|
|
|
|
{
|
|
|
|
/* Presume this to be one of the first calls. */
|
|
|
|
console_init();
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
screensize(unsigned char *x, unsigned char *y)
|
|
|
|
{
|
|
|
|
int mx, my;
|
2012-06-23 13:07:19 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
getmaxyx(stdscr, my, mx);
|
|
|
|
*x = (unsigned char)mx;
|
|
|
|
*y = (unsigned char)my;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
revers(unsigned char c)
|
|
|
|
{
|
|
|
|
reversed = c;
|
|
|
|
setcolor();
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
console_cputc(char c)
|
|
|
|
{
|
2016-12-04 16:09:55 +01:00
|
|
|
char ch = c;
|
2012-06-23 13:07:19 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
/* usually ACS_* don't fit in a char */
|
|
|
|
switch (c) {
|
2012-06-23 13:07:19 +02:00
|
|
|
case CH_ULCORNER:
|
|
|
|
ch = ACS_ULCORNER;
|
|
|
|
break;
|
|
|
|
case CH_LLCORNER:
|
|
|
|
ch = ACS_LLCORNER;
|
|
|
|
break;
|
|
|
|
case CH_URCORNER:
|
|
|
|
ch = ACS_URCORNER;
|
|
|
|
break;
|
|
|
|
case CH_LRCORNER:
|
|
|
|
ch = ACS_LRCORNER;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2011-04-12 21:45:27 +02:00
|
|
|
}
|
|
|
|
addch(ch);
|
2013-03-30 23:03:04 +01:00
|
|
|
refresh();
|
2011-04-12 21:45:27 +02:00
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
console_cputs(char *str)
|
|
|
|
{
|
|
|
|
addstr(str);
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
cclear(unsigned char length)
|
|
|
|
{
|
|
|
|
hline(' ', length);
|
2013-03-30 23:03:04 +01:00
|
|
|
refresh();
|
2011-04-12 21:45:27 +02:00
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
chline(unsigned char length)
|
|
|
|
{
|
|
|
|
hline(ACS_HLINE, length);
|
|
|
|
refresh();
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
cvline(unsigned char length)
|
|
|
|
{
|
|
|
|
vline(ACS_VLINE, length);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
gotoxy(unsigned char x, unsigned char y)
|
|
|
|
{
|
|
|
|
move(y, x);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
cclearxy(unsigned char x, unsigned char y, unsigned char length)
|
|
|
|
{
|
|
|
|
gotoxy(x, y);
|
|
|
|
cclear(length);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
chlinexy(unsigned char x, unsigned char y, unsigned char length)
|
|
|
|
{
|
|
|
|
gotoxy(x, y);
|
|
|
|
chline(length);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
cvlinexy(unsigned char x, unsigned char y, unsigned char length)
|
|
|
|
{
|
|
|
|
gotoxy(x, y);
|
|
|
|
cvline(length);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
cputsxy(unsigned char x, unsigned char y, char *str)
|
|
|
|
{
|
|
|
|
gotoxy(x, y);
|
|
|
|
console_cputs(str);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
cputcxy(unsigned char x, unsigned char y, char c)
|
|
|
|
{
|
|
|
|
gotoxy(x, y);
|
|
|
|
console_cputc(c);
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
textcolor(unsigned char c)
|
|
|
|
{
|
2013-03-26 11:37:10 +01:00
|
|
|
color = map_color(c);
|
2011-04-12 21:45:27 +02:00
|
|
|
setcolor();
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
console_readkey(int k)
|
|
|
|
{
|
|
|
|
ctk_arch_key_t key;
|
|
|
|
|
2012-06-23 13:07:19 +02:00
|
|
|
key = (ctk_arch_key_t) k;
|
|
|
|
/*fprintf(stderr, "key: %d\n", k); */
|
2011-04-12 21:45:27 +02:00
|
|
|
switch (k) {
|
2013-03-26 02:01:28 +01:00
|
|
|
#ifdef NCURSES_MOUSE_VERSION
|
2012-06-23 13:07:19 +02:00
|
|
|
case KEY_MOUSE:
|
2011-04-14 20:26:13 +02:00
|
|
|
{
|
|
|
|
MEVENT event;
|
2012-06-23 13:07:19 +02:00
|
|
|
|
|
|
|
if(getmouse(&event) == OK) {
|
2011-04-14 20:26:13 +02:00
|
|
|
xpos = event.x;
|
|
|
|
ypos = event.y;
|
|
|
|
button = event.bstate & BUTTON1_PRESSED
|
2012-06-23 13:07:19 +02:00
|
|
|
|| event.bstate & BUTTON1_CLICKED
|
|
|
|
|| event.bstate & BUTTON1_DOUBLE_CLICKED;
|
|
|
|
/*fprintf(stderr, "mevent: %d: %d, %d, %d, %lx ; %d\n",
|
|
|
|
event.id, event.x, event.y, event.z, event.bstate, button); */
|
|
|
|
}
|
2011-04-14 20:26:13 +02:00
|
|
|
return;
|
|
|
|
}
|
2013-03-26 02:01:28 +01:00
|
|
|
#endif
|
2012-06-23 13:07:19 +02:00
|
|
|
case KEY_LEFT:
|
|
|
|
key = CH_CURS_LEFT;
|
|
|
|
break;
|
|
|
|
case KEY_UP:
|
|
|
|
key = CH_CURS_UP;
|
|
|
|
break;
|
|
|
|
case KEY_RIGHT:
|
|
|
|
key = CH_CURS_RIGHT;
|
|
|
|
break;
|
|
|
|
case KEY_DOWN:
|
|
|
|
key = CH_CURS_DOWN;
|
|
|
|
break;
|
|
|
|
case KEY_F(9): /* Gnome uses F10 as menu trigger now... */
|
|
|
|
case KEY_F(10):
|
|
|
|
key = CTK_CONF_MENU_KEY;
|
|
|
|
break;
|
2013-03-30 23:00:44 +01:00
|
|
|
case '\r':
|
2012-06-23 13:07:19 +02:00
|
|
|
case KEY_ENTER:
|
|
|
|
key = CH_ENTER;
|
|
|
|
break;
|
|
|
|
case 127:
|
|
|
|
case KEY_BACKSPACE:
|
|
|
|
case KEY_DC:
|
|
|
|
key = CH_DEL;
|
|
|
|
break;
|
|
|
|
case KEY_BTAB:
|
|
|
|
case KEY_CTAB:
|
|
|
|
case KEY_PPAGE:
|
|
|
|
case KEY_PREVIOUS:
|
|
|
|
key = CTK_CONF_WIDGETUP_KEY;
|
|
|
|
break;
|
|
|
|
case KEY_NPAGE:
|
|
|
|
case KEY_NEXT:
|
|
|
|
key = CTK_CONF_WIDGETDOWN_KEY;
|
|
|
|
break;
|
|
|
|
case KEY_STAB:
|
|
|
|
case KEY_HOME:
|
|
|
|
case KEY_END:
|
|
|
|
key = CTK_CONF_WINDOWSWITCH_KEY;
|
|
|
|
break;
|
|
|
|
default:
|
|
|
|
break;
|
2011-04-12 21:45:27 +02:00
|
|
|
}
|
|
|
|
if(key == 0) {
|
|
|
|
return;
|
|
|
|
}
|
|
|
|
|
|
|
|
memset(keys + keys_in, key, sizeof(ctk_arch_key_t));
|
|
|
|
keys_in++;
|
|
|
|
available++;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
static void
|
|
|
|
console_read(void)
|
|
|
|
{
|
|
|
|
int k;
|
2012-06-23 13:07:19 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
k = getch();
|
2013-03-30 23:26:22 +01:00
|
|
|
if(k != ERR) {
|
2011-04-12 21:45:27 +02:00
|
|
|
console_readkey(k);
|
2013-03-30 23:26:22 +01:00
|
|
|
}
|
2011-04-12 21:45:27 +02:00
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
char
|
|
|
|
ctk_arch_getkey(void)
|
|
|
|
{
|
2013-03-26 08:51:37 +01:00
|
|
|
char k;
|
2013-03-31 04:07:03 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
console_read();
|
2013-03-26 08:51:37 +01:00
|
|
|
k = keys[keys_out++];
|
2012-06-23 13:07:19 +02:00
|
|
|
|
2011-04-12 21:45:27 +02:00
|
|
|
available--;
|
|
|
|
return k;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned char
|
|
|
|
ctk_arch_keyavail(void)
|
|
|
|
{
|
|
|
|
console_read();
|
|
|
|
return available;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
ctk_mouse_init(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned short
|
|
|
|
ctk_mouse_x(void)
|
|
|
|
{
|
|
|
|
console_read();
|
|
|
|
return xpos;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned short
|
|
|
|
ctk_mouse_y(void)
|
|
|
|
{
|
|
|
|
console_read();
|
|
|
|
return ypos;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned short
|
|
|
|
ctk_mouse_xtoc(unsigned short x)
|
|
|
|
{
|
|
|
|
return x;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned short
|
|
|
|
ctk_mouse_ytoc(unsigned short y)
|
|
|
|
{
|
|
|
|
return y;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
unsigned char
|
|
|
|
ctk_mouse_button(void)
|
|
|
|
{
|
|
|
|
console_read();
|
|
|
|
return button;
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
ctk_mouse_hide(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|
|
|
|
void
|
|
|
|
ctk_mouse_show(void)
|
|
|
|
{
|
|
|
|
}
|
|
|
|
/*-----------------------------------------------------------------------------------*/
|