"Fossies" - the Fresh Open Source Software Archive  

Source code changes of the file "sdl1/pdckbd.c" between
PDCurses-3.8.tar.gz and PDCurses-3.9.tar.gz

About: PDCurses is a multiple platforms curses library implementing most of the functions available in X/Open and System V R4 curses.

pdckbd.c  (PDCurses-3.8):pdckbd.c  (PDCurses-3.9)
skipping to change at line 16 skipping to change at line 16
pdckbd pdckbd
------ ------
### Synopsis ### Synopsis
unsigned long PDC_get_input_fd(void); unsigned long PDC_get_input_fd(void);
### Description ### Description
PDC_get_input_fd() returns the file descriptor that PDCurses PDC_get_input_fd() returns the file descriptor that PDCurses reads
reads its input from. It can be used for select(). its input from. It can be used for select().
### Portability ### Portability
X/Open BSD SYS V X/Open ncurses NetBSD
PDC_get_input_fd - - - PDC_get_input_fd - - -
**man-end****************************************************************/ **man-end****************************************************************/
#include <string.h> #include <string.h>
unsigned long pdc_key_modifiers = 0L;
static SDL_Event event; static SDL_Event event;
static SDLKey oldkey; static SDLKey oldkey;
static MOUSE_STATUS old_mouse_status; static MOUSE_STATUS old_mouse_status;
static struct static struct
{ {
SDLKey keycode; SDLKey keycode;
bool numkeypad; bool numkeypad;
unsigned short normal; unsigned short normal;
unsigned short shifted; unsigned short shifted;
skipping to change at line 130 skipping to change at line 128
current < pdc_lastupdate || ((current - pdc_lastupdate) > 30)) current < pdc_lastupdate || ((current - pdc_lastupdate) > 30))
PDC_update_rects(); PDC_update_rects();
return haveevent; return haveevent;
} }
static int _process_key_event(void) static int _process_key_event(void)
{ {
int i, key = 0; int i, key = 0;
pdc_key_modifiers = 0L; SP->key_modifiers = 0L;
SP->key_code = FALSE; SP->key_code = FALSE;
if (event.type == SDL_KEYUP) if (event.type == SDL_KEYUP)
{ {
if (SP->return_key_modifiers && event.key.keysym.sym == oldkey) if (SP->return_key_modifiers && event.key.keysym.sym == oldkey)
{ {
SP->key_code = TRUE; SP->key_code = TRUE;
switch (oldkey) switch (oldkey)
{ {
skipping to change at line 165 skipping to change at line 163
} }
SP->key_code = FALSE; SP->key_code = FALSE;
} }
return -1; return -1;
} }
oldkey = event.key.keysym.sym; oldkey = event.key.keysym.sym;
if (SP->save_key_modifiers) if (event.key.keysym.mod & KMOD_NUM)
{ SP->key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (event.key.keysym.mod & KMOD_NUM)
pdc_key_modifiers |= PDC_KEY_MODIFIER_NUMLOCK;
if (event.key.keysym.mod & KMOD_SHIFT) if (event.key.keysym.mod & KMOD_SHIFT)
pdc_key_modifiers |= PDC_KEY_MODIFIER_SHIFT; SP->key_modifiers |= PDC_KEY_MODIFIER_SHIFT;
if (event.key.keysym.mod & KMOD_CTRL) if (event.key.keysym.mod & KMOD_CTRL)
pdc_key_modifiers |= PDC_KEY_MODIFIER_CONTROL; SP->key_modifiers |= PDC_KEY_MODIFIER_CONTROL;
if (event.key.keysym.mod & KMOD_ALT) if (event.key.keysym.mod & KMOD_ALT)
pdc_key_modifiers |= PDC_KEY_MODIFIER_ALT; SP->key_modifiers |= PDC_KEY_MODIFIER_ALT;
}
for (i = 0; key_table[i].keycode; i++) for (i = 0; key_table[i].keycode; i++)
{ {
if (key_table[i].keycode == event.key.keysym.sym) if (key_table[i].keycode == event.key.keysym.sym)
{ {
if ((event.key.keysym.mod & KMOD_SHIFT) || if ((event.key.keysym.mod & KMOD_SHIFT) ||
(key_table[i].numkeypad && (event.key.keysym.mod & KMOD_NUM))) (key_table[i].numkeypad && (event.key.keysym.mod & KMOD_NUM)))
{ {
key = key_table[i].shifted; key = key_table[i].shifted;
} }
skipping to change at line 247 skipping to change at line 242
} }
return key ? key : -1; return key ? key : -1;
} }
static int _process_mouse_event(void) static int _process_mouse_event(void)
{ {
SDLMod keymods; SDLMod keymods;
short shift_flags = 0; short shift_flags = 0;
memset(&pdc_mouse_status, 0, sizeof(MOUSE_STATUS)); memset(&SP->mouse_status, 0, sizeof(MOUSE_STATUS));
keymods = SDL_GetModState(); keymods = SDL_GetModState();
if (keymods & KMOD_SHIFT) if (keymods & KMOD_SHIFT)
shift_flags |= BUTTON_SHIFT; shift_flags |= BUTTON_SHIFT;
if (keymods & KMOD_CTRL) if (keymods & KMOD_CTRL)
shift_flags |= BUTTON_CONTROL; shift_flags |= BUTTON_CONTROL;
if (keymods & KMOD_ALT) if (keymods & KMOD_ALT)
shift_flags |= BUTTON_ALT; shift_flags |= BUTTON_ALT;
if (event.type == SDL_MOUSEMOTION) if (event.type == SDL_MOUSEMOTION)
{ {
int i; int i;
pdc_mouse_status.x = event.motion.x / pdc_fwidth; SP->mouse_status.x = (event.motion.x - pdc_xoffset) / pdc_fwidth;
pdc_mouse_status.y = event.motion.y / pdc_fheight; SP->mouse_status.y = (event.motion.y - pdc_yoffset) / pdc_fheight;
if (!event.motion.state || if (!event.motion.state ||
(pdc_mouse_status.x == old_mouse_status.x && (SP->mouse_status.x == old_mouse_status.x &&
pdc_mouse_status.y == old_mouse_status.y)) SP->mouse_status.y == old_mouse_status.y))
return -1; return -1;
pdc_mouse_status.changes = PDC_MOUSE_MOVED; SP->mouse_status.changes = PDC_MOUSE_MOVED;
for (i = 0; i < 3; i++) for (i = 0; i < 3; i++)
{ {
if (event.motion.state & SDL_BUTTON(i + 1)) if (event.motion.state & SDL_BUTTON(i + 1))
{ {
pdc_mouse_status.button[i] = BUTTON_MOVED | shift_flags; SP->mouse_status.button[i] = BUTTON_MOVED | shift_flags;
pdc_mouse_status.changes |= (1 << i); SP->mouse_status.changes |= (1 << i);
} }
} }
} }
else else
{ {
short action = (event.button.state == SDL_PRESSED) ? short action = (event.button.state == SDL_PRESSED) ?
BUTTON_PRESSED : BUTTON_RELEASED; BUTTON_PRESSED : BUTTON_RELEASED;
Uint8 btn = event.button.button; Uint8 btn = event.button.button;
/* handle scroll wheel */ /* handle scroll wheel */
if ((btn >= 4 && btn <= 7) && action == BUTTON_RELEASED) if ((btn >= 4 && btn <= 7) && action == BUTTON_RELEASED)
{ {
pdc_mouse_status.x = pdc_mouse_status.y = -1; SP->mouse_status.x = SP->mouse_status.y = -1;
switch (btn) switch (btn)
{ {
case 4: case 4:
pdc_mouse_status.changes = PDC_MOUSE_WHEEL_UP; SP->mouse_status.changes = PDC_MOUSE_WHEEL_UP;
break; break;
case 5: case 5:
pdc_mouse_status.changes = PDC_MOUSE_WHEEL_DOWN; SP->mouse_status.changes = PDC_MOUSE_WHEEL_DOWN;
break; break;
case 6: case 6:
pdc_mouse_status.changes = PDC_MOUSE_WHEEL_LEFT; SP->mouse_status.changes = PDC_MOUSE_WHEEL_LEFT;
break; break;
case 7: case 7:
pdc_mouse_status.changes = PDC_MOUSE_WHEEL_RIGHT; SP->mouse_status.changes = PDC_MOUSE_WHEEL_RIGHT;
} }
SP->key_code = TRUE; SP->key_code = TRUE;
return KEY_MOUSE; return KEY_MOUSE;
} }
if (btn < 1 || btn > 3) if (btn < 1 || btn > 3)
return -1; return -1;
/* check for a click -- a press followed immediately by a release */ /* check for a click -- a press followed immediately by a release */
skipping to change at line 334 skipping to change at line 329
if (SDL_PollEvent(&rel)) if (SDL_PollEvent(&rel))
{ {
if (rel.type == SDL_MOUSEBUTTONUP && rel.button.button == btn) if (rel.type == SDL_MOUSEBUTTONUP && rel.button.button == btn)
action = BUTTON_CLICKED; action = BUTTON_CLICKED;
else else
SDL_PushEvent(&rel); SDL_PushEvent(&rel);
} }
} }
pdc_mouse_status.x = event.button.x / pdc_fwidth; SP->mouse_status.x = (event.button.x - pdc_xoffset) / pdc_fwidth;
pdc_mouse_status.y = event.button.y / pdc_fheight; SP->mouse_status.y = (event.button.y - pdc_yoffset) / pdc_fheight;
btn--; btn--;
pdc_mouse_status.button[btn] = action | shift_flags; SP->mouse_status.button[btn] = action | shift_flags;
pdc_mouse_status.changes = (1 << btn); SP->mouse_status.changes = (1 << btn);
} }
old_mouse_status = pdc_mouse_status; old_mouse_status = SP->mouse_status;
SP->key_code = TRUE; SP->key_code = TRUE;
return KEY_MOUSE; return KEY_MOUSE;
} }
/* return the next available key or mouse event */ /* return the next available key or mouse event */
int PDC_get_key(void) int PDC_get_key(void)
{ {
switch (event.type) switch (event.type)
skipping to change at line 378 skipping to change at line 373
SP->key_code = TRUE; SP->key_code = TRUE;
return KEY_RESIZE; return KEY_RESIZE;
} }
} }
break; break;
case SDL_MOUSEMOTION: case SDL_MOUSEMOTION:
SDL_ShowCursor(SDL_ENABLE); SDL_ShowCursor(SDL_ENABLE);
case SDL_MOUSEBUTTONUP: case SDL_MOUSEBUTTONUP:
case SDL_MOUSEBUTTONDOWN: case SDL_MOUSEBUTTONDOWN:
oldkey = SDLK_SPACE; oldkey = SDLK_SPACE;
if (SP->_trap_mbe) return _process_mouse_event();
return _process_mouse_event();
break;
case SDL_KEYUP: case SDL_KEYUP:
case SDL_KEYDOWN: case SDL_KEYDOWN:
PDC_mouse_set(); PDC_mouse_set();
return _process_key_event(); return _process_key_event();
case SDL_USEREVENT: case SDL_USEREVENT:
PDC_blink_text(); PDC_blink_text();
} }
return -1; return -1;
} }
skipping to change at line 402 skipping to change at line 395
/* discard any pending keyboard or mouse input -- this is the core /* discard any pending keyboard or mouse input -- this is the core
routine for flushinp() */ routine for flushinp() */
void PDC_flushinp(void) void PDC_flushinp(void)
{ {
PDC_LOG(("PDC_flushinp() - called\n")); PDC_LOG(("PDC_flushinp() - called\n"));
while (PDC_check_key()); while (PDC_check_key());
} }
bool PDC_has_mouse(void)
{
return TRUE;
}
int PDC_mouse_set(void) int PDC_mouse_set(void)
{ {
SDL_ShowCursor(SP->_trap_mbe ? SDL_ENABLE : SDL_DISABLE); SDL_ShowCursor(SP->_trap_mbe ? SDL_ENABLE : SDL_DISABLE);
return OK; return OK;
} }
int PDC_modifiers_set(void) int PDC_modifiers_set(void)
{ {
return OK; return OK;
 End of changes. 23 change blocks. 
38 lines changed or deleted 36 lines changed or added

Home  |  About  |  Features  |  All  |  Newest  |  Dox  |  Diffs  |  RSS Feeds  |  Screenshots  |  Comments  |  Imprint  |  Privacy  |  HTTP(S)