improved shift key

This commit is contained in:
Dagen Brock 2016-01-20 10:42:37 -06:00
parent d8bd306c8a
commit d152517883

View File

@ -403,7 +403,6 @@ SDL_bool IsFullScreen(SDL_Window *win)
void void
handle_sdl_key_event(SDL_Event event) handle_sdl_key_event(SDL_Event event)
{ {
printf("*");
int state_xor; int state_xor;
int state = 0; int state = 0;
@ -413,12 +412,15 @@ handle_sdl_key_event(SDL_Event event)
// simulate xmask style here // simulate xmask style here
//state = state & (ControlMask | LockMask | ShiftMask); //state = state & (ControlMask | LockMask | ShiftMask);
printf("\n %04x\n", mod);
if( mod & KMOD_LCTRL || mod & KMOD_RCTRL || event.key.keysym.sym == SDLK_LCTRL || event.key.keysym.sym == SDLK_RCTRL) { // when mod key is first press, comes as event, otherwise just a modifier
if( mod & KMOD_LCTRL || mod & KMOD_RCTRL ||
event.type == SDL_KEYDOWN && (event.key.keysym.sym == SDLK_LCTRL || event.key.keysym.sym == SDLK_RCTRL)) {
printf("CTL"); printf("CTL");
state = state | ControlMask; state = state | ControlMask;
} }
if( (mod & KMOD_LSHIFT) || (mod & KMOD_RSHIFT) || event.key.keysym.sym == SDLK_LSHIFT || event.key.keysym.sym == SDLK_RSHIFT) { if( (mod & KMOD_LSHIFT) || (mod & KMOD_RSHIFT) ||
event.type == SDL_KEYDOWN && (event.key.keysym.sym == SDLK_LSHIFT || event.key.keysym.sym == SDLK_RSHIFT)) {
printf("SHFT"); printf("SHFT");
state = state | ShiftMask; state = state | ShiftMask;
} }
@ -426,9 +428,6 @@ handle_sdl_key_event(SDL_Event event)
printf("CAPS"); printf("CAPS");
state = state | LockMask; state = state | LockMask;
} }
if( mod & KMOD_LSHIFT ) {
printf("lshift");
}
state_xor = kb_shift_control_state ^ state; state_xor = kb_shift_control_state ^ state;
is_up = 0; is_up = 0;
@ -1345,18 +1344,15 @@ x_update_mouse(int raw_x, int raw_y, int button_states, int buttons_valid)
int int
handle_sdl_mouse_motion_event(SDL_Event event) { handle_sdl_mouse_motion_event(SDL_Event event) {
int x, y; int x, y;
printf (" %04x\t", event.motion.state &7); // @todo: FIX MOUSE BUTTON MAPPING, AT LEAST CLEAN UP AND DOCUMENT BEHAVIOR
//printf (" %04x\t", event.motion.state &7);
x = event.motion.x - BASE_MARGIN_LEFT; x = event.motion.x - BASE_MARGIN_LEFT;
y = event.motion.y - BASE_MARGIN_TOP; y = event.motion.y - BASE_MARGIN_TOP;
if (event.type == SDL_MOUSEBUTTONUP) { if (event.type == SDL_MOUSEBUTTONUP) {
return update_mouse(x, y,0 , event.motion.state &7 ); return update_mouse(x, y,0 , event.motion.state &7 );
} else { } else {
return update_mouse(x, y, event.motion.state, event.motion.state &7 ); return update_mouse(x, y, event.motion.state, event.motion.state &7 );
} }
} }
void void
@ -1431,19 +1427,12 @@ check_input_events()
case EnterNotify: case EnterNotify:
case LeaveNotify: case LeaveNotify:
/* These events are disabled now */ /* These events are disabled now */
printf("Enter/Leave event for winow %08x, sub: %08x\n",
(word32)ev.xcrossing.window,
(word32)ev.xcrossing.subwindow);
printf("Enter/L mode: %08x, detail: %08x, type:%02x\n",
ev.xcrossing.mode, ev.xcrossing.detail,
ev.xcrossing.type);
break; break;
case ButtonPress: case ButtonPress:
buttons = (1 << ev.xbutton.button) >> 1; buttons = (1 << ev.xbutton.button) >> 1;
printf( "%04x %04x", buttons, buttons & 7); printf( "%04x %04x", buttons, buttons & 7);
motion |= x_update_mouse(ev.xbutton.x, ev.xbutton.y, motion |= x_update_mouse(ev.xbutton.x, ev.xbutton.y,
buttons, buttons & 7); buttons, buttons & 7);
break; break;
case ButtonRelease: case ButtonRelease:
buttons = (1 << ev.xbutton.button) >> 1; buttons = (1 << ev.xbutton.button) >> 1;