// File: /workspace/github_c_makefile_star2_O2/STMicroelectronics[P]STMems_Android_Sensor_HAL_Input/sensors.cpp
// Function: sensors_poll_context_t::sensors_poll_context_t()
sensors_poll_context_t::sensors_poll_context_t()
{
#if (SENSORS_MAGNETIC_FIELD_ENABLE == 1)
	mSensors[magn] = new MagnSensor();
	mPollFds[magn].fd = mSensors[magn]->getFd();
	mPollFds[magn].events = POLLIN;
	mPollFds[magn].revents = 0;
#endif

#if (SENSORS_GYROSCOPE_ENABLE == 1)
	mSensors[gyro] = new GyroSensor();
	mPollFds[gyro].fd = mSensors[gyro]->getFd();
	mPollFds[gyro].events = POLLIN;
	mPollFds[gyro].revents = 0;
#endif

#if (SENSORS_VIRTUAL_GYROSCOPE_ENABLE == 1)
	mSensors[virtual_gyro] = new VirtualGyroSensor();
	mPollFds[virtual_gyro].fd = mSensors[virtual_gyro]->getFd();
	mPollFds[virtual_gyro].events = POLLIN;
	mPollFds[virtual_gyro].revents = 0;
#endif

#if (SENSORS_ACCELEROMETER_ENABLE == 1)
	mSensors[accel] = new AccelSensor();
	mPollFds[accel].fd = mSensors[accel]->getFd();
	mPollFds[accel].events = POLLIN;
	mPollFds[accel].revents = 0;
#endif

#if (SENSOR_FUSION_ENABLE == 1)
	mSensors[inemo] = new iNemoEngineSensor();
	mPollFds[inemo].fd = mSensors[inemo]->getFd();
	mPollFds[inemo].events = POLLIN;
	mPollFds[inemo].revents = 0;
#endif

#if ((SENSORS_PRESSURE_ENABLE == 1) || (SENSORS_TEMP_PRESS_ENABLE == 1))
	mSensors[press] = new PressSensor();
	mPollFds[press].fd = mSensors[press]->getFd();
	mPollFds[press].events = POLLIN;
	mPollFds[press].revents = 0;
#endif

#if (SENSORS_TEMP_ENABLE == 1)
	mSensors[temperature] = new TempSensor();
	mPollFds[temperature].fd = mSensors[temperature]->getFd();
	mPollFds[temperature].events = POLLIN;
	mPollFds[temperature].revents = 0;
#endif

#if ((SENSORS_TILT_ENABLE == 1) && (ANDROID_VERSION >= ANDROID_L))
	mSensors[tilt] = new TiltSensor();
	mPollFds[tilt].fd = mSensors[tilt]->getFd();
	mPollFds[tilt].events = POLLIN;
	mPollFds[tilt].revents = 0;
#endif

#if (SENSORS_STEP_COUNTER_ENABLE == 1)
	mSensors[step_c] = new StepCounterSensor();
	mPollFds[step_c].fd = mSensors[step_c]->getFd();
	mPollFds[step_c].events = POLLIN;
	mPollFds[step_c].revents = 0;
#endif

#if (SENSORS_STEP_DETECTOR_ENABLE == 1)
	mSensors[step_d] = new StepDetectorSensor();
	mPollFds[step_d].fd = mSensors[step_d]->getFd();
	mPollFds[step_d].events = POLLIN;
	mPollFds[step_d].revents = 0;
#endif

#if (SENSORS_SIGN_MOTION_ENABLE == 1)
	mSensors[sign_m] = new SignMotionSensor();
	mPollFds[sign_m].fd = mSensors[sign_m]->getFd();
	mPollFds[sign_m].events = POLLIN;
	mPollFds[sign_m].revents = 0;
#endif

#if (SENSORS_TAP_ENABLE == 1)
	mSensors[tap] = new TapSensor();
	mPollFds[tap].fd = mSensors[tap]->getFd();
	mPollFds[tap].events = POLLIN;
	mPollFds[tap].revents = 0;
#endif

#if ((SENSORS_HUMIDITY_ENABLE == 1) || (SENSORS_TEMP_RH_ENABLE == 1))
	mSensors[humidity] = new HumiditySensor();
	mPollFds[humidity].fd = mSensors[humidity]->getFd();
	mPollFds[humidity].events = POLLIN;
	mPollFds[humidity].revents = 0;
#endif

#if (ANDROID_VERSION >= ANDROID_JBMR2)
	int FlushFds[2];
	int err = pipe(FlushFds);
	if (err < 0) {
		ALOGE("Failed to create pipe for flush sensor.");
	} else {
		fcntl(FlushFds[0], F_SETFL, O_NONBLOCK);
		fcntl(FlushFds[1], F_SETFL, O_NONBLOCK);
		mWriteFlushPipe = FlushFds[1];
		mPollFds[flushFD].fd = FlushFds[0];
		mPollFds[flushFD].events = POLLIN;
		mPollFds[flushFD].revents = 0;
	}
#endif
}

