The last two commits fix issues with invalid key inputs:
Adjust size on mem_copy to only copy the valid keyboard state from the SDL array, mem_zero the remaining mouse and joystick state at the beginning.
Make sure keys and scancodes are within array bounds to prevent out of bound writes. Add missing scancode assignment to mouse wheel events and ignore scrolling in x direction.
This should at least prevent random segmentation faults when using currently unsupported keyboard layouts...