/* * performActions() * Evaluate all keyboard and mouse events * Parameters: * char* - data from device * Returns: * -none- */ void performActions(char *data) { /* Mouse joystick */ mouse_move(IS_JOYSTICK_UP(data), IS_JOYSTICK_DOWN(data), IS_JOYSTICK_LEFT(data), IS_JOYSTICK_RIGHT(data)); /* Mouse clicks */ mouse_click(IS_BUTTON_3(data), &click_mode_left, 1); mouse_click(IS_BUTTON_4(data), &click_mode_right, 3); /* Keys events */ keyboard_press(IS_CURSOR_UP(data), &key_up, "Up"); keyboard_press(IS_CURSOR_DOWN(data), &key_down, "Down"); keyboard_press(IS_CURSOR_LEFT(data), &key_left, "Left"); keyboard_press(IS_CURSOR_RIGHT(data), &key_right, "Right"); keyboard_press(IS_BUTTON_6(data), &key_pprior, "Prior"); keyboard_press(IS_BUTTON_8(data), &key_pnext, "Next"); keyboard_press(IS_BUTTON_1(data), &key_return, "Return"); keyboard_press(IS_BUTTON_2(data), &key_escape, "Escape"); /* Keys speed config */ mouse_speed(IS_BUTTON_5(data), &speed_decrement, 1, "Increment"); mouse_speed(IS_BUTTON_7(data), &speed_increment, -1, "Decrement"); }
static int keypress( const input_event_key_t *event ) { int swallow; const keyboard_spectrum_keys_t *ptr; if( ui_widget_level >= 0 ) { ui_widget_keyhandler( event->native_key ); return 0; } /* Escape => ask UI to end mouse grab, return if grab ended */ if( event->native_key == INPUT_KEY_Escape && ui_mouse_grabbed ) { ui_mouse_grabbed = ui_mouse_release( 0 ); if( !ui_mouse_grabbed ) return 0; } swallow = 0; /* Joystick emulation via keyboard keys */ if ( event->spectrum_key == settings_current.joystick_keyboard_up ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_UP , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_down ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_DOWN , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_left ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_LEFT , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_right ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_RIGHT, 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_fire ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_FIRE , 1 ); } if( swallow ) return 0; ptr = keyboard_get_spectrum_keys( event->spectrum_key ); if( ptr ) { keyboard_press( ptr->key1 ); keyboard_press( ptr->key2 ); } ui_popup_menu( event->native_key ); return 0; }
void process_inbox(Sup_Pdu_t *inbox) { switch (inbox->command) { case SUP_CMD_KEYDOWN: keyboard_press(inbox->data); case SUP_CMD_KEYUP: keyboard_release(inbox->data); case SUP_CMD_NOOP: DBG_PRINTF("Received NOOP"); default: DBG_PRINTF("Unknown command: %d", inbox->command); } return; uint8_t apiResult; if (CyBle_GattGetBusyStatus() == CYBLE_STACK_STATE_FREE) { apiResult = CyBle_HidssGetCharacteristicValue(CYBLE_HUMAN_INTERFACE_DEVICE_SERVICE_INDEX, CYBLE_HIDS_PROTOCOL_MODE, sizeof(protocol), &protocol); if(apiResult == CYBLE_ERROR_OK) { if(protocol == CYBLE_HIDS_PROTOCOL_MODE_BOOT) { apiResult = CyBle_HidssSendNotification(cyBle_connHandle, CYBLE_HUMAN_INTERFACE_DEVICE_SERVICE_INDEX, CYBLE_HIDS_BOOT_KYBRD_IN_REP, KEYBOARD_DATA_SIZE, keyboard_report.raw); } else { apiResult = CyBle_HidssSendNotification(cyBle_connHandle, CYBLE_HUMAN_INTERFACE_DEVICE_SERVICE_INDEX, CYBLE_HUMAN_INTERFACE_DEVICE_REPORT_IN, KEYBOARD_DATA_SIZE, keyboard_report.raw); } if(apiResult != CYBLE_ERROR_OK) { DBG_PRINTF("HID notification API Error: %x \r\n", apiResult); } } } }
static int do_joystick( const input_event_joystick_t *joystick_event, int press ) { int which; #ifdef USE_WIDGET if( ui_widget_level >= 0 ) { if( press ) ui_widget_keyhandler( joystick_event->button ); return 0; } #ifndef GEKKO /* Home button opens the menu on Wii */ switch( joystick_event->button ) { case INPUT_JOYSTICK_FIRE_2: if( press ) ui_popup_menu( INPUT_KEY_F1 ); break; default: break; /* Remove gcc warning */ } #endif /* #ifndef GEKKO */ #endif /* #ifdef USE_WIDGET */ which = joystick_event->which; if( joystick_event->button < INPUT_JOYSTICK_FIRE_1 ) { joystick_button button; switch( joystick_event->button ) { case INPUT_JOYSTICK_UP : button = JOYSTICK_BUTTON_UP; break; case INPUT_JOYSTICK_DOWN : button = JOYSTICK_BUTTON_DOWN; break; case INPUT_JOYSTICK_LEFT : button = JOYSTICK_BUTTON_LEFT; break; case INPUT_JOYSTICK_RIGHT: button = JOYSTICK_BUTTON_RIGHT; break; default: ui_error( UI_ERROR_ERROR, "do_joystick: unknown button %d", joystick_event->button ); fuse_abort(); } joystick_press( which, button, press ); } else { keyboard_key_name key; key = get_fire_button_key( which, joystick_event->button ); if( key == KEYBOARD_JOYSTICK_FIRE ) { joystick_press( which, JOYSTICK_BUTTON_FIRE, press ); } else { if( press ) { keyboard_press( key ); } else { keyboard_release( key ); } } } return 0; }
static int keypress( const input_event_key_t *event ) { int swallow; const keyboard_spectrum_keys_t *ptr; #ifdef USE_WIDGET if( widget_level >= 0 ) { widget_keyhandler( event->native_key ); return 0; } #endif /* #ifdef USE_WIDGET */ /* Escape => ask UI to end mouse grab, return if grab ended */ if( event->native_key == INPUT_KEY_Escape && ui_mouse_grabbed ) { ui_mouse_grabbed = ui_mouse_release( 0 ); if( !ui_mouse_grabbed ) return 0; } swallow = 0; /* Joystick emulation via keyboard keys */ if ( event->spectrum_key == settings_current.joystick_keyboard_up ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_UP , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_down ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_DOWN , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_left ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_LEFT , 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_right ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_RIGHT, 1 ); } else if( event->spectrum_key == settings_current.joystick_keyboard_fire ) { swallow = joystick_press( JOYSTICK_KEYBOARD, JOYSTICK_BUTTON_FIRE , 1 ); } if( swallow ) return 0; ptr = keyboard_get_spectrum_keys( event->spectrum_key ); if( ptr ) { keyboard_press( ptr->key1 ); keyboard_press( ptr->key2 ); } #ifdef USE_WIDGET switch( event->native_key ) { case INPUT_KEY_F1: fuse_emulation_pause(); widget_do( WIDGET_TYPE_MENU, &widget_menu ); fuse_emulation_unpause(); break; case INPUT_KEY_F2: fuse_emulation_pause(); menu_file_savesnapshot( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F3: fuse_emulation_pause(); menu_file_open( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F4: fuse_emulation_pause(); menu_options_general( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F5: fuse_emulation_pause(); menu_machine_reset( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F6: fuse_emulation_pause(); menu_media_tape_write( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F7: fuse_emulation_pause(); menu_media_tape_open( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F8: menu_media_tape_play( 0 ); break; case INPUT_KEY_F9: fuse_emulation_pause(); menu_machine_select( 0 ); fuse_emulation_unpause(); break; case INPUT_KEY_F10: fuse_emulation_pause(); menu_file_exit( 0 ); fuse_emulation_unpause(); break; default: break; /* Remove gcc warning */ } #endif /* #ifdef USE_WIDGET */ return 0; }
static int do_joystick( const input_event_joystick_t *joystick_event, int press ) { int which; #ifdef USE_WIDGET if( widget_level >= 0 ) { if( press ) widget_keyhandler( joystick_event->button ); return 0; } switch( joystick_event->button ) { case INPUT_JOYSTICK_FIRE_2: fuse_emulation_pause(); widget_do( WIDGET_TYPE_MENU, &widget_menu ); fuse_emulation_unpause(); break; default: break; /* Remove gcc warning */ } #endif /* #ifdef USE_WIDGET */ which = joystick_event->which; if( joystick_event->button < INPUT_JOYSTICK_FIRE_1 ) { joystick_button button; switch( joystick_event->button ) { case INPUT_JOYSTICK_UP : button = JOYSTICK_BUTTON_UP; break; case INPUT_JOYSTICK_DOWN : button = JOYSTICK_BUTTON_DOWN; break; case INPUT_JOYSTICK_LEFT : button = JOYSTICK_BUTTON_LEFT; break; case INPUT_JOYSTICK_RIGHT: button = JOYSTICK_BUTTON_RIGHT; break; default: ui_error( UI_ERROR_ERROR, "do_joystick: unknown button %d", joystick_event->button ); fuse_abort(); } joystick_press( which, button, press ); } else { keyboard_key_name key; key = get_fire_button_key( which, joystick_event->button ); if( key == KEYBOARD_JOYSTICK_FIRE ) { joystick_press( which, JOYSTICK_BUTTON_FIRE, press ); } else { if( press ) { keyboard_press( key ); } else { keyboard_release( key ); } } } return 0; }