1 /* 2 * OpenBOR - http://www.chronocrash.com 3 * ----------------------------------------------------------------------- 4 * All rights reserved, see LICENSE in OpenBOR root for details. 5 * 6 * Copyright (c) 2004 - 2019 OpenBOR Team 7 */ 8 9 #ifndef CONTROL_H 10 #define CONTROL_H 11 // Generic control stuff (keyboard+joystick). 12 13 #include <stdint.h> 14 15 // 32 is an arbitrary number larger than the number of input devices that will ever be available 16 #define MAX_DEVICES 32 17 #define CONTROL_DEVICE_NAME_SIZE 64 18 19 #define CONTROL_NONE (1+(MAX_BUTTONS*99)) //Kratus (20-04-21) value used to clear all keys 20 21 #define WII_SHUTDOWN -1 22 #define WII_RESET -2 23 24 typedef struct { 25 int deviceID; 26 uint32_t keyflags; 27 uint32_t newkeyflags; 28 } s_playercontrols; 29 30 void control_init(); 31 void control_exit(); 32 33 /* Listen to input from deviceID. The first input from deviceID will be returned by the next call to 34 control_getremappedkey(). Call with deviceID=-1 to finish remapping. */ 35 void control_remapdevice(int deviceID); 36 37 // Returns the keycode of the first key pressed on the device being remapped, or -1 if nothing has been pressed yet 38 int control_getremappedkey(); 39 40 // Returns an array of size SDID_COUNT 41 int *control_getmappings(int deviceID); 42 43 // Resets mappings for device to default 44 void control_resetmappings(int deviceID); 45 void control_update(s_playercontrols **allPlayerControls, int numPlayers); 46 void control_update_keyboard(s_playercontrols *keyboardControls); 47 const char *control_getkeyname(int deviceID, int keycode); 48 bool control_isvaliddevice(int deviceID); 49 const char *control_getdevicename(int deviceID); 50 void control_rumble(int deviceID, int ratio, int msec); 51 52 bool control_loadmappings(const char *filename); 53 bool control_savemappings(const char *filename); 54 55 // clears saved mappings and resets every device's mappings to defaults 56 void control_clearmappings(); 57 58 59 #define control_getmappedkeyname(deviceID, key) control_getkeyname(deviceID, control_getmappings(deviceID)[key]) 60 61 #endif /* defined(CONTROL_H) */ 62 63