示例#1
0
static int32_t engine_handle_input(struct android_app* app, AInputEvent* event) {
    struct engine* engine = (struct engine*)app->userData;
    GLint index=0;
    GLint action, code;
    int32_t retval = 0;
    float x, y;
    GLint count=0;
    
    action = AMotionEvent_getAction(event);
    code = action & AMOTION_EVENT_ACTION_MASK;
    code = action & AMOTION_EVENT_ACTION_MASK;
    index = action & AMOTION_EVENT_ACTION_POINTER_INDEX_MASK;
    index >>= AMOTION_EVENT_ACTION_POINTER_INDEX_SHIFT;
    tMotionEvent events;
    memset(&events, 0, sizeof(tMotionEvent));
    switch( code )
    {
        case AKEY_EVENT_ACTION_DOWN:
            computeValues(event, &events, index);
            EventNotify(&events);
            engine->animating = 1;
            retval = 1;
            break;
            
        case AKEY_EVENT_ACTION_UP:
            computeValues(event, &events, index);
            EventNotify(&events);
            engine->animating = 1;
            retval = 1;
            break;
            
        case AMOTION_EVENT_ACTION_POINTER_DOWN:
            computeValues(event, &events, index);
            EventNotify(&events);
            retval = 1;
            break;
            
        case AMOTION_EVENT_ACTION_POINTER_UP:
            computeValues(event, &events, index);
            EventNotify(&events);
            retval = 1;
            break;
            
        case AMOTION_EVENT_ACTION_MOVE:
            computeMoveValues(event, &events);
            EventNotify(&events);
            engine->animating = 1;
            retval = 1;
            break;
    }
    return retval;
}
示例#2
0
static void SDIO_EventNotify_CPUThread(u64 userdata, s64 cycles_late)
{
  auto device =
      static_cast<CWII_IPC_HLE_Device_sdio_slot0*>(GetDeviceByName("/dev/sdio/slot0").get());
  if (device)
    device->EventNotify();
}
示例#3
0
IPCCommandResult SDIOSlot0::SendCommand(const IOCtlRequest& request)
{
  INFO_LOG(IOS_SD, "IOCTL_SENDCMD %x IPC:%08x", Memory::Read_U32(request.buffer_in),
           request.address);

  const s32 return_value = ExecuteCommand(request, request.buffer_in, request.buffer_in_size, 0, 0,
                                          request.buffer_out, request.buffer_out_size);

  if (return_value == RET_EVENT_REGISTER)
  {
    // Check if the condition is already true
    EventNotify();
    return GetNoReply();
  }

  return GetDefaultReply(IPC_SUCCESS);
}
// The front SD slot
IPCCommandResult CWII_IPC_HLE_Device_sdio_slot0::IOCtl(u32 _CommandAddress)
{
	u32 Cmd = Memory::Read_U32(_CommandAddress + 0xC);

	u32 BufferIn      = Memory::Read_U32(_CommandAddress + 0x10);
	u32 BufferInSize  = Memory::Read_U32(_CommandAddress + 0x14);
	u32 BufferOut     = Memory::Read_U32(_CommandAddress + 0x18);
	u32 BufferOutSize = Memory::Read_U32(_CommandAddress + 0x1C);

	// As a safety precaution we fill the out buffer with zeros to avoid
	// returning nonsense values
	Memory::Memset(BufferOut, 0, BufferOutSize);

	u32 ReturnValue = 0;
	switch (Cmd)
	{
	case IOCTL_WRITEHCR:
		{
		u32 reg = Memory::Read_U32(BufferIn);
		u32 val = Memory::Read_U32(BufferIn + 16);

		DEBUG_LOG(WII_IPC_SD, "IOCTL_WRITEHCR 0x%08x - 0x%08x", reg, val);

		if (reg >= 0x200)
		{
			DEBUG_LOG(WII_IPC_SD, "IOCTL_WRITEHCR out of range");
			break;
		}

		if ((reg == HCR_CLOCKCONTROL) && (val & 1))
		{
			// Clock is set to oscillate, enable bit 1 to say it's stable
			m_Registers[reg] = val | 2;
		}
		else if ((reg == HCR_SOFTWARERESET) && val)
		{
			// When a reset is specified, the register gets cleared
			m_Registers[reg] = 0;
		}
		else
		{
			// Default to just storing the new value
			m_Registers[reg] = val;
		}
		}
		break;

	case IOCTL_READHCR:
		{
		u32 reg = Memory::Read_U32(BufferIn);

		if (reg >= 0x200)
		{
			DEBUG_LOG(WII_IPC_SD, "IOCTL_READHCR out of range");
			break;
		}

		u32 val = m_Registers[reg];
		DEBUG_LOG(WII_IPC_SD, "IOCTL_READHCR 0x%08x - 0x%08x", reg, val);

		// Just reading the register
		Memory::Write_U32(val, BufferOut);
		}
		break;

	case IOCTL_RESETCARD:
		DEBUG_LOG(WII_IPC_SD, "IOCTL_RESETCARD");
		if (m_Card)
			m_Status |= CARD_INITIALIZED;
		// Returns 16bit RCA and 16bit 0s (meaning success)
		Memory::Write_U32(0x9f620000, BufferOut);
		break;

	case IOCTL_SETCLK:
		{
		DEBUG_LOG(WII_IPC_SD, "IOCTL_SETCLK");
		// libogc only sets it to 1 and makes sure the return isn't negative...
		// one half of the sdclk divisor: a power of two or zero.
		u32 clock = Memory::Read_U32(BufferIn);
		if (clock != 1)
			INFO_LOG(WII_IPC_SD, "Setting to %i, interesting", clock);
		}
		break;

	case IOCTL_SENDCMD:
		INFO_LOG(WII_IPC_SD, "IOCTL_SENDCMD %x IPC:%08x",
			Memory::Read_U32(BufferIn), _CommandAddress);
		ReturnValue = ExecuteCommand(BufferIn, BufferInSize, 0, 0, BufferOut, BufferOutSize);
		break;

	case IOCTL_GETSTATUS:
		if (SConfig::GetInstance().m_WiiSDCard)
			m_Status |= CARD_INSERTED;
		else
			m_Status = CARD_NOT_EXIST;
		INFO_LOG(WII_IPC_SD, "IOCTL_GETSTATUS. Replying that SD card is %s%s",
			(m_Status & CARD_INSERTED) ? "inserted" : "not present",
			(m_Status & CARD_INITIALIZED) ? " and initialized" : "");
		Memory::Write_U32(m_Status, BufferOut);
		break;

	case IOCTL_GETOCR:
		DEBUG_LOG(WII_IPC_SD, "IOCTL_GETOCR");
		Memory::Write_U32(0x80ff8000, BufferOut);
		break;

	default:
		ERROR_LOG(WII_IPC_SD, "Unknown SD IOCtl command (0x%08x)", Cmd);
		break;
	}

	// INFO_LOG(WII_IPC_SD, "InBuffer");
	// DumpCommands(BufferIn, BufferInSize / 4, LogTypes::WII_IPC_SD);
	// INFO_LOG(WII_IPC_SD, "OutBuffer");
	// DumpCommands(BufferOut, BufferOutSize/4, LogTypes::WII_IPC_SD);

	if (ReturnValue == RET_EVENT_REGISTER)
	{
		// async
		m_event.addr = _CommandAddress;
		Memory::Write_U32(0, _CommandAddress + 0x4);
		// Check if the condition is already true
		EventNotify();
		return IPC_NO_REPLY;
	}
	else if (ReturnValue == RET_EVENT_UNREGISTER)
	{
		// release returns 0
		// unknown sd int
		// technically we do it out of order, oh well
		EnqueueReply(m_event.addr, EVENT_INVALID);
		m_event.addr = 0;
		m_event.type = EVENT_NONE;
		Memory::Write_U32(0, _CommandAddress + 0x4);
		return IPC_DEFAULT_REPLY;
	}
	else
	{
		Memory::Write_U32(ReturnValue, _CommandAddress + 0x4);
		return IPC_DEFAULT_REPLY;
	}
}
示例#5
0
void SDIO_EventNotify()
{
	auto pDevice = static_cast<CWII_IPC_HLE_Device_sdio_slot0*>(GetDeviceByName("/dev/sdio/slot0").get());
	if (pDevice)
		pDevice->EventNotify();
}