27#include "map_overlay.h"
33#include "player_autonav.h"
41typedef struct Keybind_ {
49static const char *keybind_info[KST_END][3] = {
51 [KST_ACCEL] = { N_(
"Accelerate" ),
52 N_(
"Makes your ship accelerate forward." ),
"accel" },
53 [KST_LEFT] = { N_(
"Turn Left" ), N_(
"Makes your ship turn left." ),
55 [KST_RIGHT] = { N_(
"Turn Right" ), N_(
"Makes your ship turn right." ),
57 [KST_REVERSE] = { N_(
"Reverse" ),
58 N_(
"Makes your ship face the direction you're moving "
59 "from. Useful for braking." ),
61 [KST_FACE] = { N_(
"Face Target" ),
62 N_(
"Faces the targeted ship if one is targeted, otherwise "
63 "faces targeted spob, or jump point." ),
67 [KST_STEALTH] = { N_(
"Stealth" ), N_(
"Tries to enter stealth mode." ),
69 [KST_GAME_SPEED] = { N_(
"Toggle Speed" ), N_(
"Toggles speed modifier." ),
71 [KST_PAUSE] = { N_(
"Pause" ), N_(
"Pauses the game." ),
"pause" },
74 [KST_AUTONAV] = { N_(
"Autonavigation On" ),
75 N_(
"Initializes the autonavigation system." ),
79 N_(
"Attempts to approach the targeted ship or space object, "
80 "or targets the nearest landable space object. "
81 "Requests landing permission if necessary. "
82 "Prioritizes ships over space objects." ),
84 [KST_MOUSE_FLYING] = { N_(
"Mouse Flight" ), N_(
"Toggles mouse flying." ),
86 [KST_JUMP] = { N_(
"Initiate Jump" ),
87 N_(
"Attempts to jump via a jump point." ),
"jump" },
90 [KST_TARGET_NEXT] = { N_(
"Target Next" ),
91 N_(
"Cycles through ship targets." ),
"target_next" },
92 [KST_TARGET_PREV] = { N_(
"Target Previous" ),
93 N_(
"Cycles backwards through ship targets." ),
95 [KST_TARGET_CLOSE] = { N_(
"Target Nearest" ),
96 N_(
"Targets the nearest non-disabled ship." ),
98 [KST_TARGET_SPOB] = { N_(
"Target Spob" ),
99 N_(
"Cycles through space object targets." ),
101 [KST_TARGET_JUMP] = { N_(
"Target Jumpgate" ),
102 N_(
"Cycles through jump points." ),
"thyperspace" },
105 [KST_HTARGET_NEXT] = { N_(
"Target Next Hostile" ),
106 N_(
"Cycles through hostile ship targets." ),
107 "target_nextHostile" },
108 [KST_HTARGET_PREV] = { N_(
"Target Previous Hostile" ),
110 "Cycles backwards through hostile ship targets." ),
111 "target_prevHostile" },
112 [KST_HTARGET_CLOSE] = { N_(
"Target Nearest Hostile" ),
113 N_(
"Targets the nearest hostile ship." ),
117 { N_(
"Clear Target" ),
118 N_(
"Clears the currently-targeted ship, spob or jump point." ),
122 [KST_FIRE_PRIMARY] = { N_(
"Fire Primary Weapon" ),
123 N_(
"Fires primary weapons." ),
"primary" },
124 [KST_FIRE_SECONDARY] = { N_(
"Fire Secondary Weapon" ),
125 N_(
"Fires secondary weapons." ),
"secondary" },
126 [KST_COOLDOWN] = { N_(
"Active Cooldown" ), N_(
"Begins active cooldown." ),
130 [KST_WEAPSET1] = { N_(
"Weapon Set 1" ), N_(
"Activates weapon set 1." ),
132 [KST_WEAPSET2] = { N_(
"Weapon Set 2" ), N_(
"Activates weapon set 2." ),
134 [KST_WEAPSET3] = { N_(
"Weapon Set 3" ), N_(
"Activates weapon set 3." ),
136 [KST_WEAPSET4] = { N_(
"Weapon Set 4" ), N_(
"Activates weapon set 4." ),
138 [KST_WEAPSET5] = { N_(
"Weapon Set 5" ), N_(
"Activates weapon set 5." ),
140 [KST_WEAPSET6] = { N_(
"Weapon Set 6" ), N_(
"Activates weapon set 6." ),
142 [KST_WEAPSET7] = { N_(
"Weapon Set 7" ), N_(
"Activates weapon set 7." ),
144 [KST_WEAPSET8] = { N_(
"Weapon Set 8" ), N_(
"Activates weapon set 8." ),
146 [KST_WEAPSET9] = { N_(
"Weapon Set 9" ), N_(
"Activates weapon set 9." ),
148 [KST_WEAPSET0] = { N_(
"Weapon Set 0" ), N_(
"Activates weapon set 0." ),
152 [KST_OVERLAY_MAP] = { N_(
"Overlay Map" ),
153 N_(
"Opens the in-system overlay map." ),
"overlay" },
154 [KST_STAR_MAP] = { N_(
"Star Map" ), N_(
"Opens the star map." ),
158 [KST_MENU_SMALL] = { N_(
"Small Menu" ),
159 N_(
"Opens the small in-game menu." ),
"menu" },
160 [KST_MENU_INFO] = { N_(
"Information Menu" ),
161 N_(
"Opens the information menu." ),
"info" },
162 [KST_CONSOLE] = { N_(
"Lua Console" ), N_(
"Opens the Lua console." ),
166 [KST_ESCORT_NEXT] = { N_(
"Target Next Escort" ),
167 N_(
"Cycles through your escorts." ),
"e_targetNext" },
168 [KST_ESCORT_PREV] = { N_(
"Target Previous Escort" ),
169 N_(
"Cycles backwards through your escorts." ),
171 [KST_ESCORT_ATTACK] = { N_(
"Escort Attack Command" ),
172 N_(
"Orders escorts to attack your target." ),
174 [KST_ESCORT_HALT] = { N_(
"Escort Hold Command" ),
175 N_(
"Orders escorts to hold their formation." ),
177 [KST_ESCORT_RETURN] =
178 { N_(
"Escort Return Command" ),
179 N_(
"Orders escorts to return to your ship hangars." ),
"e_return" },
180 [KST_ESCORT_CLEAR] = { N_(
"Escort Clear Commands" ),
181 N_(
"Clears your escorts of commands." ),
"e_clear" },
185 { N_(
"Hail Target" ),
186 N_(
"Attempts to initialize communication with the targeted ship." ),
188 [KST_AUTOHAIL] = { N_(
"Autohail" ),
189 N_(
"Automatically initialize communication with a ship "
190 "that is hailing you." ),
192 [KST_SCAN] = { N_(
"Scan Target" ), N_(
"Attempts to scan the target." ),
194 [KST_LOG_UP] = { N_(
"Log Scroll Up" ), N_(
"Scrolls the log upwards." ),
196 [KST_LOG_DOWN] = { N_(
"Log Scroll Down" ),
197 N_(
"Scrolls the log downwards." ),
"log_down" },
200 [KST_ZOOM_IN] = { N_(
"Radar Zoom In" ), N_(
"Zooms in on the radar." ),
202 [KST_ZOOM_OUT] = { N_(
"Radar Zoom Out" ), N_(
"Zooms out on the radar." ),
205 [KST_FULLSCREEN] = { N_(
"Toggle Fullscreen" ),
206 N_(
"Toggles between windowed and fullscreen mode." ),
207 "togglefullscreen" },
209 [KST_SCREENSHOT] = { N_(
"Screenshot" ), N_(
"Takes a screenshot." ),
211 [KST_PASTE] = { N_(
"Paste" ),
212 N_(
"Paste from the operating system's clipboard." ),
250static void input_key( KeySemanticType keynum,
double value,
double kabs,
255static void input_joyaxis(
const SDL_Keycode axis,
const int value );
256static void input_joyevent(
const int event,
const SDL_Keycode button );
257static void input_keyevent(
const int event,
const SDL_Keycode key,
258 const SDL_Keymod mod,
const int repeat );
259static int input_doubleClickTest(
unsigned int *time,
const void **last,
260 const void *clicked );
308 input_setKeybind( KST_FIRE_PRIMARY, KEYBIND_KEYBOARD, SDLK_SPACE, NMOD_ANY );
331 input_setKeybind( KST_ESCORT_ATTACK, KEYBIND_KEYBOARD, SDLK_END, NMOD_ANY );
332 input_setKeybind( KST_ESCORT_HALT, KEYBIND_KEYBOARD, SDLK_INSERT, NMOD_ANY );
335 input_setKeybind( KST_ESCORT_CLEAR, KEYBIND_KEYBOARD, SDLK_HOME, NMOD_ANY );
351 input_setKeybind( KST_LOG_DOWN, KEYBIND_KEYBOARD, SDLK_PAGEDOWN, NMOD_ANY );
354 input_setKeybind( KST_ZOOM_OUT, KEYBIND_KEYBOARD, SDLK_KP_MINUS, NMOD_ANY );
362 input_setKeybind( KST_MENU_SMALL, KEYBIND_KEYBOARD, SDLK_ESCAPE, NMOD_ANY );
374 SDL_EventState( SDL_SYSWMEVENT, SDL_DISABLE );
377 SDL_EventState( SDL_KEYDOWN, SDL_ENABLE );
378 SDL_EventState( SDL_KEYUP, SDL_ENABLE );
381 SDL_EventState( SDL_MOUSEMOTION, SDL_ENABLE );
382 SDL_EventState( SDL_MOUSEBUTTONDOWN, SDL_ENABLE );
383 SDL_EventState( SDL_MOUSEBUTTONUP, SDL_ENABLE );
386 SDL_EventState( SDL_JOYAXISMOTION, SDL_DISABLE );
387 SDL_EventState( SDL_JOYHATMOTION, SDL_DISABLE );
388 SDL_EventState( SDL_JOYBUTTONDOWN, SDL_DISABLE );
389 SDL_EventState( SDL_JOYBUTTONUP, SDL_DISABLE );
392 SDL_EventState( SDL_QUIT, SDL_ENABLE );
395 SDL_EventState( SDL_WINDOWEVENT, SDL_ENABLE );
398 SDL_EventState( SDL_TEXTINPUT,
402 SDL_EventState( SDL_MOUSEWHEEL, SDL_ENABLE );
405 for (
int i = 0; i < KST_END; i++) {
407 memset( k, 0,
sizeof(
Keybind ) );
408 k->
type = KEYBIND_NULL;
409 k->
key = SDLK_UNKNOWN;
429 for (
int i = 0; i < KST_END; i++)
438 for (
int i = 0; i < KST_END; i++)
455 SDL_ShowCursor( SDL_ENABLE );
476 return SDL_ShowCursor( SDL_QUERY ) == SDL_ENABLE;
487 SDL_Keycode k = SDL_GetKeyFromName( name );
488 if (k == SDLK_UNKNOWN)
489 WARN( _(
"Keyname '%s' doesn't match any key." ), name );
503 SDL_Keycode key, SDL_Keymod mod )
505 if (( keybind >= 0 ) && ( keybind < KST_END )) {
510 k->
mod = ( type == KEYBIND_KEYBOARD ) ? mod : NMOD_ANY;
513 WARN( _(
"Unable to set keybinding '%d', that command doesn't exist" ),
528 if (keybind < KST_END) {
535 WARN( _(
"Unable to get keybinding '%d', that command doesn't exist" ),
537 return (SDL_Keycode)-1;
550 KeybindType type = KEYBIND_NULL;
551 SDL_Keymod mod = NMOD_NONE;
557 strncpy( buf, _(
"Not bound" ), len );
560 case KEYBIND_KEYBOARD: {
563 if (( mod != NMOD_NONE ) && ( mod != NMOD_ANY ))
567 if (key < 0x100 && isalpha( key ))
568 scnprintf( &buf[p], len - p,
"%c", toupper( key ) );
575 case KEYBIND_JBUTTON:
576 snprintf( buf, len, _(
"joy button %d" ), key );
579 case KEYBIND_JHAT_UP:
580 snprintf( buf, len, _(
"joy hat %d up" ), key );
583 case KEYBIND_JHAT_DOWN:
584 snprintf( buf, len, _(
"joy hat %d down" ), key );
587 case KEYBIND_JHAT_LEFT:
588 snprintf( buf, len, _(
"joy hat %d left" ), key );
591 case KEYBIND_JHAT_RIGHT:
592 snprintf( buf, len, _(
"joy hat %d right" ), key );
595 case KEYBIND_JAXISPOS:
596 snprintf( buf, len, _(
"joy axis %d-" ), key );
599 case KEYBIND_JAXISNEG:
600 snprintf( buf, len, _(
"joy axis %d+" ), key );
627 return _(
"unknown" );
642 for (
int i = 0; i < KST_END; i++) {
655 case KEYBIND_KEYBOARD:
656 if (( k->
mod == NMOD_ANY ) || ( mod == NMOD_ANY ) || ( k->
mod == mod ))
660 case KEYBIND_JAXISPOS:
661 case KEYBIND_JAXISNEG:
662 case KEYBIND_JBUTTON:
663 case KEYBIND_JHAT_UP:
664 case KEYBIND_JHAT_DOWN:
665 case KEYBIND_JHAT_LEFT:
666 case KEYBIND_JHAT_RIGHT:
683 if (( keybind >= 0 ) && ( keybind < KST_END ))
684 return keybind_info[keybind][2];
685 WARN( _(
"Unable to get keybinding '%d', that command doesn't exist" ),
695 if (( keybind >= 0 ) && ( keybind < KST_END ))
696 return _( keybind_info[keybind][0] );
697 WARN( _(
"Unable to get keybinding '%d', that command doesn't exist" ),
710 if (( keybind >= 0 ) && ( keybind < KST_END ))
711 return _( keybind_info[keybind][1] );
712 WARN( _(
"Unable to get keybinding '%d', that command doesn't exist" ),
725 SDL_Keymod mod_filtered = 0;
726 if (mod & ( KMOD_LSHIFT | KMOD_RSHIFT ))
727 mod_filtered |= NMOD_SHIFT;
728 if (mod & ( KMOD_LCTRL | KMOD_RCTRL ))
729 mod_filtered |= NMOD_CTRL;
730 if (mod & ( KMOD_LALT | KMOD_RALT ))
731 mod_filtered |= NMOD_ALT;
732 if (mod & ( KMOD_LGUI | KMOD_RGUI ))
733 mod_filtered |= NMOD_META;
747 SDL_ShowCursor( SDL_DISABLE );
751 if (conf.repeat_delay != 0) {
774 ( !toolkit_isOpen() && \
775 ( ( value == KEY_RELEASE ) || !player_isFlag( PLAYER_CINEMATICS ) ) && \
776 ( player.p != NULL ) && \
777 !pilot_isFlag( player.p, \
780 ( ( player.p == NULL ) || pilot_isFlag( player.p, PILOT_HYP_PREP ) || \
781 pilot_isFlag( player.p, PILOT_HYP_BEGIN ) || \
786 ( ( player.p != NULL ) && !pilot_isFlag( player.p, PILOT_HYP_PREP ) && \
787 !pilot_isFlag( player.p, PILOT_HYP_BEGIN ) && \
792 ( ( player.p == NULL ) || \
793 pilot_isFlag( player.p, PILOT_DEAD ) )
795 ( ( player.p != NULL ) && \
796 !pilot_isFlag( player.p, PILOT_DEAD ) )
798 ( ( player.p == NULL ) || landed || \
799 pilot_isFlag( player.p, PILOT_LANDING ) )
801 ( ( player.p != NULL ) && \
803 !pilot_isFlag( player.p, \
805#define MAP() ( map_isOpen() )
815static void input_key( KeySemanticType keynum,
double value,
double kabs,
822 if (conf.repeat_delay != 0) {
823 if (( value == KEY_PRESS ) && !repeat) {
827 }
else if (value == KEY_RELEASE) {
835 if (value == KEY_PRESS) {
836 unsigned int t = SDL_GetTicks();
861 pilot_outfitLOnkeydoubletap(
player.p, OUTFIT_KEY_ACCEL );
864 if (
player.p->afterburner != NULL) {
865 player.p->afterburner->flags |= PILOTOUTFIT_ISON_TOGGLE;
869 }
else if (value == KEY_RELEASE) {
871 pilot_outfitLOnkeyrelease(
player.p, OUTFIT_KEY_ACCEL );
873 if (
player.p->afterburner != NULL) {
874 player.p->afterburner->flags &= ~PILOTOUTFIT_ISON_TOGGLE;
880 if (value == KEY_PRESS) {
882 player_setFlag( PLAYER_ACCEL );
884 }
else if (value == KEY_RELEASE) {
885 player_rmFlag( PLAYER_ACCEL );
886 if (!player_isFlag( PLAYER_REVERSE ))
897 player_setFlag( PLAYER_TURN_LEFT );
902 pilot_outfitLOnkeydoubletap(
player.p, OUTFIT_KEY_LEFT );
903 }
else if (value == KEY_RELEASE) {
904 player_rmFlag( PLAYER_TURN_LEFT );
907 if (value == KEY_PRESS) {
909 player_setFlag( PLAYER_TURN_LEFT );
920 player_setFlag( PLAYER_TURN_RIGHT );
925 pilot_outfitLOnkeydoubletap(
player.p, OUTFIT_KEY_RIGHT );
926 }
else if (value == KEY_RELEASE) {
927 player_rmFlag( PLAYER_TURN_RIGHT );
930 if (value == KEY_PRESS) {
932 player_setFlag( PLAYER_TURN_RIGHT );
941 if (value == KEY_PRESS) {
943 player_setFlag( PLAYER_REVERSE );
947 }
else if (( value == KEY_RELEASE ) && player_isFlag( PLAYER_REVERSE )) {
948 player_rmFlag( PLAYER_REVERSE );
950 if (!player_isFlag( PLAYER_ACCEL ))
958 if (value == KEY_PRESS)
966 if (value == KEY_PRESS) {
968 player_setFlag( PLAYER_FACE );
969 }
else if (( value == KEY_RELEASE ) && player_isFlag( PLAYER_FACE ))
970 player_rmFlag( PLAYER_FACE );
977 case KST_TARGET_NEXT:
980 if (value == KEY_PRESS) {
982 map_cycleMissions( 1 );
987 case KST_TARGET_PREV:
990 if (value == KEY_PRESS) {
992 map_cycleMissions( -1 );
997 case KST_TARGET_CLOSE:
1000 if (value == KEY_PRESS) {
1002 map_cycleMissions( 1 );
1007 case KST_HTARGET_NEXT:
1010 if (value == KEY_PRESS)
1013 case KST_HTARGET_PREV:
1016 if (value == KEY_PRESS)
1019 case KST_HTARGET_CLOSE:
1022 if (value == KEY_PRESS)
1025 case KST_TARGET_CLEAR:
1028 if (value == KEY_PRESS)
1035 case KST_ESCORT_NEXT:
1036 if (!(
INGAME() && !repeat ))
1038 if (value == KEY_PRESS)
1041 case KST_ESCORT_PREV:
1042 if (!(
INGAME() && !repeat ))
1044 if (value == KEY_PRESS)
1047 case KST_ESCORT_ATTACK:
1048 if (!(
INGAME() && !repeat ))
1050 if (value == KEY_PRESS)
1053 case KST_ESCORT_HALT:
1054 if (!(
INGAME() && !repeat ))
1056 if (value == KEY_PRESS)
1059 case KST_ESCORT_RETURN:
1060 if (!(
INGAME() && !repeat ))
1062 if (value == KEY_PRESS)
1065 case KST_ESCORT_CLEAR:
1066 if (!(
INGAME() && !repeat ))
1068 if (value == KEY_PRESS)
1076 case KST_FIRE_PRIMARY:
1082 case KST_FIRE_SECONDARY:
1145 if (value == KEY_PRESS) {
1147 unsigned int wid =
window_get( MAP_WDWNAME );
1154 case KST_TARGET_SPOB:
1157 if (value == KEY_PRESS)
1164 if (value == KEY_PRESS) {
1169 case KST_TARGET_JUMP:
1172 if (value == KEY_PRESS)
1176 if (repeat ||
HYP() ||
DEAD())
1178 if (value == KEY_PRESS)
1182 if (!(
INGAME() && !repeat ))
1184 if (value == KEY_PRESS) {
1189 case KST_OVERLAY_MAP:
1190 if (( repeat || !
INGAME() ) && !MAP())
1197 case KST_MOUSE_FLYING:
1198 if (
DEAD() || repeat)
1200 if (value == KEY_PRESS)
1206 if (value == KEY_PRESS) {
1218 if (value == KEY_PRESS)
1224 if (value == KEY_PRESS)
1230 if (value == KEY_PRESS)
1236 if (value == KEY_PRESS)
1242 if (value == KEY_PRESS)
1253 if (value == KEY_PRESS)
1260 if (value == KEY_PRESS)
1264 case KST_SCREENSHOT:
1267 if (value == KEY_PRESS)
1271 case KST_FULLSCREEN:
1274 if (value == KEY_PRESS)
1275 naev_toggleFullscreen();
1281 if (value == KEY_PRESS) {
1291 case KST_GAME_SPEED:
1294 if (( value == KEY_PRESS ) &&
1295 ( !player_isFlag( PLAYER_CINEMATICS_2X ) )) {
1296 if (
player.speed < 4. * conf.game_speed)
1299 player.speed = conf.game_speed;
1304 case KST_MENU_SMALL:
1305 if (
DEAD() || repeat)
1307 if (value == KEY_PRESS)
1308 menu_small( 1, 1, 1, 1 );
1313 if (repeat ||
DEAD() ||
HYP())
1315 if (value == KEY_PRESS)
1321 if (
DEAD() || repeat)
1323 if (value == KEY_PRESS)
1333 hparam[0].
type = HOOK_PARAM_STRING;
1335 hparam[1].
type = HOOK_PARAM_BOOL;
1336 hparam[1].
u.
b = ( value > 0. );
1337 hparam[2].
type = HOOK_PARAM_SENTINEL;
1351 for (
int i = 0; i < KST_END; i++) {
1356 if (( k->
type == KEYBIND_JAXISPOS ) && ( value >= 0 )) {
1357 int press = ( value > 0 ) ? KEY_PRESS : KEY_RELEASE;
1358 if (( press == KEY_PRESS ) && k->
disabled)
1360 input_key( i, press,
FABS( ( (
double)value ) / 32767. ), 0 );
1364 if (( k->
type == KEYBIND_JAXISNEG ) && ( value <= 0 )) {
1365 int press = ( value < 0 ) ? KEY_PRESS : KEY_RELEASE;
1366 if (( press == KEY_PRESS ) && k->
disabled)
1368 input_key( i, press,
FABS( ( (
double)value ) / 32767. ), 0 );
1379 for (
int i = 0; i < KST_END; i++) {
1381 if (( event == KEY_PRESS ) && k->
disabled)
1383 if (( k->
type == KEYBIND_JBUTTON ) && ( k->
key == button ))
1395 for (
int i = 0; i < KST_END; i++) {
1400 if (k->
type == KEYBIND_JHAT_UP) {
1401 int event = ( value & SDL_HAT_UP ) ? KEY_PRESS : KEY_RELEASE;
1402 if (!( ( event == KEY_PRESS ) && k->
disabled ))
1404 }
else if (k->
type == KEYBIND_JHAT_DOWN) {
1405 int event = ( value & SDL_HAT_DOWN ) ? KEY_PRESS : KEY_RELEASE;
1406 if (!( ( event == KEY_PRESS ) && k->
disabled ))
1408 }
else if (k->
type == KEYBIND_JHAT_LEFT) {
1409 int event = ( value & SDL_HAT_LEFT ) ? KEY_PRESS : KEY_RELEASE;
1410 if (!( ( event == KEY_PRESS ) && k->
disabled ))
1412 }
else if (k->
type == KEYBIND_JHAT_RIGHT) {
1413 int event = ( value & SDL_HAT_RIGHT ) ? KEY_PRESS : KEY_RELEASE;
1414 if (!( ( event == KEY_PRESS ) && k->
disabled ))
1432 const SDL_Keymod mod,
const int repeat )
1436 for (
int i = 0; i < KST_END; i++) {
1438 if (( event == KEY_PRESS ) && k->
disabled)
1440 if (k->
type != KEYBIND_KEYBOARD)
1445 if (( k->
mod == mod_filtered ) || ( k->
mod == NMOD_ANY ) ||
1446 ( event == KEY_RELEASE ))
1483 hparam[0].
type = HOOK_PARAM_NUMBER;
1484 hparam[0].
u.
num =
event->button.button;
1485 hparam[1].
type = HOOK_PARAM_BOOL;
1486 hparam[1].
u.
b = (
event->type == SDL_MOUSEBUTTONDOWN );
1487 hparam[2].
type = HOOK_PARAM_SENTINEL;
1491 if (player_isFlag( PLAYER_CINEMATICS ))
1495 if ((
player.p == NULL ) || player_isFlag( PLAYER_DESTROYED ))
1499 if (pilot_isFlag(
player.p, PILOT_DEAD ))
1503 if (event->button.button == SDL_BUTTON_MIDDLE) {
1509 if (event->button.button != SDL_BUTTON_LEFT &&
1510 event->button.button != SDL_BUTTON_RIGHT)
1539 double minpr,
double minr )
1543 int pntid, jpid, astid, fieid;
1547 if (event->button.button == SDL_BUTTON_RIGHT) {
1550 dp =
pow2( x - p->solid.pos.x ) +
pow2( y - p->solid.pos.y );
1559 double rspb =
MAX( 1.5 * spb->
radius * zoom, minr );
1560 double dspb = hypotf( spb->
pos.
x - x, spb->
pos.
y - y );
1565 const JumpPoint *jmp = &
cur_system->jumps[jpid];
1566 double rjmp =
MAX( 1.5 * jmp->radius * zoom, minr );
1567 double djmp = hypotf( jmp->pos.x - x, jmp->pos.y - y );
1581 if (pid != PLAYER_ID) {
1584 MAX( 1.5 * PILOT_SIZE_APPROX * p->ship->size / 2 * zoom, minpr );
1586 if (dp >
pow2( rp ))
1591 if (event->button.button == SDL_BUTTON_LEFT) {
1604 else if (event->button.button == SDL_BUTTON_RIGHT) {
1631 const JumpPoint *jp = &
cur_system->jumps[jump];
1633 if (!jp_isUsable( jp ))
1639 if (
player.p->nav_hyperspace != jump)
1640 map_select( jp->target, 0 );
1642 static unsigned int lastclick_time = 0;
1643 static const JumpPoint *lastclick_jump = NULL;
1644 int doubleclick = input_doubleClickTest(
1645 &lastclick_time, (
const void **)&lastclick_jump, jp );
1647 if (jump ==
player.p->nav_hyperspace) {
1675 if (!spob_isKnown( pnt ))
1684 static unsigned int lastclick_time = 0;
1685 static const Spob *lastclick_spob = NULL;
1686 int doubleclick = input_doubleClickTest(
1687 &lastclick_time, (
const void **)&lastclick_spob, pnt );
1691 ( !spob_isFlag( pnt, SPOB_SERVICE_INHABITED ) || !pnt->
can_land ))
1694 if (spob ==
player.p->nav_spob) {
1698 if (!spob_isFlag( pnt, SPOB_SERVICE_INHABITED ) || pnt->
can_land ||
1701 if (ret == PLAYER_LAND_AGAIN) {
1703 }
else if (ret == PLAYER_LAND_DENIED) {
1741 if (pilot == PLAYER_ID)
1751 static unsigned int lastclick_time = 0;
1752 static const Pilot *lastclick_pilot = NULL;
1753 int doubleclick = input_doubleClickTest(
1754 &lastclick_time, (
const void **)&lastclick_pilot, p );
1756 if (pilot ==
player.p->target) {
1758 if (pilot_isDisabled( p ) || pilot_isFlag( p, PILOT_BOARDABLE )) {
1778 if (conf.mouse_doubleclick <= 0.)
1791 unsigned int threshold;
1793 if (conf.mouse_doubleclick <= 0.)
1806static int input_doubleClickTest(
unsigned int *time,
const void **last,
1807 const void *clicked )
1809 unsigned int threshold, ticks;
1811 if (conf.mouse_doubleclick <= 0.)
1815 threshold = *time + (int)floor( conf.mouse_doubleclick * 1000. );
1816 ticks = SDL_GetTicks();
1818 if (( ticks <= threshold ) && ( *last == clicked ))
1838 if (( event->type == SDL_MOUSEMOTION ) ||
1839 ( event->type == SDL_MOUSEBUTTONDOWN ) ||
1840 ( event->type == SDL_MOUSEBUTTONUP )) {
1842 SDL_ShowCursor( SDL_ENABLE );
1848 if (event->type == SDL_KEYDOWN && SDL_HasClipboardText() &&
1849 SDL_EventState( SDL_TEXTINPUT, SDL_QUERY ) == SDL_ENABLE) {
1851 if (( input_paste->key == event->key.keysym.sym ) &&
1852 ( input_paste->mod & mod )) {
1854 const char *txt = SDL_GetClipboardText();
1855 evt.type = SDL_TEXTINPUT;
1858 while (( ch = u8_nextchar( txt, &i ) )) {
1859 size_t e = u8_wc_toutf8( evt.text.text, ch );
1860 evt.text.text[e] =
'\0';
1861 SDL_PushEvent( &evt );
1875 if (ovr_input( event ))
1882 switch (event->type) {
1883 case SDL_JOYAXISMOTION:
1886 case SDL_JOYBUTTONDOWN:
1889 case SDL_JOYBUTTONUP:
1892 case SDL_JOYHATMOTION:
1897 if (event->key.repeat != 0)
1899 input_keyevent( KEY_PRESS, event->key.keysym.sym, event->key.keysym.mod,
1903 if (event->key.repeat != 0)
1905 input_keyevent( KEY_RELEASE, event->key.keysym.sym, event->key.keysym.mod,
1909 case SDL_MOUSEBUTTONDOWN:
1912 case SDL_MOUSEWHEEL:
1913 if (event->wheel.y > 0)
1915 else if (event->wheel.y < 0)
1918 case SDL_MOUSEMOTION:
1932 for (
int i = 0; i < KST_END; i++) {
1936 WARN( _(
"Key '%s' not found!" ), target );
int player_tryBoard(int noisy)
Attempt to board the player's target.
double cam_getZoomTarget(void)
Gets the camera zoom.
double cam_getZoom(void)
Gets the camera zoom.
void cam_setZoomTarget(double zoom, double speed)
Sets the camera zoom target.
void cli_open(void)
Opens the console.
int escorts_hold(const Pilot *parent)
Have a pilot order its escorts to hold position.
int escorts_return(const Pilot *parent)
Have a pilot order its escorts to dock.
int escorts_attack(Pilot *parent)
Have a pilot order its escorts to attack its target.
int escorts_clear(const Pilot *parent)
Have a pilot order its escorts to clear orders.
const char * pgettext_var(const char *msgctxt, const char *msgid)
int gui_radarClickEvent(SDL_Event *event)
Handles a click at a position in the current system.
int gui_handleEvent(SDL_Event *evt)
Handles GUI events.
void gui_messageScrollDown(int lines)
Scrolls down the message box.
int gui_borderClickEvent(SDL_Event *event)
Handles clicks on the GUI border icons.
void gui_setRadarRel(int mod)
Modifies the radar resolution.
void gui_messageScrollUp(int lines)
Scrolls up the message box.
int hooks_runParam(const char *stack, const HookParam *param)
Runs all the hooks of stack.
Header file with generic functions and naev-specifics.
int scnprintf(char *text, size_t maxlen, const char *fmt,...)
Like snprintf(), but returns the number of characters ACTUALLY "printed" into the buffer....
void gl_windowToScreenPos(int *sx, int *sy, int wx, int wy)
Translates the window position to screen position.
void gl_screenToGameCoords(double *nx, double *ny, int bx, int by)
Converts screen coordinates to in-game coordinates.
void pause_player(void)
Pauses the game and marks the pause as player-initiated.
void unpause_game(void)
Unpauses the game.
double pilot_getNearestPos(const Pilot *p, unsigned int *tp, double x, double y, int disabled)
Get the nearest pilot to a pilot from a certain position.
Pilot * pilot_get(unsigned int id)
Pulls a pilot out of the pilot_stack based on ID.
int pilot_afterburn(Pilot *p)
Activate the afterburner.
void pilot_weapSetUpdateOutfitState(Pilot *p)
Updates the local state of all the pilot's outfits based on the weapon sets.
void player_stealth(void)
Input binding for toggling stealth for the player.
void player_weapSetPress(int id, double value, int repeat)
Handles keyboard events involving the player's weapon-set keys. It's valid to call this while gamepla...
void player_autohail(void)
Automatically tries to hail a pilot that hailed the player.
void player_cooldownBrake(void)
Starts braking or active cooldown.
void player_accel(double acc)
Start accelerating.
void player_targetEscort(int prev)
Targets the pilot.
void player_targetAsteroidSet(int field, int id)
Sets the player's target asteroid.
void player_targetSet(unsigned int id)
Sets the player's target.
void player_hailSpob(void)
Opens communication with the player's spob target.
void player_resetSpeed(void)
Resets the player speed stuff.
void player_targetHyperspaceSet(int id, int nomsg)
Sets the player's hyperspace target.
void player_targetHyperspace(void)
Gets a hyperspace target.
void player_hyperspacePreempt(int preempt)
Enables or disables jump points preempting spobs in autoface and target clearing.
void player_toggleMouseFly(void)
Toggles mouse flying.
void player_targetNearest(void)
Player targets nearest pilot.
void player_restoreControl(int reason, const char *str)
Aborts autonav and other states that take control of the ship.
int player_jump(void)
Actually attempts to jump in hyperspace.
void player_targetSpobSet(int id)
Sets the player's target spob.
void player_accelOver(void)
Done accelerating.
int player_land(int loud)
Try to land or target closest spob if no land target.
void player_targetPrev(int mode)
Cycles to previous target.
void player_targetClear(void)
Clears the player's ship, spob or hyperspace target, in that order.
void player_targetHostile(void)
Targets the nearest hostile enemy to the player.
void player_screenshot(void)
Takes a screenshot.
void player_approach(void)
Logic to make the player approach a target pilot to board or spob to land on.
void player_targetSpob(void)
Cycle through spob targets.
void player_targetNext(int mode)
Cycles to next target.
void player_hail(void)
Opens communication with the player's target.
void player_autonavStartWindow(unsigned int wid, const char *str)
Starts autonav and closes the window.
void player_autonavPos(double x, double y)
Starts autonav with a local position destination.
void player_autonavStart(void)
Starts autonav.
void player_autonavPil(unsigned int p)
Starts autonav with a pilot to follow.
void player_autonavBoard(unsigned int p)
Starts autonav with a pilot to board.
void player_autonavSpob(const char *name, int tryland)
Starts autonav with a spob destination.
double system_getClosest(const StarSystem *sys, int *pnt, int *jp, int *ast, int *fie, double x, double y)
Gets the closest feature to a position in the system.
int space_canHyperspace(const Pilot *p)
Checks to make sure if pilot is far enough away to hyperspace.
void spob_updateLand(Spob *p)
Updates the land possibilities of a spob.
Represents an asteroid field anchor.
Represents a single asteroid.
The actual hook parameter.
union HookParam::@065274143236224234262250043114351136253171035204 u
The representation of an in-game pilot.
Represents a Space Object (SPOB), including and not limited to planets, stations, wormholes,...