// Assembly:
pushq %rbp
pushq %r14
pushq %rbx
subq $0x10, %rsp
movq %rdi, %rbx
movl $0x11b0, %edi           # imm = 0x11B0
callq 0x5220
movq %rax, %r14
movq %rax, %rdi
callq 0x5270
movq %r14, 0x120(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movl %eax, 0xe0(%rbx)
movl $0x1, 0xe4(%rbx)
movl $0x1570, %edi           # imm = 0x1570
callq 0x5220
movq %rax, %r14
movq %rax, %rdi
callq 0x51d0
movq %r14, 0x128(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movl %eax, 0xe8(%rbx)
movl $0x1, 0xec(%rbx)
movl $0x10c8, %edi           # imm = 0x10C8
callq 0x5220
movq %rax, %r14
movq %rax, %rdi
callq 0x5170
movq %r14, 0x130(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movl %eax, 0xf0(%rbx)
movl $0x1, 0xf4(%rbx)
movl $0x10d0, %edi           # imm = 0x10D0
callq 0x5220
movq %rax, %r14
movq %rax, %rdi
callq 0x5290
movq %r14, 0x138(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movl %eax, 0xf8(%rbx)
movl $0x1, 0xfc(%rbx)
movl $0x10c8, %edi           # imm = 0x10C8
callq 0x5220
movq %rax, %r14
movq %rax, %rdi
callq 0x5030
movq %r14, 0x140(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movl %eax, 0x100(%rbx)
movl $0x1, 0x104(%rbx)
movl $0x10c8, %edi           # imm = 0x10C8
callq 0x5220
movq %rax, %r14
movq %rax, %rdi
callq 0x5260
movq %r14, 0x148(%rbx)
movq (%r14), %rax
movq %r14, %rdi
callq *0x20(%rax)
movl %eax, 0x108(%rbx)
movl $0x1, 0x10c(%rbx)
leaq 0x8(%rsp), %rdi
callq 0x52e0
testl %eax, %eax
js 0x5cd5
movl 0x8(%rsp), %edi
pushq $0x4
popq %rbp
movl %ebp, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x5130
movl 0xc(%rsp), %edi
movl %ebp, %esi
movl $0x800, %edx            # imm = 0x800
xorl %eax, %eax
callq 0x5130
movl 0xc(%rsp), %eax
movl %eax, 0x118(%rbx)
movl 0x8(%rsp), %eax
movl %eax, 0x110(%rbx)
movl $0x1, 0x114(%rbx)
addq $0x10, %rsp
popq %rbx
popq %r14
popq %rbp
retq
movq 0x62a4(%rip), %rax      # 0xbf80
movq (%rax), %rdi
leaq 0x2492(%rip), %rsi      # 0x8178
leaq 0x24c4(%rip), %rdx      # 0x81b1
movl $0x403, %ecx            # imm = 0x403
xorl %eax, %eax
callq 0x5350
jmp 0x5ccc
jmp 0x5d05
jmp 0x5d05
jmp 0x5d05
jmp 0x5d05
jmp 0x5d05
movq %rax, %rbx
movq %r14, %rdi
callq 0x5210
movq %rbx, %rdi
callq 0x5420