Esempio n. 1
0
uint16_t cmap_action_to_movement_bitmask(cmap_action_t action) {
  switch (action) {
    MAPPING(NONE, NOT_MOVING);

    MAPPING(WALKING_FORWARD, FORWARD);
    MAPPING(WALKING_BACKWARD, BACKWARD);
    MAPPING(WALKING_LEFT, LEFT);
    MAPPING(WALKING_RIGHT, RIGHT);
    MAPPING(WALKING_ATTACK, ATTACK);
    MAPPING(WALKING_ENTER_CAR, ENTER_EXIT_CAR);
    MAPPING(WALKING_JUMP, JUMP_HANDBRAKE);
    MAPPING(WALKING_WEAPON_PREV, WEAPON_PREV);
    MAPPING(WALKING_WEAPON_NEXT, WEAPON_NEXT);

    MAPPING(DRIVING_FORWARD, FORWARD);
    MAPPING(DRIVING_BACKWARD, BACKWARD);
    MAPPING(DRIVING_LEFT, LEFT);
    MAPPING(DRIVING_RIGHT, RIGHT);
    MAPPING(DRIVING_ATTACK, ATTACK);
    MAPPING(DRIVING_EXIT_CAR, ENTER_EXIT_CAR);
    MAPPING(DRIVING_HANDBRAKE, JUMP_HANDBRAKE);
    MAPPING(DRIVING_WEAPON_PREV, WEAPON_PREV);
    MAPPING(DRIVING_WEAPON_NEXT, WEAPON_NEXT);
  }
  return GTA2_CTRL_NOT_MOVING;
}
 * limitations under the License.
 */
 #include <assert.h>
 #include <errno.h>
 #include <jni.h>

#include "org_apache_hadoop.h"

typedef struct errno_mapping {
  int errno_val;
  char *errno_str;
} errno_mapping_t;

#define MAPPING(x) {x, #x}
static errno_mapping_t ERRNO_MAPPINGS[] = {
  MAPPING(EPERM),
  MAPPING(ENOENT),
  MAPPING(ESRCH),
  MAPPING(EINTR),
  MAPPING(EIO),
  MAPPING(ENXIO),
  MAPPING(E2BIG),
  MAPPING(ENOEXEC),
  MAPPING(EBADF),
  MAPPING(ECHILD),
  MAPPING(EAGAIN),
  MAPPING(ENOMEM),
  MAPPING(EACCES),
  MAPPING(EFAULT),
  MAPPING(ENOTBLK),
  MAPPING(EBUSY),
Esempio n. 3
0
void cmap_load_file(char *path, char *name, char *ext, void *userdata) {
  cmap_t *cmap = calloc(1, sizeof(cmap_t));

  ini_t *ini = ini_open(path, true, false);
  cmap->description = cstr_copy(ini_read(ini, "info", "description"));
  cmap->author = cstr_copy(ini_read(ini, "info", "author"));
  cmap->version = cstr_copy(ini_read(ini, "info", "version"));

  MAPPING(1, WALKING_FORWARD);
  MAPPING(1, WALKING_BACKWARD);
  MAPPING(1, WALKING_LEFT);
  MAPPING(1, WALKING_RIGHT);
  MAPPING(1, WALKING_ATTACK);
  MAPPING(1, WALKING_ENTER_CAR);
  MAPPING(1, WALKING_JUMP);
  MAPPING(1, WALKING_WEAPON_PREV);
  MAPPING(1, WALKING_WEAPON_NEXT);

  // make all driving keys optional by copying over the walking
  // controls
  cmap_copy_walking2driving(cmap);

  MAPPING(0, DRIVING_FORWARD);
  MAPPING(0, DRIVING_BACKWARD);
  MAPPING(0, DRIVING_LEFT);
  MAPPING(0, DRIVING_RIGHT);
  MAPPING(0, DRIVING_ATTACK);
  MAPPING(0, DRIVING_EXIT_CAR);
  MAPPING(0, DRIVING_HANDBRAKE);
  MAPPING(0, DRIVING_WEAPON_PREV);
  MAPPING(0, DRIVING_WEAPON_NEXT);

  // add all deadzones (fallback is always 0.5)
  DEADZONE_STICK(leftstick);
  DEADZONE_STICK(rightstick);

  ini_cleanup(ini);

  // add it to the list
  cmap_init_t *list = (cmap_init_t *)userdata;
  if (list->first)
    list->last->next = cmap;
  else
    list->first = cmap;
  list->last = cmap;
}
Esempio n. 4
0
static bool _read_elf(VMState *state, char *program, size_t program_size);
static struct _mapping *get_info_type_mapping(VMInfoType type);
Opcode *get_opcode(VMState *state, PC_TYPE pc);

#define MAPPING(TYPE, OFFSET, END, CHUNK) { #TYPE, TYPE, OFFSET, CHUNK }
struct _mapping {
    char *name;
    VMInfoType type; /* Keep this one for sanity checks */
    size_t offset;
    size_t end;
    size_t size;
};

static struct _mapping memory_mappings[] = {
    MAPPING(VM_INFO_CHUNK,    CHUNK_OFFSET,    CHUNK_END,    SIZEOF_CHUNK),
    MAPPING(VM_INFO_REGISTER, REGISTER_OFFSET, REGISTER_END, SIZEOF_REGISTER),
    MAPPING(VM_INFO_RAM,      RAM_OFFSET,      RAM_END,      SIZEOF_RAM),
    MAPPING(VM_INFO_ROM,      ROM_OFFSET,      ROM_END,      SIZEOF_ROM),
    MAPPING(VM_INFO_IO,       IO_OFFSET,       IO_END,       SIZEOF_IO),
    MAPPING(VM_INFO_PC,       PC_OFFSET,       PC_OFFSET + 
                                               SIZEOF_PC,    SIZEOF_PC ),
};


static char *_vm_error_messages[] = { 
#   define __vm_errno__(a,b) b,
#   include "vmerrors.h"
#   undef __vm_errno__
};