void EvdevDevice::process_key(struct input_event& ev) { int idx = get_key_index_by_code(ev.code); keys[idx].pressed = ev.value; for(std::vector<Button*>::iterator i = keys[idx].bindings.begin(); i != keys[idx].bindings.end(); ++i) { if (ev.value) (*i)->set_state(BUTTON_PRESSED); else (*i)->set_state(BUTTON_RELEASED); } #if 0 CL_InputEvent e; e.device = CL_InputDevice(this); e.id = button_index; e.repeat_count = 0; if (ev.value) { e.type = CL_InputEvent::pressed; sig_key_down(e); } else { e.type = CL_InputEvent::released; sig_key_up(e); } #endif }
void InputDeviceProvider_LinuxJoystick::process_event(js_event event) { InputEvent input_event; input_event.mouse_pos = Pointf(window->get_mouse_position()) / window->get_pixel_ratio(); input_event.mouse_device_pos = window->get_mouse_position(); input_event.repeat_count = 0; // We don't threat JS_EVENT_INIT special, so this should do if (event.type & JS_EVENT_BUTTON) { // Validate event if (event.number >= button_states.size()) { return; } new_event = true; bool value = event.value; button_states[event.number] = value; if (value) { input_event.type = InputEvent::pressed; } else { input_event.type = InputEvent::released; } input_event.id = (InputCode)event.number; if (value) sig_key_down()(input_event); else sig_key_up()(input_event); } else if (event.type & JS_EVENT_AXIS) { // Validate event if (event.number >= axis_states.size()) { return; } new_event = true; float value = float(event.value) / 32767; axis_states[event.number] = value; input_event.type = InputEvent::axis_moved; input_event.id = (InputCode)event.number; input_event.axis_pos = value; sig_axis_move()(input_event); } }